BlockRazor
Go to website
English
English
  • 👉About BlockRazor
  • 👨‍💻Use Cases
    • Wallet
    • DEX
    • Searcher
    • Trading Bot
    • Algorithmic Trading
  • 💸Solana
    • Overview
    • Authentication
    • APIs
      • sendTransaction
      • getTransactionFee
      • Sandwich Detector
  • 🖥️BSC
    • Authentication
    • High-performance Network
      • Proto
      • Subscribe NewTxs
      • Subscribe NewBlocks
      • Send RawTx
      • Send RawTxBatch
      • Full Node Synchronization
    • Block Builder
      • Send Bundle
      • Send PrivateTransaction
      • Call Bundle
      • Trace Bundle
    • APIs
      • GetGasPriceStream
      • GetAllGasPriceStream
      • Sandwich Detector
  • 🛡️Scutum(ETH & BSC)
    • Overview
    • New to MEV
    • Exclusive for Project
    • General for Wallet User
    • Searcher
      • Authentication
      • Subscribe Bundle
      • Send Bundle
  • 📄Statement
    • Privacy Statement
Powered by GitBook
On this page
  • Introduction
  • Rate Limit
  • Request Parameter
  • Request Example
  • Proto
  • Response Example
  1. BSC
  2. Block Builder

Send Bundle

PreviousBlock BuilderNextSend PrivateTransaction

Last updated 6 days ago

Introduction

This API is used to receive bundles, with the method name eth_sendBundle.

The block construction algorithm of BlockRazor Builder favors bundles that transfer more native tokens (BNB) to BlockRazor Builder EOA of which address is 0x1266C6bE60392A8Ff346E8d5ECCd3E69dD9c5F20 currently.

The gas price for transactions within the bundle must be at least the minimum standard required by BSC Validators (Currently at 0.1 gwei). For Tier 1 / Tier 2 users, 0 gwei transactions can be included in the bundle, but the average gasPrice of transactions(excluding those from the public mempool) must still be no less than 0.1 gwei.

Rate Limit

Tier 4
Tier 3
Tier 2
Tier 1
Tier 0

BPS

Unlimited

Unlimited

Unlimited

Unlimited

Unlimited

Maximum number of bundles accepted per block

Unlimited

Unlimited

Unlimited

Unlimited

Unlimited

0 gwei transaction in bundle

-

-

✅

✅

✅

gRPC

-

-

-

✅

✅

eth_sendBundle only implements auth restrictions for advanced features (such as 0 gwei transaction in bundle and gRPC). If you need to use advanced features, please first set in the request.

Request Parameter

Parameters
Mandatory
Format
Example
Description

txs

Mandatory

array[hex]

["0x…4b", "0x…5c"]

List of signed raw transactions

maxBlockNumber

Optional

uint64

39177941

The maximum block number for the bundle to be valid, with the default set to the current block number + 100

minTimestamp

Optional

uint64

1710229370

Expected minimum Unix timestamp (in seconds) for the bundle to be valid

maxTimestamp

Optional

uint64

1710829390

Expected maximum Unix timestamp (in seconds) for the bundle to be valid

revertingTxHashes

Optional

array[hash]

["0x…c7", "0x…b7"]

List of transaction hashes allowed for revert

Request Example

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "eth_sendBundle",
  "params": [
    {
      "txs":["0x…4b", "0x…5c"],    // List of signed raw transactions
      "maxBlockNumber":39177941,   // The maximum block number for the bundle to be valid, with the default set to the current block number + 100
      "minTimestamp":1710229370,   // Expected minimum Unix timestamp (in seconds) for the bundle to be valid
      "maxTimestamp":1710829390,   // Expected maximum Unix timestamp (in seconds) for the bundle to be valid
      "revertingTxHashes":[
        "0x44b89abe860142d3c3bda789cf955b69ba00b71882cd968ec407a70f4719ff06", 
        "0x7d7652c685e9fda4fe2e41bad017519cffeed8ba03d59aa6401284be2ec4244c"
        ]                         // List of transaction hashes allowed for revert
    }
  ]
}‍
package main

