chaincodec-core
Core traits, shared types, and primitives for the ChainCodec ecosystem.
chaincodec-core is the shared foundation for all ChainCodec crates. It defines the traits every chain-specific decoder must implement and the universal value types that all decoded output normalizes to — so your application code never depends on chain-specific representations.
What's in this crate
| Item | Description |
|---|---|
ChainDecoder |
Trait every chain decoder (EVM, Solana, Cosmos) must implement |
SchemaRegistry |
Trait for O(1) schema lookup by fingerprint or name |
ProgressCallback |
Blanket-impl trait for batch progress callbacks |
NormalizedValue |
Universal typed value — address, uint256, bytes, string, bool, array, tuple |
RawEvent |
Uninterpreted log/event from any chain |
DecodedEvent |
Fully decoded, schema-validated event with named fields |
ChainId |
Chain identifier — EVM chain IDs, Solana, Cosmos |
EventFingerprint |
Topic0 hash or equivalent for schema matching |
DecodeError |
Typed error variants for single-event decode failures |
BatchDecodeError |
Typed error variants for batch decode failures |
ErrorMode |
Controls batch error handling: Skip / Collect / Throw |
Installation
[]
= "0.1"
Quick start
use ;
// Build a raw EVM log (normally from eth_getLogs)
let raw = RawEvent ;
// NormalizedValue is the universal output type
let addr = Address;
let value = Uint256;
let flag = Bool;
Implementing ChainDecoder
Add support for a new chain by implementing the ChainDecoder trait:
use ;
;
NormalizedValue variants
All chain decoders produce NormalizedValue so downstream storage and analytics code stays chain-agnostic.
Built-in chain IDs
use chains;
let eth = ethereum; // evm_id: 1
let arb = arbitrum; // evm_id: 42161
let base = base; // evm_id: 8453
let poly = polygon; // evm_id: 137
let op = optimism; // evm_id: 10
let avax = avalanche; // evm_id: 43114
let bnb = bsc; // evm_id: 56
// Custom chain (local Anvil / Hardhat)
let local = evm;
Error modes for batch decoding
use ErrorMode;
// Skip silently — best for analytics where a few bad logs are acceptable
let mode = Skip;
// Collect errors alongside successes — inspect failures after decoding
let mode = Collect;
// Abort immediately on first failure — best for critical data pipelines
let mode = Throw;
Ecosystem
| Crate | Purpose |
|---|---|
| chaincodec-core | Traits, types, primitives (this crate) |
| chaincodec-evm | EVM ABI event & call decoder |
| chaincodec-registry | CSDL schema registry |
| chaincodec-batch | Rayon parallel batch decode |
| chaincodec-stream | Live WebSocket event streaming |
| chaincodec-observability | OpenTelemetry metrics & tracing |
License
MIT — see LICENSE