For the complete documentation index, see llms.txt. This page is also available as Markdown.

BSC Broadcast Tx

Introducing the Broadcast Tx interface and integration method for BlockRazor BSC Transaction Sending mode.

Endpoint

Region
Relay Address

Frankfurt

64.130.47.75:50051

Tokyo

63.254.162.18:50051

Dublin

141.98.217.82:50051

Virginia

208.91.105.204:50051

Price & Rate Limit

Payment Method
Limit
Price
Action

Free

SendTx

  • TPS:10 Txs / 5s

  • Daily Tx Limit:10

Free

-

Personalized

SendTx

  • TPS:100 Txs / 5s

  • Daily Tx Limit:100000

SendTxs

  • BPS:4 batches / 1s

  • Txs per Batch:10

$50 / day $500 / month

Package

SendTx

  • TPS:100 Txs / 5s

  • Daily Tx Limit:100000

SendTxs

  • BPS:4 batches / 1s

  • Txs per Batch:10

$1250 / month packaged with 9 other services.

SendTx

Request Parameter

Parameters
Mandatory
Format
Example
Description

Transaction

Mandatory

String

"0xf8……8219"

signed raw tx

Request Example

https://github.com/BlockRazorinc/relay_example

package main

import (
	"context"
	"encoding/hex"
	"fmt"
	"math/big"

	// directory of the generated code using the provided relay.proto file
	pb "github.com/BlockRazorinc/relay_example/protobuf"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/crypto"
	"github.com/ethereum/go-ethereum/rlp"
	"google.golang.org/grpc"
)

// auth will be used to verify the credential
type Authentication struct {
	apiKey string
}

func (a *Authentication) GetRequestMetadata(context.Context, ...string) (map[string]string, error) {
	return map[string]string{"apiKey": a.apiKey}, nil
}

func (a *Authentication) RequireTransportSecurity() bool {
	return false
}

func main() {

	// BlockRazor relay endpoint address
	blzrelayEndPoint := "ip:port"

	// auth will be used to verify the credential
	auth := Authentication{
		"your auth token",
	}

	// open gRPC connection to BlockRazor relay
	var err error
	conn, err := grpc.Dial(blzrelayEndPoint, grpc.WithInsecure(), grpc.WithPerRPCCredentials(&auth), grpc.WithWriteBufferSize(0), grpc.WithInitialConnWindowSize(128*1024))
	if err != nil {
		fmt.Println("error: ", err)
		return
	}

	// use the Gateway client connection interface.
	client := pb.NewGatewayClient(conn)

	// create context
	ctx := context.Background()

	// replace with your address
	from_private_address := "42b565……44d05c"
	to_public_address := "0x4321……3f1c66"

	// replace with your transaction data
	nonce := uint64(1)
	toAddress := common.HexToAddress(to_public_address)
	var data []byte
	gasPrice := big.NewInt(1e9)
	gasLimit := uint64(22000)
	value := big.NewInt(0)
	chainid := types.NewEIP155Signer(big.NewInt(56))

	// create new transaction
	tx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)

	privateKey, err := crypto.HexToECDSA(from_private_address)
	if err != nil {
		fmt.Println("fail to casting private key to ECDSA")
		return
	}

	// sign transaction by private key
	signedTx, err := types.SignTx(tx, chainid, privateKey)
	if err != nil {
		fmt.Println("fail to sign transaction")
		return
	}

	// use rlp to encode your transaction
	body, _ := rlp.EncodeToBytes([]types.Transaction{*signedTx})

	// encode []byte to string
	encode_tx := hex.EncodeToString(body)

	// send raw tx by BlockRazor
	res, err := client.SendTx(ctx, &pb.SendTxRequest{Transaction: encode_tx})

	if err != nil {
		fmt.Println("failed to send raw tx: ", err)
		return
	} else {
		fmt.Println("raw tx sent by BlockRazor, tx hash is ", res.TxHash)
	}

}

Response Example

Success

Error

SendTxs

Request Parameter

Parameters
Mandatory
Format
Example
Description

Transactions

Mandatory

Array[String]

["0xf8……8219", "0xcb……2ac0"]

signed raw txs

Request Example

https://github.com/BlockRazorinc/relay_example

Response Example

Success

Error

Proto

The code of relay.proto is as follows:

Last updated

Was this helpful?