{"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":"en","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,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}