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.

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.

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
Python WS
Node.js WS
golang WS
wscat WS
HTTPS POST
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"}}'
Python WS
from bloxroute_cli.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:
response = await ws.call_bx(RpcRequestType.BLXR_TX, {"transaction": "f86b0184...e0b58219"})
print(response) # or process it generally
Node.js WS
const WebSocket = require('ws');
const ws = new WebSocket(
"wss://api.blxrbdn.com/ws",
{
headers: {
"Authorization" : <YOUR-AUTHORIZATION-HEADER>
},
rejectUnauthorized: false,
}
);
function proceed() {
ws.send(`{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`);
}
function handle(response) {
console.log(response); // or process it generally
}
ws.on('open', proceed);
ws.on('message', handle);
golang WS
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
}
request := `{"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}`
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
}
wscat WS
wscat -c wss://api.blxrbdn.com/ws --header "Authorization: <YOUR-AUTHORIZATION-HEADER>"
> {"jsonrpc": "2.0", "id": 1, "method": "blxr_tx", "params": {"transaction": "f86b0184...e0b58219"}}
< ......

RESPONSE

Result Fields

Result Field

Description

tx_hash

Transaction hash

Examples

Response
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 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://eth.feed.blxrbdn.com:28333, which is for streaming only and doesn't support sending transactions.