ERC-721

Smart Contract Updated Feb 2026

What is ERC-721?

ERC-721 is the technical standard for non-fungible tokens (NFTs) on Ethereum. Unlike ERC-20 tokens (where every token is identical), each ERC-721 token is unique and has its own distinct token ID. This makes them perfect for representing ownership of digital art, collectibles, game items, real estate, and any other unique asset.

ERC-721 was proposed by William Entriken, Dieter Shirley, Jacob Evans, and Nastassia Sachs in January 2018 (EIP-721). It powered the 2021 NFT boom, enabling collections like CryptoPunks, Bored Ape Yacht Club, and NBA Top Shot.

The NFT market peaked at $17 billion in trading volume in 2021, with ERC-721 being the dominant standard.

How ERC-721 Differs from ERC-20

FeatureERC-20 (Fungible)ERC-721 (Non-Fungible)
Token interchangeabilityAll tokens are identicalEach token is unique
Token IDNot applicableEach has a unique uint256 ID
balanceOfReturns total amountReturns count of distinct tokens
TransferAny amountOne specific token ID at a time
Use caseCurrency, governanceArt, collectibles, game items
MetadataMinimal (name, symbol)Rich (image, attributes, traits)

The ERC-721 Interface

Core Functions

// Basic info
function name() public view returns (string)        // "Bored Ape Yacht Club"
function symbol() public view returns (string)       // "BAYC"

// Ownership
function ownerOf(uint256 tokenId) public view returns (address)
function balanceOf(address owner) public view returns (uint256)

// Transfer
function transferFrom(address from, address to, uint256 tokenId) public
function safeTransferFrom(address from, address to, uint256 tokenId) public

// Approvals
function approve(address to, uint256 tokenId) public
function getApproved(uint256 tokenId) public view returns (address)
function setApprovalForAll(address operator, bool approved) public
function isApprovedForAll(address owner, address operator) public view returns (bool)

Key Difference: safeTransferFrom

The safeTransferFrom function checks that the recipient is capable of handling NFTs (either a smart contract implementing onERC721Received, or a regular wallet). This prevents tokens from being accidentally sent to contracts that can’t manage them — a common cause of lost NFTs.

Token Metadata

The most important feature of ERC-721 is metadata — the JSON data describing each token’s appearance and attributes:

{
  "name": "Bored Ape #1",
  "description": "Bored Ape Yacht Club Collection",
  "image": "ipfs://QmZkN.../1.png",
  "attributes": [
    { "trait_type": "Fur", "value": "Golden Brown" },
    { "trait_type": "Eyes", "value": "Bored" },
    { "trait_type": "Mouth", "value": "Bored Unshaven" },
    { "trait_type": "Background", "value": "Orange" }
  ]
}

On-Chain vs Off-Chain Metadata

StorageHow It WorksProsCons
On-chainMetadata stored in the contractPermanent, immutableVery expensive (gas costs)
IPFSMetadata on decentralized storageCheaper, persistentCan be slow, relies on IPFS pinning
CentralizedMetadata on AWS/regular serverFast, easyServer goes down → NFT has no image

Most major collections use IPFS or Arweave for metadata storage. CryptoPunks and Art Blocks use on-chain storage (all image data is in the contract), making them truly permanent.

The ERC-721 Metadata Standard

function tokenURI(uint256 tokenId) public view returns (string)

This returns a URL pointing to the token’s metadata JSON. Marketplaces like OpenSea read this URI to display the NFT’s image, name, and attributes.

How NFTs Are Created (Minting)

Standard Minting

  1. Deploy contract: Creator deploys an ERC-721 contract with max supply (e.g., 10,000)
  2. Mint function: Users call mint() and pay a mint price (e.g., 0.08 ETH)
  3. Token ID assigned: Contract assigns the next sequential token ID
  4. Metadata generated: Random traits are assigned (fur, eyes, background, etc.)
  5. Transfer: NFT is sent to the minter’s address

Reveal Mechanism

To prevent front-running (minting the rarest NFTs first), many collections use a blind mint followed by a reveal:

  1. During mint: Token URIs are hidden or point to placeholder images
  2. After sellout: Creator commits a pre-determined hash to prove no manipulation
  3. Reveal: Token URIs are updated with actual metadata, randomized via the commit hash
CollectionFloor PriceSupplyNotable Features
CryptoPunks30-60 ETH10,000First major NFT collection (2017), on-chain art
Bored Ape Yacht Club10-20 ETH10,000Commercial rights for holders
Pudgy Penguins5-10 ETH8,888IP licensing, physical toys
Azuki5-10 ETH10,000Anime art style, Bean ecosystem
Doodles1-3 ETH10,000Colorful art, burn mechanics
Miladys2-5 ETH10,000Cult following, remilio spin-offs
Moonbirds0.5-2 ETH10,000Nesting mechanics (was popular, crashed)

ERC-721 Extensions

ExtensionPurpose
ERC-721A (Azuki)Batch minting — dramatically reduces gas for minting multiple NFTs
ERC-721EnumerableOn-chain enumeration of all tokens
ERC-4907Rentable NFTs (separate “user” from “owner”)
ERC-6551NFTs that own wallets (Token Bound Accounts)

Frequently Asked Questions

Q: Can I create my own NFT collection? A: Yes. Use OpenZeppelin Wizard to generate an ERC-721 contract, or use no-code platforms like Manifold or Thirdweb. Deployment costs ~$50-200 on Ethereum, <$1 on L2s.

Q: What happens if the metadata server goes down? A: Your NFT still exists on-chain, but it may display as a blank image if the metadata/image is hosted on a centralized server. This is why IPFS/Arweave storage is preferred for permanence.

Q: Can an NFT be copied? A: Anyone can right-click and save the image, but they can’t replicate the on-chain ownership. The value of an NFT comes from verifiable provenance (proof of ownership and authenticity), not from the image itself.