Skip to main content

2 posts tagged with "NFT"

View All Tags

NFT và Digital Assets - Sở hữu Kỹ thuật số trên Blockchain

· 6 min read

Bootcamp Blockchain Mastery

NFT và Digital Assets - Sở hữu Kỹ thuật số trên Blockchain

NFT (Non-Fungible Tokens) đã trở thành hiện tượng, thay đổi cách chúng ta sở hữu và giao dịch digital assets. Bài viết này khám phá thế giới NFT.

NFT là gì?

Non-Fungible Token

NFT là token unique, không thể thay thế, đại diện cho quyền sở hữu một asset cụ thể.

Fungible vs Non-Fungible

Fungible (ERC-20)Non-Fungible (NFT)
InterchangeableUnique
1 BTC = 1 BTCEach NFT is different
DivisibleIndivisible (usually)
Example: TokensExample: Art, collectibles

Characteristics

  • Unique: Mỗi NFT là duy nhất
  • Indivisible: Không thể chia nhỏ (thường)
  • Ownership: Provenance trên blockchain
  • Verifiable: Dễ dàng verify authenticity

NFT Standards

ERC-721

Standard cho unique tokens trên Ethereum.

// ERC-721 Interface
interface IERC721 {
function balanceOf(address owner) external view returns (uint256);
function ownerOf(uint256 tokenId) external view returns (address);
function transferFrom(address from, address to, uint256 tokenId) external;
function approve(address to, uint256 tokenId) external;
function getApproved(uint256 tokenId) external view returns (address);
}

Basic ERC-721 Implementation

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

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

contract MyNFT is ERC721 {
uint256 private _tokenIds;
mapping(uint256 => string) private _tokenURIs;

constructor() ERC721("MyNFT", "MNFT") {}

function mint(address to, string memory tokenURI) public returns (uint256) {
_tokenIds++;
uint256 newTokenId = _tokenIds;

_mint(to, newTokenId);
_setTokenURI(newTokenId, tokenURI);

return newTokenId;
}

function tokenURI(uint256 tokenId) public view override returns (string memory) {
return _tokenURIs[tokenId];
}
}

ERC-1155

Multi-token standard, có thể represent cả fungible và non-fungible tokens.

// ERC-1155 allows both
contract MyMultiToken is ERC1155 {
// Fungible: amount > 1
// Non-fungible: amount = 1
function mint(
address to,
uint256 id,
uint256 amount,
bytes memory data
) public {
_mint(to, id, amount, data);
}
}

So sánh Standards

FeatureERC-721ERC-1155
Use CaseUnique itemsBoth fungible & unique
Batch TransferNoYes
Gas EfficiencyHigherLower (for batches)
MetadataPer tokenPer token ID

NFT Metadata

Token URI

NFTs thường store metadata off-chain:

{
"name": "My Awesome NFT",
"description": "This is a unique digital artwork",
"image": "https://ipfs.io/ipfs/QmXxXxXx...",
"attributes": [
{
"trait_type": "Color",
"value": "Blue"
},
{
"trait_type": "Rarity",
"value": "Legendary"
}
]
}

Storage Options

  • IPFS: Decentralized storage (recommended)
  • Arweave: Permanent storage
  • Centralized: HTTP/HTTPS URLs (not recommended)

NFT Use Cases

Digital Art

  • Artists: Sell artwork directly
  • Collectors: Build collections
  • Platforms: OpenSea, Foundation, SuperRare

Gaming

  • In-game Items: Weapons, skins, characters
  • Play-to-Earn: Earn NFTs by playing
  • Virtual Real Estate: Land in metaverse

Music

  • Albums: Exclusive releases
  • Royalties: Artists earn from resales
  • Concerts: Access tokens

Collectibles

  • Sports: NBA Top Shot, Sorare
  • Trading Cards: Digital collectibles
  • Memes: Viral content as NFTs

Identity và Credentials

  • Certificates: Educational certificates
  • Memberships: Club memberships
  • Licenses: Professional licenses

Real Estate

  • Property Titles: Ownership records
  • Fractional Ownership: Share properties
  • Rental Agreements: Smart contracts

NFT Marketplaces

OpenSea

  • Largest: Most popular marketplace
  • Multi-chain: Ethereum, Polygon, Solana
  • User-friendly: Easy to use interface

Other Marketplaces

  • Foundation: Curated platform
  • SuperRare: Exclusive art
  • Rarible: Community-owned
  • LooksRare: Token rewards for trading

Building NFT Marketplace

