skillfed

trie

Python implementation of the Ethereum Trie structure

trie v3.1.0 313.5K downloads/30d#7,712 on PyPI111
Permissive license MIT Active released

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 trie

uv

uv add trie

poetry

poetry add trie

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

ethereum trie implementationmerkle tree pythonhexary trieblockchain data structureethereum state storagetrie key-value storecryptographic hash tree
ethereummerkle-treecryptography

More Database packages