Skip to content

ContractFunc

eth_rpc.ContractFunc dataclass #

ContractFunc(
    func, contract, data=HexStr("0x"), _network=None
)

Bases: Generic[T, U]

func instance-attribute #

func

contract instance-attribute #

contract

data class-attribute instance-attribute #

data = HexStr('0x')

sync property #

sync

address property #

address

name property #

name

alias property #

alias

encode #

encode()
Source code in eth_rpc/contract/function.py
def encode(self):
    return bytes.fromhex(self.data[2:])

decode #

decode(result)
Source code in eth_rpc/contract/function.py
def decode(self, result: bytes) -> U:
    return self.func.decode_result(HexStr(result.hex()))

estimate_gas #

estimate_gas(
    *, from_=None, block_number="latest", sync=False
)
Source code in eth_rpc/contract/function.py
def estimate_gas(
    self,
    *,
    from_: Optional[HexAddress] = None,
    block_number: HexInteger | Literal["latest", "pending"] = "latest",
    sync: bool = False,
) -> MaybeAwaitable[HexInteger]:
    return run(
        self._estimate_gas, from_=from_, block_number=block_number, sync=sync
    )

access_list #

access_list(
    *,
    gas=10000000,
    sender=ADDRESS_ZERO,
    block_number=None,
    sync=False
)
Source code in eth_rpc/contract/function.py
def access_list(
    self,
    *,
    gas: int = 10000000,
    sender: HexAddress = ADDRESS_ZERO,
    block_number: int | None = None,
    sync: bool = False,
) -> MaybeAwaitable[AccessListResponse]:
    return run(
        self._access_list,
        gas=gas,
        sender=sender,
        block_number=block_number,
        sync=sync,
    )

call #

call(
    *,
    from_=None,
    block_number="latest",
    value=0,
    state_diff={},
    sync=False
)
Source code in eth_rpc/contract/function.py
def call(
    self,
    *,
    from_: Optional[HexAddress] = None,
    block_number: int | BLOCK_STRINGS = "latest",
    value: HexInteger | int = 0,
    state_diff: dict[HexAddress, Any] = {},
    sync: bool = False,
) -> MaybeAwaitable[EthResponse[T, U]]:
    return run(self._call, from_, block_number, value, state_diff, sync=sync)

get #

get(
    *,
    from_=None,
    block_number="latest",
    value=0,
    state_diff={},
    sync=False
)
Source code in eth_rpc/contract/function.py
def get(
    self,
    *,
    from_: Optional[HexAddress] = None,
    block_number: int | BLOCK_STRINGS = "latest",
    value: HexInteger | int = 0,
    state_diff: dict[HexAddress, Any] = {},
    sync: bool = False,
) -> MaybeAwaitable[U]:
    return run(
        self._get,
        from_=from_,
        block_number=block_number,
        value=value,
        state_diff=state_diff,
        sync=sync,
    )

prepare #

prepare(
    wallet,
    *,
    nonce=None,
    value=0,
    gas_price=None,
    max_fee_per_gas=None,
    max_priority_fee_per_gas=None,
    use_access_list=False,
    sync=False
)
Source code in eth_rpc/contract/function.py
def prepare(
    self,
    wallet: "BaseWallet",
    *,
    nonce: Optional[int] = None,
    value: int = 0,
    gas_price: Optional[int] = None,
    max_fee_per_gas: Optional[int] = None,
    max_priority_fee_per_gas: Optional[int] = None,
    use_access_list: bool = False,
    sync: bool = False,
) -> MaybeAwaitable[PreparedTransaction]:
    return run(
        self._prepare,
        wallet,
        nonce=nonce,
        value=value,
        gas_price=gas_price,
        max_fee_per_gas=max_fee_per_gas,
        max_priority_fee_per_gas=max_priority_fee_per_gas,
        use_access_list=use_access_list,
        sync=sync,
    )

execute #

execute(
    wallet,
    *,
    nonce=None,
    value=0,
    gas_price=None,
    max_fee_per_gas=None,
    max_priority_fee_per_gas=None,
    use_access_list=False,
    sync=False
)
Source code in eth_rpc/contract/function.py
def execute(
    self,
    wallet: "BaseWallet",
    *,
    nonce: Optional[int] = None,
    value: int = 0,
    gas_price: Optional[int] = None,
    max_fee_per_gas: Optional[int] = None,
    max_priority_fee_per_gas: Optional[int] = None,
    use_access_list: bool = False,
    sync: bool = False,
) -> MaybeAwaitable[HexStr]:
    return run(
        self._execute,
        wallet,
        nonce=nonce,
        value=value,
        gas_price=gas_price,
        max_fee_per_gas=max_fee_per_gas,
        max_priority_fee_per_gas=max_priority_fee_per_gas,
        use_access_list=use_access_list,
        sync=sync,
    )