approve method
Change or reaffirm the approved address for an NFT
The zero address indicates there is no approved address.
Throws unless owner
is the current NFT owner, or an authorized
tokenAddress An address for whom to query .
ownerPrivateKey Owner Private key.
recieverAddress The address to transfer to .
tokenID The identifier for an NFT
Implementation
Future<String> approve(String owner_PrivateKey, String contractadd,
String spenderadd, BigInt token__ID) async {
final String privateKey = owner_PrivateKey;
final credentials = await EthPrivateKey.fromHex(privateKey);
final EthereumAddress contractAddr = EthereumAddress.fromHex(contractadd);
final contract =
DeployedContract(ContractAbi.fromJson(abiFile, 'XRC721'), contractAddr);
final tokenApprove = contract.function('approve');
final EthereumAddress spender = EthereumAddress.fromHex(spenderadd);
final approve = await Transaction.callContract(
contract: contract,
function: tokenApprove,
parameters: [spender, token__ID]);
final approvel = await client.sendTransaction(credentials, approve,
chainId: null, fetchChainIdFromNetworkId: true);
return ('$approvel');
}