pub struct FlashbotsClient { /* private fields */ }Expand description
Main client for interacting with Flashbots relay
Implementations§
Source§impl FlashbotsClient
impl FlashbotsClient
Sourcepub fn new(config: FlashbotsClientConfig) -> Self
pub fn new(config: FlashbotsClientConfig) -> Self
Creates a new Flashbots client with custom configuration
Sourcepub fn new_mainnet() -> Self
pub fn new_mainnet() -> Self
Creates a new client configured for Mainnet
Sourcepub fn new_sepolia() -> Self
pub fn new_sepolia() -> Self
Creates a new client configured for Sepolia testnet
Sourcepub fn with_max_retries(self, max_retries: u32) -> Self
pub fn with_max_retries(self, max_retries: u32) -> Self
Sets maximum retry attempts for operations
Sourcepub fn with_timeout(self, timeout_seconds: u64) -> Self
pub fn with_timeout(self, timeout_seconds: u64) -> Self
Sets request timeout in seconds
Sourcepub async fn send_bundle(
&self,
bundle: Bundle,
) -> FlashbotsResult<SendBundleResponse>
pub async fn send_bundle( &self, bundle: Bundle, ) -> FlashbotsResult<SendBundleResponse>
Sends a bundle to Flashbots relay
§Example
use flashbots_rs::{FlashbotsClient, Bundle};
let client = FlashbotsClient::new_mainnet();
let bundle = Bundle::default(); // Your bundle construction
let response = client.send_bundle(bundle).await?;
println!("Bundle sent with hash: {:?}", response.bundle_hash);Sourcepub async fn send_bundle_with_retry(
&self,
bundle: Bundle,
) -> FlashbotsResult<SendBundleResponse>
pub async fn send_bundle_with_retry( &self, bundle: Bundle, ) -> FlashbotsResult<SendBundleResponse>
Sends a bundle with automatic retry logic
Sourcepub async fn simulate_bundle(
&self,
simulation: SimulateBundleRequest,
) -> FlashbotsResult<SimulateBundleResponse>
pub async fn simulate_bundle( &self, simulation: SimulateBundleRequest, ) -> FlashbotsResult<SimulateBundleResponse>
Simulates bundle execution without submitting to the network
§Example
use flashbots_rs::{FlashbotsClient, SimulateBundleRequest};
let client = FlashbotsClient::new_mainnet();
let simulation = SimulateBundleRequest::default(); // Your simulation parameters
let result = client.simulate_bundle(simulation).await?;
println!("Simulation success: {}, Gas used: {}", result.success, result.gas_used);Sourcepub async fn simulate_bundle_with_retry(
&self,
simulation: SimulateBundleRequest,
) -> FlashbotsResult<SimulateBundleResponse>
pub async fn simulate_bundle_with_retry( &self, simulation: SimulateBundleRequest, ) -> FlashbotsResult<SimulateBundleResponse>
Simulates bundle with automatic retry logic
Sourcepub async fn get_bundle_stats(
&self,
bundle_hash: H256,
block_number: U64,
) -> FlashbotsResult<BundleStats>
pub async fn get_bundle_stats( &self, bundle_hash: H256, block_number: U64, ) -> FlashbotsResult<BundleStats>
Gets bundle statistics for a specific block
Sourcepub async fn get_bundle_receipt(
&self,
bundle_hash: H256,
) -> FlashbotsResult<BundleReceipt>
pub async fn get_bundle_receipt( &self, bundle_hash: H256, ) -> FlashbotsResult<BundleReceipt>
Gets bundle receipt by hash
Sourcepub async fn get_user_stats(
&self,
address: Address,
block_number: U64,
) -> FlashbotsResult<UserStats>
pub async fn get_user_stats( &self, address: Address, block_number: U64, ) -> FlashbotsResult<UserStats>
Gets user statistics for a specific address and block
Sourcepub async fn get_health(&self) -> FlashbotsResult<bool>
pub async fn get_health(&self) -> FlashbotsResult<bool>
Checks relay health status
§Example
use flashbots_rs::FlashbotsClient;
let client = FlashbotsClient::new_mainnet();
let is_healthy = client.get_health().await?;
println!("Relay is healthy: {}", is_healthy);Sourcepub async fn get_bundle_price(
&self,
block_number: U64,
) -> FlashbotsResult<BundlePriceResponse>
pub async fn get_bundle_price( &self, block_number: U64, ) -> FlashbotsResult<BundlePriceResponse>
Gets bundle price for a specific block
Sourcepub async fn wait_for_bundle_inclusion(
&self,
bundle_hash: H256,
timeout_blocks: u64,
) -> FlashbotsResult<Option<BundleReceipt>>
pub async fn wait_for_bundle_inclusion( &self, bundle_hash: H256, timeout_blocks: u64, ) -> FlashbotsResult<Option<BundleReceipt>>
Waits for bundle to be included in a block
§Example
use flashbots_rs::FlashbotsClient;
use ethers::types::H256;
let client = FlashbotsClient::new_mainnet();
let bundle_hash = H256::zero(); // Your actual bundle hash
let receipt = client.wait_for_bundle_inclusion(bundle_hash, 10).await?;
match receipt {
Some(receipt) => println!("Bundle included: {:?}", receipt),
None => println!("Bundle not included within timeout"),
}Sourcepub async fn send_and_wait_for_bundle(
&self,
bundle: Bundle,
timeout_blocks: u64,
) -> FlashbotsResult<Option<BundleReceipt>>
pub async fn send_and_wait_for_bundle( &self, bundle: Bundle, timeout_blocks: u64, ) -> FlashbotsResult<Option<BundleReceipt>>
Sends bundle and waits for inclusion
§Example
use flashbots_rs::{FlashbotsClient, Bundle};
let client = FlashbotsClient::new_mainnet();
let bundle = Bundle::default(); // Your bundle construction
let receipt = client.send_and_wait_for_bundle(bundle, 10).await?;
match receipt {
Some(receipt) => println!("Bundle successfully included: {:?}", receipt),
None => println!("Bundle not included within timeout"),
}Sourcepub async fn simulate_and_send_bundle(
&self,
bundle: Bundle,
simulation_params: SimulateBundleRequest,
) -> FlashbotsResult<Option<SendBundleResponse>>
pub async fn simulate_and_send_bundle( &self, bundle: Bundle, simulation_params: SimulateBundleRequest, ) -> FlashbotsResult<Option<SendBundleResponse>>
Simulates bundle and sends it if simulation is successful
Sourcepub async fn send_bundles(
&self,
bundles: Vec<Bundle>,
) -> FlashbotsResult<Vec<FlashbotsResult<SendBundleResponse>>>
pub async fn send_bundles( &self, bundles: Vec<Bundle>, ) -> FlashbotsResult<Vec<FlashbotsResult<SendBundleResponse>>>
Sends multiple bundles in sequence
Sourcepub fn config(&self) -> &FlashbotsClientConfig
pub fn config(&self) -> &FlashbotsClientConfig
Returns current client configuration
Sourcepub fn with_config(&self, config: FlashbotsClientConfig) -> Self
pub fn with_config(&self, config: FlashbotsClientConfig) -> Self
Creates a new client instance with different configuration
Sourcepub async fn send_raw_bundle(
&self,
raw_bundle: Value,
) -> FlashbotsResult<SendBundleResponse>
pub async fn send_raw_bundle( &self, raw_bundle: Value, ) -> FlashbotsResult<SendBundleResponse>
Send the raw transaction packet (low-level API)
Sourcepub async fn cancel_bundles(
&self,
bundle_hashes: Vec<H256>,
) -> FlashbotsResult<CancelBundlesResponse>
pub async fn cancel_bundles( &self, bundle_hashes: Vec<H256>, ) -> FlashbotsResult<CancelBundlesResponse>
Cancel submitted transaction package
§Example
let client = FlashbotsClient::new_mainnet();
let bundle_hashes = vec![H256::zero()]; // Transaction package hash
let result = client.cancel_bundles(bundle_hashes).await?;
println!("Cancel result: {}", result.success);Sourcepub async fn get_bundle_by_hash(
&self,
bundle_hash: H256,
) -> FlashbotsResult<BundleByHashResponse>
pub async fn get_bundle_by_hash( &self, bundle_hash: H256, ) -> FlashbotsResult<BundleByHashResponse>
Retrieve transaction package details and receipts using transaction package hash.
Sourcepub async fn get_block(
&self,
block_number: U64,
) -> FlashbotsResult<BlockResponse>
pub async fn get_block( &self, block_number: U64, ) -> FlashbotsResult<BlockResponse>
Get detailed information of a specified block
§Example
let client = FlashbotsClient::new_mainnet();
let block_number = U64::from(17000000u64);
let block_info = client.get_block(block_number).await?;
println!("Block miner: {:?}", block_info.miner);Sourcepub async fn get_latest_block(&self) -> FlashbotsResult<BlockResponse>
pub async fn get_latest_block(&self) -> FlashbotsResult<BlockResponse>
Get the latest block information
Sourcepub async fn get_user_status(
&self,
address: Address,
) -> FlashbotsResult<UserStatus>
pub async fn get_user_status( &self, address: Address, ) -> FlashbotsResult<UserStatus>
Obtain user status information (without relying on specific blocks)
§Example
let client = FlashbotsClient::new_mainnet();
let address = Address::zero(); // real address
let user_status = client.get_user_status(address).await?;
println!("User reputation: {:?}", user_status.reputation);Sourcepub async fn get_gas_price(&self) -> FlashbotsResult<GasPriceResponse>
pub async fn get_gas_price(&self) -> FlashbotsResult<GasPriceResponse>
Get recommended gas prices
§Example
let client = FlashbotsClient::new_mainnet();
let gas_prices = client.get_gas_price().await?;
println!("Fast gas price: {}", gas_prices.fast_gas_price);Sourcepub async fn get_supported_endpoints(&self) -> FlashbotsResult<Vec<String>>
pub async fn get_supported_endpoints(&self) -> FlashbotsResult<Vec<String>>
Get the list of API endpoints supported by the repeater.
Sourcepub async fn get_relay_info(&self) -> FlashbotsResult<RelayInfo>
pub async fn get_relay_info(&self) -> FlashbotsResult<RelayInfo>
Get repeater information
§Example
use flashbots_rs::FlashbotsClient;
let client = FlashbotsClient::new_mainnet();
let relay_info = client.get_relay_info().await?;
println!("Relay: {} v{}", relay_info.name, relay_info.version);Sourcepub async fn get_bundle_receipts(
&self,
bundle_hashes: Vec<H256>,
) -> FlashbotsResult<Vec<BundleReceipt>>
pub async fn get_bundle_receipts( &self, bundle_hashes: Vec<H256>, ) -> FlashbotsResult<Vec<BundleReceipt>>
Batch Transaction Package Receipts
Sourcepub async fn check_bundle_inclusions(
&self,
bundle_hashes: Vec<H256>,
) -> FlashbotsResult<Vec<(H256, bool)>>
pub async fn check_bundle_inclusions( &self, bundle_hashes: Vec<H256>, ) -> FlashbotsResult<Vec<(H256, bool)>>
Check if multiple transaction packages have been included.
Sourcepub async fn send_bundle_and_get_receipt(
&self,
bundle: Bundle,
timeout_blocks: u64,
) -> FlashbotsResult<BundleReceipt>
pub async fn send_bundle_and_get_receipt( &self, bundle: Bundle, timeout_blocks: u64, ) -> FlashbotsResult<BundleReceipt>
Send transaction package and get receipt (simplified version)
Sourcepub async fn validate_bundle(&self, bundle: &Bundle) -> FlashbotsResult<bool>
pub async fn validate_bundle(&self, bundle: &Bundle) -> FlashbotsResult<bool>
Verify transaction package format
Sourcepub async fn get_relay_stats(&self) -> FlashbotsResult<Value>
pub async fn get_relay_stats(&self) -> FlashbotsResult<Value>
Obtain repeater performance statistics
Sourcepub async fn get_builder_info(&self) -> FlashbotsResult<Value>
pub async fn get_builder_info(&self) -> FlashbotsResult<Value>
Get Builder Information
Sourcepub async fn simulate_bundles(
&self,
simulations: Vec<SimulateBundleRequest>,
) -> FlashbotsResult<Vec<FlashbotsResult<SimulateBundleResponse>>>
pub async fn simulate_bundles( &self, simulations: Vec<SimulateBundleRequest>, ) -> FlashbotsResult<Vec<FlashbotsResult<SimulateBundleResponse>>>
Batch simulated trading package
Sourcepub async fn send_and_cancel_bundle(
&self,
bundle: Bundle,
) -> FlashbotsResult<bool>
pub async fn send_and_cancel_bundle( &self, bundle: Bundle, ) -> FlashbotsResult<bool>
Send the transaction package and cancel it immediately (for testing purposes).
Sourcepub async fn get_network_info(&self) -> FlashbotsResult<Value>
pub async fn get_network_info(&self) -> FlashbotsResult<Value>
Get network information
Sourcepub async fn is_blacklisted(&self, address: Address) -> FlashbotsResult<bool>
pub async fn is_blacklisted(&self, address: Address) -> FlashbotsResult<bool>
Check if the address is blacklisted.
Sourcepub async fn get_version(&self) -> FlashbotsResult<String>
pub async fn get_version(&self) -> FlashbotsResult<String>
Get repeater version
Source§impl FlashbotsClient
impl FlashbotsClient
Sourcepub fn new_production() -> Self
pub fn new_production() -> Self
Creates a production-ready client (Mainnet, high retry count)
Sourcepub fn new_development() -> Self
pub fn new_development() -> Self
Creates a development client (testnet, fast failure)
Trait Implementations§
Source§impl Clone for FlashbotsClient
impl Clone for FlashbotsClient
Source§fn clone(&self) -> FlashbotsClient
fn clone(&self) -> FlashbotsClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FlashbotsClient
impl !UnwindSafe for FlashbotsClient
impl Freeze for FlashbotsClient
impl Send for FlashbotsClient
impl Sync for FlashbotsClient
impl Unpin for FlashbotsClient
impl UnsafeUnpin for FlashbotsClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> JsonSchemaMaybe for T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.