[SOLVED] Web3 api data incorrect for erc1155

I’m seeing bad data coming out of the web3 api. For instance, this call is to get the owners of a Euler Beats Genesis NFT. It’s erc1155, but only one of each was minted. The call result has 2 entries. One of the entries is the original owner; the other is the person the original owner transferred it to. Only the second owner should be listed; the first no longer owns that NFT.

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/nft/0x8754f54074400ce745a7ceddc928fb1b7e985ed6/21760049923/owners?chain=eth&format=decimal' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY'

A different cause of bad data shows up when calling /nft/{address} - the call returns “amount” numbers that are higher than actually exist, for instance showing 134 for a token where there are 45 copies in user accounts.

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/nft/0x8754F54074400CE745a7CEddC928FB1b7E985eD6?chain=eth&format=decimal&order=DESC' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY'

Checking this last call shows where the problem exists. Most of the issue comes because one account owned 9 copies at one time, and then sold one. The 9 copy account has 9 entries, each with a quantity of 9. The account that received the 9th copy has 1 entry with a quantity of 8 (should be 1). So there’s a couple of different issues here; one is that there should only be one entry for the 9 copy account (to match erc1155 logic). The second is that when the new user was transferred one token, their balance should only have been incremented by one. And the third is that the 9 copy account’s balance should have been decremented by 1 when it transferred the token (same as the first, simple, issue)

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/nft/0x8754f54074400ce745a7ceddc928fb1b7e985ed6/563194888962/owners?chain=eth&format=decimal' \
  -H 'accept: application/json' \
  -H 'X-API-Key: API_KEY'

If this is fixed, it becomes super useful, because it would give reliable erc1155 total supply data, and reliable erc1155 ownership data.

Hi,
Only giving additional information on how to get to those 9 entries:

x = await Moralis.Web3API.token.getTokenIdOwners({address:‘0x8754f54074400ce745a7ceddc928fb1b7e985ed6’, token_id:“563194888962”})

=>

45: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12376163", …}
46: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12376204", …}
47: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12376283", …}
48: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12428373", …}
49: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12438570", …}
50: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12786791", …}
51: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "12971930", …}
52: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "13052038", …}
53: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "9", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "13080935", …}
54: {token_address: "0x8754f54074400ce745a7ceddc928fb1b7e985ed6", token_id: "563194888962", amount: "8", owner_of: "0xfa21807ede5486c83d665812525ff44c5b72f3ed", block_number: "13087726", …}

@barclander, could you check if this problem is fixed now?

I tested all these, and they work as expected (for that contract, at least). This is excellent news, as it lets us build our site data entirely from Moralis now.

Thanks for the quick fix

1 Like