Full Ethereum JSON-ABI implementation.
This crate is a re-implementation of a part of ethabi's API, with a few main differences:
- the
Contractstruct is now calledJsonAbiand also contains thefallbackandreceivefunctions - the
ParamandEventParamstructs only partially parse the type string instead of fully resolving it into a Solidity type
Parse a JSON ABI file into a JsonAbi struct:
use alloy_json_abi::JsonAbi;
# stringify!(
let path = "path/to/abi.json";
let json = std::fs::read_to_string(path).unwrap();
# );
# let json = "[]";
let abi: JsonAbi = serde_json::from_str(&json).unwrap();
for item in abi.items() {
println!("{item:?}");
}