eth-stdlib

raw JSON →
0.2.8 verified Mon Apr 27 auth: no python

Ethereum Standard Library for Python provides common utilities for Ethereum development, including address handling, ABI encoding/decoding, keccak hashing, and EIP-55 checksums. Current version 0.2.8, released monthly.

pip install eth-stdlib
error ImportError: No module named 'eth_stdlib'
cause Misspelling library name as 'eth_stdlib' (missing 'b')
fix
Import as 'from eth_stdlib import ...' (with 'b').
error AttributeError: module 'eth_stdlib' has no attribute 'keccak'
cause Using wrong function name 'keccak' instead of 'keccak256'
fix
Use 'keccak256' from eth_stdlib.
gotcha Library name is 'eth-stdlib' on PyPI but import path is 'eth_stdlib' (with 'b'). Common mistake: typing 'eth_stdlib' (missing 'b') in import.
fix Use 'from eth_stdlib import ...'.
gotcha The Address class constructor expects a hex string with or without '0x' prefix. Passing bytes will raise an error.
fix Ensure input is a string, not bytes.
deprecated Function 'to_checksum' (without '_address') may be removed in future versions.
fix Use 'to_checksum_address'.

Basic usage with Address class and utility functions.

from eth_stdlib import Address, keccak256, to_checksum_address

addr = Address('0x1234567890123456789012345678901234567890')
print(addr.checksummed)  # EIP-55 checksummed address
print(keccak256(b'hello').hex())  # keccak256 hash

addr2 = to_checksum_address('0x1234567890123456789012345678901234567890')
print(addr2)