encode_with_signature

Documentation for eth_defi.abi.encode_with_signature function.

encode_with_signature(function_signature, args)[source]

Mimic Solidity’s abi.encodeWithSignature() in Python.

This is a Python equivalent for abi.encodeWithSignature().

Example:

payload = encode_with_signature("init(address)", [my_address])
assert type(payload) == bytes
Parameters
  • function_signature (str) –

    Solidity function signature that can be hashed to a selector.

    ABI fill be extractd from this signature.

  • args (Sequence) – Argument values to be encoded.

Return type

bytes