Skip to main content

Python bindings for Heimdall - Advanced EVM bytecode analysis toolkit

Project description

Heimdall Python Bindings

Python bindings for the Heimdall EVM decompiler, providing access to extract ABI (Application Binary Interface) from EVM bytecode.

Installation

Build and install the Python module:

# From the heimdall-rs root directory
cd crates/python
maturin develop

Usage

import heimdall_py

# Decompile bytecode to extract ABI
bytecode = "0x60806040..."
abi = heimdall_py.decompile_code(bytecode)

# Access functions
for func in abi.functions:
    print(f"Function: {func.name}")
    print(f"  Inputs: {[(p.name, p.type_) for p in func.inputs]}")
    print(f"  Outputs: {[(p.name, p.type_) for p in func.outputs]}")
    print(f"  State Mutability: {func.state_mutability}")
    print(f"  Payable: {func.payable}")

# Access events
for event in abi.events:
    print(f"Event: {event.name}")
    for param in event.inputs:
        print(f"  {param.name}: {param.type_} (indexed: {param.indexed})")

# Access errors
for error in abi.errors:
    print(f"Error: {error.name}")
    for param in error.inputs:
        print(f"  {param.name}: {param.type_}")

# Special functions
if abi.constructor:
    print(f"Constructor inputs: {[(p.name, p.type_) for p in abi.constructor.inputs]}")

if abi.fallback:
    print(f"Has fallback function (payable: {abi.fallback.payable})")

if abi.receive:
    print("Has receive function")

ABI Structure

The decompiler returns an ABI object with the following structure:

  • functions: List of regular functions
  • events: List of events
  • errors: List of custom errors
  • constructor: Optional constructor function
  • fallback: Optional fallback function
  • receive: Optional receive function

Each function contains:

  • name: Function name
  • inputs: List of input parameters
  • outputs: List of output parameters
  • state_mutability: One of "pure", "view", "nonpayable", or "payable"
  • constant: Boolean indicating if function is constant (view/pure)
  • payable: Boolean indicating if function accepts Ether

Development

To build the Python bindings:

# Install maturin
pip install maturin

# Build in development mode
maturin develop

# Build release wheel
maturin build --release

Requirements

  • Python 3.10+
  • Rust toolchain
  • maturin for building

Project details


Download files

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

Source Distribution

heimdall_py-0.9.9.tar.gz (657.4 kB view details)

Uploaded Source

Built Distributions

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

heimdall_py-0.9.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

heimdall_py-0.9.9-cp310-abi3-macosx_11_0_arm64.whl (3.3 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

heimdall_py-0.9.9-cp310-abi3-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file heimdall_py-0.9.9.tar.gz.

File metadata

  • Download URL: heimdall_py-0.9.9.tar.gz
  • Upload date:
  • Size: 657.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for heimdall_py-0.9.9.tar.gz
Algorithm Hash digest
SHA256 d7dedcba3101ec51c8c6d4dc12949ff57090107b6654b5331f87b464561a81ec
MD5 0215a7f7d7a9c112cb358b7397b9ea1a
BLAKE2b-256 e3606007b83813e730dd7f72c32e4f0d6d4195f9ea45287c56472234ce99b203

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.9.tar.gz:

Publisher: python-release.yml on jalbrekt85/heimdall-py

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

File details

Details for the file heimdall_py-0.9.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9bf3c8959dff73fd8f64a24753c3d2e064bb8c589147a8123c67cc6b063482d1
MD5 fe7d031be02d336bb56f68ab8b5cac6d
BLAKE2b-256 ecf627649560cc6bc9d85c06deca2129b8afbf7bb5d0b166a8e79b6950603049

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.9-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python-release.yml on jalbrekt85/heimdall-py

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

File details

Details for the file heimdall_py-0.9.9-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.9-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b151890dc2f6854eaf1310b6ef2afed1c7abe0f8e511ba1405e8a70b9f7c0cc9
MD5 bccffc232bccd7a3a69c4a1caa3d033e
BLAKE2b-256 7897c26378d06e29683273b6d8e889d3518086fc66029968cfd699bde1dff9e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.9-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: python-release.yml on jalbrekt85/heimdall-py

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

File details

Details for the file heimdall_py-0.9.9-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.9-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 81862b1a7531fd9073d08c00eb0754f0844276412091f7e1cf8fd8206fb2ed1b
MD5 f795273b2285e1fa5d4c9f4e6ecfdc8c
BLAKE2b-256 a2e0170f8fbdb8957b75d7bb73769c514099e4c1865d9a0c64bb57024d2f753c

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.9-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: python-release.yml on jalbrekt85/heimdall-py

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