safetransferFrom method

Future<String> safetransferFrom(
  1. String contractAddres__,
  2. String __spenderAddr,
  3. String receiver__Address,
  4. BigInt token_id_,
  5. String Spender_Privatekey,
  6. String ownerAddress__,
)

Transfers the ownership of an NFT from one address to another address This works identically to the other function with an extra data parameter, except this function just sets data to "". tokenAddress An address for whom to query . ownerAddress owner Of The Token . recieverAddress The address to transfer to tokenID : The identifier for an NFT approvedPrivateKey : Approved Address Private key.

Implementation

Future<String> safetransferFrom(
    String contractAddres__,
    String __spenderAddr,
    String receiver__Address,
    BigInt token_id_,
    String Spender_Privatekey,
    String ownerAddress__) async {
  final EthereumAddress contractAddr =
      EthereumAddress.fromHex(contractAddres__);

  final contract =
      DeployedContract(ContractAbi.fromJson(abiFile, 'XRC721'), contractAddr);
  final tokenTransferFrom = contract.function('safeTransferFrom');
  final EthereumAddress spender = EthereumAddress.fromHex(__spenderAddr);
  final EthereumAddress receiver = EthereumAddress.fromHex(receiver__Address);
  final EthereumAddress ownAddr = EthereumAddress.fromHex(ownerAddress__);
  final nonce = await client.getTransactionCount(spender);
  final gasPrice = await client.getGasPrice();
  final safetransferFrom = await Transaction.callContract(
    contract: contract,
    function: tokenTransferFrom,
    parameters: [ownAddr, receiver, token_id_],
    from: spender,
    gasPrice: gasPrice,
    nonce: nonce,
    maxFeePerGas: null,
    maxPriorityFeePerGas: null,
  );
  final String spender_privateKey = Spender_Privatekey;

  final credentials = await EthPrivateKey.fromHex(spender_privateKey);

  final safetransferForms = await client.sendTransaction(
      credentials, safetransferFrom,
      chainId: null, fetchChainIdFromNetworkId: true);
  return ('$safetransferForms');
}