38 releases

new 0.8.12 Nov 12, 2024
0.8.10 Oct 28, 2024
0.7.7 Jul 8, 2024
0.7.0 Mar 30, 2024
0.3.1 Jul 30, 2023

#522 in Magic Beans

Download history 20634/week @ 2024-07-29 28347/week @ 2024-08-05 27933/week @ 2024-08-12 25635/week @ 2024-08-19 28899/week @ 2024-08-26 34666/week @ 2024-09-02 30929/week @ 2024-09-09 28920/week @ 2024-09-16 33610/week @ 2024-09-23 35873/week @ 2024-09-30 51303/week @ 2024-10-07 51297/week @ 2024-10-14 54258/week @ 2024-10-21 52358/week @ 2024-10-28 50745/week @ 2024-11-04 43874/week @ 2024-11-11

204,669 downloads per month
Used in 122 crates (27 directly)

MIT/Apache

580KB
12K SLoC

alloy-json-abi

Full Ethereum JSON-ABI implementation.

This crate is a re-implementation of a part of ethabi's API, with a few main differences:

  • the Contract struct is now called JsonAbi and also contains the fallback and receive functions
  • the Param and EventParam structs only partially parse the type string instead of fully resolving it into a Solidity type

Examples

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:?}");
}

Dependencies

~5.5–8.5MB
~159K SLoC