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
1
# ETH Example
2
curl https://api.blxrbdn.com \
3
-X POST \
4
-H "Content-Type: application/json" \
5
-H "Authorization: <YOUR-AUTHORIZATION-HEADER>" \
6
-d '{"method": "blxr_tx", "id": "1", "params": {"transaction": "f86b0184...e0b58219"}}'
7
​
8
# BSC Example
9
curl https://api.blxrbdn.com \
10
-X POST \
11
-H "Content-Type: application/json" \
12
-H "Authorization: <YOUR-AUTHORIZATION-HEADER>" \
13
-d '{"method": "blxr_tx", "id": "1", "params": {"transaction": "f86b0184...e0b58219",
14
"blockchain_network": "BSC-Mainnet"}}'
15
Copied!
1
# ETH Example
2
wscat -c wss://api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
3
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
4
{"transaction": "f86b0184...e0b58219"}}
5
< ......
6
​
7
# BSC Example
8
wscat -c wss://api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
9
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
10
{"transaction": "f86b0184...e0b58219",
11
"blockchain_network": "BSC-Mainnet"}}
12
< ......
13
​
Copied!
1
from bxcommon.rpc.provider.ws_provider import WsProvider
2
from bxcommon.rpc.rpc_request_type import RpcRequestType
3
​
4
async with WsProvider(
5
uri = "wss://api.blxrbdn.com/ws",
6
headers = {"Authorization": <YOUR-AUTHORIZATION-HEADER>}
7
) as ws:
8
​
9
# ETH Example
10
response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219"})
11
# BSC Example
12
# response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"})
13
print(response) # or process it generally
14
​
Copied!
1
const WebSocket = require('ws');
2
​
3
const ws = new WebSocket(
4
"wss://api.blxrbdn.com/ws",
5
{
6
headers: {
7
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
8
},
9
rejectUnauthorized: false,
10
}
11
);
12
​
13
function proceed() {
14
// ETH Example
15
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`);
16
// BSC Example
17
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`);
18
//
19
// or use a variable for the transaction string:
20
// rawTx = "f86b0184...e0b58219";
21
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "${rawTx}"}}`);
22
}
23
​
24
​
25
function handle(response) {
26
console.log(response.toString()); // or process it generally
27
}
28
​
29
ws.on('open', proceed);
30
ws.on('message', handle);
31
​
Copied!
1
package main
2
​
3
import (
4
"crypto/tls"
5
"fmt"
6
"github.com/gorilla/websocket"
7
"net/http"
8
)
9
​
10
func main() {
11
tlsConfig := &tls.Config{
12
InsecureSkipVerify: true,
13
}
14
dialer := websocket.DefaultDialer
15
dialer.TLSClientConfig = tlsConfig
16
wsSubscriber, _, err := dialer.Dial("wss://api.blxrbdn.com/ws", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
17
​
18
if err != nil {
19
fmt.Println(err)
20
return
21
}
22
​
23
// ETH Example
24
request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`
25
// BSC Example
26
// request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`
27
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(request))
28
if err != nil {
29
fmt.Println(err)
30
return
31
}
32
​
33
_, response, err := wsSubscriber.ReadMessage()
34
if err != nil {
35
fmt.Println(err)
36
}
37
fmt.Println(string(response)) // or process it generally
38
}
39
​
Copied!

Gateway-API:

  • Python Gateway websocket endpoint: ws://127.0.0.1:28333
  • Go-Gateway websocket endpoint: ws://127.0.0.1:28333/ws
  • We assume the Gateway IP is 127.0.0.1 with default RPC port 28332 and WebSocket port 28333 .
  • Authentication for HTTP (Authorization: <YOUR-AUTHORIZATION-HEADER>) is done against --rpc-user and --rpc-password, which the Gateway started with. Please check Authorization Headers examples to reconstruct the header.
  • The HTTP POST endpoint is http://127.0.0.1:28332.

Examples (Gateway-API)

wscat
Node.js
Python
golang
1
# ETH Example
2
wscat -c ws://127.0.0.1:28333 --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
3
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
4
{"transaction": "f86b0184...e0b58219"}}
5
< ......
6
​
7
# BSC Example
8
wscat -c ws://127.0.0.1:28333 --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
9
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params":
10
{"transaction": "f86b0184...e0b58219",
11
"blockchain_network": "BSC-Mainnet"}}
12
< ......
13
​
Copied!
1
const WebSocket = require('ws');
2
​
3
const ws = new WebSocket(
4
"ws://127.0.0.1:28333",
5
{
6
headers: {
7
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
8
},
9
rejectUnauthorized: false,
10
}
11
);
12
​
13
function proceed() {
14
// ETH Example
15
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`);
16
// BSC Example
17
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`);
18
//
19
// or use a variable for the transaction string:
20
// rawTx = "f86b0184...e0b58219";
21
// ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "${rawTx}"}}`);
22
}
23
​
24
​
25
function handle(response) {
26
console.log(response.toString()); // or process it generally
27
}
28
​
29
ws.on('open', proceed);
30
ws.on('message', handle);
Copied!
1
from bxcommon.rpc.provider.ws_provider import WsProvider
2
from bxcommon.rpc.rpc_request_type import RpcRequestType
3
​
4
async with WsProvider(
5
uri = "ws://127.0.0.1:28333",
6
headers = {"Authorization": <YOUR-AUTHORIZATION-HEADER>}
7
) as ws:
8
​
9
# ETH Example
10
response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219"})
11
# BSC Example
12
# response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"})
13
print(response) # or process it generally
Copied!
1
package main
2
​
3
import (
4
"crypto/tls"
5
"fmt"
6
"github.com/gorilla/websocket"
7
"net/http"
8
)
9
​
10
func main() {
11
tlsConfig := &tls.Config{
12
InsecureSkipVerify: true,
13
}
14
dialer := websocket.DefaultDialer
15
dialer.TLSClientConfig = tlsConfig
16
wsSubscriber, _, err := dialer.Dial("ws://127.0.0.1:28333", http.Header{"Authorization": []string{<YOUR-AUTHORIZATION-HEADER>}})
17
​
18
if err != nil {
19
fmt.Println(err)
20
return
21
}
22
​
23
// ETH Example
24
request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`
25
// BSC Example
26
// request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219", "blockchain_network": "BSC-Mainnet"}}`
27
err = wsSubscriber.WriteMessage(websocket.TextMessage, []byte(request))
28
if err != nil {
29
fmt.Println(err)
30
return
31
}
32
​
33
_, response, err := wsSubscriber.ReadMessage()
34
if err != nil {
35
fmt.Println(err)
36
}
37
fmt.Println(string(response)) // or process it generally
38
}
Copied!

RESPONSE

Result Fields

Result Field
Description
tx_hash
Transaction hash

Examples

Response
1
{
2
"jsonrpc": "2.0",
3
"id": "1",
4
"result": {
5
"tx_hash": "ffd59870844e5...bfa54a69"
6
}
7
}
8
​
Copied!

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.
Copy link