Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/Bundle

primitives/Bundle

Classes

InvalidBundleError

Defined in: src/primitives/Bundle/errors.js:6 Error thrown when bundle operations fail

Extends

  • Error

Constructors

Constructor
new InvalidBundleError(message, details): InvalidBundleError
Defined in: src/primitives/Bundle/errors.js:7
Parameters
message
any
details
any
Returns
InvalidBundleError
Overrides
Error.constructor

Properties

details
details: any
Defined in: src/primitives/Bundle/errors.js:10
name
name: string
Defined in: src/primitives/Bundle/errors.js:9
Inherited from
Error.name

Type Aliases

BundleLike

BundleLike = BundleType | { blockNumber?: BlockNumberType | bigint | number | string; maxTimestamp?: Type | bigint | number | string; minTimestamp?: Type | bigint | number | string; revertingTxHashes?: (HashType | string)[]; transactions: (Uint8Array | string)[]; }
Defined in: src/primitives/Bundle/BundleType.ts:53 Inputs that can be converted to Bundle

BundleType

BundleType = object
Defined in: src/primitives/Bundle/BundleType.ts:17 Bundle type Represents a transaction bundle for MEV (Maximal Extractable Value) strategies. Bundles are atomic collections of transactions submitted to block builders via MEV relays like Flashbots. All transactions in a bundle execute sequentially in the same block or the bundle is discarded.

See

Since

0.0.0

Properties

blockNumber?
readonly optional blockNumber: BlockNumberType
Defined in: src/primitives/Bundle/BundleType.ts:28 Target block number for bundle inclusion (optional) If specified, bundle is only valid for this block
maxTimestamp?
readonly optional maxTimestamp: Type
Defined in: src/primitives/Bundle/BundleType.ts:40 Maximum block timestamp for bundle inclusion (optional) Bundle will not be included after this timestamp
minTimestamp?
readonly optional minTimestamp: Type
Defined in: src/primitives/Bundle/BundleType.ts:34 Minimum block timestamp for bundle inclusion (optional) Bundle will not be included before this timestamp
revertingTxHashes?
readonly optional revertingTxHashes: readonly HashType[]
Defined in: src/primitives/Bundle/BundleType.ts:47 Transaction hashes allowed to revert (optional) If any other transaction reverts, entire bundle is discarded If a hash in this array reverts, bundle continues execution
transactions
readonly transactions: readonly Uint8Array[]
Defined in: src/primitives/Bundle/BundleType.ts:22 Ordered array of signed transaction bytes All transactions execute sequentially in this order

Functions

addTransaction()

addTransaction(bundle, transaction): BundleType
Defined in: src/primitives/Bundle/addTransaction.js:19 Adds a transaction to the bundle

Parameters

bundle
BundleType Bundle instance
transaction
Signed transaction to add string | Uint8Array<ArrayBufferLike>

Returns

BundleType New bundle with added transaction

Example

import * as Bundle from './Bundle/index.js';
const newBundle = Bundle.addTransaction(bundle, signedTx);

from()

from(value): BundleType
Defined in: src/primitives/Bundle/from.js:25 Creates a Bundle from various input types

Parameters

value
BundleLike Bundle input

Returns

BundleType Bundle instance

Throws

If bundle format is invalid

Example

import * as Bundle from './Bundle/index.js';
const bundle = Bundle.from({
  transactions: [tx1, tx2],
  blockNumber: 123456n,
});

size()

size(bundle): number
Defined in: src/primitives/Bundle/size.js:19 Returns the number of transactions in the bundle

Parameters

bundle
BundleType Bundle instance

Returns

number Number of transactions

Example

import * as Bundle from './Bundle/index.js';
const count = Bundle.size(bundle);
console.log(`Bundle contains ${count} transactions`);

toFlashbotsParams()

toFlashbotsParams(bundle): object
Defined in: src/primitives/Bundle/toFlashbotsParams.js:19 Converts bundle to Flashbots RPC parameters

Parameters

bundle
BundleType Bundle instance

Returns

object Flashbots eth_sendBundle parameters

Example

import * as Bundle from './Bundle/index.js';
const params = Bundle.toFlashbotsParams(bundle);
await flashbots.request({ method: "eth_sendBundle", params: [params] });

toHash()

toHash(bundle, crypto): HashType
Defined in: src/primitives/Bundle/toHash.js:22 Computes the bundle hash (keccak256 of bundle contents)

Parameters

bundle
BundleType Bundle instance
crypto
Crypto dependencies
keccak256
(data) => Uint8Array Keccak256 function

Returns

HashType Bundle hash

Example

import * as Bundle from './Bundle/index.js';
import { keccak256 } from './crypto/keccak256.js';
const hash = Bundle.toHash(bundle, { keccak256 });