A Rust library that provides automatic proxy rotation for Alloy providers. Distributes requests across multiple proxies in a round-robin fashion to avoid rate limits.
Add this to your Cargo.toml:
[dependencies]
alloy-multiproxy-provider = "0.1.0"use alloy_multiproxy_provider::MultiProxyProvider;use alloy::providers::Provider;use reqwest::Url;#[tokio::main]asyncfnmain() -> Result<(),Box<dyn std::error::Error>>{let proxies = vec!["http://proxy1.example.com:8080".to_string(),"http://username:password@proxy2.example.com:8080".to_string(),"http://proxy3.example.com:8080".to_string(),];let rpc_url = Url::parse("https://eth-mainnet.alchemyapi.io/v2/your-api-key")?;let provider = MultiProxyProvider::new(proxies, rpc_url).await?;// Use like any other Alloy providerlet block_number = provider.get_block_number().await?;println!("Latest block: {}", block_number);Ok(())}MIT