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.10.tar.gz (662.2 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.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

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

heimdall_py-0.9.10-cp310-abi3-macosx_11_0_arm64.whl (3.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

heimdall_py-0.9.10-cp310-abi3-macosx_10_12_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: heimdall_py-0.9.10.tar.gz
  • Upload date:
  • Size: 662.2 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.10.tar.gz
Algorithm Hash digest
SHA256 ced3a30cded1a7826a4d0c8936b63ffd234dea903b3b43e8c81c101a0f03c45c
MD5 6d51fca3b2d72b6e32c213a34468778d
BLAKE2b-256 c01033941f056dd316ad7d040bbfe3c396a22212108dd5aa09b1f4012d65e313

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.10.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.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.10-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5838b1fe763873732411ff8851fa4d9cb65536e75f1197a6ea0d6a585ee7e5f9
MD5 a280faf43b7d0432eef2ea1333ef190f
BLAKE2b-256 768056357d14dc4742ddfb9f09256f934e85495cc72537aaf7dee71fb495b024

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.10-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.10-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.10-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c47478dacf3e57e06a2fcdb54092e616176cb0a582a154f6cd1678906b620c7
MD5 9884cc51d2ac6dfbfeafe0f45983f9c6
BLAKE2b-256 1647c5bcfc70d2fc71cf9b05bc1e821c298d33f0795a5e58afb9608cf5edf573

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.10-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.10-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for heimdall_py-0.9.10-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f5db2f448826d1f7e715b4a3872a88e7089689b6904a6a7e5c1a3de4a80c699c
MD5 0081dcd9a0105ec895bf0836134d7d7b
BLAKE2b-256 2f334a58afcfb1f89115de4ed9f49ea51d4e635ed897a95e53d17c3dfa292e0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for heimdall_py-0.9.10-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