0Pricing
Blockchain Smart Contracts with Solidity · Ders

ERC-721 Değiştirilemez Tokenlar (NFT'ler)

Benzersiz dijital varlıklar için ERC-721 standardını keşfedin ve NFT'leri basıp yönetmeyi öğrenin.

ERC-721 Değiştirilemez Tokenlar (NFT'ler), CoddyKit'te ücretsiz bir Blockchain Smart Contracts with Solidity dersidir. Bu, 4 dersinin 3. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Blockchain Smart Contracts with Solidity öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Blockchain Smart Contracts with Solidity kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Intro to Unique Digital Assets

Welcome to the world of Non-Fungible Tokens (NFTs)! Unlike regular money or cryptocurrencies, NFTs are unique digital items.

Think of them like rare collectibles or one-of-a-kind art pieces, but entirely digital. Each NFT has distinct properties and cannot be replaced by another.

The ERC-721 Standard

On Ethereum, NFTs are defined by a standard called ERC-721. This standard is a set of rules that smart contracts must follow to create, manage, and transfer unique tokens.

It ensures that all compliant NFTs work similarly across different platforms, making them interoperable.

Key Concepts: Token ID & Ownership

Every ERC-721 token has a unique Token ID (a large number). This ID distinguishes it from all other NFTs, even those from the same collection.

The standard also defines functions to track ownership:

  • ownerOf(uint256 tokenId): Returns the address that owns a specific NFT.
  • balanceOf(address owner): Returns the number of NFTs an address owns from that contract.

Building with OpenZeppelin

Creating an ERC-721 contract from scratch can be complex. Luckily, OpenZeppelin provides battle-tested, secure implementations.

We can simply import their contracts and build upon them. This saves time and reduces the risk of vulnerabilities.

Your First ERC-721 Contract

Here's a basic structure for an ERC-721 contract using OpenZeppelin. It defines a name and symbol for our NFT collection in the constructor.

We'll add a minting function next.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract SimpleNFT is ERC721 {
    constructor() ERC721("MySimpleNFT", "MSN") {
        // Constructor for ERC721 takes name and symbol
    }
}

Creating New NFTs: Minting

To bring new NFTs into existence, we use a process called minting. The _safeMint function (provided by OpenZeppelin's ERC721) creates a new token and assigns it to an owner.

Let's add a public mint function to our contract to create new NFTs.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract SimpleNFT is ERC721 {
    uint256 private _tokenIdCounter;

    constructor() ERC721("MySimpleNFT", "MSN") {
        _tokenIdCounter = 0;
    }

    function mint(address to) public returns (uint256) {
        uint256 newItemId = _tokenIdCounter;
        _tokenIdCounter++;
        _safeMint(to, newItemId); // Mints token and assigns to 'to' address
        return newItemId;
    }
}

NFT Metadata with Token URI

An NFT's value often comes from what it represents (an image, a song, a game item). This information, called metadata, isn't stored directly on the blockchain due to cost.

Instead, the ERC-721 standard includes a tokenURI(uint256 tokenId) function. This function returns a URL pointing to a JSON file that describes the NFT's metadata (e.g., name, description, image URL).

Transferring Ownership

Once an NFT is minted, it can be transferred between owners. The ERC-721 standard includes functions for this:

  • transferFrom(address from, address to, uint256 tokenId): Transfers ownership of tokenId from from to to.
  • safeTransferFrom(...): A safer version that checks if the recipient contract can receive NFTs.

These functions ensure only the current owner or an approved address can initiate a transfer.

Delegated Transfers: Approvals

Sometimes, you might want to allow another address (like a marketplace) to transfer your NFT on your behalf. This is done using approvals.

The approve(address to, uint256 tokenId) function lets you grant permission to another address to to manage a specific tokenId. This is crucial for decentralized exchanges and other dApps.

ERC-721 Knowledge Check

Let's test your understanding of ERC-721 NFTs. Select all statements that are true.

Recap: ERC-721 NFTs

You've explored the fascinating world of ERC-721 Non-Fungible Tokens!

  • NFTs are unique digital assets, unlike fungible cryptocurrencies.
  • The ERC-721 standard defines how these unique tokens are created and managed on Ethereum.
  • Key features include unique Token IDs, ownership tracking, minting, and linking to off-chain metadata via tokenURI.
  • OpenZeppelin contracts simplify ERC-721 development.

NFTs are a cornerstone of digital ownership and are used in art, gaming, and many other applications!

Sıkça Sorulan Sorular

“ERC-721 Değiştirilemez Tokenlar (NFT'ler)” dersi ücretsiz mi?

Evet — “ERC-721 Değiştirilemez Tokenlar (NFT'ler)” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Blockchain Smart Contracts with Solidity kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Blockchain Smart Contracts with Solidity kursu toplamda 4 dersten oluşur.

“ERC-721 Değiştirilemez Tokenlar (NFT'ler)” dersinde ne öğreneceğim?

Benzersiz dijital varlıklar için ERC-721 standardını keşfedin ve NFT'leri basıp yönetmeyi öğrenin. Blockchain Smart Contracts with Solidity ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Blockchain Smart Contracts with Solidity öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Blockchain Smart Contracts with Solidity, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 3. dersidir.

“ERC-721 Değiştirilemez Tokenlar (NFT'ler)” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Blockchain Smart Contracts with Solidity dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Blockchain Smart Contracts with Solidity dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. ERC-20 Değiştirilebilir Token Standardı
  2. ERC-20 Token Uygulama
  3. ERC-721 Değiştirilemez Tokenlar (NFT'ler)
  4. ERC-1155 Çoklu Token Standardı
← Blockchain Smart Contracts with Solidity Sayfasına Dön