ERC-721NFT

ERC-721 is the Ethereum standard for non-fungible tokens (NFTs): each token has a unique ID and cannot be swapped one-for-one. ERC-1155 is a later standard that handles both fungible and non-fungible tokens in one contract.

Most tokens are interchangeable: one unit of a stablecoin is as good as any other. ERC-721 is the rulebook for tokens that are not. It defines a small set of functions that every NFT contract on Ethereum (ETH) must offer, so that wallets, marketplaces and block explorers can show who owns which item and move it safely. This entry explains how ERC-721 works, what a token ID is, how approvals can put your NFTs at risk, and how ERC-1155 differs.

Category
Cryptocurrency and Blockchain
Reading time
5 min
Also called
ERC-1155, NFT standard, Non-fungible token
Updated

ERC-721 in plain words

ERC-721 is a standard interface that a Smart Contract implements so that each token can be tracked as a unique item.1 The proposal was written by William Entriken, Dieter Shirley, Jacob Evans and Nastassia Sachs and created in January 2018.2

Every NFT has a 256-bit number called the token ID, and the pair of contract address and token ID is unique worldwide.1 The ID must not change for the life of the contract.2

Because each token is distinct, NFTs can stand for things like collectibles, tickets, in-game items or domain names such as Ethereum Name Service (ENS) names.3

How an ERC-721 token works, step by step

  1. A contract defines the collection

    One deployed contract holds the whole collection and its ownership records.1

  2. Each item gets a token ID

    A token is identified by the contract address plus its uint256 ID.1

  3. Owners are recorded on-chain

    ownerOf returns who holds an ID; balanceOf counts how many a wallet holds.2

  4. Transfers emit events

    Every move fires a Transfer event that wallets and explorers read.2

  5. Approvals let others move tokens

    approve covers one ID; setApprovalForAll lets an operator move all of yours in that contract.2

  6. Metadata points to the content

    The optional tokenURI returns a link to a JSON file with name, description and image.2

Worked examples

Example 1 — Identifying one NFT

Unique ID

Hypothetical: a collection contract holds 10,000 items and you own token ID 7421.

Example 1 — Identifying one NFT — calculation
IdentityContract address + ID 7421
ownerOf(7421)Returns your address
balanceOf(you)1

Token 7421 in another contract is a completely different asset, because uniqueness comes from the address and ID together.1

Example 2 — Moving three game items

Efficiency

Hypothetical: you send 3 in-game items to a friend.

Example 2 — Moving three game items — calculation
ERC-7213 IDs, moved one by one
ERC-11551 safeBatchTransferFrom call
EffectBatching saves gas

ERC-1155 can move several token IDs and amounts in one call, which costs less gas than separate transactions.4

Example 3 — An approval you forgot

Risk

Hypothetical: months ago you signed setApprovalForAll for a site you no longer use. You hold 4 NFTs in that collection.

Example 3 — An approval you forgot — calculation
Operator rightsAll tokens in that contract
NFTs exposed4 of 4
FixRevoke the approval

An operator approved for all can move every token you own in that contract.2 See Token Approval and Wallet Drainer.

ERC-20 vs. ERC-721 vs. ERC-1155

AspectEach unitToken types per contract
ERC-20InterchangeableOne
ERC-721Unique IDOne collection
ERC-1155Fungible or uniqueMany, mixed

Why ERC-721 matters

  • Collectibles and art

    Provably scarce digital items whose ownership anyone can check.3

  • Tickets and access

    Event tickets, attendance proofs and access keys.1

  • Names and identity

    Domain names such as ENS names are issued as NFTs.3

  • Collateral

    Some DeFi apps accept NFTs as collateral.3 See Decentralised Finance (DeFi).

Advantages and disadvantages

Advantages

  • One shared interface, so any compliant wallet or marketplace can handle any collection.
  • Ownership is public and verifiable on-chain.3
  • Safe transfers check that a receiving contract can handle NFTs, which helps stop tokens getting stuck.2
  • Creators can program extras such as resale royalties into the contract.3

Disadvantages

  • The image and description usually live off-chain behind a URI, which can change.2
  • Each item is a separate ID, so moving many items costs more than an ERC-1155 batch.4
  • Broad approvals give operators control of a whole collection.2
  • Most security losses come from phishing and exposed private keys.3

Going deeper

Read as far as you need. Each level builds on the one before it.

Fungible vs. non-fungible

Beginner

A fungible token works like cash: any unit can replace any other. A non-fungible token works like a numbered concert seat: seat 12 is not seat 13, even if they cost the same.

Required and optional parts

Intermediate

A compliant contract must implement the ERC-721 interface and ERC-165 interface detection, which lets other contracts ask which standards it supports.2

Metadata (name, symbol, tokenURI) and enumeration (totalSupply and index lookups) are optional extensions.2 Minting and burning are not specified, only the events they should emit.2

Safe transfers and ERC-1155

Advanced

safeTransferFrom calls onERC721Received on a receiving contract and reverts unless it returns a specific value, so tokens are not sent to contracts that cannot handle them.2

ERC-1155, created in June 2018, lets one contract manage many token types, each fungible, non-fungible or semi-fungible, with batch transfers and balance queries.4

The authors rejected storing all metadata on-chain because of the cost, which is why most collections rely on URIs.2

Common mistakes

  1. Assuming the image is on-chain

    The token usually stores only a link to the metadata, and that link can change.2

  2. Matching by token ID alone

    Token ID 1 exists in thousands of contracts; always check the contract address.

  3. Signing approve-all casually

    setApprovalForAll hands over every token in the collection. See Token Approval.

  4. Using transferFrom to a contract

    Unlike the safe version, it does not check whether the receiving contract can handle NFTs.2

Check your understanding

Test yourself before moving on. Each answer comes with an explanation.

Q1What makes an ERC-721 token unique worldwide?
Q2Which standard can hold both fungible and non-fungible tokens in one contract?

Key points to remember

  1. ERC-721 is the Ethereum standard for non-fungible tokens.
  2. Each NFT is identified by its contract address plus a uint256 token ID.
  3. Approvals can let others move one token or a whole collection.
  4. Metadata usually sits off-chain behind a tokenURI.
  5. ERC-1155 handles many token types and batch transfers in one contract.

Frequently asked questions

Is an NFT the same as ERC-721?

Not exactly. NFT is the general idea of a unique token; ERC-721 is the most widely used standard for building one on Ethereum. ERC-1155 can also create NFTs.

Does owning an ERC-721 token give me copyright?

The standard itself only records ownership of the token. Any rights to the underlying artwork depend on the project’s own terms.

Can ERC-721 tokens exist on other blockchains?

Yes. Networks that run the Ethereum Virtual Machine can host contracts that follow the same standard.

Further learning

Sources

This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.

  1. ethereum.org. ERC-721 Non-Fungible Token Standard (opens in a new tab) Checked .
  2. Ethereum Improvement Proposals. ERC-721: Non-Fungible Token Standard (opens in a new tab) Checked .
  3. ethereum.org. Non-fungible tokens (NFT) (opens in a new tab) Checked .
  4. Ethereum Improvement Proposals. ERC-1155: Multi Token Standard (opens in a new tab) Checked .

Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.