The BroadcasterMiddleware is designed to send the same bundle to multiple relay URLs simultaneously. This is useful for increasing the chances of your bundle being picked up by different builders.
Important: Like FlashbotsMiddleware, this does NOT sign transactions. You must use a signer middleware first.
When using Middleware::send_transaction, it defaults to targeting the next block and does not perform simulation.
use ethers::prelude::*;
use std::convert::TryFrom;
use ethers_flashbots::BroadcasterMiddleware;
use url::Url;
// ... setup provider, signer, and wallet ...
let mut client = SignerMiddleware::new(
BroadcasterMiddleware::new(
provider,
vec![Url::parse("https://rpc.titanbuilder.xyz")?, Url::parse("https://relay.flashbots.net")?],
Url::parse("https://relay.flashbots.net")?, // simulation relay
signer
),
wallet
);
let tx = TransactionRequest::pay("vitalik.eth", 100);
let pending_tx = client.send_transaction(tx, None).await?;