Struct ethers_flashbots::FlashbotsMiddleware[][src]

pub struct FlashbotsMiddleware<M, S> { /* fields omitted */ }
Expand description

A middleware used to send bundles to a Flashbots relay.

NOTE: This middleware does NOT sign your transactions. Use another method to sign your transactions, and then forward the signed transactions to the middleware.

You can either send custom bundles (see BundleRequest) or send transactions as you normally would (see Middleware::send_transaction) from another middleware.

If you use Middleware::send_transaction then a bundle will be constructed for you with the following assumptions:

  • You do not want to allow the transaction to revert
  • You do not care to set a minimum or maximum timestamp for the bundle
  • The block you are targetting with your bundle is the next block
  • You do not want to simulate the bundle before sending to the relay

Example

use ethers::prelude::*;
use std::convert::TryFrom;
use ethers_flashbots::FlashbotsMiddleware;
use url::Url;

let provider = Provider::<Http>::try_from("http://localhost:8545")
    .expect("Could not instantiate HTTP provider");

// Used to sign Flashbots relay requests - this is your searcher identity
let signer: LocalWallet = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"
    .parse()?;

// Used to sign transactions
let wallet: LocalWallet = "380eb0f3d505f087e438eca80bc4df9a7faa24f868e69fc0440261a0fc0567dc"
    .parse()?;

// Note: The order is important! You want the signer
// middleware to sign your transactions *before* they
// are sent to your Flashbots middleware.
let mut client = SignerMiddleware::new(
    FlashbotsMiddleware::new(
        provider,
        Url::parse("https://relay.flashbots.net")?,
        signer
    ),
    wallet
);

// This transaction will now be send as a Flashbots bundle!
let tx = TransactionRequest::pay("vitalik.eth", 100);
let pending_tx = client.send_transaction(tx, None).await?;

Implementations

Initialize a new Flashbots middleware.

The signer is used to sign requests to the relay.

Get the relay client used by the middleware.

Simulate a bundle.

See eth_callBundle for more information.

Send a bundle to the relayer.

See eth_sendBundle for more information.

Get stats for a particular bundle.

Get stats for your searcher identity.

Your searcher identity is determined by the signer you constructed the middleware with.

Trait Implementations

Formats the value using the given formatter. Read more

The next middleware in the stack

The HTTP or Websocket provider.

Helper for filling a transaction

This returns true if either the middleware stack contains a SignerMiddleware, or the JSON-RPC provider has an unlocked key that can sign using the eth_sign call. If none of the above conditions are met, then the middleware stack is not capable of signing data. Read more

Executes the given call and returns a number of possible traces for it

Traces a call to eth_sendRawTransaction without making the call, returning the traces

Replays a transaction, returning the traces

Replays all transactions in a block returning the requested traces for each transaction

Returns traces created at given block

Return traces matching the given filter

Returns trace at the given position

Returns all traces of a given transaction

Returns all receipts for that block. Must be done on a parity node.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.