Sending Transactions

Use this endpoint to send a single transaction faster than the p2p network using the BDN.

REQUEST

Method: blxr_tx

Parameters

ParameterDescriptionInstructions & Notes

transaction

Raw transactions bytes without 0x prefix.

Mandatory. Learn more about constructing the transaction here.

blockchain_network

Blockchain network name.

Optional. Default: Mainnet

Available options are: Mainnet for ETH Mainnet, BSC-Mainnet, and Polygon-Mainnet

*Use with Cloud-API when working with BSC.

validators_only

Used for sending semi-private transactions on Polygon.

Available only with Cloud-API

Optional.

Default: False. See Semi-Private Transaction section for more info.

next_validator

Used for sending semi-private transactions on Polygon.

Available only with Cloud-API

Optional.

Default: False. See Semi-Private Transaction section for more info.

fall_back

The duration of time (in ms) that your transaction will be delayed before propagation by the BDN as a normal transaction

Available only when using next_validator

Default: 0

If the value is 0, the transaction will never be propagated by the BDN as a normal transaction.

node_validation

Transaction is sent to the blockchain node for validation, and the Gateway returns any error message received in response.

Available only with Gateway API

Optional

Default: False

Cloud-API

  • 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)

  • The HTTPS POST endpoint is https://api.blxrbdn.com .

Sending transactions via WebSocket instead of HTTPS can lead to a latency improvement of up to 10ms.

Examples

# 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"}}
< ....

Gateway-API:

  • 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

# 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"}}
< ......

RESPONSE

Result Fields

Result FieldDescription

tx_hash

Transaction hash

Examples

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

Example - gRPC

package main

import (
	"context"
	"fmt"
	pb "github.com/bloXroute-Labs/bxgateway-private-go/bxgateway/v2/protobuf"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"time"
)

func main() {
	// gRPC server default values
	gatewayHostIP := "127.0.0.1"
	gatewayGRPCPort := 5001
	
	// Open gRPC connection to Gateway.
	conn, _ := grpc.Dial(
		fmt.Sprintf("%v:%v", gatewayHostIP, gatewayGRPCPort), 
		grpc.WithTransportCredentials(insecure.NewCredentials()),
	)

	// Use the Gateway client connection interface. 
	client := pb.NewGatewayClient(conn)
	
	// create context and defer cancel of context
	callContext, cancel := context.WithTimeout(context.Background(), 24*time.Hour)
	defer cancel()
	
	// send tx
	reply, err := client.BlxrTx(callContext, &pb.BlxrTxRequest{AuthHeader: "<YOUR-AUTHORIZATION-HEADER>", Transaction: "f86b0184...e0b58219"})
	if err != nil {
		print(err)
		return
	}
	
	txHash := reply.TxHash
	print(txHash) // or process it generally
}

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.

Last updated