contract NFTMarketplace {
struct Listing {
address seller;
uint256 price;
bool active;
}

mapping(uint256 => Listing) public listings;
IERC721 public nftContract;

function listNFT(uint256 tokenId, uint256 price) external {
require(nftContract.ownerOf(tokenId) == msg.sender, "Not owner");
require(nftContract.isApprovedForAll(msg.sender, address(this)), "Not approved");

listings[tokenId] = Listing({
seller: msg.sender,
price: price,
active: true
});
}

function buyNFT(uint256 tokenId) external payable {
Listing memory listing = listings[tokenId];
require(listing.active, "Not for sale");
require(msg.value >= listing.price, "Insufficient payment");

nftContract.safeTransferFrom(listing.seller, msg.sender, tokenId);
payable(listing.seller).transfer(listing.price);

delete listings[tokenId];
}
}

Royalties và Secondary Sales

Royalty Mechanism

Artists có thể earn từ mỗi resale:

contract RoyaltyNFT is ERC721 {
uint256 public royaltyPercentage = 5; // 5%
address public artist;

function _calculateRoyalty(uint256 salePrice) internal view returns (uint256) {
return (salePrice * royaltyPercentage) / 100;
}
}

EIP-2981 (Royalty Standard)

interface IERC2981 {
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}

NFT Minting Strategies

Standard Minting

function mint(address to) public {
uint256 tokenId = totalSupply() + 1;
_mint(to, tokenId);
}

Presale và Whitelist

mapping(address => bool) public whitelist;
bool public presaleActive;

function presaleMint() external {
require(presaleActive, "Presale not active");
require(whitelist[msg.sender], "Not whitelisted");
// Mint logic
}

Dutch Auction

Giá giảm dần theo thời gian:

uint256 public startPrice = 1 ether;
uint256 public endPrice = 0.1 ether;
uint256 public duration = 1 hours;

function getCurrentPrice() public view returns (uint256) {
uint256 elapsed = block.timestamp - startTime;
if (elapsed >= duration) return endPrice;

uint256 priceRange = startPrice - endPrice;
return startPrice - (priceRange * elapsed / duration);
}

Gas Optimization cho NFTs

Batch Minting

// Inefficient ❌
function mintMultiple(address[] memory to) public {
for (uint i = 0; i < to.length; i++) {
_mint(to[i], i + 1);
}
}

// More efficient ✅
function batchMint(address[] memory to) public {
for (uint i = 0; i < to.length; i++) {
_mint(to[i], totalSupply() + i + 1);
}
}

Storage Optimization

  • Use uint8 for small numbers
  • Pack structs
  • Use events for non-essential data

Security Considerations

Reentrancy Protection

bool private locked;

modifier nonReentrant() {
require(!locked, "Reentrant call");
locked = true;
_;
locked = false;
}

Access Control

mapping(address => bool) public authorizedMinters;

modifier onlyAuthorized() {
require(authorizedMinters[msg.sender] || msg.sender == owner, "Not authorized");
_;
}

Input Validation

function mint(address to, string memory uri) external {
require(to != address(0), "Invalid address");
require(bytes(uri).length > 0, "Empty URI");
// Mint logic
}

NFT Analytics

Key Metrics

  • Floor Price: Lowest listed price
  • Volume: Total trading volume
  • Holders: Number of unique owners
  • Rarity: Statistical rarity scores

Tools

  • NFTGo: NFT analytics platform
  • Rarity.tools: Rarity rankings
  • DappRadar: NFT market data

Future of NFTs

  • Utility NFTs: More than just art
  • Gaming: Play-to-earn integration
  • Metaverse: Virtual items
  • Fractionalization: Split ownership

Challenges

  • Gas Costs: Expensive on Ethereum
  • Scams: Rug pulls và fake projects
  • Market Volatility: Price fluctuations

Kết luận

NFTs đang mở ra khả năng mới cho digital ownership và creativity. Hiểu về standards, marketplaces và security best practices giúp bạn tham gia ecosystem một cách an toàn và hiệu quả.

Tiếp tục học về Blockchain Security trong Bootcamp Blockchain Mastery!

Blockchain Mastery - Khóa học toàn diện về công nghệ Blockchain

· 4 min read

Blockchain là gì và tại sao nên học?

Blockchain là công nghệ lưu trữ và truyền tải thông tin bằng các khối được liên kết với nhau, quản lý bởi nhiều máy tính độc lập. Đây là nền tảng của DeFi, NFT, và tiền mã hóa.

