0Pricing
Web3 & DApp Development Fundamentals · Lektion

Der ERC-721-Standard

Non-Fungible Tokens

Der ERC-721-Standard ist eine kostenlose Web3 & DApp Development Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 1 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Web3 & DApp Development Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

What Is ERC-721?

ERC-721 is the standard for non-fungible tokens (NFTs). Unlike ERC-20, each token is unique and identified by a distinct tokenId.

NFTs represent ownership of one-of-a-kind items: art, collectibles, in-game assets, and more.

Fungible vs Non-Fungible

The key contrast:

  • ERC-20 - all tokens identical and interchangeable, tracked by balance
  • ERC-721 - each token unique, tracked by owner per tokenId

You own specific token #42, not a fraction of a pool.

Core Ownership Functions

ERC-721 tracks ownership with two key views:

  • ownerOf(tokenId) - who owns a specific token
  • balanceOf(owner) - how many tokens an address owns
<code>function ownerOf(uint256 tokenId) external view returns (address);
function balanceOf(address owner) external view returns (uint256);</code>

Transfer Functions

ERC-721 provides transferFrom and the safer safeTransferFrom, which checks that a receiving contract can handle NFTs.

<code>function transferFrom(address from, address to, uint256 tokenId) external;
function safeTransferFrom(address from, address to, uint256 tokenId) external;</code>

Approval Functions

Owners can authorize others to transfer specific tokens with approve, or grant blanket permission over all their tokens with setApprovalForAll.

<code>function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool approved) external;
function getApproved(uint256 tokenId) external view returns (address);
function isApprovedForAll(address owner, address operator) external view returns (bool);</code>

Required Events

ERC-721 defines three events: Transfer, Approval, and ApprovalForAll. Note the tokenId is indexed so transfers of a specific NFT are easy to track.

<code>event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);</code>

safeTransferFrom and onERC721Received

safeTransferFrom protects against NFTs getting stuck. If the recipient is a contract, it must implement onERC721Received and return the correct magic value, otherwise the transfer reverts.

<code>// receiving contract must implement:
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data)
    external returns (bytes4);</code>

The Metadata Extension

Most NFTs implement the optional metadata extension adding name(), symbol(), and crucially tokenURI(tokenId), which points to the token's off-chain JSON metadata.

<code>function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);</code>

ERC-165 Interface Detection

ERC-721 builds on ERC-165, which lets contracts advertise which interfaces they support via supportsInterface. Marketplaces use it to detect NFTs.

<code>function supportsInterface(bytes4 interfaceId) external view returns (bool);</code>

Using OpenZeppelin ERC721

As with ERC-20, the practical approach is to inherit OpenZeppelin's audited ERC721 implementation and add your minting logic.

<code>// import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
// contract MyNFT is ERC721 {
//     constructor() ERC721('MyNFT', 'MNFT') {}
// }</code>

Where the Asset Lives

An NFT on-chain is just an id and an owner. The actual image or media usually lives off-chain (often on IPFS), referenced by the tokenURI. The chain proves ownership, not the file itself.

Quick Check

Test your understanding of the ERC-721 standard.

Recap

You learned the ERC-721 standard:

  • NFTs are unique, identified by tokenId, tracked via ownerOf
  • Transfers use transferFrom and safer safeTransferFrom
  • Approvals: per-token approve and blanket setApprovalForAll
  • Metadata extension adds tokenURI; ERC-165 enables interface detection
  • Assets usually live off-chain, referenced by the URI

Häufig gestellte Fragen

Ist die Lektion „Der ERC-721-Standard“ kostenlos?

Ja — der vollständige Text von „Der ERC-721-Standard“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Web3 & DApp Development Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Web3 & DApp Development Fundamentals-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Der ERC-721-Standard“?

Non-Fungible Tokens Du übst Web3 & DApp Development Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Web3 & DApp Development Fundamentals zu starten?

Keine Vorkenntnisse erforderlich. Web3 & DApp Development Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 1 von 4.

Wie lange dauert die Lektion „Der ERC-721-Standard“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Web3 & DApp Development Fundamentals-Lektion Code schreiben und ausführen?

Ja. Jede Web3 & DApp Development Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Der ERC-721-Standard
  2. NFTs minten
  3. Token-Metadaten
  4. Marktplätze
← Zurück zu Web3 & DApp Development Fundamentals