Skip to main content

PyPi Version Python Versions pre-commit Code style: black

Credits

This is a fork of eth_mpt package with minor improvements.

Modified Merkle Paticia Trie

MPT is the data structure used in Ethereum as a cryptographically authenticated key-value data storage.

This library is a Python implementation of Modified Merkle Patrica Trie with a very simple interface.

Example

storage = {}
trie = MerklePatriciaTrie(storage)

trie.update(b'do', b'verb')
trie.update(b'dog', b'puppy')
trie.update(b'doge', b'coin')
trie.update(b'horse', b'stallion')

old_root = trie.root()
old_root_hash = trie.root_hash()

print("Root hash is {}".format(old_root_hash.hex()))

trie.delete(b'doge')

print("New root hash is {}".format(trie.root_hash().hex()))

trie_from_old_hash = MerklePatriciaTrie(storage, root=old_root)

print(trie_from_old_hash.get(b'doge'))

try:
    print(trie.get(b'doge'))
except KeyError:
    print('Not accessible in a new trie.')

Installing

Install and update using pip:

pip install -U mercle_patricia_trie

Metadata

Release files for merkle-patricia-trie 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for merkle-patricia-trie 0.4.0
File Size Uploaded Provenance Actions
merkle_patricia_trie-0.4.0.tar.gz 12.8 kB Without provenance Details for merkle_patricia_trie-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for merkle-patricia-trie 0.4.0
File Interpreter ABI Platform Actions
merkle_patricia_trie-0.4.0-py3-none-any.whl Python 3 none any Details for merkle_patricia_trie-0.4.0-py3-none-any.whl

Total release size: 24.2 kB

Release files / merkle_patricia_trie-0.4.0.tar.gz

Download URL merkle_patricia_trie-0.4.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3ed7f430587b1e47679c25c5baee51a3a57fcc5423aaf9f05caf1b7176a6e7cd
BLAKE2b-256 checksum
How to use checksums
40720f95928c9f9d21259c7900974dfd777688acd5df828ff719f673ac51cb4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Release files / merkle_patricia_trie-0.4.0-py3-none-any.whl

Download URL merkle_patricia_trie-0.4.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1299e0b59dfcf7876582bf631f33d997640051852daaff94625de9f1fe835b3
BLAKE2b-256 checksum
How to use checksums
a4bb984d01835a07264525d37bb300b6728a4149772dbef1d3bd6696185ba5dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.14

Security for merkle-patricia-trie 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page