Non-Fungible Tokens (NFTs)
An NFT is a unique digital token that represents ownership of a specific asset โ art, music, video, in-game items, or even real-world assets. Unlike cryptocurrencies, each NFT is distinct and cannot be exchanged one-to-one with another.
Fungible vs Non-Fungible
Fungible (e.g., ETH): Non-Fungible (e.g., NFT):
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
โ 1 ETH = 1 ETH โ โ NFT #1 โ NFT #2 โ
โ Perfectly โ โ Unique properties โ
โ interchangeable โ โ Cannot be divided โ
โ Divisible โ โ Indivisible โ
โ Same value โ โ Different value โ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโ
ERC-721 Standard
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract MyNFT is ERC721, Ownable {
uint256 private _tokenIdCounter;
constructor() ERC721("MyNFT", "MNFT") {}
function mint(address to) public onlyOwner {
_mint(to, _tokenIdCounter);
_tokenIdCounter++;
}
function totalSupply() public view returns (uint) {
return _tokenIdCounter;
}
}
NFT Metadata and Storage
NFT Structure:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ On-Chain (Ethereum) โ
โ โโ Token ID: 42 โ
โ โโ Owner: 0x742d35Cc... โ
โ โโ Metadata URI: "ipfs://Qm..." โ
โ โ
โ Off-Chain (IPFS / Arweave) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ { โ โ
โ โ "name": "Cool Cat #42", โ โ
โ โ "description": "A cool cat", โ โ
โ โ "image": "ipfs://Qm...", โ โ
โ โ "attributes": [ โ โ
โ โ {"trait_type": "Color", โ โ
โ โ "value": "Blue"}, โ โ
โ โ {"trait_type": "Eyes", โ โ
โ โ "value": "Laser"} โ โ
โ โ ] โ โ
โ โ } โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
NFT Use Cases
Digital Art: Artists sell directly to collectors without galleries.
Music: Musicians tokenize songs, fans own a piece.
Gaming: In-game items (swords, skins) are owned by players.
Real Estate: Property deeds tokenized as NFTs.
Identity: Soul-bound tokens for credentials and reputation.