Search code examples
nftmultiversx

What role does a nonce serve for an NFT issued on Elrond Network?


Here is an example for transferring an NFT in the Elrond docs:

TransferTransaction {
    Sender: <account address of the sender>
    Receiver: <same as sender>
    Value: 0
    GasLimit: 1000000 + length of Data field in bytes * 1500
    Data: "ESDTNFTTransfer" +
          "@" + <token identifier in hexadecimal encoding> +
          "@" + <the NFT nonce in hexadecimal encoding> + 
          "@" + <quantity to transfer in hexadecimal encoding> +
          "@" + <destination address in hexadecimal encoding>
}

Source: https://docs.elrond.com/developers/nft-tokens/#transfers

What role does the nonce serve above? And how is it retrieved?


Solution

  • On Elrond, an individual NFT is defined by a (token id, nonce) pair, where the token id corresponds to the id associated with an issuance class (e.g., NFT-TICKER-123456) and the nonce corresponds to one specific NFT (with various attributes and url data, etc.) issued under that ticker.

    You can retrieve the nonces associated with NFTs held by an account using the Elrond gateway APIs. For example, on Devnet:

    https://devnet-gateway.elrond.com/address/ACCOUNT_ADDRESS/esdt
    

    The data returned will look like:

    {
       "data":{
          "esdts":{
             "ABA-eea2e8-01":{
                "attributes":"AAAAA09rIQ==",
                "balance":"1",
                "creator":"erd1qqqqqqqqqqqqqpgq7t2u...",
                "hash":"YSBoYXNo",
                "name":"NFT",
                "nonce":1,
                "royalties":"0",
                "tokenIdentifier":"ABA-eea2e8-01",
                "uris":[
                   "aHR0cDo6Ly9ldGhhbmZhc3QuY29t"
                ]
             }
          }
       },
       "error":"",
       "code":"successful"
    }
    

    Each key, value pair corresponds to a balance of ESDT or a specific NFT. For example, here the key "ABA-eea2e8-01" consists of a NFT token id and nonce concatenated with "-", and its values include the NFT's associated attributes.