getAllTokenIds & getNFTMetadata

Hello, i have a problem when I call getAllTokenIds & getTokenIdMetadata.
when I call getAllTokenIds ok the id is correct but all the metadata and token uri are the same, so I would like to check getTokenIdMetadata and the same. my contract address is “0xe11b8e0243e3eed9df387ca279caad4d2b35951a”

my js =>

const options = { address: CONTRACT_ADDRESS, chain: "rinkeby"};
    const NFTs = await Moralis.Web3API.token.getAllTokenIds(options);
    console.log(NFTs);
    const addr = NFTs.result[2].token_address;
    console.log(addr);
    const options2 = { address: addr, chain: "rinkeby" };
    const metaData = await Moralis.Web3API.token.getNFTMetadata(options2);
    console.log(metaData);

the response =>

{total: 3, page: 0, page_size: 500, result: Array(3)}page: 0page_size: 500result: Array(3)0: amount: "2"contract_type: "ERC1155"metadata: "{“name”:“jeremie et alice”,“description”:“nft de jeremie et alice, le plus beau couple de l’univers <3”,“image”:"https://ipfs.moralis.io:2053/ipfs/QmY9GhWzdsa9jexD7LyNbYcDiamFSK85Z6HPs1i9UufRQq"}"name: nullsymbol: nullsynced_at: "2021-10-09T11:01:51.877Z"token_address: "0xe11b8e0243e3eed9df387ca279caad4d2b35951a"token_id: "3"token_uri: “https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC”[[Prototype]]: Object1: amount: "2"contract_type: "ERC1155"metadata: "{“name”:“jeremie et alice”,“description”:“nft de jeremie et alice, le plus beau couple de l’univers <3”,“image”:"https://ipfs.moralis.io:2053/ipfs/QmY9GhWzdsa9jexD7LyNbYcDiamFSK85Z6HPs1i9UufRQq"}"name: nullsymbol: nullsynced_at: "2021-10-09T11:01:51.868Z"token_address: "0xe11b8e0243e3eed9df387ca279caad4d2b35951a"token_id: "2"token_uri: “https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC”[[Prototype]]: Object2: amount: "2"contract_type: "ERC1155"metadata: "{“name”:“jeremie et alice”,“description”:“nft de jeremie et alice, le plus beau couple de l’univers <3”,“image”:"https://ipfs.moralis.io:2053/ipfs/QmY9GhWzdsa9jexD7LyNbYcDiamFSK85Z6HPs1i9UufRQq"}"name: nullsymbol: nullsynced_at: "2021-10-09T11:01:51.883Z"token_address: "0xe11b8e0243e3eed9df387ca279caad4d2b35951a"token_id: "1"token_uri: “https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC”[[Prototype]]: Objectlength: 3[[Prototype]]: Array(0)total: 3[[Prototype]]: Object
lovecollections.js:81 0xe11b8e0243e3eed9df387ca279caad4d2b35951a
lovecollections.js:84 {token_address: ‘0xe11b8e0243e3eed9df387ca279caad4d2b35951a’, name: null, symbol: null, abi: null, contract_type: ‘ERC1155’, …}abi: nullcontract_type: "ERC1155"name: nullsupports_token_uri: nullsymbol: nullsynced_at: nulltoken_address: “0xe11b8e0243e3eed9df387ca279caad4d2b35951a”[[Prototype]]: Object

thank for ur help

I’ll check in 1-2 hours.

1 Like

ok no problem. I use the fonction getTokenIdMetadata for each id and I also have the same metadata for each, in the opensea testnet. I can see its good, the 3 nft are different .

the link to the opensea testnet => https://testnets.opensea.io/collection/unidentified-contract-em3gofco9a

it looks like I got same uri for all 3 token ids with contract.functions.uri(token_id):

import json
from web3 import Web3

b = 'https://speedy-nodes-nyc.moralis.io/ID_HERE/eth/rinkeby/archive'
web3 = Web3(Web3.HTTPProvider(b))

contract = "0xe11b8e0243e3eed9df387ca279caad4d2b35951a"
contract = web3.toChecksumAddress(contract)
abi = json.loads(open("abi2.json", 'rt').read())
contract = web3.eth.contract(address=contract, abi=abi)
for b in (1, 2, 3):
    x = contract.functions.uri(b).call();
    print(b, x)

=>

1 https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC
2 https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC
3 https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC

It looks like what it happened was that on first mint you used as parameter for the metadata: https://ipfs.moralis.io:2053/ipfs/QmSqZBXjQivqe52SXjUoMkNzzE8EvHyJaX73QtN26csibY, for second mint you used as parameter for the metadata: https://ipfs.moralis.io:2053/ipfs/QmU4iNYTKJ6qDtiwBMFSJs9XiMtP1dLvTBwvb8Dtn35SxL and for third mint you used as parameter for the metadata: https://ipfs.moralis.io:2053/ipfs/QmfTYxTSfuFNFynJQPs88ccPTYTc9S9vr7rnwMoKthmruC and somehow now the uri returns only the last link for any token when querying contract.functions.uri(token_id).
maybe opensea checked the contract in realtime and was able to read the metadata uri before was rewritten on the following mint.

hooo ok i understand thank u I will see how to change that :slight_smile:

1 Like

hoooo i understand because erc1155 use just 1 uri for all the smart contract so I can’t have 2 nft with different URI ? maybe I need to switch to er721 but I would like to create 2 exemple for each nft so its why I choose er1155,
can I just add a in my mint function like that ?
emit URI(string value, uint256 indexed id);

You can have multiple uri-s for erc1155, but is not easy to use it with IPFS now because you will need to use folders.

1 Like

ho ok i will try and if I can’t I think I will do it with erc721 thank you for ur support :wink: