Links

Sending Transactions

This endpoint allows you to send a single transaction that will be distributed faster using the BDN.

REQUEST

Method: blxr_tx
Sending transactions via WebSocket instead of HTTP can lead to a latency improvement of up to 10ms.

Parameters

Parameter
Description
transaction
[Mandatory] Raw transactions bytes without 0x prefix.
nonce_monitoring
[Optional, default: False] A boolean flag indicating if Tx Nonce Monitoring should be enabled for the transaction. This parameter only effects Cloud-API requests. *Currently only available for users testing the Beta version, but will soon be available to all.
blockchain_network
[Optional, default: Mainnet] Blockchain network name. Use with Cloud-API when working with BSC. Available options are: Mainnet for ETH Mainnet, BSC-Mainnet for BSC Mainnet, and Polygon-Mainnet for Polygon Mainnet.
validators_only
[Optional, default: False] Support for semi private transactions in all networks. See section Semi-Private Transaction for more info.
​
Cloud-API:
  • The HTTPS POST endpoint is https://api.blxrbdn.com .
  • The WebSocket endpoint for sending transactions is wss://api.blxrbdn.com/ws . All users sending transactions via a WebSocket connection should use this endpoint.
  • See Cloud-API IPs to work directly with IP ( wss://<IP>/ws)
Examples (Cloud-API)
HTTPS POST
wscat WS
Python WS
Node.js WS
golang WS
# ETH Example
curl https://api.blxrbdn.com \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: <YOUR-AUTHORIZATION-HEADER>" \
-d '{"method": "blxr_tx", "id": "1", "params": {"transaction": "f86b0184...e0b58219"}}'
​
# BSC Example
curl https://api.blxrbdn.com \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: <YOUR-AUTHORIZATION-HEADER>" \
-d '{"method": "blxr_tx", "id": "1", "params": {"transaction": "f86b0184...e0b58219",
"blockchain_network": "BSC-Mainnet"}}'
# ETH Example
wscat -c wss://api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
{"transaction": "f86b0184...e0b58219"}}
< ......
​
# BSC Example
wscat -c wss://api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
{"transaction": "f86b0184...e0b58219",
"blockchain_network": "BSC-Mainnet"}}
< ....
from bxcommon.rpc.provider.ws_provider import WsProvider
from bxcommon.rpc.rpc_request_type import RpcRequestType
​
async with WsProvider(
uri = "wss://api.blxrbdn.com/ws",
headers = {"Authorization": <YOUR-AUTHORIZATION-HEADER>}
) as ws:
​
# ETH Example
response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219"})
# BSC Example
# response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"})
print(response) # or process it generally
​
const WebSocket = require('ws');
​
const ws = new WebSocket(
"wss://api.blxrbdn.com/ws",
{
headers: {
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
},
rejectUnauthorized: false,
}
);
​
function proceed() {
// ETH Example
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`);
// BSC Example
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`);
//
// or use a variable for the transaction string:
// rawTx = "f86b0184...e0b58219";
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "${rawTx}"}}`);
}
​
​
function handle(response) {
console.log(response.toString()); // or process it generally
}
​
ws.on('open', proceed);
ws.on('message', handle);
​
package main
​
import (
"crypto/tls"
"fmt"
"github.com/gorilla/websocket"
"net/http"
)
​
func main() {
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
}
dialer := websocket.DefaultDialer
dialer.TLSClientConfig = tlsConfig
wsSubscriber, _, err := dialer.Dial("wss://api.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
​
if err != nil {
fmt.Println(err)
return
}
​
// ETH Example
request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`
// BSC Example
// request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(request))
if err != nil {
fmt.Println(err)
return
}
​
_, response, err := wsSubscriber.ReadMessage()
if err != nil {
fmt.Println(err)
}
fmt.Println(string(response)) // or process it generally
}
​

Gateway-API:

  • Go-Gateway websocket endpoint: ws://127.0.0.1:28333/ws
  • We assume the WebSocket port 28333 .
  • Please check Authorization Headers examples to reconstruct the header.

Examples (Gateway-API)

wscat
Node.js
Python
golang
# ETH Example
wscat -c ws://127.0.0.1:28333/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
{"transaction": "f86b0184...e0b58219"}}
< ......
​
# BSC Example
wscat -c ws://127.0.0.1:28333/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
{"transaction": "f86b0184...e0b58219",
"blockchain_network": "BSC-Mainnet"}}
< ......
const WebSocket = require('ws');
​
const ws = new WebSocket(
"ws://127.0.0.1:28333/ws",
{
headers: {
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
},
rejectUnauthorized: false,
}
);
​
function proceed() {
// ETH Example
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`);
// BSC Example
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`);
//
// or use a variable for the transaction string:
// rawTx = "f86b0184...e0b58219";
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "${rawTx}"}}`);
}
​
​
function handle(response) {
console.log(response.toString()); // or process it generally
}
​
ws.on('open', proceed);
ws.on('message', handle);
from bxcommon.rpc.provider.ws_provider import WsProvider
from bxcommon.rpc.rpc_request_type import RpcRequestType
​
async with WsProvider(
uri = "ws://127.0.0.1:28333/ws",
headers = {"Authorization": <YOUR-AUTHORIZATION-HEADER>}
) as ws:
​
# ETH Example
response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219"})
# BSC Example
# response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"})
print(response) # or process it generally
package main
​
import (
"crypto/tls"
"fmt"
"github.com/gorilla/websocket"
"net/http"
)
​
func main() {
tlsConfig := &tls.Config{
InsecureSkipVerify: true,
}
dialer := websocket.DefaultDialer
dialer.TLSClientConfig = tlsConfig
wsSubscriber, _, err := dialer.Dial("ws://127.0.0.1:28333/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
​
if err != nil {
fmt.Println(err)
return
}
​
// ETH Example
request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`
// BSC Example
// request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(request))
if err != nil {
fmt.Println(err)
return
}
​
_, response, err := wsSubscriber.ReadMessage()
if err != nil {
fmt.Println(err)
}
fmt.Println(string(response)) // or process it generally
}

RESPONSE

Result Fields

Result Field
Description
tx_hash
Transaction hash

Examples

Response
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"tx_hash": "ffd59870844e5...bfa54a69"
}
}
​

NOTES

All Users

Sending Transactions to the Cloud-API or Gateway-API requires you to register an account on the bloXroute portal. During the registration process, a certificate, private key, and secret hash will be generated for your account. The certificate and key will be used to authenticate your account.
The bloXroute best practice is for users to send transactions to both the Gateway-API and to their blockchain node. You should send transactions in parallel to the Gateway and to your blockchain node as a backup.
Users should not send transactions to the transactions streams WebSocket endpoint wss://<REGION>.<NETWORK>.blxrbdn.com/ws(e.g.wss://virginia.eth.blxrbdn.com/ws) which is for streaming only and doesn't support sending transactions.