{"id":1827,"library":"eth-utils","title":"eth-utils","description":"eth-utils provides a collection of common utility functions for Python code that interacts with Ethereum. It includes functionalities for ABI manipulation, address checksumming, type conversions, cryptographic hashing, and hexadecimal encoding/decoding. The library is currently at version 6.0.0 and maintains a frequent release cadence, often introducing minor and patch updates, with major versions released approximately annually.","status":"active","version":"6.0.0","language":"en","source_language":"en","source_url":"https://github.com/ethereum/eth-utils","tags":["ethereum","web3","cryptography","utilities","abi"],"install":[{"cmd":"pip install eth-utils","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"to_checksum_address","correct":"from eth_utils import to_checksum_address"},{"symbol":"to_bytes","correct":"from eth_utils import to_bytes"},{"symbol":"is_address","correct":"from eth_utils import is_address"},{"note":"Functions from the `curried` submodule are partially applied versions.","symbol":"hexstr_if_str","correct":"from eth_utils.curried import hexstr_if_str"},{"note":"While many functions are directly importable from `eth_utils`, it's clearer and more explicit to import ABI-related functions from `eth_utils.abi`.","wrong":"from eth_utils import abi_to_signature","symbol":"abi_to_signature","correct":"from eth_utils.abi import abi_to_signature"}],"quickstart":{"code":"from eth_utils import to_checksum_address, is_address, to_bytes, decode_hex\n\n# Example 1: Checksumming an Ethereum address\naddress_raw = '0xd3cda913deb6f67967b99d67acdfa1712c293601'\nchecksum_address = to_checksum_address(address_raw)\nprint(f\"Raw address: {address_raw}\")\nprint(f\"Checksummed address: {checksum_address}\")\n\n# Example 2: Validating an address\nis_valid = is_address(checksum_address)\nprint(f\"Is '{checksum_address}' a valid address? {is_valid}\")\n\n# Example 3: Converting string to bytes, explicitly specifying type\nhex_string = '0x123456'\nbytes_data = to_bytes(hexstr=hex_string)\nprint(f\"Hex string '{hex_string}' to bytes: {bytes_data}\")\n\n# Example 4: Decoding a hexadecimal string to bytes\ndecoded_bytes = decode_hex('0xabcdef')\nprint(f\"Decoded '0xabcdef' to bytes: {decoded_bytes}\")","lang":"python","description":"This quickstart demonstrates common utility functions like `to_checksum_address` for EIP-55 compliant addresses, `is_address` for validation, and `to_bytes` and `decode_hex` for handling various string and byte conversions, emphasizing the need for explicit type specification in conversions."},"warnings":[{"fix":"Update `requirements.txt` or `pyproject.toml` to use `eth-utils` instead of `ethereum-utils`.","message":"The `ethereum-utils` PyPI package was renamed to `eth-utils` in November 2017. Projects still depending on `ethereum-utils` will not receive updates and should migrate to `eth-utils`.","severity":"breaking","affected_versions":"<1.0.0 (of `ethereum-utils`)"},{"fix":"Upgrade your Python environment to version 3.10 or later.","message":"With the release of `eth-utils` v6.0.0, support for Python 3.8 and 3.9 has been dropped. Ensure your project is running on Python 3.10 or newer.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Always use keyword arguments `text='your_string'` or `hexstr='0x...'`. For example, `to_bytes(text='hello')` or `to_bytes(hexstr='0x1234')`.","message":"When using conversion utilities like `to_bytes` or `to_hex` with string inputs, you must explicitly specify whether the string is `text` (e.g., UTF-8 encoded) or a `hexstr` (hex-encoded bytestring). The library cannot reliably auto-detect this, leading to incorrect conversions if not specified.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always explicitly convert the result to a list or iterate over the generator if you need to access all elements: `list(apply_formatter_to_array(formatter, value))`.","message":"The `apply_formatter_to_array` function in `eth-utils` returns a generator, which must be consumed (e.g., by converting to a `list`) to access all formatted elements. This differs from some other libraries (e.g., `web3.py`'s historical `apply_formatter_to_array`) which might return a concrete list or array directly.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}