sourcify 0.0.4

A lightweight wrapper for Sourcify and 4byte APIs for fetching Ethereum smart contract source code and signatures
Documentation

Supported APIs

Quickstart

Install

[dependencies]
sourcify = "0.0.4"

Example

use sourcify::Sourcify;

#[tokio::main]
async fn main() -> sourcify::Result<()> {
    let client = Sourcify::new();

    let contract = client
        .v2()
        .get_contract_with_fields(
            1,
            "0xdAC17F958D2ee523a2206206994597C13D831ec7",
            &[sourcify::v2::field::SOURCES, sourcify::v2::field::ABI],
        )
        .await?;

    if let Some(contract) = contract {
        println!("{} source files", contract.sources.map_or(0, |sources| sources.len()));
    }

    let signatures = client.four_byte().lookup_function("0xa9059cbb").await?;
    for signature in signatures {
        println!("{}", signature.name);
    }

    Ok(())
}

Examples

cargo run --example fetch_contract -- 1 0xdAC17F958D2ee523a2206206994597C13D831ec7
cargo run --example four_byte -- 0xa9059cbb

Limitations

This crate is intentionally a read-only wrapper. It does not handle interactive contract verification or signature submission.