degenbot.provider.call_helpers

Low-level RPC call helpers.

Thin wrappers around AlloyProvider.call() that handle ABI encoding/decoding and block identifier resolution.

Module Contents

degenbot.provider.call_helpers.encode_function_calldata(function_prototype: str, function_arguments: collections.abc.Sequence[Any] | None) → bytes

Encode calldata for the given function prototype with ordered arguments.

The resulting bytes array will include the 4-byte function selector, followed by the ABI-encoded arguments.

Returns:

The encoded calldata bytes.

degenbot.provider.call_helpers.extract_argument_types_from_function_prototype(function_prototype: str) → list[str]

Extract the argument types from the function prototype.

e.g. the argument types for the prototype ‘function(address,uint256)’ are [‘address’,’uint256’]

Returns:

The list of ABI type strings.

degenbot.provider.call_helpers.raw_call(provider: degenbot.provider.AlloyProvider, address: degenbot.types.chain.ChecksummedAddress, calldata: bytes, return_types: list[str], block_identifier: degenbot.types.rpc_types.BlockIdentifier | None = None) → tuple[Any, ...]

Perform an eth_call at the given address and return the decoded response.

Parameters:
  • provider – AlloyProvider instance

  • address – Contract address to call

  • calldata – Encoded function call data

  • return_types – ABI types for decoding the response

  • block_identifier – Block number or tag for the call

Returns:

Decoded response as tuple