{"id":1826,"library":"eth-typing","title":"eth-typing: Common type annotations for ethereum python packages","description":"eth-typing provides common type annotations for various Ethereum Python packages, offering a standardized set of types for improved type hinting and code clarity across the Ethereum ecosystem. It is actively maintained with frequent releases, currently at version 6.0.0, supporting modern Python versions. [1, 2, 5]","status":"active","version":"6.0.0","language":"python","source_language":"en","source_url":"https://github.com/ethereum/eth-typing","tags":["ethereum","typing","types","web3","abi","evm","blockchain"],"install":[{"cmd":"pip install eth-typing","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"TypeStr","correct":"from eth_typing import TypeStr"},{"symbol":"HexStr","correct":"from eth_typing.encoding import HexStr"},{"note":"Specific EVM-related types are found in submodules like `eth_typing.evm`.","wrong":"from eth_typing import Address","symbol":"Address","correct":"from eth_typing.evm import Address"},{"note":"Use `ChecksumAddress` for ERC-55 formatted addresses, `HexAddress` for general hex-encoded addresses. [9]","wrong":"from eth_typing.evm import HexAddress","symbol":"ChecksumAddress","correct":"from eth_typing.evm import ChecksumAddress"},{"note":"ABI-related types are located in the `eth_typing.abi` submodule. [1, 9]","wrong":"from eth_typing import ABI","symbol":"ABI","correct":"from eth_typing.abi import ABI"}],"quickstart":{"code":"from eth_typing.evm import Address, ChecksumAddress\nfrom eth_typing.encoding import HexStr\n\ndef process_ethereum_address(address: Address) -> ChecksumAddress:\n    # In a real application, you would perform checksum validation\n    # or other address-related logic here.\n    # For this example, we'll just cast it for demonstration.\n    # eth-utils or web3.py typically handle checksumming.\n    if not isinstance(address, str) or not address.startswith('0x'):\n        raise ValueError('Invalid address format')\n    # Simulate a checksummed address return\n    return ChecksumAddress(address.lower()) # Simplified for quickstart\n\nmy_raw_address: Address = Address('0x742d35Cc6634C0532925a3b844Bc454e4438f444')\nchecksum_addr: ChecksumAddress = process_ethereum_address(my_raw_address)\n\nprint(f'Processed Address: {checksum_addr}')\n\ndef get_hex_string_length(hex_str: HexStr) -> int:\n    return len(hex_str)\n\nmy_hex_string: HexStr = HexStr('0xabcdef123456')\nprint(f'Hex string length: {get_hex_string_length(my_hex_string)}')","lang":"python","description":"Demonstrates importing and using `Address`, `ChecksumAddress`, and `HexStr` for type hinting. This example simplifies address processing as `eth-typing` focuses solely on type definitions, not implementation logic."},"warnings":[{"fix":"Upgrade Python to 3.10+ or pin `eth-typing` version to `<6.0.0`.","message":"Version 6.0.0 drops support for Python 3.8 and 3.9. Users on these Python versions should remain on `eth-typing<6` or upgrade their Python environment. [10]","severity":"breaking","affected_versions":"6.0.0+"},{"fix":"Review ABI definitions and update them to use `stateMutability` and more specific ABI element types as recommended by the documentation.","message":"Several ABI-related TypedDict attributes (e.g., `constant`, `payable` in function types) are deprecated in favor of `stateMutability`. Additionally, specific function types (`ABIFunction`, `ABIConstructor`, etc.) should be used instead of the general `ABIElement` for clarity. [1, 9]","severity":"deprecated","affected_versions":"5.x, 6.0.0+"},{"fix":"Be aware of `NotRequired` fields in `TypedDicts`. Explicitly check for key existence or provide default values when accessing such fields. Type checkers will warn if you access a `NotRequired` field without a check if `strict` mode is enabled.","message":"Many fields in `eth-typing`'s `TypedDict` definitions (especially in `eth_typing.abi`) use `typing.NotRequired`. This means type checkers will not enforce their presence. Developers expecting all fields to be mandatory might face unexpected `KeyError`s at runtime if not handled defensively. [1]","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'1':55 '2':56 '5':57 '6.0.0':50 'abi':62 'across':36 'activ':42 'annot':6,17 'blockchain':64 'clariti':35 'code':34 'common':4,15 'current':47 'ecosystem':39 'eth':2,12 'eth-typ':1,11 'ethereum':8,20,38,58 'evm':63 'frequent':45 'hint':32 'improv':30 'maintain':43 'modern':52 'offer':23 'packag':10,22 'provid':14 'python':9,21,53 'releas':46 'set':26 'standard':25 'support':51 'type':3,5,13,16,28,31,59,60 'various':19 'version':49,54 'web3':61","created_at":"2026-04-09T05:06:56.364305+00:00","updated_at":"2026-04-16T14:51:51.197767+00:00","problems":[{"fix":"Run `pip install eth-typing` to install the library. On Windows, if this fails, you may need to install 'Microsoft C++ Build Tools' for Python to compile certain dependencies.","cause":"The 'eth-typing' library is not installed in your Python environment, or there's an issue with the installation, often due to missing C++ build tools on Windows.","error":"ModuleNotFoundError: No module named 'eth_typing'"},{"fix":"Check the `eth-typing` documentation (for version 6.0.0 or your installed version) to find the correct import path or the new name for the type. You might need to import from a submodule like `eth_typing.evm` or `eth_typing.abi`, or use an updated type name. If migrating from older versions, pin `eth-typing` to a compatible version or update your code to match the new API.","cause":"The specific type 'X' you are trying to import from 'eth_typing' has either been renamed, moved to a different submodule, or removed in the installed version of the library (e.g., due to API changes between major versions). For example, `ContractName` was moved in a past update.","error":"ImportError: cannot import name 'X' from 'eth_typing'"},{"fix":"Upgrade the conflicting packages to compatible versions using `pip install --upgrade <package_name> eth-typing` or explicitly specify compatible versions for all conflicting libraries in your `requirements.txt` file (e.g., `eth-typing==Z`, `eth-utils==A`). Consider using a virtual environment to manage dependencies for different projects.","cause":"This error indicates a dependency conflict where another installed library (`<package_name>`) requires a different version range of `eth-typing` than what is currently installed or being attempted to install, leading to an incompatible package environment.","error":"ERROR: <package_name> has requirement eth-typing<X,>=Y, but you'll have eth-typing Z which is incompatible."},{"fix":"Convert the non-checksummed address to a checksummed address using `Web3.toChecksumAddress()` before passing it to `web3.py` functions. Example: `from web3 import Web3; w3 = Web3(Web3.HTTPProvider('http://localhost:8545')); checksum_address = w3.toChecksumAddress('0x06012c8cf97bead5deae237070f9587f8e7a266d')`.","cause":"You are attempting to use an Ethereum address string that is not a checksummed address (as defined by EIP-55) with `web3.py`. `web3.py` (which relies on `eth-typing` for address types) enforces checksumming to prevent common typos and increase safety.","error":"Web3.py only accepts checksum addresses. The software that gave you this non-checksum address should be considered unsafe, please file it as a bug on their platform. Try using an ENS name instead. Or, if you must accept lower safety, use Web3.toChecksumAddress(lower_case_address)."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"6.0.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ethereum/eth-typing","docs":null,"changelog":null,"pypi":"https://pypi.org/project/eth-typing/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["type-stubs","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":null}}