### Install MEV-Boost from Source using go install Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-boost/getting-started/installation.md Installs the latest version of MEV-Boost using the go install command. The executable will be placed in your $GOPATH/bin directory. ```bash go install github.com/flashbots/mev-boost@latest mev-boost -help ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/flashbots/flashbots-docs/blob/main/README.md After creating the .env file, run this command to install project dependencies using Yarn. ```console yarn install ``` -------------------------------- ### Install Portable MEV-Boost using go install Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-boost/getting-started/installation.md Installs the portable version of MEV-Boost using 'go install' with specific CGO flags to resolve 'SIGILL: illegal instruction' errors. Ensure you have Go 1.18+ installed. ```bash CGO_CFLAGS="-O -D__BLST_PORTABLE__" go install github.com/flashbots/mev-boost@latest ``` -------------------------------- ### Install Specific MEV-Boost Version from Source Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-boost/getting-started/installation.md Installs a specific version of MEV-Boost using the go install command with the @VERSION syntax. Replace VERSION with the desired tag from the releases page. ```bash go install github.com/flashbots/mev-boost@VERSION ``` -------------------------------- ### Verify MEV-Boost Installation Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-boost/getting-started/installation.md Verifies the MEV-Boost installation by running the executable with the -help flag. This command should be run from the directory where the binary was placed or built. ```bash ./mev-boost -help ``` -------------------------------- ### mev_simBundle Request Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx This example demonstrates the request format for mev_simBundle, used to simulate matched bundles on MEV-Share. It includes inclusion parameters, transaction details, and validity configurations. ```json { "params": [ { "inclusion": { "block": "0x8b8da8", "maxBlock": "0x8b8dab" }, "body": [ { "tx": "0x02f87b058201d5843b9aca00843b9aca368255f0940000c335bc9d5d1af0402cad63fa7f258363d71a808f696d2073686172696969696969696e67c001a00d8d998fb0dc1e4da9b1de477acea54f185153d66d0af45a4ecfd20e453772baa07bd0ad1e1afb3f19749aaa5660f22859a6e485942346cd7186c024a5da747ada", "canRevert": false }, { "tx": "0x02f880058201d685e9103fda0085e9103fda368255f0940000c335bc9d5d1af0402cad63fa7f258363d71a8092696d206261636b72756e6e69696969696e67c080a0c5058ccf5759e29d4ad28e038f632a9b6269bbb0644c61447e0f14d56c453d73a048e877ee621c4b6be1234a8ad84379e80d45b288a7271e2b1aede7a04f06fd98", "canRevert": false } ], "version": "v0.1", "validity": { "refund": [], "refundConfig": [] } }, { "parentBlock": "0x8b8da8" } ], "method": "mev_simBundle", "id": 1, "jsonrpc": "2.0" } ``` -------------------------------- ### Forge Deployment Output Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/flash-loan-arbitrage/simple-blind-arbitrage.mdx Example output from a successful contract deployment using forge, showing the deployer address, deployed contract address, and transaction hash. ```text No files changed, compilation skipped Deployer: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 Deployed to: 0xc075BC0f734EFE6ceD866324fc2A9DBe1065CBB1 Transaction hash: 0xe9567cce60dfdc1f815f4724340228f2af77ee5cc157a69d07c4b270fcab3a30 ``` -------------------------------- ### Start Local Development Server Source: https://github.com/flashbots/flashbots-docs/blob/main/README.md Run this command to start the Docusaurus development server. Changes are often reflected live without a server restart. ```console yarn start ``` -------------------------------- ### Flashbots Bundle Simulation Output Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/troubleshooting.mdx An example of the JSON output from the `eth_callBundle` simulation. This includes total gas used, bundle hash, coinbase difference, and detailed results for each transaction within the bundle, such as gas used, fees, and addresses. ```json { "totalGasUsed": 98564, "bundleHash": "0x9a6a9fa038343fe3c57260fb7bdb2c79ebadb3088656300d8a494123ebda6d85", "coinbaseDiff": BigNumber(0x034dc9949767a4), }, "results": [ { "coinbaseDiff": "929953106847652", "ethSentToCoinbase": "0", "fromAddress": "0x9874Ef8519a0Fc7a6B553aad92fDF0E469488931", "gasFees": "929953106847652", "gasPrice": "35008022393", "gasUsed": 29964, "toAddress": "0x48B2dD9CEFbA73c60882478a16BC3428Aceed2B9", "txHash": "0xee3f6f22bf3b4740b36833d41d4872f48f98c6328fa04b3679558e482ba0e328", "value": "0x0000000000000000000000000000000000000000000000000000000000000001" }, ... ], } ``` -------------------------------- ### Flashbots Bundle Stats Output Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/troubleshooting.mdx Example JSON output from the eth_getBundleStats RPC endpoint, detailing simulation and submission timestamps. ```json { "isSimulated": true, "isSentToMiners": true, "isHighPriority": true, "simulatedAt": "2021-10-29T04:00:50.526Z", "submittedAt": "2021-10-29T04:00:50.472Z", "sentToMinersAt": "2021-10-29T04:00:50.546Z" } ``` -------------------------------- ### Install and Run MEV-Boost Source: https://context7.com/flashbots/flashbots-docs/llms.txt Install and run the MEV-Boost validator sidecar for proposer-builder separation. Validators connect MEV-Boost to trusted relays to access the competitive block-building market. ```bash # Install via go install go install github.com/flashbots/mev-boost@latest mev-boost -help ``` ```bash # Or pull Docker image docker pull flashbots/mev-boost:latest docker run flashbots/mev-boost -help ``` ```bash # Run on Mainnet pointed at Flashbots relay ./mev-boost \ -mainnet \ -relay-check \ -relays https://0xac6e77dfe25ecd6110b8e780608cce0dab71fdd5ebea22a16c0205200f2f8e2e3ad3b71d3499c54ad14d6c21b41a37ae@boost-relay.flashbots.net ``` ```bash # Run on Sepolia testnet ./mev-boost \ -sepolia \ -relay-check \ -relays https://0x845bd072b7cd566f02faeb0a4033ce9399e42839ced64e8b2adcfc859ed1e8e1a5a293336a49feac6d9a5edb779be53a@builder-relay-sepolia.flashbots.net ``` ```bash # Multiple relays (comma-separated) ./mev-boost -mainnet -relay-check \ -relays RELAY_URL_1,RELAY_URL_2 ``` ```bash # Systemd service (save to /etc/systemd/system/mev-boost.service): # [Unit] # Description=mev-boost # Wants=network-online.target # After=network-online.target # # [Service] # User=mev-boost # Group=mev-boost # WorkingDirectory=/home/mev-boost # Type=simple # Restart=always # RestartSec=5 # ExecStart=/home/mev-boost/bin/mev-boost -mainnet -relay-check -relays YOUR_RELAY_CHOICE # # [Install] # WantedBy=multi-user.target ``` ```bash # Verify validator registration via Relay Data API: curl "https://boost-relay.flashbots.net/relay/v1/data/validator_registration?pubkey=0xYOUR_VALIDATOR_PUBKEY" ``` ```json # Response: # { # "message": { # "fee_recipient": "0x6db5c947ba388f0e708c03339d534af9fae5679c", # "gas_limit": "30000000", # "timestamp": "1663063595", # "pubkey": "0xb606e206c..." # }, # "signature": "0x94f1f6..." # } ``` -------------------------------- ### Example eth_callBundle Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example of a complete eth_callBundle request, including signed transactions, block numbers, and an optional timestamp for simulation. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_callBundle", "params": [ { "txs": ["0x123abc...", "0x456def..."], "blockNumber": "0xb63dcd", "stateBlockNumber": "latest", "timestamp": 1615920932 } ] } ``` -------------------------------- ### mev_simBundle Response Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx A successful response from mev_simBundle, indicating simulation success and providing details on gas prices, profit, and logs. ```json { "success": true, "stateBlock": "0x8b8da8", "mevGasPrice": "0x74c7906005", "profit": "0x4bc800904fc000", "refundableValue": "0x4bc800904fc000", "gasUsed": "0xa620", "logs": [{}, {}] } ``` -------------------------------- ### Install MEV-Share Client Library (TypeScript) Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/getting-started.mdx Add the MEV-Share client library to your project using yarn. ```bash yarn add @flashbots/mev-share-client ``` -------------------------------- ### mev_sendBundle Request Example Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example request for the mev_sendBundle RPC method, utilizing the newer bundle format for MEV-Share. This format includes version, inclusion block details, and transaction body. ```json { "params": [ { "version": "v0.1", "inclusion": { "block": "0x8b8da8", "maxBlock": "0x8b8dab" }, "body": [ { "hash": "0x24e6e999b8abf2c4df46e8a02516c0983043039a5a54f89fa87274427ce64798" }, { "tx": "0x02f880058201d685e9103fda0085e9103fda368255f0940000c335bc9d5d1af0402cad63fa7f258363d71a8092696d206261636b72756e6e69696969696e67c080a0c5058ccf5759e29d4ad28e038f632a9b6269bbb0644c61447e0f14d56c453d73a048e877ee621c4b6be1234a8ad84379e80d45b288a7271e2b1aede7a04f06fd98", "canRevert": false } ], "validity": { "refund": [], "refundConfig": [] } } ], "method": "mev_sendBundle", "id": 1, "jsonrpc": "2.0" } ``` -------------------------------- ### Run Docker Container for Node.js Source: https://github.com/flashbots/flashbots-docs/blob/main/README.md Use this command to start a Docker container with Node.js v22.18.0, mounting the current directory for development. ```bash docker run -p 3000:3000 --rm -it -w /mnt -v $(pwd):/mnt node:22.18.0 /bin/bash ``` -------------------------------- ### Copy Environment Template Source: https://github.com/flashbots/flashbots-docs/blob/main/README.md Before starting local development, copy the .env.template file to .env to configure environment variables. ```sh cp .env.template .env ``` -------------------------------- ### Example eth_callBundle Response Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx A sample response from eth_callBundle, detailing gas prices, bundle hash, and results of individual transactions within the bundle. ```json { "jsonrpc": "2.0", "id": "123", "result": { "bundleGasPrice": "476190476193", "bundleHash": "0x73b1e258c7a42fd0230b2fd05529c5d4b6fcb66c227783f8bece8aeacdd1db2e", "coinbaseDiff": "20000000000126000", "ethSentToCoinbase": "20000000000000000", "gasFees": "126000", "results": [ { "coinbaseDiff": "10000000000063000", "ethSentToCoinbase": "10000000000000000", "fromAddress": "0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0", "gasFees": "63000", "gasPrice": "476190476193", "gasUsed": 21000, "toAddress": "0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C", "txHash": "0x669b4704a7d993a946cdd6e2f95233f308ce0c4649d2e04944e8299efcaa098a", "value": "0x" }, { "coinbaseDiff": "10000000000063000", "ethSentToCoinbase": "10000000000000000", "fromAddress": "0x02A727155aeF8609c9f7F2179b2a1f560B39F5A0", "gasFees": "63000", "gasPrice": "476190476193", "gasUsed": 21000, "toAddress": "0x73625f59CAdc5009Cb458B751b3E7b6b48C06f2C", "txHash": "0xa839ee83465657cac01adc1d50d96c1b586ed498120a84a64749c0034b4f19fa", "value": "0x" } ], "stateBlockNumber": 5221585, "totalGasUsed": 42000 } } ``` -------------------------------- ### Import and Initialize MEV-Share Client (TypeScript) Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/getting-started.mdx Import necessary modules and initialize the MEV-Share client using your provider and signer. Replace placeholders with your actual data. ```typescript import {Wallet, JsonRpcProvider} from 'ethers'; import MevShareClient, { BundleParams, IPendingBundle, IPendingTransaction, TransactionOptions, } from '@flashbots/mev-share-client'; const provider = new JsonRpcProvider(RPC_URL); const authSigner = new Wallet(FB_REPUTATION_PRIVATE_KEY, provider); const mevShareClient = MevShareClient.useEthereumMainnet(authSigner); ``` -------------------------------- ### Setup and Contract Initialization for MEV-Share Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/limit-order/setup.mdx Initializes the MEV-Share client, provider, and wallet instances. It also sets up contract instances for Uniswap V2 router and factory. Ensure your RPC_URL and private keys are set in your environment variables. ```typescript import MevShareClient, {IPendingTransaction} from '@flashbots/mev-share-client' import { Contract, JsonRpcProvider, Wallet } from 'ethers' import { UNISWAP_V2_ABI, UNISWAP_FACTORY_ABI, ERC20_ABI } from './abi' // <-- new import import dotenv from "dotenv" dotenv.config() const RPC_URL = process.env.RPC_URL || 'http://127.0.0.1:8545' const EXECUTOR_KEY = process.env.EXECUTOR_KEY || Wallet.createRandom().privateKey const FB_REPUTATION_PRIVATE_KEY = process.env.FB_REPUTATION_KEY || Wallet.createRandom().privateKey // create web3 provider & wallets, connect to mev-share const provider = new JsonRpcProvider(RPC_URL) const executorWallet = new Wallet(EXECUTOR_KEY, provider) const authSigner = new Wallet(FB_REPUTATION_PRIVATE_KEY, provider) const mevshare = MevShareClient.useEthereumGoerli(authSigner) // if you want to connect to mainnet instead: // const mevshare = MevShareClient.useEthereumMainnet(authSigner) // create contract instances const UNISWAP_V2_ADDRESS = '0x7a250d5630b4cf539739df2c5dacb4c659f2488d' const UNISWAP_FACTORY_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f' const uniswapRouterContract = new Contract(UNISWAP_V2_ADDRESS, UNISWAP_V2_ABI, executorWallet) const uniswapFactoryContract = new Contract(UNISWAP_FACTORY_ADDRESS, UNISWAP_FACTORY_ABI, provider) ``` -------------------------------- ### eth_cancelPrivateTransaction Example Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/additional-documentation/eth-sendPrivateTransaction.mdx An example JSON-RPC request for cancelling a private transaction. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_cancelPrivateTransaction", "params": [ { "txHash": "0x45df1bc3de765927b053ec029fc9d15d6321945b23cac0614eb0b5e61f3a2f2a" } ] } ``` -------------------------------- ### eth_sendPrivateRawTransaction Example Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/additional-documentation/eth-sendPrivateTransaction.mdx An example JSON-RPC request for sending a private raw transaction. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_sendPrivateRawTransaction", "params": ["0x123abc..."] } ``` -------------------------------- ### Initialize New Bot Project with Yarn Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/limit-order/setup.mdx Sets up a new Typescript project directory and initializes it with Yarn. Installs core development dependencies and the ethers and mev-share-client libraries. ```bash mkdir simple-limit-order-bot && cd simple-limit-order-bot yarn init # install typescript & eslint dev dependencies yarn add -D @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser dotenv eslint eslint-plugin-tsdoc ts-node typescript # install ethers & mev-share client yarn add ethers @flashbots/mev-share-client ``` -------------------------------- ### Flashbots Provider Setup (Go) Source: https://context7.com/flashbots/flashbots-docs/llms.txt Build authenticated Flashbots HTTP requests in Go by signing the JSON-RPC payload with an ECDSA private key and adding the X-Flashbots-Signature header. ```go package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" ) const ( flashbotURL = "https://relay.flashbots.net" flashbotXHeader = "X-Flashbots-Signature" ) var privateKey, _ = crypto.HexToECDSA( "2e19800fcbbf0abb7cf6d72ee7171f08943bc8e5c3568d1d7420e52136898154", ) func flashbotHeader(signature []byte) string { return crypto.PubkeyToAddress(privateKey.PublicKey).Hex() + ":" + hexutil.Encode(signature) } func main() { client := &http.Client{Timeout: time.Second * 3} params := map[string]interface{}{ "jsonrpc": "2.0", "id": 1, "method": "eth_sendBundle", "params": []interface{}{map[string]interface{}{ "txs": []string{"0x123abc...", "0x456def..."}, "blockNumber": "0xb63dcd", }}, } payload, _ := json.Marshal(params) req, _ := http.NewRequest("POST", flashbotURL, bytes.NewBuffer(payload)) sig, _ := crypto.Sign( accounts.TextHash([]byte(hexutil.Encode(crypto.Keccak256(payload)))), privateKey, ) req.Header.Add("Content-Type", "application/json") req.Header.Add(flashbotXHeader, flashbotHeader(sig)) resp, _ := client.Do(req) res, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(res)) // Output: {"jsonrpc":"2.0","id":"1","result":{"bundleHash":"0x2228f5..."}} } ``` -------------------------------- ### eth_cancelPrivateTransaction Example Response Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/additional-documentation/eth-sendPrivateTransaction.mdx An example JSON-RPC response indicating the success or failure of a private transaction cancellation. ```json { "jsonrpc": "2.0", "id": 1, "result": true // true if tx successfully cancelled, false if not } ``` -------------------------------- ### Example eth_sendPrivateTransaction Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/additional-documentation/eth-sendPrivateTransaction.mdx An example JSON-RPC request object for sending a private transaction with specified preferences. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_sendPrivateTransaction", "params": [ { "tx": "0x123abc...", "maxBlockNumber": "0xcd23a0", "preferences": { "fast": true, "privacy": { "hints": ["calldata", "transaction_hash"], "builders": ["default"] }, "validity": { "refund": [{ "address": "0xadd123", "percent": 50 }] } } } ] } ``` -------------------------------- ### Configure web3.py Provider for Flashbots Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/quick-start.mdx Initialize a web3.py instance for interacting with Flashbots. Use an environment variable for your 'ETH_SIGNATURE_KEY', which serves as an identifying key for Flashbots communication. ```python import os from eth_account.account import Account from eth_account.signers.local import LocalAccount from flashbots import flashbot from web3 import Web3, HTTPProvider # Create a web3 object with a standard json rpc provider, such as Infura, Alchemy, or your own node. w3 = Web3(HTTPProvider("http://localhost:8545")) # ETH_ACCOUNT_SIGNATURE is an Ethereum private key that does NOT store funds and is NOT your bot's primary key. # This is an identifying key for signing payloads to establish reputation and whitelisting ETH_ACCOUNT_SIGNATURE: LocalAccount = Account.from_key(os.environ.get("ETH_SIGNATURE_KEY")) ``` -------------------------------- ### Flashbots Provider Setup (Go) Source: https://context7.com/flashbots/flashbots-docs/llms.txt Build authenticated Flashbots HTTP requests in Go by signing the JSON-RPC payload with an ECDSA private key and adding the X-Flashbots-Signature header. ```APIDOC ## Flashbots Provider Setup (Go) Build authenticated Flashbots HTTP requests in Go by signing the JSON-RPC payload with an ECDSA private key and adding the `X-Flashbots-Signature` header. ```go package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http" "time" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" ) const ( flashbotURL = "https://relay.flashbots.net" flashbotXHeader = "X-Flashbots-Signature" ) var privateKey, _ = crypto.HexToECDSA( "2e19800fcbbf0abb7cf6d72ee7171f08943bc8e5c3568d1d7420e52136898154", ) func flashbotHeader(signature []byte) string { return crypto.PubkeyToAddress(privateKey.PublicKey).Hex() + ":" + hexutil.Encode(signature) } func main() { client := &http.Client{Timeout: time.Second * 3} params := map[string]interface{}{ "jsonrpc": "2.0", "id": 1, "method": "eth_sendBundle", "params": []interface{}{ map[string]interface{}{ "txs": []string{"0x123abc...", "0x456def..."}, "blockNumber": "0xb63dcd", }}, } payload, _ := json.Marshal(params) req, _ := http.NewRequest("POST", flashbotURL, bytes.NewBuffer(payload)) sig, _ := crypto.Sign( accounts.TextHash([]byte(hexutil.Encode(crypto.Keccak256(payload)))), privateKey, ) req.Header.Add("Content-Type", "application/json") req.Header.Add(flashbotXHeader, flashbotHeader(sig)) resp, _ := client.Do(req) res, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(res)) // Output: {"jsonrpc":"2.0","id":"1","result":{"bundleHash":"0x2228f5..."}} } ``` ``` -------------------------------- ### Example eth_sendPrivateTransaction Response Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/additional-documentation/eth-sendPrivateTransaction.mdx An example JSON-RPC response object for a successful eth_sendPrivateTransaction request, returning the transaction hash. ```json { "jsonrpc": "2.0", "id": 1, "result": "0x45df1bc3de765927b053ec029fc9d15d6321945b23cac0614eb0b5e61f3a2f2a" // tx hash } ``` -------------------------------- ### Simulate and Send Flashbots Bundles on Testnets Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/testnets.mdx This example demonstrates how to sign transactions, simulate a bundle for inclusion in a specific block, and then submit the bundle for inclusion in subsequent blocks. Submitting for multiple future blocks increases the likelihood of inclusion on testnets with fewer validators. ```javascript const wallet = new ethers.Wallet(SOME_PRIVATE_KEY); const signedTransactions = await flashbotsProvider.signBundle([ { signer: wallet, transaction: { to: "0xf1a54b075fb71768ac31b33fd7c61ad8f9f7dd18", gasPrice: 10, gasLimit: 21000, chainId: 5, value: 0, }, }, { signer: wallet, transaction: { to: "0xf1a54b075fb71768ac31b33fd7c61ad8f9f7dd18", gasPrice: 10, gasLimit: 21000, chainId: 5, value: 0, }, }, ]); const blockNumber = await provider.getBlockNumber(); console.log(new Date()); const simulation = await flashbotsProvider.simulate( signedTransactions, blockNumber + 1 ); console.log(new Date()); // Using TypeScript discrimination if ("error" in simulation) { console.log(`Simulation Error: ${simulation.error.message}`); } else { console.log( `Simulation Success: ${blockNumber} ${JSON.stringify( simulation, null, 2 )}` ); } console.log(signedTransactions); for (var i = 1; i <= 10; i++) { const bundleSubmission = flashbotsProvider.sendRawBundle( signedTransactions, blockNumber + i ); console.log("submitted for block # ", blockNumber + i); } console.log("bundles submitted"); ``` -------------------------------- ### Example eth_sendBundle Response with Builders Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example response to an eth_sendBundle request that specified builders. Note the inclusion of the 'smart' field. ```json { "jsonrpc": "2.0", "id": "123", "result": { "bundleHash": "0x2228f5d8954ce31dc1601a8ba264dbd401bf1428388ce88238932815c5d6f23f", "smart": "true" } } ``` -------------------------------- ### Example MEV-Share SSE Response Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/event-stream.mdx This is an example of the data format received from the MEV-Share SSE endpoint, containing transaction details. ```json :ping data: {"hash":"0xc7dc06c994400830054ab815732d91275bc1241f9be62b62b687b7882f19b8d4","logs":null,"txs":[{"to":"0x0000c335bc9d5d1af0402cad63fa7f258363d71a","functionSelector":"0x696d2073","callData":"0x696d20736861726969696969696e67"}]} ``` -------------------------------- ### Build Static Website Source: https://github.com/flashbots/flashbots-docs/blob/main/README.md Execute this command to generate the static content for the website, which will be placed in the 'build' directory. ```console yarn build ``` -------------------------------- ### Build MEV-Boost from Source Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-boost/getting-started/installation.md Builds the MEV-Boost software after cloning the repository and potentially checking out a specific version. ```bash make build ``` -------------------------------- ### Example Transaction Event JSON Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/event-stream.mdx This is an example of a transaction event received from the MEV Share SSE endpoint. Note that all fields are optional. ```json { "hash":"0xb756c9f6c34309d32c32daf1289c96d64a1068dfc2ead5e9bd0504640b91249e", "logs":[ { "address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "topics":[ "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", "0x0000000000000000000000001b59718eafa2bffe5318e07c1c3cb2edde354f9c", "0x0000000000000000000000005c7bcd6e7de5423a257d81b442095a1a6ced35c5" ], "data":"0x000000000000000000000000000000000000000000000000161545fdcf782a85" }, { "address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", "topics":[ "0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65", "0x0000000000000000000000005c7bcd6e7de5423a257d81b442095a1a6ced35c5" ], "data":"0x000000000000000000000000000000000000000000000000161545fdcf782a85" }, { "address":"0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5", "topics":[ "0x8ab9dc6c19fe88e69bc70221b339c84332752fdd49591b7c51e66bae3947b73c", "0x0000000000000000000000000000000000000000000000000000000000000089", "0x0000000000000000000000000000000000000000000000000000000000117363", "0x0000000000000000000000003a23f943181408eac424116af7b7790c94cb97a5" ], "data":"0x000000000000000000000000000000000000000000000000161fb772f99eaf7a000000000000000000000000000000000000000000000000161fb772f99eaf7a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000008900000000000000000000000000000000000000000000000000016b90ac92248e000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000001b59718eafa2bffe5318e07c1c3cb2edde354f9c000000000000000000000000b658ba58f7153e99c05c9b7610f17bfeeab6bff5000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b658ba58f7153e99c05c9b7610f17bfeeab6bff500000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000005216e484d6dde000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ``` -------------------------------- ### flashbots_getFeeRefundTotalsByRecipient Example Response Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example response detailing pending and received fee refunds, along with the maximum block number processed for refunds. ```json { "pending":"0x17812ea4fbbe314", "received":"0x108d1b27b63a213", "maxBlockNumber":"0x13ddb08" } ``` -------------------------------- ### Listen for MEV-Share Transactions in TypeScript/JavaScript Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/flash-loan-arbitrage/bot.mdx Initialize the MEV-Share client and set up a listener for incoming transaction events. Ensure you have authenticated with your signer. ```typescript const authSigner = new Wallet(Env.authKey).connect(provider) const mevshare = MevShareClient.useEthereumMainnet(authSigner) mevshare.on("transaction", async (pendingTx: IPendingTransaction) => { // handle tx event }) ``` -------------------------------- ### Example eth_sendPrivateTransaction Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example JSON-RPC request for eth_sendPrivateTransaction, demonstrating the use of transaction hash, maxBlockNumber, and detailed privacy and validity preferences. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_sendPrivateTransaction", "params": [ { "tx": "0x123abc...", "maxBlockNumber": "0xcd23a0", "preferences": { "fast": true, "privacy": { "hints": ["calldata", "transaction_hash"], "builders": ["default"] }, "validity": { "refund": [{"address": "0xadd123", "percent": 50}] } } } ] } ``` -------------------------------- ### Example eth_sendBundle Request Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/advanced/rpc-endpoint.mdx An example JSON-RPC request for the eth_sendBundle method, demonstrating the inclusion of transactions and block number. This is used to submit bundles to Flashbots. ```json { "jsonrpc": "2.0", "id": 1, "method": "eth_sendBundle", "params": [ { "txs": ["0x123abc...", "0x456def..."], "blockNumber": "0xb63dcd", "minTimestamp": 0, "maxTimestamp": 1615920932 } ] } ``` -------------------------------- ### Simulate MEV-Share Bundle with mev_simBundle Source: https://context7.com/flashbots/flashbots-docs/llms.txt Use the `mev_simBundle` method to simulate MEV-Share bundles against a parent block. This helps compute MEV gas price, profit, and refundable value before submission. Requires signed transactions in the bundle. ```bash curl -X POST \ -H "Content-Type: application/json" \ -H "X-Flashbots-Signature: 0xYourAddress:0xSignatureHex" \ -d '{ "jsonrpc": "2.0", "id": 1, "method": "mev_simBundle", "params": [ { "version": "v0.1", "inclusion": { "block": "0x8b8da8", "maxBlock": "0x8b8dab" }, "body": [ { "tx": "0x02f87b058201d5843b9aca00843b9aca368255f094...", "canRevert": false }, { "tx": "0x02f880058201d685e9103fda0085e9103fda368255f094...", "canRevert": false } ], "validity": { "refund": [], "refundConfig": [] } }, { "parentBlock": "0x8b8da8" } ] }' \ https://relay.flashbots.net ``` -------------------------------- ### Flashbots Provider Setup (Rust) Source: https://context7.com/flashbots/flashbots-docs/llms.txt Create a Rust Flashbots client using ethers-flashbots middleware, which wraps the standard ethers provider and routes transactions through relay.flashbots.net. Requires a local wallet for signing and an Infura key for the provider. ```rust use ethers::core::rand::thread_rng; use ethers::prelude::*; use ethers_flashbots::*; use std::convert::TryFrom; use url::Url; #[tokio::main] async fn main() { let provider = Provider::::try_from( "https://mainnet.infura.io/v3/YOUR_INFURA_KEY" ).unwrap(); // Searcher identity key (no funds required) let bundle_signer = LocalWallet::new(&mut thread_rng()); // Transaction signing key let wallet = LocalWallet::new(&mut thread_rng()); let flashbots_client = SignerMiddleware::new( FlashbotsMiddleware::new( provider, Url::parse("https://relay.flashbots.net").unwrap(), bundle_signer, ), wallet, ); // Send a transaction — automatically routed through Flashbots let tx = TransactionRequest::pay("vitalik.eth", 100); let pending = flashbots_client.send_transaction(tx, None).await.unwrap(); let receipt = pending.await.unwrap().unwrap(); println!("Included in block: {:?}", receipt.block_number); } ``` -------------------------------- ### Example MEV-Share Event JSON Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/flash-loan-arbitrage/bot.mdx This is an example of a JSON object representing an event received from the MEV-Share stream. It includes transaction hash, logs, and potentially transaction details for bundles. ```json { "hash": "0x0c459dce812747c643f06c82eeca2a2f584b4e30af79b2b546fd015e4aac4541", "logs": [ { "address": "0xca25091555d36ac0be8119ad967898ac30223b41", "topics": [ "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" ], "data": "0x" }, { "address": "0xca25091555d36ac0be8119ad967898ac30223b41", "topics": [ "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822", "0x0000000000000000000000000000000000000000000000000000000000000000", "0x0000000000000000000000000000000000000000000000000000000000000000" ], "data": "0x" } ], "txs": null } ``` -------------------------------- ### Initialize Flashbots Provider (Python) Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-auction/quick-start.mdx Initializes a Flashbots provider using a standard web3 provider and an ETH_ACCOUNT_SIGNATURE for authentication and reputation. ```python from flashbots import flashbot # Assuming w3 is an initialized web3 provider instance # and ETH_ACCOUNT_SIGNATURE is your private key or signature string flashbot(w3, ETH_ACCOUNT_SIGNATURE) ``` -------------------------------- ### Get UniV2 Swap Event Signature Hash Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-mev-share/searchers/tutorials/flash-loan-arbitrage/bot.mdx Use `cast sig-event` to get the keccak256 hash of a smart contract event signature. This hash is used to identify specific event types in transaction logs. ```bash cast sig-event "event Swap( address indexed sender, uint amount0In, uint amount1In, uint amount0Out, uint amount1Out, address indexed to );" 0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822 ``` -------------------------------- ### Configure Hints for MEV-Share Searchers Source: https://github.com/flashbots/flashbots-docs/blob/main/docs/flashbots-protect/settings-guide.md Use the 'hint' query parameter to control which transaction data is visible to MEV-Share searchers. This example shares contract address and logs but excludes calldata and function selector. ```url https://rpc.flashbots.net?hint=contract_address&hint=logs ```