Skip to main content

Universal blockchain ABI decoder — production-grade EVM event & call decoding

Project description

chaincodec (Python)

Universal blockchain ABI decoder — production-grade EVM event log and function call decoding, with 50+ built-in DeFi/NFT/bridge protocol schemas.

PyPI Python License: MIT

Install

pip install chaincodec

Prebuilt wheels for Linux (x64, arm64, musl), macOS (x64, arm64), and Windows (x64). No Rust toolchain required.

Quick Start

import asyncio
from chaincodec import EvmDecoder, MemoryRegistry

async def main():
    # Load a schema
    registry = MemoryRegistry()
    registry.load_file("schemas/erc20.csdl")

    decoder = EvmDecoder()

    # Decode an ERC-20 Transfer event
    raw_log = {
        "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "topics": [
            "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
            "0x000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045",
            "0x000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b",
        ],
        "data": "0x000000000000000000000000000000000000000000000000000000003b9aca00",
    }

    fingerprint = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
    schema = registry.get_by_fingerprint(fingerprint)

    event = decoder.decode_event(raw_log, schema)
    print(event)
    # DecodedEvent(schema="ERC20Transfer", fields={"from": "0xd8dA...", "to": "0xAb58...", "value": 1000000000})

asyncio.run(main())

Decode Function Calls

from chaincodec import EvmCallDecoder, MemoryRegistry

registry = MemoryRegistry()
registry.load_file("schemas/uniswap-v3.csdl")

decoder = EvmCallDecoder()
call_data = bytes.fromhex("414bf389...")  # exactInputSingle calldata

result = decoder.decode_call(call_data, registry)
print(result.function_name)  # "exactInputSingle"
print(result.inputs)         # [("tokenIn", "0x..."), ("amountIn", 1000000)]

Encode Function Calls

from chaincodec import EvmEncoder, MemoryRegistry

registry = MemoryRegistry()
registry.load_file("schemas/erc20.csdl")

encoder = EvmEncoder()
calldata = encoder.encode_call("transfer", ["0xRecipient...", 1_000_000], registry)
# b'\xa9\x05\x9c\xbb...'

Batch Decode

from chaincodec import EvmDecoder, MemoryRegistry

registry = MemoryRegistry()
registry.load_directory("schemas/")   # loads all 50+ schemas

decoder = EvmDecoder()
events = decoder.decode_batch(raw_logs, registry)
# Parallel decode via Rayon — >1M events/sec

Built-in Schemas (53 protocols)

Category Protocols
Tokens ERC-20, ERC-721, ERC-1155, WETH, ERC-4626, ENS, ERC-4337
DEX Uniswap V2/V3, SushiSwap, Curve, Balancer V2, Camelot, DODO, Bancor V3
Lending Aave V2/V3, Compound V2/V3, Morpho Blue, Spark
Derivatives GMX, GMX V1, dYdX V4, Perpetual Protocol, Synthetix V3, Ribbon Finance
LSD/Staking Lido, Rocket Pool, Frax Ether, Stader, EigenLayer, Convex, Yearn
Bridges Wormhole, LayerZero V2, Hop, Celer, Stargate, Across
NFT OpenSea, Blur, CryptoPunks, BAYC, LooksRare
Governance Safe Multisig, Compound Governance
Oracle Chainlink (Aggregator, VRF, CCIP)
Other Pendle Finance, Maker DAO

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

chainfoundry_chaincodec-0.2.0-cp311-cp311-win_amd64.whl (566.0 kB view details)

Uploaded CPython 3.11Windows x86-64

chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_11_0_arm64.whl (654.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl (669.2 kB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (752.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (727.3 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ ARM64

File details

Details for the file chainfoundry_chaincodec-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for chainfoundry_chaincodec-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 31a55a89f9afa954783e618f5cbc607915ed0da6a202a6c6f1dcbcd22064989e
MD5 2d49aeaabb7b820b29e3f4ad03949d03
BLAKE2b-256 17328c9950065cb4146496a6193a94bde4e96326af003a58b4988e6bd5515f85

See more details on using hashes here.

Provenance

The following attestation bundles were made for chainfoundry_chaincodec-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: publish.yml on DarshanKumar89/chainkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f21f9d77414cdc91e98da39e0945deccf94a9630141b670dbaad812ea8420e85
MD5 3ef1e338a8c44c24bb327085dfeea223
BLAKE2b-256 35c6dde7d23ad9cbcb861a1567b80f39b9e52368871ab48667427c2dbf48f788

See more details on using hashes here.

Provenance

The following attestation bundles were made for chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: publish.yml on DarshanKumar89/chainkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 ad12044335f675b28ec8c4a57d8c35472afac9de4b019bf695230e0c5db4552d
MD5 0f727832f45f942a2648067654f8d125
BLAKE2b-256 55e581cb89e16e647b7ff8fa9f433380246c50617b53ca013f54453d03e1c43c

See more details on using hashes here.

Provenance

The following attestation bundles were made for chainfoundry_chaincodec-0.2.0-cp311-cp311-macosx_10_12_x86_64.whl:

Publisher: publish.yml on DarshanKumar89/chainkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bd64a26ff63329d5388a26614f1363b35e4ed46f22fa7ff059736e1342fbf94
MD5 259046e8bf8658f401fcbeaab887552d
BLAKE2b-256 0ca9839292fc2cbfa7877fbedb003cc8816ca2f056483e664d8b138be4ab9b4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on DarshanKumar89/chainkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 13db8faae31d9275ae4f9178c151e7bff205b627af31d65407fa90109e6d3efc
MD5 a989cd8b29525d3ef159288323818ce2
BLAKE2b-256 597f5801c1ee9ffbcd85907d8848b40ef14b9f4fd0aa0be257bc26ce43155f6e

See more details on using hashes here.

Provenance

The following attestation bundles were made for chainfoundry_chaincodec-0.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on DarshanKumar89/chainkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page