verbs.abi.Function#
- class Function[source]#
ABI function class
Class representing a contract function with functionality to encode and decode calls and results to/from this function.
- Parameters:
abi (
dict
) – Parsed ABI JSON of the function.
- inputs#
List of function input types.
- Type:
list[str]
- outputs#
List of function output types.
- Type:
list[str]
Examples
f_abi = { "name": "foo", "inputs": [ {"internalType": "int256", "name": "a", "type": "int256"} ], "outputs": [], "stateMutability": "view", "type": "function", } f = Function(f_abi) encoded_args = f.encode([10]) result = f.call( env, sender_address, contract_address, args )
- call(env: EmptyEnvRandom | EmptyEnvGasPriority | ForkEnvRandom | ForkEnvGasPriority, sender: bytes, address: bytes, args: List[Any], value: int = 0) Tuple[Tuple[Any, ...], List, int] [source]#
Directly call this function without committing any changes
- Parameters:
- Returns:
- execute(env: EmptyEnvRandom | EmptyEnvGasPriority | ForkEnvRandom | ForkEnvGasPriority, sender: bytes, address: bytes, args: List[Any], value: int = 0) Tuple[Tuple[Any, ...], List, int] [source]#
Directly call this function and commit any changes
- Parameters:
- Returns:
- transaction(sender: bytes, address: bytes, args: List[Any], checked: bool = True, gas_priority_fee: int | None = None, nonce: int | None = None, value: int | None = None) Tuple[bytes, bytes, bytes, bool, int | None, int | None, int | None] [source]#
Create a transaction to submit to the current simulation block
- Parameters:
sender (
bytes
) – Address of the call sender.address (
bytes
) – Address of the contract to call.args (
list
) – List of arguments to this function.value (
int
, optional) – Value attached to the transaction, default 0.checked (
bool
, optional) – IfTrue
the simulation will panic if the transaction from this call is reverted (defaultFalse
).gas_priority_fee (
int
, optional) – Transaction priority, defaultNone
is ignorednonce (
int
, optional) – Transaction nonce, defaultNone
is ignoredvalue – Transaction value, default
None
is ignored
- Returns:
verbs.types.Transaction
– Transaction that can be submitted to the simulation for execution in the next block.