Expand description
§sourcify
A lightweight read-only wrapper for Sourcify, including the Sourcify v2 API and Sourcify 4byte signature API.
§Supported APIs
v2::Clientwraps the Sourcify v2 contract data API.four_byte::Clientwraps the Sourcify 4byte signature API.
§Limitations
The crate is intentionally small: use Sourcify::v2 to retrieve verified
contract data, source files, ABI, and metadata by chain ID and address, and
use Sourcify::four_byte to resolve function selectors or event topics.
§Contract Source Lookup
use sourcify::{v2, Sourcify};
#[tokio::main]
async fn main() -> sourcify::Result<()> {
let client = Sourcify::new();
let contract = client
.v2()
.get_contract_with_fields(
1,
"0xdAC17F958D2ee523a2206206994597C13D831ec7",
&[v2::field::SOURCES, v2::field::ABI, v2::field::METADATA],
)
.await?;
if let Some(contract) = contract {
println!("verified on chain {}", contract.chain_id);
}
Ok(())
}§4byte Lookup
use sourcify::Sourcify;
#[tokio::main]
async fn main() -> sourcify::Result<()> {
let client = Sourcify::new();
let signatures = client.four_byte().lookup_function("0xa9059cbb").await?;
for signature in signatures {
println!("{}", signature.name);
}
Ok(())
}Re-exports§
Modules§
- error
- Error and result types returned by this crate.
- four_
byte - Read-only Sourcify 4byte signature API client.
See
Clientfor the main entry point. - v2
- Read-only Sourcify v2 API client.
See
Clientfor the main entry point.
Structs§
- Sourcify
- Shared entry point for the Sourcify v2 and 4byte clients.