ContractsUtils class
A utility class providing methods to interact with contracts.
ContractsUtils
simplifies tasks such as reading from a contract,
encoding data for contract calls, and signing off-chain transactions.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
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
-
encodedDataForContractCall(
String contractName, EthereumAddress contractAddress, String methodName, List params, {String? jsonInterface, bool include0x = false, int? forcePadLength, bool padToEvenLength = false}) → String - Encodes data for a contract call using the specified function and parameters.
-
encodeERC20ApproveCall(
EthereumAddress tokenAddress, EthereumAddress spender, BigInt amount) → Uint8List - Encodes the data for an ERC20 'approve' operation.
-
encodeERC20TransferCall(
EthereumAddress tokenAddress, EthereumAddress recipient, BigInt amount) → Uint8List - Encodes the data for an ERC20 'transfer' operation.
-
encodeERC721ApproveCall(
EthereumAddress tokenAddress, EthereumAddress spender, BigInt tokenId) → Uint8List - Encodes the data for an ERC721 'approve' operation.
-
encodeERC721SafeTransferCall(
EthereumAddress from, EthereumAddress nftContractAddress, EthereumAddress to, BigInt tokenId) → Uint8List - Encodes the data for an ERC721 'safeTransferFrom' operation.
-
getERC20TokenDetails(
Web3Client web3client, EthereumAddress tokenAddress) → Future< TokenDetails> - Retrieves detailed information about an ERC20 token.
-
isNativeToken(
String address) → bool -
Checks if the given
address
is the native token's address. -
readFromContract(
Web3Client client, String contractName, EthereumAddress contractAddress, String methodName, List params, {String? jsonInterface}) → Future< List> - Reads data from a deployed contract using the specified function and parameters.
-
readFromContractWithFirstResult(
{required Web3Client client, required String contractName, required EthereumAddress contractAddress, required String methodName, required List params}) → Future< BigInt> - Reads data from a specified contract and returns the first result as BigInt.
-
signOffChain(
EthPrivateKey credentials, String from, String to, String data, String nonce, {BigInt? value, BigInt? gasPrice, BigInt? gasLimit}) → String - Signs an off-chain transaction using the provided credentials and transaction data.