Error: Updating contract instance failed: 'transfer' in 'nft_review' at {"index":xxxx,"subindex":x} failed with code -42000002

Hello,

I am following tutorial Mint and transfer the NFT — Concordium documentation

Every step worked fine until i try to transfer tokens, than I recieve, following error

Error: Updating contract instance failed:
‘transfer’ in ‘nft_review’ at {“index”:xxxx,“subindex”:x} failed with code -42000002.

The view call is following

  {
      "all_tokens": [
          "00000001",
          "00000002"
      ],
      "state": [
          [
              {
                  "Account": [
                      "3MRLmmWoEjLipzxTQF1A6Ex2n3TuEiTvfpWNGVxJ1xuSTNvhvf"
                  ]
              },
              {
                  "operators": [],
                  "owned_tokens": [
                      "00000001"
                  ]
              }
          ],
          [
              {
                  "Account": [
                      "3SfHLNkmy61ZUQkAhMvAwKj47EYDBiUPbn3wHghFD6qGr8WDGc"
                  ]
              },
              {
                  "operators": [],
                  "owned_tokens": [
                      "00000002"
                  ]
              }
          ]
      ]
  }

The transfer command is following

./concordium-client contract update xxxx --entrypoint transfer --parameter-json /home/yasir/concordium_dev/contracts/nft/nft-artifects/transfer-params.json --schema /home/yasir/concordium_dev/contracts/nft/nft-review/dist/cis2-nft/schema.bin --sender Yasir --energy 6000 --grpc-port 20000 --grpc-ip node.testnet.concordium.com

transfer-params.json is following

[
{
“token_id”: “00000001”,
“amount”: “1”,
“from”: {“Account”:[“3SfHLNkmy61ZUQkAhMvAwKj47EYDBiUPbn3wHghFD6qGr8WDGc”]},
“to”: {“Account”:[“4GyTSko7UZ9iTeUHSLD2c4f3KR6C2nRyyNWbrFMWyC7rRLWDE9”]},
“data”: “”

}

]

  /// The balance of the token owner is insufficient for the transfer (Error
    /// code: -42000002).
    InsufficientFunds,
1 Like

Thx, it worked, the view call shows successful transfer but it is not shown in the browser wallet
Invocation resulted in success:

  • Energy used: 1978 NRG
  • Return value:
    {
    “all_tokens”: [
    “00000001”,
    “00000002”
    ],
    “state”: [
    [
    {
    “Account”: [
    “3MRLmmWoEjLipzxTQF1A6Ex2n3TuEiTvfpWNGVxJ1xuSTNvhvf”
    ]
    },
    {
    “operators”: ,
    “owned_tokens”: [
    “00000001”
    ]
    }
    ],
    [
    {
    “Account”: [
    “3SfHLNkmy61ZUQkAhMvAwKj47EYDBiUPbn3wHghFD6qGr8WDGc”
    ]
    },
    {
    “operators”: ,
    “owned_tokens”:
    }
    ],
    [
    {
    “Account”: [
    “4GyTSko7UZ9iTeUHSLD2c4f3KR6C2nRyyNWbrFMWyC7rRLWDE9”
    ]
    },
    {
    “operators”: ,
    “owned_tokens”: [
    “00000002”
    ]
    }
    ]
    ]
    }

You can go to the Manage tab in the browser wallet. Then you input the smartContractAddress and it should allow you to select which token you want to show in the browser wallet.

We don’t show tokens by default in the browser wallet because anyone can airdrop any random tokens to your address and we don’t want to have a full list of random tokens in the browser wallet that the user does not care about.


I get this

I assume, when you created your token, you didn’t provide a valid token metadata. Your token metadata url should point to a place with some valid metadata.

{
    "hash": {
          "None": [ ]
    },
    "url": "https://ipfs.io/ipfs/QmRP2Uuz3xjFCYbzYLrwmRiaGULQjncKk8nMQcjWZxbsjS"
  }

or

your smart contract does not emit Mint, TokenMetadata events correctly.

1 Like

You can for example upload your metadata file to a public gists on github:

{
“hash”: {
“None”:
},
“url”: “https://gist.githubusercontent.com/DOBEN/e035ef44705cdf8919f72c98a25d54eb/raw/8c6b375a2dff448e7bbd12a27fc420d41f268f12/gistfile1.txt
}

After creating your gists make sure you click raw to get the above raw URL link:

Here is some description what fields your metadata can have:
https://proposals.concordium.software/CIS/cis-2.html#token-metadata-json

1 Like

After creating the gist, I will need to change the url in contract

pub const TOKEN_METADATA_BASE_URL: &str = “metadata link”;

and than call mint or redeploy and init

I followed as you directed, but still token is not shown in the wallet

tokenMeta

  [
      {
          "hash": {
              "None": []
          },
          "url": "https://gist.githubusercontent.com/muniryasir/17eb32cad3529631b9bb2e6fb48e843c/raw/0d75b19aa61af76379be01b917ccdc5e0c0fa899/token-metadata.json00000005"
      }
  ]

looking at the URL, you have some characters 00000005 appended that you need to remove:

https://gist.githubusercontent.com/muniryasir/17eb32cad3529631b9bb2e6fb48e843c/raw/0d75b19aa61af76379be01b917ccdc5e0c0fa899/token-metadata.json

These get appended when i mint

Please see

pub const TOKEN_METADATA_BASE_URL: &str = “https://gist.githubusercontent.com/muniryasir/17eb32cad3529631b9bb2e6fb48e843c/raw/0d75b19aa61af76379be01b917ccdc5e0c0fa899/token-metadata.json”;

The line entered in lib.rs

The nft-params.json is following

{
“owner”: {
“Account”: [“3SfHLNkmy61ZUQkAhMvAwKj47EYDBiUPbn3wHghFD6qGr8WDGc”]
},
“tokens”: [“00000005”]
}

It appends the tokens to url

You can change the logic of the smart contract to not append the tokenID if that is your goal or you can upload the metadata file with the correct “appended token id”.

I appended the file with token id, please see

gist.githubusercontent.com/muniryasir/17eb32cad3529631b9bb2e6fb48e843c/raw/32a9f7792b6483c3dccd3f4c91fd867323a3befd/token-metadata.json00000005

Still it won’t show in the wallet

Presumably, either something with the event logged by your smart contract is off or some problems with the metadata URL.

Can you share your smart contract index?

pleas see the smart contract index 8439

I tried to import the contract index in the Android mobile wallet (gives better error messages). And it reported: “Unable to load metadata”.

So presumably, your URL in the metadata file does not load.
https://ipfs.io/ipfs/QmSCUnCxKi8V3E3EkjmjgmqzsigAGpoU81ZjU42jJBt1Zd?filename=heart_of_blood.png

ok so what do you suggest? the ipfs link is not working it used to, should i upload a different file and then try with that?

This seems a problem related to IPFS file availability. You can read up about how to pin a file in IPFS and ensure it is reliable available. Your token metadata needs to be available otherwise how should the Concordium wallet display it.

Hello,

I uploaded and pinned file using Pinata Blog | What is an IPFS Pinning Service?

the file is available as well


updated the gist file as well

gist.githubusercontent.com/muniryasir/17eb32cad3529631b9bb2e6fb48e843c/raw/0a6e91f9a3bd54e7982f5ff1711ae63c823c0c24/token-metadata.json00000005

however, still no change

Can you share which contract address you tested the above metadata? The old smart contract index has no new minted token.