Contract class
A wrapper for interacting with deployed Ethereum contracts through RPCProviderBase.
The Contract class provides methods to perform various operations on Ethereum smart contracts, including making static calls, checking deployment status, getting contract balance, and encoding data for common operations like ERC20 approvals and transfers.
Constructors
- Contract(RPCProviderBase _provider)
Properties
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- provider → RPCProviderBase
-
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
- setProvider ← RPCProviderBase
-
write-only
Methods
-
call(
EthereumAddress contractAddress, ContractAbi abi, String methodName, {List? params, EthereumAddress? sender}) → Future< List> - Performs a static call to a contract method.
-
deployed(
EthereumAddress? address, {BlockNum atBlock = const BlockNum.current()}) → Future< bool> - Checks if a contract is deployed.
-
getBalance(
EthereumAddress? address, {BlockNum atBlock = const BlockNum.current()}) → Future< EtherAmount> - Gets the amount of Ether held by a contract.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
encodeERC20ApproveCall(
EthereumAddress address, EthereumAddress spender, EtherAmount amount) → Uint8List - Encodes the calldata for ERC20 approval.
-
encodeERC20TransferCall(
EthereumAddress address, EthereumAddress recipient, EtherAmount amount) → Uint8List - Encodes the calldata for ERC20 transfer.
-
encodeERC721ApproveCall(
EthereumAddress contractAddress, EthereumAddress to, BigInt tokenId) → Uint8List - Encodes the calldata for ERC721 approval.
-
encodeERC721SafeTransferCall(
EthereumAddress contractAddress, EthereumAddress from, EthereumAddress to, BigInt tokenId) → Uint8List - Encodes the calldata for ERC721 safe transfer.
-
encodeFunctionCall(
String methodName, EthereumAddress contractAddress, ContractAbi abi, List params) → Uint8List - Encodes the calldata for a function call.
-
execute(
EthereumAddress walletAddress, {required EthereumAddress to, EtherAmount? amount, Uint8List? innerCallData}) → Uint8List - Generates the calldata for a user operation.
-
executeBatch(
{required EthereumAddress walletAddress, required List< EthereumAddress> recipients, List<EtherAmount> ? amounts, List<Uint8List> ? innerCalls}) → Uint8List - Generates the calldata for a batched user operation.
-
getContractFunction(
String methodName, EthereumAddress contractAddress, ContractAbi abi) → ContractFunction - Returns a ContractFunction instance for a given method.
-
nftApproveOperation(
EthereumAddress contractAddress, EthereumAddress owner, EthereumAddress spender, BigInt tokenId) → UserOperation - Returns a UserOperation to approve the spender of the NFT.
-
nftTransferOperation(
EthereumAddress contractAddress, EthereumAddress owner, EthereumAddress recipient, BigInt tokenId) → UserOperation - Returns a UserOperation to transfer an NFT.
-
tokenApproveOperation(
EthereumAddress contractAddress, EthereumAddress owner, EthereumAddress spender, EtherAmount amount) → UserOperation - Returns the UserOperation for an ERC20 approval.
-
tokenTransferOperation(
EthereumAddress contractAddress, EthereumAddress owner, EthereumAddress recipient, EtherAmount amount) → UserOperation - Returns the UserOperation for an ERC20 transfer.