pub struct FlashbotsMiddleware<M, S> { /* private fields */ }
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.

Get the relay client used by the middleware to simulate bundles if set.

Set a separate relay to use for simulating bundles.

This can either be a full Flashbots relay or a node that implements the eth_callBundle remote procedure call.

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.
Fill necessary details of a transaction for dispatch Read more
Send a transaction with a simple escalation policy. Read more
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.
Sign a transaction via RPC call
Returns a stream of logs are loaded in pages of given page size
After replaying any previous transactions in the same block, Replays a transaction, returning the traces configured with passed options
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

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
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.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more