2

I am getting NFT images directly from the decentralized storages (for example, ipfs), but this is slowing down my entire app as sometimes fetching can take some time. Is this ideal does everyone follow the same process? or is there a way to get images faster from an index or database

Another thing would be nice is to get these images in different sizes, so that I don't have to resize it on my end.

1 Answer 1

1

Yes, I agree that getting data from decentralized storage can sometimes become time intensive.

Have you tried QuickNode Graph API? there are images indexed on QuickNode's end, and it returns images in different sizes so you can use them based on your use case.

Here how the GraphQL query to get images would look:

query Query($contractAddress: String!, $tokenId: String!) {
  ethereum {
    nft(contractAddress: $contractAddress, tokenId: $tokenId) {
      collection {
        image {
          url
        }
        ... on ERC1155Collection {
          externalUrl
        }
      }
      ... on ERC1155NFT {
        uploads {
          url
        }
      }
      ... on ERC721NFT {
        uploads {
          url
        }
      }
    }
  }
}

The above will return images for that NFT. It works for both ERC-1155 as well as ERC-721.

Use these following as variables:

{
  "contractAddress": "contract_address_goes_here",
  "tokenId": "token_id_of_nft"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.