faster-eth-utils
raw JSON → 5.3.26 verified Mon Apr 27 auth: no python
A faster fork of eth-utils providing common utility functions for Python code that interacts with Ethereum, implemented in C. Current version 5.3.26, requires Python >=3.10 and <4. Released frequently, approximately weekly.
pip install faster-eth-utils Common errors
error ImportError: cannot import name 'to_bytes' from 'eth_utils' ↓
cause Missing dependency or incompatible version of eth-utils / faster-eth-utils.
fix
Ensure faster-eth-utils is installed (pip install faster-eth-utils) and that eth-utils is not installed separately.
error ModuleNotFoundError: No module named 'eth_utils' ↓
cause faster-eth-utils is not installed, or the import path is wrong.
fix
Install faster-eth-utils (pip install faster-eth-utils). Import from eth_utils, not faster_eth_utils.
error TypeError: to_bytes() got an unexpected keyword argument 'hexstr' ↓
cause Using an older version of eth-utils API that is not supported in faster-eth-utils.
fix
Check the function signature in the latest documentation. For to_bytes, use hexstr= parameter as shown, or upgrade to the latest version.
Warnings
deprecated Python 3.9 support removed. Requires Python >=3.10. ↓
fix Upgrade Python to 3.10+.
breaking Function signatures may change in minor versions. Test thoroughly when upgrading. ↓
fix Pin version and review changelog before upgrading.
gotcha Do not install both eth-utils and faster-eth-utils in the same environment. faster-eth-utils is intended as a replacement. ↓
fix Uninstall eth-utils before installing faster-eth-utils, or use a virtual environment.
Imports
- to_bytes wrong
from faster_eth_utils import to_bytescorrectfrom eth_utils import to_bytes - to_checksum_address wrong
from faster_eth_utils import to_checksum_addresscorrectfrom eth_utils import to_checksum_address - keccak wrong
from faster_eth_utils import keccakcorrectfrom eth_utils import keccak
Quickstart
from eth_utils import to_bytes, to_checksum_address, keccak
# Example: convert hex to bytes
result = to_bytes(hexstr='0xdeadbeef')
print(result)
# Example: checksum address
addr = to_checksum_address('0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed')
print(addr)
# Example: keccak hash
hash = keccak(b'test')
print(hash.hex())