How to use Bundle for Private Transaction

This guide explains how to submit transaction bundles on BNB Smart Chain using GetBlock's MEV endpoint.

A bundle is a group of transactions submitted together with a guarantee that either all transactions execute in sequence or none are included. This atomic execution model supports several advanced use cases:

  • Arbitrage — Execute a buy on one DEX and a sell on another within the same block, ensuring both trades complete or neither does

  • Liquidations — Check a position's health and liquidate it atomically, preventing front-running

  • Complex strategies — Coordinate multi-step transactions with guaranteed execution order

Prerequisites

Before submitting bundles, ensure you have:

  • A GetBlock API key with MEV endpoint access

  • Node.js v16 or later

  • A funded BSC wallet with sufficient BNB for all transactions and gas

API Reference

Connect to the MEV WebSocket endpoint with your API key:

wss://bsc.getblock.io/mev/ws?api_key=YOUR_API_KEY

Prerequisites

You must have the following:

  • Node.js v18 or later installed

  • A funded BSC wallet with sufficient BNB for transactions and gas

  • GetBlock's BSC Accelerated Dedication Node

Quickstart

1

Set up the project

2

Create a new file named index.js. This is where you will make your first call.

3

Set the ES module "type": "module" in your package.json.

4

Add the following code to index.js:

The following example demonstrates a simple BNB transfer with a priority fee:

5

Run the code using this command:

6

Sample response

Example: DEX Arbitrage

chevron-rightThis example demonstrates a complete arbitrage strategy: buying a token on PancakeSwap V2 and selling on PancakeSwap V3 within the same block, with an optional priority fee.hashtag

Reference Addresses

Address
Purpose

0x10ED43C718714eb63d5aA57B78B54704E256024E

PancakeSwap V2 Router

0x13f4EA83D0bd40E75C8222255bc855a974568Dd4

PancakeSwap V3 Router

0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

WBNB

0x6374Ca2da5646C73Eb444aB99780495d61035f9b

Priority fee recipient

Code Example

Comparing Bundles and Private Transactions

Choose the appropriate method based on your use case:

Aspect

bsc_privateTx

mev_sendBundle

Transaction count

Single

Multiple

Atomicity

Not applicable

All-or-nothing execution

Use cases

Simple transfers, individual swaps

Arbitrage, multi-step operations

Adding priority fees

Via Multicall3

Separate transaction in bundle

mev_builders format

Array: ["all"]

Object: {"all": ""}

Best Practices

1. Use Sequential Nonces

All transactions in a bundle must have consecutive nonces starting from your wallet's current nonce:

2. Include a Priority Fee

Adding a fee payment as the final transaction increases the likelihood of bundle inclusion:

Choose an Appropriate blocks_count Value

The blocks_count parameter determines how long your bundle remains valid. Shorter validity periods signal higher urgency to builders:

Use Case
Recommended blocks_count

Time-sensitive arbitrage

2–3

Standard bundles

5

Less urgent operations

10–20

Simulate Before Submitting

Test your transaction logic before submitting a bundle by simulating each transaction:

Troubleshooting

Problem
Solution

Bundle Not Included

If your bundle is not included after the specified block count:

  • Increase the priority fee — Add a higher fee payment transaction

  • Verify nonce sequence — Nonces must be strictly consecutive with no gaps

  • Reduce blocks_count — Shorter validity signals higher priority to builders

  • Validate each transaction — Ensure every transaction in the bundle is valid independently

"Invalid bundle" Error

This error indicates a formatting or validation issue:

  • Check parameter format — The transactions parameter must be an array; mev_builders must be an object

  • Verify signatures — All transactions must be properly signed

  • Confirm chain ID — Use chain ID 56 for BSC Mainnet

Partial Execution

Bundles execute atomically, so partial execution should not occur. If you observe partial execution:

  • Contact support — This indicates a potential builder issue

  • Verify using the bundle hash — Check the bundle status on a block explorer

Last updated

Was this helpful?