addNFTTransfer method

Transaction addNFTTransfer(
  1. dynamic to,
  2. double amount,
  3. dynamic nftAddress
)

Add a NFT transfer to the transaction @param {String | Uint8List} to Address of the recipient (hexadecimal or binary buffer) @param {double} amount Amount of UCO to transfer @param {String | Uint8List} nftAddress Address of NFT to spend (hexadecimal or binary buffer)

Implementation

Transaction addNFTTransfer(to, double amount, nftAddress) {
  if (!(to is Uint8List) && !(to is String)) {
    throw "'to' must be a string or Uint8List";
  }

  if (to is String) {
    if (!isHex(to)) {
      throw "'to' must be an hexadecimal string";
    }
  } else {
    to = uint8ListToHex(to);
  }

  if (!(nftAddress is Uint8List) && !(nftAddress is String)) {
    throw "'nftAddress' must be a string or Uint8List";
  }

  if (nftAddress is String) {
    if (!isHex(nftAddress)) {
      throw "'nftAddress' must be an hexadecimal string";
    }
  } else {
    nftAddress = uint8ListToHex(nftAddress);
  }
  final NFTTransfer nftTransfer =
      NFTTransfer(amount: amount, nft: nftAddress, to: to);
  this.data!.ledger!.nft!.transfers!.add(nftTransfer);
  return this;
}