YasirM
March 19, 2024, 2:01pm
1
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”: “”
}
]
Doris
March 19, 2024, 5:23pm
2
}
}
/// The different errors the contract can produce.
#[derive(Debug, PartialEq, Eq, SchemaType, Serial, Deserial)]
pub enum Cis2Error<R> {
/// Invalid token id (Error code: -42000001).
InvalidTokenId,
/// The balance of the token owner is insufficient for the transfer (Error
/// code: -42000002).
InsufficientFunds,
/// Sender is unauthorized to call this function (Error code: -42000003).
Unauthorized,
/// Custom error
Custom(R),
}
/// Convert `Cis2Error` into a reject with error code:
/// - InvalidTokenId: -42000001
/// - InsufficientFunds: -42000002
/// - Unauthorized: -42000003
/// The balance of the token owner is insufficient for the transfer (Error
/// code: -42000002).
InsufficientFunds,
1 Like
YasirM
March 19, 2024, 5:29pm
3
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”
]
}
]
]
}
Doris
March 19, 2024, 6:22pm
4
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.
Doris
March 19, 2024, 6:34pm
6
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
Doris
March 19, 2024, 6:38pm
7
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
YasirM
March 19, 2024, 6:52pm
8
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
YasirM
March 20, 2024, 9:14am
9
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"
}
]
Doris
March 20, 2024, 11:47am
10
YasirM
March 20, 2024, 12:18pm
11
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
Doris
March 20, 2024, 8:41pm
12
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”.
YasirM
March 21, 2024, 6:24am
13
Doris
March 21, 2024, 1:40pm
14
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?
YasirM
March 21, 2024, 1:48pm
15
pleas see the smart contract index 8439
Doris
March 21, 2024, 4:28pm
16
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
YasirM
March 21, 2024, 5:38pm
17
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?
Doris
March 21, 2024, 6:26pm
18
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.
YasirM
March 22, 2024, 12:38pm
19
Doris
March 23, 2024, 9:43am
20
Can you share which contract address you tested the above metadata? The old smart contract index has no new minted token.