Komozoi EVM — Python Bindings
komozoievm is a Python package that exposes the Komozoi EVM C++ engine for
simulating Ethereum transactions and contract execution against either a
user-supplied mock chain state or a real chain provider.
The package is built from the same C++ sources as the native library and is distributed as binary wheels on PyPI.
Installation
pip install komozoievm
Building from a source checkout requires a C++17 compiler and CMake:
pip install .
Quick start
import komozoievm as evm
src = "0x0000000000000000000000000000000000000001"
dst = "0x0000000000000000000000000000000000000002"
# An in-memory chain populated by Python code. Addresses must be valid
# 20-byte hex strings; malformed values raise ``ValueError``.
chain = evm.MockChain()
chain.set_balance(src, 10 * 10**18)
chain.set_code(dst, bytes.fromhex("6001600101"))
# Simulate a call without mutating state.
block = evm.BlockInfo(number=1, timestamp=1_700_000_000, base_fee=10)
result = chain.simulate(dst, src, b"", 0, block)
print(result.success, result.return_data.hex())
# ``execute`` performs the same call but commits the resulting state.
result = chain.execute(dst, src, value=1_000_000_000_000_000_000)
Module layout
komozoievm is a single top-level module. Names listed below are the public
Python surface; everything not listed should be treated as internal and is
subject to change.
Types
| Python type | Description |
|---|---|
Address |
20-byte Ethereum address. Accepts bytes, bytearray, hex str (with or without 0x), None, or another Address. str(address) returns the EIP-55 checksum form. |
U256 |
256-bit unsigned integer. Implicitly converts from Python int; values out of range raise OverflowError. |
Address and U256 are thin wrappers; functions that accept them also accept
the plain Python equivalents (bytes, str, int).
Data classes
BlockInfo(number, timestamp, base_fee=0, gas_limit=30_000_000, chain_id=1, coinbase=..., randao=0)— fields exposed for the block context.AccountInfo(address, balance=0, next_nonce=0)— minimal account state.AccessListEntry(address, storage_keys=()).SimulationResultwith attributes:success: bool,return_data: bytes,reason: str,gas_used: int.CallTrace— an aggregating tracer that records every contract call performed during a transaction. Pass an instance astrace=tosimulate/execute; the captured entries are available on thecallsattribute.CallTraceEntrywith attributes:src: Address,dst: Address,calldata: bytes,returndata: bytes,gas_used: int,success: bool.EventTracewith attributes:src: Address,topics: list[int],data: bytes.
Transaction construction
tx = evm.TransactionBuilder(
to=address,
nonce=int,
gas_limit=int,
value=0,
gas_price=0,
max_fee_per_gas=0,
max_priority_fee_per_gas=0,
data=b"",
access_list=[],
).build()
For common contract calls, you can use the Transaction.call helper:
tx = evm.Transaction.call(
from_=address,
to=address,
value=0,
data=b"",
gas_limit=100_000
)
For signed transactions, pass a 32-byte private key:
raw = tx.sign_and_encode(private_key=bytes.fromhex(...))
Chain providers
StateProvider is an abstract base class that Python code can subclass to
serve as the chain backend. Override:
get_account_info(self, address: Address, block_number: int = 0) -> AccountInfoget_contract_code(self, address: Address) -> bytesget_storage_slots(self, address: Address, slot_keys: list[int], block_number: int = 0) -> list[int]update_account(self, address: Address, info: AccountInfo) -> boolsave_contract_code(self, address: Address, code: bytes) -> boolupdate_storage_slots(self, address: Address, entries: dict[int, int]) -> bool
MockChain is a built-in StateProvider implementation backed by in-memory
hash tables. It is the recommended starting point for test suites and is what
the examples in this document use.
Running the EVM
The high-level entry points on any StateProvider (including MockChain)
hide transaction construction behind keyword arguments:
result = chain.simulate(dst, src, data=b"", value=0, block=None,
gas=3_000_000, trace=None)
result = chain.execute(dst, src, data=b"", value=0, block=None,
gas=3_000_000, trace=None)
gas = evm.EVM.initial_gas_cost(calldata)
All arguments after src are optional. block defaults to a sensible
context; value and gas accept either int or float (e.g. 1e18
for one ETH, 1.5e6 for 1.5M gas) — floats are rounded to the nearest
integer for gas and truncated toward zero for value. data defaults
to empty calldata, and gas defaults to 3,000,000.
If dst has no contract code installed it is treated as an Externally
Owned Account: the call succeeds immediately after any value transfer,
without executing any bytecode. Installing code via set_code turns
the address into a contract from that point on.
simulate does not mutate the underlying provider. execute writes the
resulting state back through the provider's update_* callbacks.
For lower-level control you can build a Transaction (or
TransactionBuilder) explicitly and run it through the EVM class:
machine = evm.EVM(chain)
tx = evm.Transaction.call(from_=src, to=dst, data=b"", gas_limit=100_000)
result = machine.simulate(tx, block_info, tracer=None)
Tracing
The simplest way to capture every contract call made by a transaction is
evm.CallTrace:
trace = evm.CallTrace()
chain.execute(dst, src, trace=trace)
for entry in trace.calls:
print(entry.src, "->", entry.dst, entry.success)
For custom logic, subclass evm.Tracer and override the callbacks:
class MyTracer(evm.Tracer):
def on_contract_call(self, chain, call_trace):
print(f"Call from {call_trace.src} to {call_trace.dst}")
def on_event_log(self, chain, event_trace):
print(f"Log from {event_trace.src} with {len(event_trace.topics)} topics")
chain.execute(dst, src, trace=MyTracer())
Threading and memory
The bindings release the GIL during long-running EVM execution so that Python threads can make progress in parallel. Callbacks into Python (state provider methods, tracers) reacquire the GIL automatically.
Versioning
Wheels are tagged with the upstream Komozoi EVM version followed by a build metadata suffix when applicable. Breaking changes to the Python API are only introduced on a major version bump.
Metadata
Release files for komozoi-evm 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| komozoi_evm-0.0.2.tar.gz | 94.2 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| komozoi_evm-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.13 | CPython 3.13 | Linux glibc 2.17+ x86-64 | Details |
| komozoi_evm-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | CPython 3.12 | Linux glibc 2.17+ x86-64 | Details |
| komozoi_evm-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.17+ x86-64 | Details |
| komozoi_evm-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.17+ x86-64 | Details |
| komozoi_evm-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 1.9 MB
Release files / komozoi_evm-0.0.2.tar.gz
| Download URL | komozoi_evm-0.0.2.tar.gz |
|---|---|
| Size | 94.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1f2f0996e5e09e0ecfc53415610263db1be5659d857bca4c086b12f0a194601
|
|
BLAKE2b-256 checksum How to use checksums |
22832e19060f18098d34d0a0af5ac0c9459e6371b467c579f423763097e5853d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / komozoi_evm-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | komozoi_evm-0.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 358.8 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
4aa4c1a7a0e8ad9df142ace14902941ce537703b5b627e7bdd16f16e32fd6840
|
|
BLAKE2b-256 checksum How to use checksums |
b7f7b93682382dd213b5189ee5a81b7c3b5846aaeafdbad53a2933a116d49307
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / komozoi_evm-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | komozoi_evm-0.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 358.7 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
8bee9b61f424bf5411abf4ea93722c693c8f28ed43d8175c10a994e36ec896bc
|
|
BLAKE2b-256 checksum How to use checksums |
0427072236148d3af7336151298692a0b54a738aa21b7c75c0a5412e3b0311f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / komozoi_evm-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | komozoi_evm-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 358.6 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
a2a50a269c733d8c424db2ad821b6185dba92f5171cab3b8774b6e6b352b9c93
|
|
BLAKE2b-256 checksum How to use checksums |
b5ae4453c2c4d95e0b52694b3776ecd68dbf4afb7a8dd4c762dd204de8165c3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / komozoi_evm-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | komozoi_evm-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 357.3 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
d4add7d73e1b42c3c0b4973712ddc1c2fa9f50b518764dc2e32a5e9db295abda
|
|
BLAKE2b-256 checksum How to use checksums |
b8f3841bdb89e2a18f187458a6e5ffdc6f892f3fe453e17cc4e2a9ec3f9f177f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency logRelease files / komozoi_evm-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | komozoi_evm-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 357.5 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf9460ccca2341e6e59cb22d0088e5aa9991198e55fd9d4994fc69fadad0a862
|
|
BLAKE2b-256 checksum How to use checksums |
103521269bf76041a96d8b745b2656b8966217b64cf7a66c12e2f553e56fda47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 24, 2026.
Transparency log