API

Clients

Providers

Fallback providers

Errors

class pons._client.ContractPanicReason(value)[source]

Reasons leading to a contract call panicking.

ASSERTION = 1

If you call assert with an argument that evaluates to false.

COMPILER = 0

Used for generic compiler inserted panics.

DIVISION_BY_ZERO = 18

If you divide or modulo by zero (e.g. 5 / 0 or 23 % 0).

EMPTY_ARRAY = 49

If you call .pop() on an empty array.

INVALID_ENCODING = 34

If you access a storage byte array that is incorrectly encoded.

INVALID_ENUM_VALUE = 33

If you convert a value that is too big or negative into an enum type.

OUT_OF_BOUNDS = 50

If you access an array, bytesN or an array slice at an out-of-bounds or negative index (i.e. x[i] where i >= x.length or i < 0).

OUT_OF_MEMORY = 65

If you allocate too much memory or create an array that is too large.

OVERFLOW = 17

If an arithmetic operation results in underflow or overflow outside of an unchecked { ... } block.

UNKNOWN = -1

Unknown panic code.

ZERO_DEREFERENCE = 81

If you call a zero-initialized variable of internal function type.

Signers

Contract ABI

Testing utilities

pons exposes several types useful for testing applications that connect to Ethereum RPC servers. Not intended for the production environment.

Install with the feature local-provider for it to be available.

Compiler

Install with the feature compiler for it to be available.

Secondary classes

The instances of these classes are not created by the user directly, but rather found as return values, or attributes of other objects.

Utility classes

class pons._contract_abi.Methods[source]

Bases: Generic [MethodType].

A holder for named methods which can be accessed as attributes, or iterated over.

__getattr__(method_name: str) MethodType[source]

Returns the method by name.

__iter__() Iterator[MethodType][source]

Returns the iterator over all methods.

class pons._contract_abi.MethodType

Generic method type parameter.

class pons._contract_abi.Signature[source]

Generalized signature of either inputs or outputs of a method.

property canonical_form: str

Returns the signature serialized in the canonical form as a string.

class pons._contract_abi.Method(name: str, mutability: Mutability, inputs: Mapping[str, Type] | Sequence[Type], outputs: None | Mapping[str, Type] | Sequence[Type] | Type = None)[source]

A contract method.

Note

If the name of a parameter (input or output) given to the constructor matches a Python keyword, _ will be appended to it.

decode_output(output_bytes: bytes) Any[source]

Decodes the output from ABI-packed bytes.

classmethod from_json(method_entry: dict[str, Any]) Method[source]

Creates this object from a JSON ABI method entry.

property inputs: Signature

The input signature of this method.

mutating: bool

Whether this method may mutate the contract state.

property name: str

The name of this method.

outputs: Signature

Method’s output signature.

payable: bool

Whether this method is marked as payable.

property selector: bytes

Method’s selector.

Compiled and deployed contracts

Filter objects

class pons._client.BlockFilter[source]

BlockFilter(id_: int, provider_path: tuple[int, …])

class pons._client.PendingTransactionFilter[source]

PendingTransactionFilter(id_: int, provider_path: tuple[int, …])

class pons._client.LogFilter[source]

LogFilter(id_: int, provider_path: tuple[int, …])

Solidity types

Type aliases are exported from the abi submodule. Arrays can be obtained from Type objects by indexing them (either with an integer for a fixed-size array, or with ... for a variable-sized array).

Helper aliases are exported from pons.abi submodule:

pons.abi.uint(bits: int) UInt[source]

Returns the uint<bits> type.

pons.abi.int(bits: int) Int[source]

Returns the int<bits> type.

pons.abi.bytes(size: None | int = None) Bytes[source]

Returns the bytes<size> type, or bytes if size is None.

pons.abi.address: AddressType

address type.

pons.abi.string: String

string type.

pons.abi.bool: Bool

bool type.

pons.abi.struct(**kwargs: Type) Struct[source]

Returns the structure type with given fields.

Actual type objects, for reference:

class pons._abi_types.Type[source]

The base type for Solidity types.

class pons._abi_types.UInt(bits: int)[source]

Corresponds to the Solidity uint<bits> type.

class pons._abi_types.Int(bits: int)[source]

Corresponds to the Solidity int<bits> type.

class pons._abi_types.Bytes(size: None | int = None)[source]

Corresponds to the Solidity bytes<size> type.

class pons._abi_types.AddressType[source]

Corresponds to the Solidity address type. Not to be confused with ethereum_rpc.Address which represents an address value.

class pons._abi_types.String[source]

Corresponds to the Solidity string type.

class pons._abi_types.Bool[source]

Corresponds to the Solidity bool type.

class pons._abi_types.Struct(fields: Mapping[str, Type])[source]

Corresponds to the Solidity struct type.