0Pricing
Blockchain Smart Contracts with Solidity · 강의

ERC-721 대체 불가능 토큰(NFT)

고유한 디지털 자산을 위한 ERC-721 표준을 살펴보고 NFT를 발행하고 관리하는 방법을 학습합니다.

ERC-721 대체 불가능 토큰(NFT)은(는) CoddyKit의 무료 Blockchain Smart Contracts with Solidity 강의입니다. 이것은 4개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Blockchain Smart Contracts with Solidity 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Blockchain Smart Contracts with Solidity 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

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!

자주 묻는 질문

“ERC-721 대체 불가능 토큰(NFT)” 강의는 무료인가요?

네 — “ERC-721 대체 불가능 토큰(NFT)” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Blockchain Smart Contracts with Solidity 강의 전체를 잠금 해제할 수 있습니다. Blockchain Smart Contracts with Solidity 강의에는 총 4개의 강의가 포함되어 있습니다.

“ERC-721 대체 불가능 토큰(NFT)”에서 뭘 배우나요?

고유한 디지털 자산을 위한 ERC-721 표준을 살펴보고 NFT를 발행하고 관리하는 방법을 학습합니다. 브라우저에서 직접 실행하는 실습 코드로 Blockchain Smart Contracts with Solidity을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Blockchain Smart Contracts with Solidity을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Blockchain Smart Contracts with Solidity은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 3번째 강의입니다.

“ERC-721 대체 불가능 토큰(NFT)” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Blockchain Smart Contracts with Solidity 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Blockchain Smart Contracts with Solidity 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. ERC-20 대체 가능 토큰 표준
  2. ERC-20 토큰 구현
  3. ERC-721 대체 불가능 토큰(NFT)
  4. ERC-1155 멀티 토큰 표준
← Blockchain Smart Contracts with Solidity(으)로 돌아가기