import (
	"context"
	"crypto/ecdsa"
	"fmt"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/crypto"
	"github.com/xkwang/go-builder-client/sendbundle"
	"google.golang.org/grpc"
	"log"
	"math/big"
)

type Authentication struct {
	Token string
}

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

func (a *Authentication) RequireTransportSecurity() bool {
	return false // non-TLS connection is defaulted. It is recommended to enable TLS configuration in production
}

func main() {
	blzrelayEndPoint := "endpoint_url"

	auth := Authentication{
		Token: "your_token",
	}

	conn, err := grpc.Dial(
		blzrelayEndPoint,
		grpc.WithInsecure(), // non-TLS connection
		grpc.WithPerRPCCredentials(&auth),
	)
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	chainId := int64(56)
	to := common.HexToAddress("toAddress")
	pk, _ := crypto.HexToECDSA("private key")
	_, rawTx, err := GenerateAndSignTx(
		big.NewInt(0),     //value
		big.NewInt(21000), //gas limit
		big.NewInt(1e9),   //gas price
		&to, nil, 1, big.NewInt(chainId), pk)
	fmt.Printf("rawTx:%x\n", rawTx)
	if err != nil {
		log.Println("Error creating signed tx:", err)
	}
	client := sendbundle.NewBundleServiceClient(conn)
	r, err := client.SendBundle(context.Background(), &sendbundle.SendBundleArgs{
		Txs: [][]byte{
			rawTx,
		},
		//MaxBlockNumber: 1,
		//RevertingTxHashes: []string{signedTx.Hash().String()},
	})
	//r, err := client.SendTransaction(context.Background(), &sendbundle.SendTransactionArgs{Tx: rawTx})
	if err != nil {
		fmt.Println(err)
	} else {
		println("response:", r.Result)
	}
}

func GenerateAndSignTx(value, gas, gasPrice *big.Int, to *common.Address, dataBytes []byte, nonce uint64, chainID *big.Int, privateKeyECDSA *ecdsa.PrivateKey) (*types.Transaction, []byte, error) {
	tx := types.NewTx(&types.LegacyTx{
		Nonce:    nonce,
		To:       to,
		Value:    value,
		Gas:      gas.Uint64(),
		GasPrice: gasPrice,
		Data:     dataBytes,
	})
	signer := types.NewEIP155Signer(chainID)
	signedTx, err := types.SignTx(tx, signer, privateKeyECDSA)
	if err != nil {
		return nil, nil, fmt.Errorf("failed to sign transaction: %v", err)
	}

	rawTxBytes, err := signedTx.MarshalBinary()
	if err != nil {
		return nil, nil, fmt.Errorf("failed to marshal signed transaction: %v", err)
	}

	return signedTx, rawTxBytes, nil
}

Proto

syntax = "proto3";

package sendbundle;

option go_package = "internal/ethapi/sendbundle;sendbundle";

service BundleService {
  rpc SendBundle (SendBundleArgs) returns (SendBundleResponse);
  rpc SendTransaction (SendTransactionArgs) returns (SendTransactionResponse);
}

message SendBundleArgs {
  repeated bytes txs = 1;
  uint64 maxBlockNumber = 2;
  uint64 minTimestamp = 3;
  uint64 maxTimestamp = 4;
  repeated string revertingTxHashes = 5;
}

message SendTransactionArgs {
  bytes tx = 1;
}

message SendBundleResponse {
    string result = 1;
}

message SendTransactionResponse {
    string result = 1;
}

Response Example

{
 "jsonrpc":"2.0",
 "id":"1",
 "result":"0xa06b……f7e8ec"  //bundle hash
}‍
{
  "jsonrpc":"2.0",
  "id":"1",
  "error":{
    "code":-38000,
    "message":"the maxBlockNumber should not be smaller than currentBlockNum"
    }
}

🖥️
Authentication