Chapter 6
Building an ERC-721 NFT
ERC-721 defines non-fungible tokens — each tokenId is unique, with its own owner and metadata URI. Marketplaces, wallets, and indexers depend on standard methods, so a production NFT contract must implement them faithfully.
Use _safeMint instead of _mint when recipients might be contracts — it calls onERC721Received and reverts if the receiver cannot accept NFTs. Skipping this check has locked countless tokens in contracts that never implemented the callback.
Metadata should be immutable or governed explicitly after reveal. Changing URIs without user consent erodes trust. Pin JSON and images to IPFS or Arweave for permanence, and test that tokenURI resolves correctly from both your frontend and major marketplace crawlers.