chaincodec-evm
EVM ABI event decoder, function call decoder, and ABI encoder — built on alloy-rs.
Decode eth_getLogs entries, function calldata, and EIP-712 typed data payloads into clean, typed Rust structs. All values normalize to NormalizedValue — no raw ABI bytes, no manual hex parsing.
Features
- Event decoding — decode
eth_getLogslog entries against a CSDL schema using topic0 fingerprint matching - Call decoding — decode function calldata from any standard Ethereum ABI JSON
- ABI encoding — encode function calls for on-chain submission
- EIP-712 typed data — parse
eth_signTypedData_v4payloads - Fingerprinting — compute
keccak256(event_signature)topic0 selectors - Type normalization — all decoded values become
NormalizedValue(address, uint256, bytes, string, tuple, …) - 50+ built-in schemas — ERC-20/721/1155, Uniswap, Aave, Compound, and more via
chaincodec-registry
Installation
[]
= "0.1"
= "0.1"
= "0.1"
Decode an EVM event log
use EvmDecoder;
use MemoryRegistry;
use ;
Decode function calldata
use EvmCallDecoder;
// Load ABI JSON (from Etherscan export, Hardhat artifacts, Foundry out/, etc.)
let abi_json = read_to_string?;
let decoder = from_abi_json?;
// Raw calldata bytes from a transaction's `input` field
let calldata = decode?;
let call = decoder.decode_call?;
println!; // "exactInputSingle"
for in &call.inputs
// tokenIn: 0xC02aaA39b... (WETH)
// tokenOut: 0xA0b8699... (USDC)
// amountIn: 1000000000000000000
// amountOutMin: 1800000000
Encode a function call
use EvmCallDecoder;
use NormalizedValue;
let abi_json = read_to_string?;
let decoder = from_abi_json?;
let calldata = decoder.encode_call?;
// Submit calldata to your JSON-RPC provider
println!;
Compute topic0 fingerprint
use fingerprint;
let fp = compute;
// "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
let fp2 = compute;
// Uniswap V2 Swap event topic0
Error handling
use DecodeError;
match decoder.decode_event
Bundled schemas (50+)
chaincodec-registry ships ready-to-use schemas. Load all of them:
registry.load_directory?;
| Category | Schemas |
|---|---|
| Token standards | ERC-20, ERC-721, ERC-1155, ERC-4337, WETH |
| DEXes | Uniswap V2, Uniswap V3, Curve, Balancer, SushiSwap |
| Lending | Aave V2, Aave V3, Compound V2, Compound V3, MakerDAO |
| Oracles | ChainLink Aggregator, ChainLink VRF, ChainLink CCIP |
| Liquid staking | Lido, Rocket Pool, Stader, Frax |
| Bridges | Wormhole, LayerZero V2, Hop, Celer |
| Other | ENS, Safe Multisig, GMX V1, dYdX V4, Bancor V3 |
Ecosystem
| Crate | Purpose |
|---|---|
| chaincodec-core | Traits, types, primitives |
| chaincodec-evm | EVM ABI event & call decoder (this crate) |
| chaincodec-registry | CSDL schema registry |
| chaincodec-batch | Rayon parallel batch decode |
| chaincodec-stream | Live WebSocket event streaming |
License
MIT — see LICENSE