Loading...
An NFT is a token where every unit is unique. ERC-721 is the standard for that uniqueness.
solidityimport "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; contract CoolCats is ERC721, Ownable { uint256 public nextId; constructor() ERC721("CoolCats", "CAT") Ownable(msg.sender) {} function mint(address to) public onlyOwner returns (uint256) { uint256 id = nextId++; _safeMint(to, id); return id; } }
ownerOf(tokenId) — who owns a given tokenbalanceOf(address) — how many tokens does an address owntransferFrom, safeTransferFromapprove, setApprovalForAll — delegate transfer rights_safeMint — internal helper to mint safely (checks the recipient can accept)NFTs don't store images on-chain (too expensive). They store a URI pointing to a JSON file:
json{ "name": "Cat #42", "description": "...", "image": "ipfs://..." }
OZ provides ERC721URIStorage if you want per-token URIs, or override _baseURI() for a common prefix.
Write a MintPass ERC-721 with:
mint() function that lets ANYONE mint themselves one tokennextId on each mint