encodeERC721ApproveCall static method

Uint8List encodeERC721ApproveCall(
  1. EthereumAddress contractAddress,
  2. EthereumAddress to,
  3. BigInt tokenId
)

Encodes an ERC-721 token approval function call.

Parameters:

  • contractAddress: The EthereumAddress of the ERC-721 token contract.
  • to: The EthereumAddress of the address to grant approval.
  • tokenId: The BigInt representing the ID of the token to approve.

Returns: A Uint8List containing the ABI-encoded data for the 'approve' function call.

Example:

var encodedCall = encodeERC721ApproveCall(
  EthereumAddress.fromHex('0x9876543210abcdef9876543210abcdef98765432'),
  EthereumAddress.fromHex('0x1234567890abcdef1234567890abcdef12345678'),
  BigInt.from(123),
);

This method uses the ERC-721 contract ABI to return a calldata for 'approve' function call.

Implementation

static Uint8List encodeERC721ApproveCall(
    EthereumAddress contractAddress, EthereumAddress to, BigInt tokenId) {
  return encodeFunctionCall("approve", contractAddress,
      ContractAbis.get("ERC721_Approve"), [to.hex, tokenId]);
}