transferFrom method

Future<String> transferFrom(
  1. String _contractAddres__,
  2. String __spenderAddr_,
  3. String receiver__Address_,
  4. BigInt token_id__,
  5. dynamic Spender__Privatekey,
  6. dynamic owner_Address__,
)

Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT recieverAddress IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST Throws unless ownerAddress is the current owner, an authorized . 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> transferFrom(
    String _contractAddres__,
    String __spenderAddr_,
    String receiver__Address_,
    BigInt token_id__,
    Spender__Privatekey,
    owner_Address__) async {
  final EthereumAddress contractAddr =
      EthereumAddress.fromHex(_contractAddres__);

  final contract =
      DeployedContract(ContractAbi.fromJson(abiFile, 'XRC721'), contractAddr);
  final tokenTransferFrom = contract.function('transferFrom');
  final EthereumAddress spender = EthereumAddress.fromHex(__spenderAddr_);
  final EthereumAddress receiver =
      EthereumAddress.fromHex(receiver__Address_);
  final EthereumAddress ownAddr = EthereumAddress.fromHex(owner_Address__);
  final nonce = await client.getTransactionCount(spender);
  final gasPrice = await client.getGasPrice();
  final transferFrom = 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 transferForms = await client.sendTransaction(
      credentials, transferFrom,
      chainId: null, fetchChainIdFromNetworkId: true);
  return ('$transferForms');
}