Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@flashbots/ethers-provider-bundle
Advanced tools
ethers-provider-flashbots-bundle ================================
Contains the FlashbotsBundleProvider
ethers.js provider to provide high-level access to eth_sendBundle rpc endpoint.
Flashbots-enabled relays and miners will expose a single jsonrpc endpoint: eth_sendBundle
. Since this is a brand-new, non-standard endpoint, ethers.js and other libraries do not natively support these requests (like getTransactionCount
). In order to interact with eth_sendBundle
, you will also need access to another full-featured endpoint for nonce-calculation, gas estimation, and transaction status.
This library is not a fully functional ethers.js implementation, just a simple provider class, designed to interact with your existing ethers.js v5 module.
You can pass in a generic ethers.js provider to the flashbots provider in the constructor:
const NETWORK_INFO = {chainId: 1, ensAddress: '', name: 'mainnet'}
// Standard json rpc provider directly from ethers.js
const provider = new providers.JsonRpcProvider({url: ETHEREUM_RPC_URL}, NETWORK_INFO)
// flashbots provider requires passing in a standard provider
const flashbotsProvider = new FlashbotsBundleProvider(provider, flashbotsApiKey, flashbotsSecret)
The flashbotsProvider provides the sendBundle function:
flashbotsProvider.sendBundle(bundledTransactions: Array<FlashbotsBundleTransaction | FlashbotsBundleRawTransaction>, targetBlockNumber: number)
=> Promise<FlashbotsTransactionResponse>
// Using the map below ships two different bundles, targeting the next two blocks
const blockNumber = await provider.getBlockNumber()
const minTimestamp = (await provider.getBlock(blockNumber)).timestamp
const maxTimestamp = minTimestamp + 120
const bundlePromises = _.map([blockNumber + 1, blockNumber + 2], targetBlockNumber =>
this.flashbotsProvider.sendBundle(
[
{
signedTransaction: SIGNED_ORACLE_UPDATE_FROM_PENDING_POOL // serialized signed transaction hex
},
{
signer: wallet, // ethers signer
transaction: transaction // ethers populated transaction object
}
],
targetBlockNumber, // block number at which this bundle is valid
{
minTimestamp, // optional minimum timestamp at which this bundle is valid (inclusive)
maxTimestamp // optional maximum timestamp at which this bundle is valid (inclusive)
}
)
)
A Flashbots bundle consists of one or more transactions in strict order to be relayed to the miner directly. While the miner requires signed transaction, sendBundle()
can receive a mix of pre-signed transaction and TransactionRequest
+ Signer
(wallet) objects
These bundles can pay the miner either via gas fees OR via block.coinbase.transfer(minerReward)
The only block number for which the bundle is to be considered valid. If you would like more than one block to be targeted, submit multiple rpc calls targeting each specific block. This value should be higher than the value of getBlockNumber(). Submitting a bundle with a target block number of the current block, or earlier, is a no-op.
A high-level object which contains metadata available at transaction submission time, as well as the following functions which can wait, track, and simulate the bundle's behavior
Included is a simple demo of how to construct the FlashbotsProvider with api key authentication and submit a [non-functional] bundle. This will not yield any mev, but could serve as a sample initialization to help integrate into your own functional searcher.
FAQs
This repository contains the `FlashbotsBundleProvider` ethers.js provider, an additional `Provider` to `ethers.js` to enable high-level access to `eth_sendBundle` and `eth_callBundle` rpc endpoint on [mev-relay](https://github.com/flashbots/mev-relay-js).
The npm package @flashbots/ethers-provider-bundle receives a total of 6,608 weekly downloads. As such, @flashbots/ethers-provider-bundle popularity was classified as popular.
We found that @flashbots/ethers-provider-bundle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.