trie
Python implementation of the Ethereum Trie structure
What it is and what it does
This package provides a Python implementation of the Hexary Trie, the data structure used by Ethereum for storing account state and transaction data. It supports standard key-value operations (set, get, delete, exists) and can be used like a Python dictionary. The trie maintains a cryptographic root hash that changes deterministically when data is modified, making it useful for verifying state consistency across distributed systems.
The package depends on eth-utils, hexbytes, rlp, sortedcontainers, and eth-hash to handle Ethereum-specific serialization, hashing, and data structures. It includes traversal APIs for inspecting internal trie structure and a fog-based walker for efficiently exploring large tries without loading all nodes into memory.
Use it for:
- Building Ethereum client implementations or state verification tools that need to reconstruct and validate blockchain state
- Storing and querying hierarchical key-value data with cryptographic proofs of correctness
- Implementing smart contract state backends or local blockchain simulators
- Auditing or debugging Ethereum state by traversing trie structure and verifying node integrity
- Prototyping distributed ledger systems that require deterministic, hashable state trees
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Implements the Ethereum Merkle Trie data structure for efficient key-value storage and retrieval with cryptographic root hashing.
Yes. The package is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. Install it if you are working with Ethereum state structures, building blockchain tooling, or need a production-grade Merkle Trie implementation in Python.
Install
trie on PyPI
pip
pip install trieuv
uv add triepoetry
poetry add trieInstalling trie
Before you install
Low install friction with a pure Python wheel. Active maintenance with recent commits and stable production status across Python 3.8–3.13.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
from trie import HexaryTrie
t = HexaryTrie(db={})
t.set(b'my-key', b'some-value')
value = t.get(b'my-key')
root = t.root_hash
Verify before relying
- Performance characteristics (insertion/lookup speed, memory overhead) for large tries
- Database backend compatibility beyond in-memory dict
- Concurrency or thread-safety guarantees
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 5 — eth-utils, hexbytes, rlp, sortedcontainers, eth-hash |
| Maintenance | actively maintained — 562 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 313,511/month — #7,712 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: trie-3.1.0-py3-none-any.whl
Keywords: ethereum, blockchain, evm, trie, merkle
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
PyTriePyTrie provides a pure Python 3 trie data…
permissive · top 15,000 on PyPI
pygtriepygtrie provides pure Python implementations of…
permissive · top 5,000 on PyPI
eth-bloomImplements Ethereum's bloom filter algorithm…
permissive · top 15,000 on PyPI
sqltrieSQLTrie implements a prefix tree (trie) data…
permissive · top 5,000 on PyPI
marisa-trieProvides memory-efficient trie data structures…
copyleft · top 5,000 on PyPI
cidr-trieStores and queries CIDR IP address blocks (IPv4…
permissive · top 15,000 on PyPI
py-radixImplements a radix tree data structure for…
permissive · top 15,000 on PyPI
base58checkEncodes and decodes byte arrays using the…
permissive · top 15,000 on PyPI
eth-rlpProvides RLP (Recursive Length Prefix) encoding…
permissive · top 5,000 on PyPI
hashringImplements consistent hashing in Python using…
permissive · top 15,000 on PyPI