Types

The following types are available from the eth_typing module.

i.e.

from eth_typing import TypeStr

Application Binary Interface

eth_typing.abi.ABI

List of components representing function and event interfaces (elements of an ABI).

alias of Sequence[Union[ABIFunction, ABIEvent]]

class eth_typing.abi.ABIConstructor(*args, **kwargs)

TypedDict representing the ABI for a constructor function.

constant: bool
inputs: Sequence[ABIFunctionParam]

Function input parameters.

payable: bool
stateMutability: Literal['pure', 'view', 'nonpayable', 'payable']
type: Literal['constructor']

Type of the constructor function.

eth_typing.abi.ABIElement

Base type for ABIFunction and ABIEvent types.

alias of Union[ABIFunction, ABIEvent]

class eth_typing.abi.ABIEvent(*args, **kwargs)

TypedDict to represent the ABI for an event.

anonymous: bool

If True, event is anonymous. Cannot filter the event by name.

inputs: Sequence[ABIEventParam]

Input parameters for the event.

name: str

Event name identifier.

type: Literal['event']

Event ABI type.

class eth_typing.abi.ABIEventParam(*args, **kwargs)

TypedDict to represent the ABI for event parameters.

indexed: bool

If True, event parameter can be used as a topic filter.

name: str

Name of the event parameter.

type: str

Type of the event parameter.

class eth_typing.abi.ABIFallback(*args, **kwargs)

TypedDict representing the ABI for a fallback function.

constant: bool
payable: bool
stateMutability: Literal['pure', 'view', 'nonpayable', 'payable']
type: Literal['fallback']

Type of the fallback function.

class eth_typing.abi.ABIFunction(*args, **kwargs)

TypedDict representing the ABI for a function.

constant: bool
inputs: Sequence[ABIFunctionParam]

Function input parameters.

name: str

Name of the function.

outputs: Sequence[ABIFunctionParam]

Function return values.

payable: bool
stateMutability: Literal['pure', 'view', 'nonpayable', 'payable']
type: Literal['function']

Type of the function.

class eth_typing.abi.ABIFunctionComponent(*args, **kwargs)

TypedDict representing the ABI for nested function parameters.

Used as a component of ABIFunctionParams.

components: Sequence[ABIFunctionComponent]

List of nested function parameters

name: str

Name of the function parameter.

type: str

Type of the function parameter.

class eth_typing.abi.ABIFunctionInfo(*args, **kwargs)

TypedDict to represent an ABIFunction with the function selector and corresponding arguments.

abi: ABIFunction

ABI for the function interface.

arguments: Tuple[Any, ...]

Function input parameters.

selector: HexStr

Solidity Function selector sighash.

class eth_typing.abi.ABIFunctionParam(*args, **kwargs)

TypedDict representing the ABI for function parameters.

components: Sequence[ABIFunctionComponent]

List of function parameters

name: str

Name of the function parameter.

type: str

Type of the function parameter.

class eth_typing.abi.ABIFunctionType(*args, **kwargs)

TypedDict representing the ABI for all function types.

This is the base type for functions. Please use ABIFunction, ABIConstructor, ABIFallback or ABIReceive instead.

constant: bool

Function is constant and does not change state. Deprecated in favor of stateMutability pure and view.

payable: bool

Contract is payable to receive ether on deployment. Deprecated in favor of stateMutability payable and nonpayable.

stateMutability: Literal['pure', 'view', 'nonpayable', 'payable']

State mutability of the constructor.

class eth_typing.abi.ABIReceive(*args, **kwargs)

TypedDict representing the ABI for a receive function.

constant: bool
payable: bool
stateMutability: Literal['pure', 'view', 'nonpayable', 'payable']
type: Literal['receive']

Type of the receive function.

eth_typing.abi.Decodable

Binary data to be decoded.

alias of Union[bytes, bytearray]

eth_typing.abi.TypeStr

String representation of a data type.

Enumerables

ForkName

Class that contains the different names used to represent hard forks on the Ethereum network.

class ForkName:
    Frontier = 'Frontier'
    Homestead = 'Homestead'
    EIP150 = 'EIP150'
    EIP158 = 'EIP158'
    Byzantium = 'Byzantium'
    Constantinople = 'Constantinople'
    Metropolis = 'Metropolis'

ChainId

IntEnum class defining EVM-compatible network name enums as their respective chain id int values.

To learn more about chain ids, see CAIP-2 for details.

The list of chain ids is available from the ethereum-lists/chains repository.

class ChainId(IntEnum):
    # L1 networks
    ETH = 1
    EXP = 2
    ROP = 3
    RIN = 4
    GOR = 5
    # L2 networks
    OETH = 10
    GNO = 100

Discovery

NodeID

A 32-byte identifier for a node in the Discovery DHT

NodeID = NewType('NodeID', bytes)

EthPM

ContractName

Any string conforming to the regular expression [a-zA-Z][a-zA-Z0-9_]{0,255}.

ContractName = NewType('ContractName', str)

URI

Any string that represents a URI.

URI = NewType('URI', str)

EVM

Address

Any bytestring representing a canonical address.

Address = NewType('Address', bytes)

HexAddress

Any HexStr representing a hex encoded address.

HexAddress = NewType('HexAddress', HexStr)

ChecksumAddress

Any HexAddress that is formatted according to ERC55.

ChecksumAddress = NewType('ChecksumAddress', HexAddress)

AnyAddress

Any of Address, HexAddress, ChecksumAddress.

AnyAddress = TypeVar('AnyAddress', Address, HexAddress, ChecksumAddress)

Hash32

Any 32 byte hash.

Hash32 = NewType('Hash32', bytes)

BlockNumber

Any integer that represents a valid block number on a chain.

BlockNumber = NewType('BlockNumber', int)

BlockIdentifier

Either a 32 byte hash or an integer block number

BlockIdentifier = Union[Hash32, BlockNumber]

Encodings

HexStr

Any string that is hex encoded.

HexStr = NewType('HexStr', str)

Primitives

Any of bytes, int, or bool used as the Primitive arg for conversion utils in ETH-Utils.

Primitives = Union[bytes, int, bool]