API#
Clients#
Providers#
Fallback providers#
Errors#
- class pons._provider.RPCError(code: ErrorCode, message: str, data: None | bytes = None)[source]#
A wrapper for a call execution error returned as a proper RPC response.
- 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
or23 % 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]
wherei >= x.length
ori < 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.
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.
- 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.
Compiled and deployed contracts#
Entities#
- class pons._entities.CustomAmount#
A type derived from
Amount
.
- class pons._entities.CustomAddress#
A type derived from
Address
.
- class pons._entities.TxReceipt[source]#
Transaction receipt.
- block_hash: BlockHash#
Hash of the block including this transaction.
- contract_address: None | Address#
If it was a successful deployment transaction, contains the address of the deployed contract.
- cumulative_gas_used: int#
The total amount of gas used when this transaction was executed in the block.
- effective_gas_price: Amount#
The actual value per gas deducted from the sender’s account.
- from_: Address#
Address of the sender.
- to: None | Address#
Address of the receiver.
None
when the transaction is a contract creation transaction.
- transaction_hash: TxHash#
Hash of the transaction.
- class pons._entities.BlockInfo[source]#
Block info.
- base_fee_per_gas: Amount#
Base fee per gas in this block.
- parent_hash: BlockHash#
Parent block’s hash.
- class pons._entities.TxInfo[source]#
Transaction info.
- block_hash: None | BlockHash#
The hash of the block this transaction belongs to.
None
for pending transactions.
- from_: Address#
Transaction sender.
- gas_price: Amount#
Gas price used by the transaction.
- hash_: TxHash#
Transaction hash.
- max_fee_per_gas: None | Amount#
maxFeePerGas
value specified by the sender. Only for EIP1559 transactions.
- max_priority_fee_per_gas: None | Amount#
maxPriorityFeePerGas
value specified by the sender. Only for EIP1559 transactions.
- value: Amount#
Associated funds.
- class pons._entities.BlockFilter[source]#
BlockFilter(id_: pons._entities.BlockFilterId, provider_path: tuple[int, …])
- class pons._entities.PendingTransactionFilter[source]#
PendingTransactionFilter(id_: pons._entities.PendingTransactionFilterId, provider_path: tuple[int, …])
- class pons._entities.LogFilter[source]#
LogFilter(id_: pons._entities.LogFilterId, provider_path: tuple[int, …])
- class pons._entities.LogEntry[source]#
Log entry metadata.
- address: Address#
The contract address from which this log originated.
- block_hash: BlockHash#
Hash of the block where this log was in.
- topics: tuple[LogTopic, ...]#
Values of indexed event fields. For a named event, the first topic is the event’s selector.
- transaction_hash: TxHash#
Hash of the transactions this log was created from.
- class JSON#
A JSON-ifiable object (
bool
,int
,float
,str
,None
, iterable ofJSON
, or mapping ofstr
toJSON
).
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.bytes(size: None | int = None) Bytes [source]#
Returns the
bytes<size>
type, orbytes
ifsize
isNone
.
- pons.abi.address: AddressType#
address
type.
Actual type objects, for reference:
- class pons._abi_types.Bytes(size: None | int = None)[source]#
Corresponds to the Solidity
bytes<size>
type.