Crate alloy_json_abi

Source
Expand description

§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;

let path = "path/to/abi.json";
let json = std::fs::read_to_string(path).unwrap();
let abi: JsonAbi = serde_json::from_str(&json).unwrap();
for item in abi.items() {
    println!("{item:?}");
}

Re-exports§

Modules§

Structs§

Enums§

  • A JSON ABI item.
  • The contract internal type. This could be a regular Solidity type, a user-defined type, an enum, a struct, a contract, or an address payable.
  • A JSON ABI function’s state mutability.