public static void SendNFT(string destinationAddress, string collectionIdentifier, ulong nftNonce, int quantity, UnityAction<CompleteCallback<string[]>> completeMethod)
Parameters
Name
Description
destinationAddress
The address to send the NFT to.
collectionIdentifier
The collection ID.
nftNonce
Nonce of the NFT in decimal format.
quantity
Number of units to send.
completeMethod
Callback to track the status of the transaction. At complete, the message will be the transaction hash.
Check the following image for a better understanding of how to get the parameters:
Example
public class Test : MonoBehaviour
{
private string destinationAddress = "erd1jza9qqw0l24svfmm2u8wj24gdf84hksd5xrctk0s0a36leyqptgs5whlhf";
public void SendNFT()
{
//send transaction
MultiversX.UnityTools.API.SendNFT(destinationAddress, "CLOTHES-35c061", 25, 1, CompleteMethod);
}
private void CompleteMethod(CompleteCallback<string[]> result)
{
switch (result.status)
{
case OperationStatus.InProgress:
Debug.Log($"Waiting for xPortal signature");
break;
case OperationStatus.Error:
Debug.LogError($"{result.errorMessage}");
break;
case OperationStatus.Success:
//result.data contains the hash of the transaction
//at this point transaction is broadcasted to the blockchain to be processed
//use this method to check if it was processed succesfully or not
MultiversX.UnityTools.API.CheckTransactionStatus(result.data, TransactionProcessed, 1);
break;
}
}
private void TransactionProcessed(CompleteCallback<Transaction[]> result)
{
switch (result.status)
{
case OperationStatus.InProgress:
foreach (Transaction transaction in result.data)
{
Debug.Log($"Tx: {transaction.TxHash} : {transaction.Status}");
}
break;
case OperationStatus.Success:
Debug.Log("Success");
break;
case OperationStatus.Error:
Debug.LogError($"{result.status} {result.errorMessage}");
foreach (Transaction transaction in result.data)
{
//the GetLogs() will return additional info about why the transaction failed.
Debug.Log($"Tx: {transaction.TxHash} : {transaction.Status} {transaction.GetLogs()}");
}
break;
}
}
}
The nonce parameter shown is in hex format, and it is needed in the decimal format, so use an external converter like this to get it:
19 in decimal = 25