Python Reference
The Python implementation is alx-protocol, published on PyPI. The package implements the core protocol as a peer of the JavaScript and Rust packages: the package creates, validates, and traces Blocks from the same rules and is checked against the same conformance vectors, so identities agree across languages.
Implementation
| Resource | Location |
|---|---|
| Package | alx-protocol |
| Registry | PyPI |
| Install | pip install alx-protocol |
| Import | import alx_protocol |
| Command line | python -m alx_protocol validate <file> validates a Block or a JSON array of Blocks |
| Requirements | Python 3.11 or later |
Create and Validate a Block
Create and validate a Block, then print its identity. The script prints the same blockHash as the JavaScript script in Quick Start. Blocks are dictionaries with the protocol field names: blockHash, contentHash, parentHashes, content, and protocolVersion. A failed operation raises ValueError with the error identifier in brackets at the start of the message. Parse Block JSON received from another system with decode_strict_json_bytes() to reject invalid UTF-8, duplicate members, and trailing data.
from alx_protocol import create_block, validate_block
block = create_block({"type": "note", "text": "Hello ALX"}, [])
result = validate_block(block)
print(block["blockHash"])
print(result["ok"])
0xe501e2ad688365e24523f3ceda68958aa53aa13eb63dbda953c3690c119faa0a
True
Capabilities
Every core capability is supported, together with the optional Merkle, Ed25519, and P-256 extensions; EIP-712 signing is not bundled. The Implementation Parity table on SDK Reference lists each capability.
When to Use Python
Choose this package for Python services, data pipelines, and AI workflows that create or verify Blocks. The package computes the same identities as the JavaScript and Rust packages for the same content and parent set.