Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.05 KB

File metadata and controls

43 lines (30 loc) · 1.05 KB

Alloy Multi-Proxy Provider

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.

Installation

Add this to your Cargo.toml:

[dependencies]
alloy-multiproxy-provider = "0.1.0"

Usage

use alloy_multiproxy_provider::MultiProxyProvider;
use alloy::providers::Provider;
use reqwest::Url;

#[tokio::main]
async fn main() -> 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 provider
    let block_number = provider.get_block_number().await?;
    println!("Latest block: {}", block_number);
    
    Ok(())
}

License

MIT