Skip to main content

Crate ethcli

Crate ethcli 

Source
Expand description

ethcli - Comprehensive Ethereum CLI

A Rust library and CLI for Ethereum data: fetching logs, analyzing transactions, querying accounts, and exploring contracts.

§Example - Fetching Logs

use ethcli::{Config, LogFetcher, Chain, OutputFormat};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = Config::builder()
        .chain(Chain::Ethereum)
        .contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
        .event("Transfer(address indexed from, address indexed to, uint256 value)")
        .from_block(18_000_000)
        .to_block_number(18_001_000)
        .concurrency(10)
        .build()?;

    let fetcher = LogFetcher::new(config).await?;
    let result = fetcher.fetch_all().await?;

    println!("Fetched {} logs", result.len());
    Ok(())
}

Re-exports§

pub use abi::AbiFetcher;
pub use abi::DecodedLog;
pub use abi::EventSignature;
pub use abi::LogDecoder;
pub use checkpoint::Checkpoint;
pub use checkpoint::CheckpointManager;
pub use config::BlockNumber;
pub use config::BlockRange;
pub use config::Chain;
pub use config::ChainId;
pub use config::Config;
pub use config::ConfigBuilder;
pub use config::ConfigFile;
pub use config::EndpointConfig;
pub use config::NodeType;
pub use config::OutputConfig;
pub use config::OutputFormat;
pub use config::ProxyConfig;
pub use config::RpcConfig;
pub use error::AbiError;
pub use error::CheckpointError;
pub use error::ConfigError;
pub use error::Error;
pub use error::OutputError;
pub use error::Result;
pub use error::RpcError;
pub use etherscan::CacheStats;
pub use etherscan::Client as EtherscanClient;
pub use etherscan::SignatureCache;
pub use fetcher::FetchLogs;
pub use fetcher::FetchProgress;
pub use fetcher::FetchResult;
pub use fetcher::FetchStats;
pub use fetcher::LogFetcher;
pub use fetcher::StreamingFetcher;
pub use output::create_writer;
pub use output::CsvWriter;
pub use output::JsonWriter;
pub use output::OutputWriter;
pub use output::SqliteWriter;
pub use proxy::validate_proxy_url;
pub use proxy::ProxyRotator;
pub use proxy::RotationMode;
pub use rpc::optimize_endpoint;
pub use rpc::test_connectivity;
pub use rpc::Endpoint;
pub use rpc::EndpointHealth;
pub use rpc::HealthTracker;
pub use rpc::OptimizationResult;
pub use rpc::RpcPool;
pub use tx::format_analysis;
pub use tx::TransactionAnalysis;
pub use tx::TxAnalyzer;
pub use utils::format::Align;
pub use utils::format::Column;
pub use utils::format::Table;
pub use utils::TokenMetadata;

Modules§

abi
ABI handling, event parsing, and log decoding
aggregator
Aggregation layer for combining data from multiple API sources
bytecode
Bytecode analysis module
cache
chainlink
Chainlink price feed queries via RPC
checkpoint
Checkpoint system for resumable fetching
cli
CLI command modules
config
Configuration management for ethcli
error
Error types for ethcli
etherscan
Etherscan API client module
fetcher
Main log fetcher coordinator
output
Output writers for different formats
proxy
Proxy rotation support
rpc
RPC endpoint management and parallel request handling
tx
Transaction analysis module
utils
Shared utility functions

Macros§

progress
Macro for progress messages that respects quiet mode
status
Print a status message with formatting if stderr is a TTY