Skip to main content

Module ethereum

Module ethereum 

Source
Expand description

§Ethereum Client

This module provides an Ethereum blockchain client that supports Ethereum mainnet and EVM-compatible chains (Polygon, Arbitrum, etc.).

§Features

  • Balance queries via block explorer APIs (with USD valuation via DexScreener)
  • Transaction details lookup via Etherscan proxy API (eth_getTransactionByHash)
  • Transaction receipt fetching for gas usage and status
  • Transaction history retrieval
  • ERC-20 token balance fetching (via tokentx + tokenbalance endpoints)
  • Token holder count estimation with pagination
  • Token information and holder analytics
  • Support for both block explorer API and JSON-RPC modes

§Usage

use scope::chains::EthereumClient;
use scope::config::ChainsConfig;

#[tokio::main]
async fn main() -> scope::Result<()> {
    let config = ChainsConfig::default();
    let client = EthereumClient::new(&config)?;
     
    let mut balance = client.get_balance("0x742d35Cc6634C0532925a3b844Bc9e7595f1b3c2").await?;
    client.enrich_balance_usd(&mut balance).await;
    println!("Balance: {} (${:.2})", balance.formatted, balance.usd_value.unwrap_or(0.0));
    Ok(())
}

Structs§

EthereumClient
Ethereum and EVM-compatible chain client.

Enums§

ApiType
API type for the client endpoint.