Tại sao Blockchain đang "hot"?

  1. Công nghệ của tương lai: Cách mạng hóa nhiều ngành công nghiệp
  2. Nhu cầu nhân lực cao: Hơn 40,000 vị trí blockchain developer toàn cầu
  3. Mức lương hấp dẫn: $100,000 - $200,000/năm cho senior developer
  4. Cơ hội khởi nghiệp: Nhiều startup thành công với vốn đầu tư lớn

Chương trình học Blockchain Mastery

Level 1: Nền tảng Blockchain

Giới thiệu về Blockchain

  • Khái niệm distributed ledger
  • Lịch sử từ Bitcoin đến Ethereum
  • So sánh với cơ sở dữ liệu truyền thống

Kiến trúc Blockchain

  • Cấu trúc của block
  • Hash function và cryptographic hashing
  • Merkle Tree và Merkle Root
  • Blockchain network và nodes

Consensus Mechanisms

  • Proof of Work (PoW)
  • Proof of Stake (PoS)
  • Delegated Proof of Stake (DPoS)

Level 2: Bitcoin và Tiền mã hóa

Bitcoin Deep Dive

  • Bitcoin protocol và network
  • UTXO model
  • Mining và mining pools
  • Bitcoin economics

Altcoins và Tokenomics

  • Các loại tiền mã hóa phổ biến
  • Stablecoins (USDT, USDC, DAI)
  • Token distribution và utility

Level 3: Ethereum và Smart Contracts

Ethereum Platform

  • Ethereum Virtual Machine (EVM)
  • Gas và transaction fees
  • Ethereum accounts và state
  • Ethereum 2.0 và roadmap

Smart Contracts Development với Solidity

pragma solidity ^0.8.0;

contract HelloWorld {
string public message;

constructor(string memory _message) {
message = _message;
}

function setMessage(string memory _message) public {
message = _message;
}
}

Best Practices

  • Security patterns
  • Gas optimization
  • Error handling
  • Testing và deployment

Level 4: DApps Development

Web3 Development Stack

  • Web3.js và Ethers.js
  • Connecting wallet (MetaMask)
  • Reading blockchain data
  • Sending transactions

IPFS và Decentralized Storage

  • IPFS architecture
  • Content addressing
  • Integration với DApps

Level 5: DeFi (Decentralized Finance)

DeFi Fundamentals

  • Decentralized Exchanges (DEX)
  • Lending và Borrowing protocols
  • Yield farming và Liquidity mining
  • Uniswap (AMM)
  • Aave (Lending)
  • Compound (Interest rates)

Level 6: NFT và Digital Assets

NFT Standards

  • ERC-721 Standard
  • ERC-1155 Multi-token
  • NFT Marketplace Development

Level 7: Blockchain Security

Common Vulnerabilities

  • Reentrancy attacks
  • Integer overflow
  • Front-running
  • Access control issues

Security Tools

  • MythX, Slither
  • Smart contract auditing
  • Best practices

Level 8: Advanced Topics

Layer 2 Solutions

  • Polygon (Sidechains)
  • Arbitrum (Optimistic Rollups)
  • Zk-Rollups

Cross-Chain Development

  • Bridge protocols
  • Interoperability
  • Multi-chain architecture

Lộ trình học tập 20 tuần

  • Tuần 1-2: Nền tảng Blockchain
  • Tuần 3-4: Bitcoin và Cryptocurrency
  • Tuần 5-8: Ethereum và Smart Contracts
  • Tuần 9-12: DApp Development
  • Tuần 13-16: DeFi và NFT
  • Tuần 17-20: Security và Advanced Topics

Kết quả sau khóa học

✅ Hiểu sâu về công nghệ Blockchain
✅ Thành thạo Solidity và Smart Contracts
✅ Xây dựng được DApps hoàn chỉnh
✅ Phát triển DeFi protocols
✅ Tạo và quản lý NFT
✅ Nắm vững bảo mật blockchain
✅ Có portfolio dự án thực tế

Cơ hội nghề nghiệp

  • Blockchain Developer: $80,000 - $150,000/năm
  • Smart Contract Auditor: $100,000 - $200,000/năm
  • DeFi Protocol Developer: $120,000 - $180,000/năm
  • Blockchain Architect: $150,000 - $250,000/năm

Kết luận

Blockchain Mastery là khóa học toàn diện giúp bạn từ zero trở thành blockchain developer chuyên nghiệp. Với chương trình học thực tế và mentor hỗ trợ, bạn sẽ sẵn sàng cho sự nghiệp trong ngành Web3.


Tham gia ngay khóa học Blockchain Mastery để bắt đầu hành trình của bạn!