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, and BSC-Mainnet for BSC Mainnet.

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)

Gateway-API:

    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.
    The WebSocket endpoint is ws://127.0.0.1:28333.
    To send transactions to the Gateway-API, replace the endpoint in the below Cloud-API examples with the corresponding Gateway endpoint.

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 bloxroute_cli.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!
​

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 first send transactions to the Gateway and then to your blockchain node as a backup.
Users should not send transactions to the transactions streams WebSocket endpoint wss://<NETWORK-NAME>.feed.blxrbdn.com:28333(e.g.wss://eth.feed.blxrbdn.com:28333) which is for streaming only and doesn't support sending transactions.
Last modified 20d ago
Copy link