NFT Frontend Minting and Integration 3 — Questions and Answers
Question 1: When a frontend reads an NFT's tokenURI that starts with 'ipfs://', what must it do to fetch the metadata over HTTP?
- Resolve it through an IPFS gateway URL (Correct answer)
- Decode it as base64 only
- Send it to MetaMask
- Ignore it and use the contract address
Correct answer: Resolve it through an IPFS gateway URL
Browsers can't fetch ipfs:// directly, so the URI is rewritten to a gateway like https://ipfs.io/ipfs/<cid>.
Question 2: An NFT's metadata JSON contains an 'image' field. According to common standards, what should the frontend render it as?
- A URL pointing to the image asset (often IPFS or HTTP) (Correct answer)
- Raw hex color codes
- The owner's wallet address
- A Solidity bytecode string
Correct answer: A URL pointing to the image asset (often IPFS or HTTP)
The ERC-721 metadata 'image' field is a URI the frontend loads to display the artwork.
Question 3: Why might a frontend cache fetched NFT metadata rather than re-requesting it on every render?
- Metadata is typically immutable on IPFS, so caching reduces gateway load and latency (Correct answer)
- Caching mints new tokens
- It lowers gas fees
- It changes the tokenId
Correct answer: Metadata is typically immutable on IPFS, so caching reduces gateway load and latency
Pinned IPFS metadata rarely changes, so caching avoids repeated slow gateway requests.
Question 4: What is a robust pattern for handling an NFT image that fails to load from one IPFS gateway?
- Fall back to an alternative gateway via the onError handler (Correct answer)
- Mint the NFT again
- Disconnect the wallet
- Throw and crash the app
Correct answer: Fall back to an alternative gateway via the onError handler
Using onError to try a backup gateway makes image display resilient to a single gateway outage.
Question 5: When displaying a collection, why is calling 'balanceOf' then 'tokenOfOwnerByIndex' only possible if the contract implements a certain extension?
- It requires the ERC-721Enumerable extension (Correct answer)
- It requires ERC-20
- It requires the contract to be paused
- It requires a Chainlink oracle
Correct answer: It requires the ERC-721Enumerable extension
tokenOfOwnerByIndex is part of ERC-721Enumerable, which not all NFT contracts implement.
Question 6: What does the 'attributes' array in standard NFT metadata typically power on a frontend?
- Display of traits and rarity properties (Correct answer)
- The contract's gas limit
- Wallet authentication
- The RPC endpoint URL
Correct answer: Display of traits and rarity properties
The attributes array holds trait_type/value pairs that frontends render as the NFT's properties.
Question 7: If a tokenURI returns base64-encoded JSON inline (on-chain metadata), what must the frontend do before parsing it?
- Decode the base64 data URI to get the JSON string (Correct answer)
- Upload it to IPFS
- Send it to the contract
- Convert it to a private key
Correct answer: Decode the base64 data URI to get the JSON string
On-chain metadata is delivered as a data:application/json;base64 URI that must be decoded before JSON.parse.
When a frontend reads an NFT's tokenURI that starts with 'ipfs://', what must it do to fetch the metadata over HTTP?