EncodedCall

Documentation for eth_defi.event_reader.multicall_batcher.EncodedCall Python class.

class EncodedCall[source]

Multicall payload, minified implementation.

  • Designed for multiprocessing and historical reads

  • Only carry encoded data, not ABI etc. metadata

  • Contain extra_data which allows route to call results from several calls to one handler class

Example:

convert_to_shares_payload = eth_abi.encode(['uint256'], [share_probe_amount])

share_price_call = EncodedCall.from_keccak_signature(
    address=address,
    signature=Web3.keccak(text="convertToShares(uint256)")[0:4],
    function="convertToShares",
    data=convert_to_shares_payload,
    extra_data=None,
)

Attributes summary

func_name

Store ABI function for debugging purposers

address

Contract address

data

Call ABI-encoded payload

extra_data

Use this to match the reader

first_block_number

First block hint when doing historical multicall reading.

Methods summary

__init__(func_name, address, data, extra_data)

call(web3, block_identifier[, from_, gas])

Return raw results of the call.

from_contract_call(call[, extra_data, ...])

Create poller call from Web3.py Contract proxy object

from_keccak_signature(address, function, ...)

Create poller call directly from a raw function signature

get_curl_info(block_number)

Get human-readable details for debugging.

get_debug_info()

Get human-readable details for debugging.

is_valid_for_block(block_number)

func_name: str

Store ABI function for debugging purposers

address: eth_typing.evm.HexAddress

Contract address

data: bytes

Call ABI-encoded payload

extra_data: dict | None

Use this to match the reader

first_block_number: int | None

First block hint when doing historical multicall reading.

Skip calls for blocks that are earlier than this block number.

get_debug_info()[source]

Get human-readable details for debugging.

  • Punch into Tenderly simulator

  • Data contains both function signature and data payload

Return type

str

get_curl_info(block_number)[source]

Get human-readable details for debugging.

  • Punch into Tenderly simulator

  • Data contains both function signature and data payload

Parameters

block_number (int) –

Return type

str

static from_contract_call(call, extra_data=None, first_block_number=None)[source]

Create poller call from Web3.py Contract proxy object

Parameters
  • call (web3.contract.contract.ContractFunction) –

  • extra_data (Optional[dict]) –

  • first_block_number (Optional[int]) –

Return type

eth_defi.event_reader.multicall_batcher.EncodedCall

static from_keccak_signature(address, function, signature, data, extra_data, first_block_number=None)[source]

Create poller call directly from a raw function signature

Parameters
Return type

eth_defi.event_reader.multicall_batcher.EncodedCall

call(web3, block_identifier, from_='0x0000000000000000000000000000000000000000', gas=75000000)[source]

Return raw results of the call.

Example:

erc_7575_call = EncodedCall.from_keccak_signature(
    address=self.vault_address,
    signature=Web3.keccak(text="share()")[0:4],
    function="share",
    data=b"",
    extra_data=None,
)

result = erc_7575_call.call(self.web3, block_identifier="latest")
share_token_address = convert_uint256_bytes_to_address(result)
Returns

Raw call results as bytes

Raises

ValueError – If the call reverts

Parameters
  • web3 (web3.main.Web3) –

  • block_identifier (Union[Literal['latest', 'earliest', 'pending', 'safe', 'finalized'], eth_typing.evm.BlockNumber, eth_typing.evm.Hash32, eth_typing.encoding.HexStr, int]) –

Return type

bytes

__init__(func_name, address, data, extra_data, first_block_number=None)
Parameters
Return type

None