Ver3.0 ๐ ๋ผ๋ผ๋ฒจ๊ณผ Web3.js๋ก NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ ๊ตฌ์ถํ๊ธฐ

๐ ๋ผ๋ผ๋ฒจ๊ณผ Web3.js๋ก NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ ๊ตฌ์ถํ๊ธฐ
๋ธ๋ก์ฒด์ธ ๊ธฐ์ ๋ก ๋ง๋๋ ์ฐจ์ธ๋ ๋ฉค๋ฒ์ญ ํ๋ซํผ ์๋ฒฝ ๊ฐ์ด๋
๐ ์์ฆ NFT๊ฐ ๋จ์ํ ๋์งํธ ์ํธ๋ฅผ ๋์ด์ ๋ฉค๋ฒ์ญ, ์ปค๋ฎค๋ํฐ ์ ๊ทผ๊ถ, ํน๋ณ ํํ ๋ฑ ๋ค์ํ ์ฉ๋๋ก ํ์ฉ๋๊ณ ์๋ค๋ ๊ฑฐ ์๊ณ ์์ด? ํนํ Web3 ์๋๊ฐ ๋ณธ๊ฒฉํ๋๋ฉด์ NFT๋ฅผ ํ์ฉํ ๋ฉค๋ฒ์ญ ์์คํ
์ด ์์ฒญ๋ ์ฃผ๋ชฉ์ ๋ฐ๊ณ ์์ด. ์ค๋์ ๋ผ๋ผ๋ฒจ(Laravel)์ด๋ผ๋ ๊ฐ๋ ฅํ PHP ํ๋ ์์ํฌ์ Web3.js๋ฅผ ๊ฒฐํฉํด์ ์ค์ ๋ก ์๋ํ๋ NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ๋ฅผ ์ด๋ป๊ฒ ๊ตฌ์ถํ๋์ง ์์ธํ ์์๋ณผ ๊ฑฐ์ผ!
์ด ๊ธ์ ๋ค ์ฝ๊ณ ๋๋ฉด ๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ๋ฉค๋ฒ์ญ ์์คํ
์ ๊ตฌ์กฐ๋ฅผ ์๋ฒฝํ ์ดํดํ๊ณ , ์ง์ ๊ตฌ์ถํ ์ ์๋ ์ค์ ๋ฅ๋ ฅ์ ๊ฐ์ถ๊ฒ ๋ ๊ฑฐ์ผ. ๐ฏ
๐จ NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ๋ ๋ฌด์์ธ๊ฐ?
๋จผ์ NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ๊ฐ ์ ํํ ๋ญ์ง๋ถํฐ ์ง๊ณ ๋์ด๊ฐ์. ์ ํต์ ์ธ ๋ฉค๋ฒ์ญ ์์คํ
์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ฌ์ฉ์ ์ ๋ณด๋ฅผ ์ ์ฅํ๊ณ ๊ด๋ฆฌํ๋ ์ค์ํ๋ ๋ฐฉ์์ด์์ด. ํ์ง๋ง NFT ๋ฉค๋ฒ์ญ์ ์์ ํ ๋ค๋ฅธ ์ ๊ทผ๋ฒ์ ์ฌ์ฉํด.
NFT(Non-Fungible Token)๋ ๋ธ๋ก์ฒด์ธ ์์์ ๊ณ ์ ํ ๋์งํธ ์์ฐ์ ๋ํ๋ด๋ ํ ํฐ์ด์ผ. ์ด NFT๋ฅผ ๋ฉค๋ฒ์ญ ์ฆ๋ช
์๋ก ํ์ฉํ๋ ๊ฑฐ์ง. ์ฌ์ฉ์๊ฐ ํน์ NFT๋ฅผ ์ง๊ฐ์ ๋ณด์ ํ๊ณ ์์ผ๋ฉด, ๊ทธ NFT๊ฐ ๊ณง ๋ฉค๋ฒ์ญ ์๊ฒฉ์ฆ๋ช
์ด ๋๋ ์์คํ
์ด์ผ. ๐ซ
๐ NFT ๋ฉค๋ฒ์ญ์ ํต์ฌ ์ฅ์
1. ์ง์ ํ ์์ ๊ถ - ์ฌ์ฉ์๊ฐ ๋ฉค๋ฒ์ญ์ ์ค์ ๋ก ์์ ํ๋ฉฐ, ํ๋ซํผ์ด ์์๋ก ๋ฐํํ ์ ์์ด
2. ๊ฑฐ๋ ๊ฐ๋ฅ์ฑ - ๋ฉค๋ฒ์ญ์ ๋ค๋ฅธ ์ฌ๋์๊ฒ ํ๋งคํ๊ฑฐ๋ ์๋ํ ์ ์์ด
3. ํฌ๋ช
์ฑ - ๋ชจ๋ ๊ฑฐ๋์ ์์ ๊ถ ์ด๋ ฅ์ด ๋ธ๋ก์ฒด์ธ์ ๊ธฐ๋ก๋ผ
4. ์ํธ์ด์ฉ์ฑ - ๋ค๋ฅธ ํ๋ซํผ์์๋ ๋์ผํ NFT๋ฅผ ์ธ์ฆ ์๋จ์ผ๋ก ํ์ฉ ๊ฐ๋ฅํด
5. ํฌ์์ฑ ๋ณด์ฅ - ์ค๋งํธ ์ปจํธ๋ํธ๋ก ๋ฐํ๋์ ์ ํํ ์ ์์ด
๐ ๏ธ ๊ธฐ์ ์คํ ์ ํ๊ณผ ํ๊ฒฝ ๊ตฌ์ฑ
NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ๋ฅผ ๊ตฌ์ถํ๋ ค๋ฉด ๋ฐฑ์๋, ํ๋ก ํธ์๋, ๋ธ๋ก์ฒด์ธ ์ด ์ธ ๊ฐ์ง ์์ญ์ ๊ธฐ์ ์ด ์กฐํ๋กญ๊ฒ ์๋ํด์ผ ํด. ์ฐ๋ฆฌ๊ฐ ์ ํํ ๊ธฐ์ ์คํ์ ํ๋์ฉ ์ดํด๋ณด์.
๐ฆ ๋ผ๋ผ๋ฒจ(Laravel) - ๋ฐฑ์๋์ ์ค์ฌ
๋ผ๋ผ๋ฒจ์ PHP ๊ธฐ๋ฐ์ ์น ์ ํ๋ฆฌ์ผ์ด์ ํ๋ ์์ํฌ๋ก, ์ฐ์ํ ๋ฌธ๋ฒ๊ณผ ๊ฐ๋ ฅํ ๊ธฐ๋ฅ์ผ๋ก ์ ๋ช ํด. NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ์์ ๋ผ๋ผ๋ฒจ์ด ๋ด๋นํ๋ ์ญํ ์ ๋ค์๊ณผ ๊ฐ์:
๐ฏ ๋ผ๋ผ๋ฒจ์ ์ฃผ์ ์ญํ
โข ์ฌ์ฉ์ ๊ด๋ฆฌ - ํ์๊ฐ์
, ๋ก๊ทธ์ธ, ํ๋กํ ๊ด๋ฆฌ
โข NFT ์์ ๊ถ ๊ฒ์ฆ - ๋ธ๋ก์ฒด์ธ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๊ณ ์บ์ฑ
โข ์ฝํ
์ธ ์ ๊ทผ ์ ์ด - NFT ๋ณด์ ์ฌ๋ถ์ ๋ฐ๋ฅธ ๊ถํ ๊ด๋ฆฌ
โข API ์ ๊ณต - ํ๋ก ํธ์๋์ ๋ธ๋ก์ฒด์ธ ์ฌ์ด์ ์ค๊ฐ์ ์ญํ
โข ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ด๋ฆฌ - ์ฌ์ฉ์ ์ ๋ณด, ํ๋ ๋ก๊ทธ, ์บ์ ๋ฐ์ดํฐ ์ ์ฅ
๐ Web3.js - ๋ธ๋ก์ฒด์ธ๊ณผ์ ์ฐ๊ฒฐ๊ณ ๋ฆฌ
Web3.js๋ ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ์ํธ์์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ์๋ฐ์คํฌ๋ฆฝํธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ผ. ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํตํด ์ฌ์ฉ์์ ๋ฉํ๋ง์คํฌ ์ง๊ฐ๊ณผ ์ฐ๊ฒฐํ๊ณ , NFT ์์ ๊ถ์ ํ์ธํ๊ณ , ์ค๋งํธ ์ปจํธ๋ํธ์ ํต์ ํ ์ ์์ด.
๐ง ๊ฐ๋ฐ ํ๊ฒฝ ๊ตฌ์ฑํ๊ธฐ
๋ณธ๊ฒฉ์ ์ผ๋ก ์์ํ๊ธฐ ์ ์ ํ์ํ ๋๊ตฌ๋ค์ ์ค์นํด๋ณด์. ๋ค์ ํญ๋ชฉ๋ค์ด ์ค๋น๋์ด ์์ด์ผ ํด:
| ๊ตฌ์ฑ ์์ | ๋ฒ์ | ์ฉ๋ |
|---|---|---|
| PHP | 8.1 ์ด์ | ๋ผ๋ผ๋ฒจ ์คํ ํ๊ฒฝ |
| Composer | ์ต์ ๋ฒ์ | PHP ํจํค์ง ๊ด๋ฆฌ์ |
| Node.js | 16.x ์ด์ | ํ๋ก ํธ์๋ ๋น๋ ๋๊ตฌ |
| MySQL/PostgreSQL | 8.0 / 13 ์ด์ | ๋ฐ์ดํฐ๋ฒ ์ด์ค |
| MetaMask | ๋ธ๋ผ์ฐ์ ํ์ฅ | ์ง๊ฐ ์ฐ๊ฒฐ ํ ์คํธ |
๐ ๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ ์์ฑ
์, ์ด์ ์ค์ ๋ก ํ๋ก์ ํธ๋ฅผ ๋ง๋ค์ด๋ณด์. ํฐ๋ฏธ๋์ ์ด๊ณ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํด:
composer create-project laravel/laravel nft-membership
cd nft-membership
php artisan serve
์ด ๋ช ๋ น์ด๋ฅผ ์คํํ๋ฉด ๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ๊ฐ ์์ฑ๋๊ณ , ๊ฐ๋ฐ ์๋ฒ๊ฐ http://localhost:8000 ์์ ์คํ๋ผ. ๋ธ๋ผ์ฐ์ ์์ ์ ์ํด๋ณด๋ฉด ๋ผ๋ผ๋ฒจ ํ์ ํ์ด์ง๊ฐ ๋ณด์ผ ๊ฑฐ์ผ! ๐
๐ก ๊ฐ๋ฐ ํ: ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์ผ๋ก๋ Laravel Sail(Docker ๊ธฐ๋ฐ)์ด๋ Laravel Valet(Mac ์ ์ฉ)์ ์ฌ์ฉํ๋ฉด ๋ ํธ๋ฆฌํด. ํนํ Sail์ ๋ฐ์ดํฐ๋ฒ ์ด์ค, Redis ๋ฑ์ ํ ๋ฒ์ ์ค์ ํ ์ ์์ด์ ์ถ์ฒํด!
๐ ์ค๋งํธ ์ปจํธ๋ํธ ์ดํดํ๊ธฐ
NFT ๋ฉค๋ฒ์ญ ์์คํ ์ ํต์ฌ์ ์ค๋งํธ ์ปจํธ๋ํธ์ผ. ์ค๋งํธ ์ปจํธ๋ํธ๋ ๋ธ๋ก์ฒด์ธ ์์์ ์๋์ผ๋ก ์คํ๋๋ ํ๋ก๊ทธ๋จ์ผ๋ก, NFT์ ๋ฐํ, ์ ์ก, ์์ ๊ถ ๊ด๋ฆฌ ๋ฑ์ ๋ด๋นํด. ์ฐ๋ฆฌ๋ ERC-721 ํ์ค์ ์ฌ์ฉํ ๊ฑฐ์ผ.
๐ ERC-721 ํ์ค์ด๋?
ERC-721์ ์ด๋๋ฆฌ์ ๋คํธ์ํฌ์์ NFT๋ฅผ ๋ง๋ค๊ธฐ ์ํ ํ์ค ๊ท๊ฒฉ์ด์ผ. ์ด ํ์ค์ ๋ฐ๋ฅด๋ฉด ๋ค์ํ ํ๋ซํผ๊ณผ ์ง๊ฐ์์ ํธํ์ฑ์ด ๋ณด์ฅ๋ผ. ๊ธฐ๋ณธ์ ์ธ ERC-721 ์ปจํธ๋ํธ๋ ๋ค์๊ณผ ๊ฐ์ ๊ธฐ๋ฅ์ ์ ๊ณตํด:
๐ฏ ERC-721 ํต์ฌ ํจ์๋ค
โข balanceOf(address) - ํน์ ์ฃผ์๊ฐ ๋ณด์ ํ NFT ๊ฐ์ ์กฐํ
โข ownerOf(tokenId) - ํน์ NFT์ ์์ ์ ์ฃผ์ ์กฐํ
โข transferFrom(from, to, tokenId) - NFT ์ ์ก
โข approve(to, tokenId) - NFT ์ ์ก ๊ถํ ๋ถ์ฌ
โข tokenURI(tokenId) - NFT ๋ฉํ๋ฐ์ดํฐ URI ์กฐํ
์ค์ ํ๋ก์ ํธ์์๋ OpenZeppelin ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด์ ์์ ํ๊ณ ๊ฒ์ฆ๋ ์ค๋งํธ ์ปจํธ๋ํธ๋ฅผ ์์ฑํ๋ ๊ฒ ์ข์. ๋ค์์ ๋ฉค๋ฒ์ญ NFT๋ฅผ ์ํ ๊ธฐ๋ณธ ์ปจํธ๋ํธ ์์์ผ:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MembershipNFT is ERC721, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
// ๋ฉค๋ฒ์ญ ๋ฑ๊ธ ์ ์
enum MembershipTier { Bronze, Silver, Gold, Platinum }
// ํ ํฐ ID๋ณ ๋ฉค๋ฒ์ญ ๋ฑ๊ธ ๋งคํ
mapping(uint256 => MembershipTier) public tokenTiers;
// ๋ฑ๊ธ๋ณ ์ต๋ ๋ฐํ๋
mapping(MembershipTier => uint256) public maxSupply;
mapping(MembershipTier => uint256) public currentSupply;
constructor() ERC721("MembershipNFT", "MNFT") {
maxSupply[MembershipTier.Bronze] = 10000;
maxSupply[MembershipTier.Silver] = 5000;
maxSupply[MembershipTier.Gold] = 1000;
maxSupply[MembershipTier.Platinum] = 100;
}
function mintMembership(address recipient, MembershipTier tier)
public onlyOwner returns (uint256) {
require(currentSupply[tier] < maxSupply[tier], "Tier sold out");
_tokenIds.increment();
uint256 newTokenId = _tokenIds.current();
_safeMint(recipient, newTokenId);
tokenTiers[newTokenId] = tier;
currentSupply[tier]++;
return newTokenId;
}
function getMembershipTier(uint256 tokenId)
public view returns (MembershipTier) {
require(_exists(tokenId), "Token does not exist");
return tokenTiers[tokenId];
}
}
์ด ์ปจํธ๋ํธ๋ Bronze, Silver, Gold, Platinum ๋ค ๊ฐ์ง ๋ฑ๊ธ์ ๋ฉค๋ฒ์ญ NFT๋ฅผ ๋ฐํํ ์ ์์ด. ๊ฐ ๋ฑ๊ธ๋ง๋ค ์ต๋ ๋ฐํ๋์ด ์ ํด์ ธ ์์ด์ ํฌ์์ฑ์ ๋ณด์ฅํ์ง. ๐
โ ๏ธ ๋ณด์ ์ฃผ์์ฌํญ: ์ค์ ๋ฉ์ธ๋ท์ ๋ฐฐํฌํ๊ธฐ ์ ์ ๋ฐ๋์ ํ ์คํธ๋ท(Goerli, Sepolia ๋ฑ)์์ ์ถฉ๋ถํ ํ ์คํธํด์ผ ํด. ์ค๋งํธ ์ปจํธ๋ํธ๋ ํ ๋ฒ ๋ฐฐํฌ๋๋ฉด ์์ ์ด ๋ถ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ ๋ฒ๊ทธ๊ฐ ์์ผ๋ฉด ํฐ ๋ฌธ์ ๊ฐ ๋ ์ ์์ด!
๐ Web3.js ํตํฉํ๊ธฐ
์ด์ ํ๋ก ํธ์๋์์ ๋ธ๋ก์ฒด์ธ๊ณผ ํต์ ํ ์ ์๋๋ก Web3.js๋ฅผ ์ค์ ํด๋ณด์. ๋จผ์ ํ์ํ ํจํค์ง๋ฅผ ์ค์นํด์ผ ํด:
npm install web3
npm install @metamask/detect-provider
๐ฆ ๋ฉํ๋ง์คํฌ ์ฐ๊ฒฐ ๊ตฌํ
์ฌ์ฉ์๊ฐ ์์ ์ ์ง๊ฐ์ ์ฐ๊ฒฐํ ์ ์๋๋ก ๋ฉํ๋ง์คํฌ ํตํฉ ๊ธฐ๋ฅ์ ๋ง๋ค์ด๋ณด์. ๋ผ๋ผ๋ฒจ ํ๋ก์ ํธ์ resources/js ํด๋์ web3-connector.js ํ์ผ์ ์์ฑํด:
import Web3 from 'web3';
import detectEthereumProvider from '@metamask/detect-provider';
class Web3Connector {
constructor() {
this.web3 = null;
this.account = null;
this.chainId = null;
this.contractAddress = process.env.MIX_CONTRACT_ADDRESS;
this.contractABI = []; // ์ฌ๊ธฐ์ ์ปจํธ๋ํธ ABI ์
๋ ฅ
}
async connect() {
try {
// ๋ฉํ๋ง์คํฌ ๊ฐ์ง
const provider = await detectEthereumProvider();
if (!provider) {
throw new Error('๋ฉํ๋ง์คํฌ๋ฅผ ์ค์นํด์ฃผ์ธ์!');
}
// Web3 ์ธ์คํด์ค ์์ฑ
this.web3 = new Web3(provider);
// ๊ณ์ ์ฐ๊ฒฐ ์์ฒญ
const accounts = await provider.request({
method: 'eth_requestAccounts'
});
this.account = accounts[0];
// ๋คํธ์ํฌ ID ํ์ธ
this.chainId = await this.web3.eth.getChainId();
// ๊ณ์ ๋ณ๊ฒฝ ๊ฐ์ง
provider.on('accountsChanged', (accounts) => {
this.account = accounts[0];
this.onAccountChanged(accounts[0]);
});
// ๋คํธ์ํฌ ๋ณ๊ฒฝ ๊ฐ์ง
provider.on('chainChanged', (chainId) => {
window.location.reload();
});
return {
success: true,
account: this.account,
chainId: this.chainId
};
} catch (error) {
console.error('์ง๊ฐ ์ฐ๊ฒฐ ์คํจ:', error);
return {
success: false,
error: error.message
};
}
}
async checkNFTOwnership(walletAddress) {
try {
const contract = new this.web3.eth.Contract(
this.contractABI,
this.contractAddress
);
// NFT ๋ณด์ ๊ฐ์ ํ์ธ
const balance = await contract.methods
.balanceOf(walletAddress)
.call();
if (balance > 0) {
// ์ฒซ ๋ฒ์งธ NFT์ ํ ํฐ ID ๊ฐ์ ธ์ค๊ธฐ
const tokenId = await contract.methods
.tokenOfOwnerByIndex(walletAddress, 0)
.call();
// ๋ฉค๋ฒ์ญ ๋ฑ๊ธ ํ์ธ
const tier = await contract.methods
.getMembershipTier(tokenId)
.call();
return {
hasNFT: true,
balance: balance,
tokenId: tokenId,
tier: tier
};
}
return {
hasNFT: false,
balance: 0
};
} catch (error) {
console.error('NFT ์์ ๊ถ ํ์ธ ์คํจ:', error);
throw error;
}
}
async signMessage(message) {
try {
const signature = await this.web3.eth.personal.sign(
message,
this.account,
''
);
return signature;
} catch (error) {
console.error('์๋ช
์คํจ:', error);
throw error;
}
}
onAccountChanged(newAccount) {
// ๊ณ์ ๋ณ๊ฒฝ ์ ์ฒ๋ฆฌํ ๋ก์ง
console.log('๊ณ์ ์ด ๋ณ๊ฒฝ๋์์ต๋๋ค:', newAccount);
}
disconnect() {
this.account = null;
this.web3 = null;
}
}
export default new Web3Connector();
์ด ์ฝ๋๋ ๋ฉํ๋ง์คํฌ ์ฐ๊ฒฐ, NFT ์์ ๊ถ ํ์ธ, ๋ฉ์์ง ์๋ช ๋ฑ์ ํต์ฌ ๊ธฐ๋ฅ์ ์ ๊ณตํด. ํนํ checkNFTOwnership ํจ์๋ ์ฌ์ฉ์๊ฐ ๋ฉค๋ฒ์ญ NFT๋ฅผ ๋ณด์ ํ๊ณ ์๋์ง, ์ด๋ค ๋ฑ๊ธ์ธ์ง ํ์ธํ๋ ์ค์ํ ์ญํ ์ ํด. ๐
๐จ ๋ผ๋ผ๋ฒจ ๋ฐฑ์๋ ๊ตฌ์ถํ๊ธฐ
์ด์ ๋ผ๋ผ๋ฒจ ๋ฐฑ์๋๋ฅผ ๋ณธ๊ฒฉ์ ์ผ๋ก ๊ตฌ์ถํด๋ณด์. NFT ๋ฉค๋ฒ์ญ ์์คํ ์์ ๋ฐฑ์๋๋ ์ฌ์ฉ์ ์ธ์ฆ, ๊ถํ ๊ด๋ฆฌ, ๋ฐ์ดํฐ ์บ์ฑ ๋ฑ์ ๋ด๋นํด.
๐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ค๊ณ
๋จผ์ ํ์ํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ํ ์ด๋ธ์ ์ค๊ณํด์ผ ํด. ๋ค์ ๋ง์ด๊ทธ๋ ์ด์ ํ์ผ๋ค์ ์์ฑํ์:
php artisan make:migration create_users_table
php artisan make:migration create_nft_ownerships_table
php artisan make:migration create_membership_tiers_table
users ํ ์ด๋ธ ๋ง์ด๊ทธ๋ ์ด์ (์ด๋ฏธ ์กด์ฌํ์ง๋ง ์์ ):
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name')->nullable();
$table->string('email')->unique()->nullable();
$table->string('wallet_address')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password')->nullable();
$table->rememberToken();
$table->timestamps();
$table->index('wallet_address');
});
}
nft_ownerships ํ ์ด๋ธ ๋ง์ด๊ทธ๋ ์ด์ :
public function up()
{
Schema::create('nft_ownerships', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('token_id');
$table->string('contract_address');
$table->integer('tier'); // 0: Bronze, 1: Silver, 2: Gold, 3: Platinum
$table->timestamp('verified_at');
$table->timestamp('last_checked_at');
$table->timestamps();
$table->unique(['token_id', 'contract_address']);
$table->index(['user_id', 'tier']);
});
}
membership_tiers ํ ์ด๋ธ ๋ง์ด๊ทธ๋ ์ด์ :
public function up()
{
Schema::create('membership_tiers', function (Blueprint $table) {
$table->id();
$table->string('name'); // Bronze, Silver, Gold, Platinum
$table->integer('level'); // 1, 2, 3, 4
$table->json('benefits'); // ํํ ๋ชฉ๋ก
$table->json('access_permissions'); // ์ ๊ทผ ๊ถํ
$table->timestamps();
});
}
๋ง์ด๊ทธ๋ ์ด์ ์ ์คํํด์ ํ ์ด๋ธ์ ์์ฑํ์:
php artisan migrate
๐ ์ธ์ฆ ์์คํ ๊ตฌํ
NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ์์๋ ์ ํต์ ์ธ ์ด๋ฉ์ผ/๋น๋ฐ๋ฒํธ ๋ฐฉ์ ๋์ ์ง๊ฐ ์ฃผ์ ๊ธฐ๋ฐ ์ธ์ฆ์ ์ฌ์ฉํด. ์ฌ์ฉ์๊ฐ ๋ฉํ๋ง์คํฌ๋ก ๋ฉ์์ง์ ์๋ช ํ๋ฉด, ๊ทธ ์๋ช ์ ๊ฒ์ฆํด์ ๋ก๊ทธ์ธ์ ์ฒ๋ฆฌํ๋ ๋ฐฉ์์ด์ผ.
๋จผ์ Web3 ์ธ์ฆ์ ์ํ ์ปจํธ๋กค๋ฌ๋ฅผ ๋ง๋ค์:
php artisan make:controller Web3AuthController
Web3AuthController.php ํ์ผ:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
use Elliptic\EC;
use kornrunner\Keccak;
class Web3AuthController extends Controller
{
public function getNonce(Request $request)
{
$request->validate([
'wallet_address' => 'required|string'
]);
$walletAddress = strtolower($request->wallet_address);
// ์ฌ์ฉ์ ์ฐพ๊ธฐ ๋๋ ์์ฑ
$user = User::firstOrCreate(
['wallet_address' => $walletAddress],
['name' => 'User ' . substr($walletAddress, 0, 8)]
);
// ๋
ผ์ค ์์ฑ ๋ฐ ์ ์ฅ
$nonce = Str::random(32);
$user->update(['nonce' => $nonce]);
return response()->json([
'nonce' => $nonce,
'message' => "์ฌ๋ฅ๋ท NFT ๋ฉค๋ฒ์ญ ๋ก๊ทธ์ธ\n\n๋
ผ์ค: {$nonce}\n\n์ด ์๋ช
์ ์ธ์ฆ ๋ชฉ์ ์ผ๋ก๋ง ์ฌ์ฉ๋ฉ๋๋ค."
]);
}
public function verify(Request $request)
{
$request->validate([
'wallet_address' => 'required|string',
'signature' => 'required|string'
]);
$walletAddress = strtolower($request->wallet_address);
$signature = $request->signature;
$user = User::where('wallet_address', $walletAddress)->first();
if (!$user || !$user->nonce) {
return response()->json([
'success' => false,
'message' => '๋
ผ์ค๋ฅผ ๋จผ์ ์์ฒญํด์ฃผ์ธ์.'
], 400);
}
$message = "์ฌ๋ฅ๋ท NFT ๋ฉค๋ฒ์ญ ๋ก๊ทธ์ธ\n\n๋
ผ์ค: {$user->nonce}\n\n์ด ์๋ช
์ ์ธ์ฆ ๋ชฉ์ ์ผ๋ก๋ง ์ฌ์ฉ๋ฉ๋๋ค.";
// ์๋ช
๊ฒ์ฆ
if ($this->verifySignature($message, $signature, $walletAddress)) {
// ๋
ผ์ค ์ด๊ธฐํ
$user->update(['nonce' => null]);
// ๋ก๊ทธ์ธ ์ฒ๋ฆฌ
Auth::login($user);
return response()->json([
'success' => true,
'message' => '๋ก๊ทธ์ธ ์ฑ๊ณต',
'user' => $user
]);
}
return response()->json([
'success' => false,
'message' => '์๋ช
๊ฒ์ฆ ์คํจ'
], 401);
}
private function verifySignature($message, $signature, $address)
{
$msglen = strlen($message);
$hash = Keccak::hash("\x19Ethereum Signed Message:\n{$msglen}{$message}", 256);
$sign = [
'r' => substr($signature, 2, 64),
's' => substr($signature, 66, 64)
];
$recid = ord(hex2bin(substr($signature, 130, 2))) - 27;
if ($recid != ($recid & 1)) {
return false;
}
$ec = new EC('secp256k1');
$pubkey = $ec->recoverPubKey($hash, $sign, $recid);
$derived_address = '0x' . substr(Keccak::hash(substr(hex2bin($pubkey->encode('hex')), 1), 256), 24);
return (strtolower($address) === strtolower($derived_address));
}
public function logout(Request $request)
{
Auth::logout();
return response()->json([
'success' => true,
'message' => '๋ก๊ทธ์์ ์ฑ๊ณต'
]);
}
}
์ด ์ปจํธ๋กค๋ฌ๋ ์ธ ๊ฐ์ง ์ฃผ์ ๊ธฐ๋ฅ์ ์ ๊ณตํด:
1. getNonce() - ์ฌ์ฉ์์๊ฒ ๊ณ ์ ํ ๋
ผ์ค๋ฅผ ๋ฐ๊ธํด
2. verify() - ์ฌ์ฉ์์ ์๋ช
์ ๊ฒ์ฆํ๊ณ ๋ก๊ทธ์ธ ์ฒ๋ฆฌํด
3. logout() - ๋ก๊ทธ์์ ์ฒ๋ฆฌํด
๐ก ๋ณด์ ํ: ๋ ผ์ค(Nonce)๋ "Number used ONCE"์ ์ฝ์๋ก, ์ฌ์ ๊ณต๊ฒฉ(Replay Attack)์ ๋ฐฉ์งํ๊ธฐ ์ํด ์ฌ์ฉ๋ผ. ํ ๋ฒ ์ฌ์ฉ๋ ๋ ผ์ค๋ ์ฆ์ ๋ฌดํจํ๋์ด์ผ ํด!
๐ฏ NFT ์์ ๊ถ ๊ฒ์ฆ ์๋น์ค
์ฌ์ฉ์๊ฐ ์ค์ ๋ก NFT๋ฅผ ๋ณด์ ํ๊ณ ์๋์ง ํ์ธํ๋ ์๋น์ค๋ฅผ ๋ง๋ค์ด๋ณด์. ์ด ์๋น์ค๋ ๋ธ๋ก์ฒด์ธ์ ์ง์ ์กฐํํ๊ณ , ๊ฒฐ๊ณผ๋ฅผ ์บ์ฑํด์ ์ฑ๋ฅ์ ์ต์ ํํด.
php artisan make:service NFTVerificationService
app/Services/NFTVerificationService.php:
namespace App\Services;
use App\Models\NftOwnership;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Cache;
use Carbon\Carbon;
class NFTVerificationService
{
private $infuraUrl;
private $contractAddress;
private $contractABI;
public function __construct()
{
$this->infuraUrl = config('services.infura.url');
$this->contractAddress = config('services.nft.contract_address');
$this->contractABI = json_decode(file_get_contents(storage_path('app/contract-abi.json')), true);
}
public function verifyOwnership($userId, $walletAddress)
{
// ์บ์ ํ์ธ (5๋ถ๊ฐ ์ ํจ)
$cacheKey = "nft_ownership_{$walletAddress}";
if (Cache::has($cacheKey)) {
return Cache::get($cacheKey);
}
try {
// ๋ธ๋ก์ฒด์ธ์์ NFT ๋ณด์ ํ์ธ
$balance = $this->getBalance($walletAddress);
if ($balance > 0) {
// ํ ํฐ ID์ ๋ฑ๊ธ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ
$tokenData = $this->getTokenData($walletAddress);
// ๋ฐ์ดํฐ๋ฒ ์ด์ค์ ์ ์ฅ
$ownership = NftOwnership::updateOrCreate(
[
'user_id' => $userId,
'token_id' => $tokenData['tokenId'],
'contract_address' => $this->contractAddress
],
[
'tier' => $tokenData['tier'],
'verified_at' => Carbon::now(),
'last_checked_at' => Carbon::now()
]
);
$result = [
'hasNFT' => true,
'balance' => $balance,
'tokenId' => $tokenData['tokenId'],
'tier' => $tokenData['tier'],
'tierName' => $this->getTierName($tokenData['tier'])
];
// ์บ์์ ์ ์ฅ
Cache::put($cacheKey, $result, 300); // 5๋ถ
return $result;
}
$result = [
'hasNFT' => false,
'balance' => 0
];
Cache::put($cacheKey, $result, 300);
return $result;
} catch (\Exception $e) {
\Log::error('NFT ๊ฒ์ฆ ์ค๋ฅ: ' . $e->getMessage());
throw $e;
}
}
private function getBalance($walletAddress)
{
$data = [
'jsonrpc' => '2.0',
'method' => 'eth_call',
'params' => [
[
'to' => $this->contractAddress,
'data' => $this->encodeBalanceOf($walletAddress)
],
'latest'
],
'id' => 1
];
$response = Http::post($this->infuraUrl, $data);
$result = $response->json();
if (isset($result['result'])) {
return hexdec($result['result']);
}
return 0;
}
private function getTokenData($walletAddress)
{
// tokenOfOwnerByIndex ํธ์ถ
$tokenIdData = [
'jsonrpc' => '2.0',
'method' => 'eth_call',
'params' => [
[
'to' => $this->contractAddress,
'data' => $this->encodeTokenOfOwnerByIndex($walletAddress, 0)
],
'latest'
],
'id' => 1
];
$response = Http::post($this->infuraUrl, $tokenIdData);
$tokenId = hexdec($response->json()['result']);
// getMembershipTier ํธ์ถ
$tierData = [
'jsonrpc' => '2.0',
'method' => 'eth_call',
'params' => [
[
'to' => $this->contractAddress,
'data' => $this->encodeGetMembershipTier($tokenId)
],
'latest'
],
'id' => 1
];
$response = Http::post($this->infuraUrl, $tierData);
$tier = hexdec($response->json()['result']);
return [
'tokenId' => $tokenId,
'tier' => $tier
];
}
private function encodeBalanceOf($address)
{
$methodId = substr(Keccak::hash('balanceOf(address)', 256), 0, 8);
$paddedAddress = str_pad(substr($address, 2), 64, '0', STR_PAD_LEFT);
return '0x' . $methodId . $paddedAddress;
}
private function encodeTokenOfOwnerByIndex($address, $index)
{
$methodId = substr(Keccak::hash('tokenOfOwnerByIndex(address,uint256)', 256), 0, 8);
$paddedAddress = str_pad(substr($address, 2), 64, '0', STR_PAD_LEFT);
$paddedIndex = str_pad(dechex($index), 64, '0', STR_PAD_LEFT);
return '0x' . $methodId . $paddedAddress . $paddedIndex;
}
private function encodeGetMembershipTier($tokenId)
{
$methodId = substr(Keccak::hash('getMembershipTier(uint256)', 256), 0, 8);
$paddedTokenId = str_pad(dechex($tokenId), 64, '0', STR_PAD_LEFT);
return '0x' . $methodId . $paddedTokenId;
}
private function getTierName($tier)
{
$tiers = ['Bronze', 'Silver', 'Gold', 'Platinum'];
return $tiers[$tier] ?? 'Unknown';
}
public function clearCache($walletAddress)
{
Cache::forget("nft_ownership_{$walletAddress}");
}
}
์ด ์๋น์ค๋ Infura API๋ฅผ ํตํด ์ด๋๋ฆฌ์ ๋ธ๋ก์ฒด์ธ๊ณผ ํต์ ํด. Infura๋ ๋ธ๋ก์ฒด์ธ ๋ ธ๋๋ฅผ ์ง์ ์ด์ํ์ง ์๊ณ ๋ ๋ธ๋ก์ฒด์ธ ๋ฐ์ดํฐ์ ์ ๊ทผํ ์ ์๊ฒ ํด์ฃผ๋ ์๋น์ค์ผ. ๋ฌด๋ฃ ํ๋์ผ๋ก๋ ์ถฉ๋ถํ ์ฌ์ฉํ ์ ์์ด! ๐
๐ญ ๋ฏธ๋ค์จ์ด๋ก ์ ๊ทผ ์ ์ดํ๊ธฐ
์ด์ NFT ๋ณด์ ์ฌ๋ถ์ ๋ฐ๋ผ ์ฝํ ์ธ ์ ๊ทผ์ ์ ์ดํ๋ ๋ฏธ๋ค์จ์ด๋ฅผ ๋ง๋ค์ด๋ณด์. ์ด ๋ฏธ๋ค์จ์ด๋ ํน์ ๋ผ์ฐํธ์ ์ ๊ทผํ ๋ ์ฌ์ฉ์๊ฐ ์ ์ ํ ๋ฑ๊ธ์ NFT๋ฅผ ๋ณด์ ํ๊ณ ์๋์ง ํ์ธํด.
php artisan make:middleware CheckNFTMembership
app/Http/Middleware/CheckNFTMembership.php:
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use App\Services\NFTVerificationService;
class CheckNFTMembership
{
protected $nftService;
public function __construct(NFTVerificationService $nftService)
{
$this->nftService = $nftService;
}
public function handle(Request $request, Closure $next, $requiredTier = null)
{
if (!auth()->check()) {
return response()->json([
'error' => '๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค.'
], 401);
}
$user = auth()->user();
try {
$ownership = $this->nftService->verifyOwnership(
$user->id,
$user->wallet_address
);
if (!$ownership['hasNFT']) {
return response()->json([
'error' => 'NFT ๋ฉค๋ฒ์ญ์ด ํ์ํฉ๋๋ค.',
'message' => '์ด ์ฝํ
์ธ ์ ์ ๊ทผํ๋ ค๋ฉด ๋ฉค๋ฒ์ญ NFT๋ฅผ ๋ณด์ ํด์ผ ํฉ๋๋ค.'
], 403);
}
// ํน์ ๋ฑ๊ธ์ด ์๊ตฌ๋๋ ๊ฒฝ์ฐ
if ($requiredTier !== null) {
$tierLevels = [
'bronze' => 0,
'silver' => 1,
'gold' => 2,
'platinum' => 3
];
$requiredLevel = $tierLevels[strtolower($requiredTier)] ?? 0;
if ($ownership['tier'] < $requiredLevel) {
return response()->json([
'error' => '๋ฑ๊ธ์ด ๋ถ์กฑํฉ๋๋ค.',
'message' => "์ด ์ฝํ
์ธ ๋ {$requiredTier} ๋ฑ๊ธ ์ด์์ด ํ์ํฉ๋๋ค.",
'currentTier' => $ownership['tierName'],
'requiredTier' => ucfirst($requiredTier)
], 403);
}
}
// ์์ฒญ์ ์์ ๊ถ ์ ๋ณด ์ถ๊ฐ
$request->merge(['nft_ownership' => $ownership]);
} catch (\Exception $e) {
\Log::error('NFT ๊ฒ์ฆ ์ค ์ค๋ฅ: ' . $e->getMessage());
return response()->json([
'error' => '๊ฒ์ฆ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.'
], 500);
}
return $next($request);
}
}
๋ฏธ๋ค์จ์ด๋ฅผ app/Http/Kernel.php์ ๋ฑ๋กํ์:
protected $routeMiddleware = [
// ... ๊ธฐ์กด ๋ฏธ๋ค์จ์ด๋ค
'nft.membership' => \App\Http\Middleware\CheckNFTMembership::class,
];
์ด์ ๋ผ์ฐํธ์์ ์ด๋ ๊ฒ ์ฌ์ฉํ ์ ์์ด:
// ๊ธฐ๋ณธ ๋ฉค๋ฒ์ญ๋ง ํ์
Route::get('/premium-content', [ContentController::class, 'premium'])
->middleware(['auth', 'nft.membership']);
// Gold ๋ฑ๊ธ ์ด์ ํ์
Route::get('/exclusive-content', [ContentController::class, 'exclusive'])
->middleware(['auth', 'nft.membership:gold']);
// Platinum ๋ฑ๊ธ๋ง ์ ๊ทผ ๊ฐ๋ฅ
Route::get('/vip-content', [ContentController::class, 'vip'])
->middleware(['auth', 'nft.membership:platinum']);
๐ฏ ๋ฏธ๋ค์จ์ด ํ์ฉ ์๋๋ฆฌ์ค
โข Bronze - ๊ธฐ๋ณธ ์ฝํ
์ธ , ์ปค๋ฎค๋ํฐ ํฌ๋ผ ์ ๊ทผ
โข Silver - ํ๋ฆฌ๋ฏธ์ ์ํฐํด, ์๊ฐ ์จ๋น๋ ์ฐธ์ฌ
โข Gold - ๋
์ ํํ ๋ฆฌ์ผ, 1:1 ๋ฉํ ๋ง ์ ์ฒญ
โข Platinum - VIP ์ด๋ฒคํธ, ์กฐ๊ธฐ ์ก์ธ์ค, ํน๋ณ ํํ
๐จ ํ๋ก ํธ์๋ UI ๊ตฌํํ๊ธฐ
์ด์ ์ฌ์ฉ์๊ฐ ์ค์ ๋ก ์ํธ์์ฉํ ํ๋ก ํธ์๋ ์ธํฐํ์ด์ค๋ฅผ ๋ง๋ค์ด๋ณด์. Vue.js๋ฅผ ์ฌ์ฉํด์ ๋ฐ์ํ UI๋ฅผ ๊ตฌ์ถํ ๊ฑฐ์ผ.
๐ผ๏ธ ์ง๊ฐ ์ฐ๊ฒฐ ์ปดํฌ๋ํธ
resources/js/components/WalletConnect.vue ํ์ผ์ ์์ฑํ์:
<template>
<div class="wallet-connect">
<div v-if="!connected" class="connect-section">
<button @click="connectWallet" class="connect-button">
๐ฆ ๋ฉํ๋ง์คํฌ ์ฐ๊ฒฐํ๊ธฐ
</button>
<p class="help-text">
NFT ๋ฉค๋ฒ์ญ์ ํ์ธํ๋ ค๋ฉด ์ง๊ฐ์ ์ฐ๊ฒฐํด์ฃผ์ธ์
</p>
</div>
<div v-else class="connected-section">
<div class="wallet-info">
<div class="address">
<span class="label">์ฐ๊ฒฐ๋ ์ง๊ฐ:</span>
<span class="value">{{ shortenAddress(account) }}</span>
</div>
<div v-if="membership" class="membership-info">
<div class="tier-badge" :class="membership.tierName.toLowerCase()">
{{ getTierEmoji(membership.tierName) }} {{ membership.tierName }}
</div>
<div class="token-id">
Token ID: #{{ membership.tokenId }}
</div>
</div>
<div v-else class="no-membership">
<p>๐ข ๋ฉค๋ฒ์ญ NFT๋ฅผ ๋ณด์ ํ๊ณ ์์ง ์์ต๋๋ค</p>
<button @click="goToMint" class="mint-button">
NFT ๊ตฌ๋งคํ๊ธฐ
</button>
</div>
</div>
<button @click="disconnect" class="disconnect-button">
์ฐ๊ฒฐ ํด์
</button>
</div>
<div v-if="loading" class="loading-overlay">
<div class="spinner"></div>
<p>{{ loadingMessage }}</p>
</div>
<div v-if="error" class="error-message">
โ ๏ธ {{ error }}
</div>
</div>
</template>
<script>
import web3Connector from '../web3-connector';
import axios from 'axios';
export default {
name: 'WalletConnect',
data() {
return {
connected: false,
account: null,
membership: null,
loading: false,
loadingMessage: '',
error: null
};
},
methods: {
async connectWallet() {
this.loading = true;
this.loadingMessage = '์ง๊ฐ ์ฐ๊ฒฐ ์ค...';
this.error = null;
try {
// ๋ฉํ๋ง์คํฌ ์ฐ๊ฒฐ
const result = await web3Connector.connect();
if (!result.success) {
throw new Error(result.error);
}
this.account = result.account;
this.connected = true;
// ๋
ผ์ค ์์ฒญ
this.loadingMessage = '์ธ์ฆ ์ค๋น ์ค...';
const nonceResponse = await axios.post('/api/auth/nonce', {
wallet_address: this.account
});
// ๋ฉ์์ง ์๋ช
this.loadingMessage = '์๋ช
์์ฒญ ์ค...';
const signature = await web3Connector.signMessage(
nonceResponse.data.message
);
// ์๋ช
๊ฒ์ฆ ๋ฐ ๋ก๊ทธ์ธ
this.loadingMessage = '๋ก๊ทธ์ธ ์ฒ๋ฆฌ ์ค...';
const verifyResponse = await axios.post('/api/auth/verify', {
wallet_address: this.account,
signature: signature
});
if (verifyResponse.data.success) {
// NFT ์์ ๊ถ ํ์ธ
this.loadingMessage = 'NFT ํ์ธ ์ค...';
await this.checkMembership();
this.$emit('connected', {
account: this.account,
membership: this.membership
});
}
} catch (error) {
console.error('์ฐ๊ฒฐ ์คํจ:', error);
this.error = error.message || '์ง๊ฐ ์ฐ๊ฒฐ์ ์คํจํ์ต๋๋ค.';
this.connected = false;
} finally {
this.loading = false;
}
},
async checkMembership() {
try {
const response = await axios.get('/api/membership/check');
if (response.data.hasNFT) {
this.membership = response.data;
} else {
this.membership = null;
}
} catch (error) {
console.error('๋ฉค๋ฒ์ญ ํ์ธ ์คํจ:', error);
}
},
disconnect() {
web3Connector.disconnect();
this.connected = false;
this.account = null;
this.membership = null;
axios.post('/api/auth/logout');
this.$emit('disconnected');
},
shortenAddress(address) {
if (!address) return '';
return `${address.substring(0, 6)}...${address.substring(38)}`;
},
getTierEmoji(tier) {
const emojis = {
'Bronze': '๐ฅ',
'Silver': '๐ฅ',
'Gold': '๐ฅ',
'Platinum': '๐'
};
return emojis[tier] || '๐ซ';
},
goToMint() {
this.$router.push('/mint');
}
},
mounted() {
// ํ์ด์ง ๋ก๋ ์ ์ฐ๊ฒฐ ์ํ ํ์ธ
if (window.ethereum && window.ethereum.selectedAddress) {
this.account = window.ethereum.selectedAddress;
this.connected = true;
this.checkMembership();
}
}
};
</script>
<style scoped>
.wallet-connect {
max-width: 500px;
margin: 0 auto;
padding: 20px;
}
.connect-button {
width: 100%;
padding: 16px 24px;
font-size: 18px;
font-weight: 600;
color: white;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border: none;
border-radius: 12px;
cursor: pointer;
transition: transform 0.2s;
}
.connect-button:hover {
transform: translateY(-2px);
}
.help-text {
text-align: center;
color: #666;
margin-top: 12px;
font-size: 14px;
}
.connected-section {
background: white;
border-radius: 16px;
padding: 24px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.wallet-info {
margin-bottom: 20px;
}
.address {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px;
background: #f5f5f5;
border-radius: 8px;
margin-bottom: 16px;
}
.label {
font-weight: 600;
color: #333;
}
.value {
font-family: monospace;
color: #667eea;
}
.membership-info {
text-align: center;
padding: 20px;
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
border-radius: 12px;
}
.tier-badge {
display: inline-block;
padding: 8px 20px;
border-radius: 20px;
font-weight: 700;
font-size: 18px;
margin-bottom: 8px;
}
.tier-badge.bronze { background: #cd7f32; color: white; }
.tier-badge.silver { background: #c0c0c0; color: #333; }
.tier-badge.gold { background: #ffd700; color: #333; }
.tier-badge.platinum { background: linear-gradient(135deg, #e5e4e2 0%, #b9b9b9 100%); color: #333; }
.token-id {
color: #666;
font-size: 14px;
margin-top: 8px;
}
.no-membership {
text-align: center;
padding: 20px;
}
.mint-button {
padding: 12px 24px;
background: #66bb6a;
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
margin-top: 12px;
}
.disconnect-button {
width: 100%;
padding: 12px;
background: #f5f5f5;
border: 1px solid #ddd;
border-radius: 8px;
cursor: pointer;
font-weight: 600;
color: #666;
}
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.7);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
}
.spinner {
width: 50px;
height: 50px;
border: 4px solid #f3f3f3;
border-top: 4px solid #667eea;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-overlay p {
color: white;
margin-top: 20px;
font-size: 16px;
}
.error-message {
background: #ffebee;
color: #c62828;
padding: 12px;
border-radius: 8px;
margin-top: 12px;
text-align: center;
}
</style>
์ด ์ปดํฌ๋ํธ๋ ์ง๊ฐ ์ฐ๊ฒฐ๋ถํฐ ๋ฉค๋ฒ์ญ ํ์ธ๊น์ง ์ ์ฒด ํ๋ก์ธ์ค๋ฅผ ์ฒ๋ฆฌํด. ์ฌ์ฉ์ ๊ฒฝํ์ ์ํด ๋ก๋ฉ ์ํ, ์๋ฌ ์ฒ๋ฆฌ, ์๊ฐ์ ํผ๋๋ฐฑ ๋ฑ์ ๋ชจ๋ ํฌํจํ๊ณ ์์ด. ๐จ
๐ฅ ์ค์ ํ์ฉ ์๋๋ฆฌ์ค
์ด์ ์ค์ ๋ก NFT ๋ฉค๋ฒ์ญ ์์คํ ์ ์ด๋ป๊ฒ ํ์ฉํ ์ ์๋์ง ๊ตฌ์ฒด์ ์ธ ์๋๋ฆฌ์ค๋ฅผ ์ดํด๋ณด์.
๐ ์จ๋ผ์ธ ๊ต์ก ํ๋ซํผ
์๋๋ฆฌ์ค: ํ๋ก๊ทธ๋๋ฐ ๊ฐ์๋ฅผ ์ ๊ณตํ๋ ์จ๋ผ์ธ ๊ต์ก ํ๋ซํผ
Bronze ๋ฉค๋ฒ์ญ (๊ธฐ๋ณธ)
โข ๋ฌด๋ฃ ๊ฐ์ ์์ฒญ
โข ์ปค๋ฎค๋ํฐ ํฌ๋ผ ์ฐธ์ฌ
โข ์ 1ํ Q&A ์ธ์
์ฐธ์ฌ
Silver ๋ฉค๋ฒ์ญ
โข ๋ชจ๋ ํ๋ฆฌ๋ฏธ์ ๊ฐ์ ๋ฌด์ ํ ์์ฒญ
โข ์ค์ต ํ๋ก์ ํธ ์์ค์ฝ๋ ๋ค์ด๋ก๋
โข ๊ฐ์ฌ์๊ฒ ์ง๋ฌธํ๊ธฐ (์ฃผ 3ํ)
Gold ๋ฉค๋ฒ์ญ
โข Silver ํํ ์ ๋ถ
โข 1:1 ์ฝ๋ ๋ฆฌ๋ทฐ (์ 2ํ)
โข ์ทจ์
ํฌํธํด๋ฆฌ์ค ์ฒจ์ญ
โข ๋
์ ์จ๋น๋ ์ฐธ์ฌ
Platinum ๋ฉค๋ฒ์ญ
โข Gold ํํ ์ ๋ถ
โข ๊ฐ์ธ ๋ฉํ ๋ง (์ 4์๊ฐ)
โข ๊ธฐ์
ํ๋ก์ ํธ ์ฐธ์ฌ ๊ธฐํ
โข ํ์ ์
๋ฐ์ดํธ ๋ณด์ฅ
์ด๋ฐ ์์ผ๋ก ๋ฑ๊ธ๋ณ๋ก ์ฐจ๋ณํ๋ ํํ์ ์ ๊ณตํ๋ฉด, ์ฌ์ฉ์๋ค์ ์์ ์๊ฒ ๋ง๋ ๋ฑ๊ธ์ ์ ํํ ์ ์์ด. ๊ทธ๋ฆฌ๊ณ NFT์ด๊ธฐ ๋๋ฌธ์ ๋์ค์ ๋ค๋ฅธ ์ฌ๋์๊ฒ ํ๋งคํ๊ฑฐ๋ ์๋ํ ์๋ ์์ง! ๐ฐ
๐ฎ ๊ฒ์ด๋ฐ ์ปค๋ฎค๋ํฐ
์๋๋ฆฌ์ค: ๊ฒ์ ๊ธธ๋ ๋ฐ ์ปค๋ฎค๋ํฐ ํ๋ซํผ
NFT ๋ฉค๋ฒ์ญ์ ๋ณด์ ํ ์ ์ ๋ง ๊ธธ๋์ ๊ฐ์
ํ ์ ์๊ณ , ๋ฑ๊ธ์ ๋ฐ๋ผ ๋ค์๊ณผ ๊ฐ์ ํํ์ ์ ๊ณต:
โข ๊ฒ์ ๋ด ์์ดํ
์์ด๋๋
โข ํ ๋๋จผํธ ์ฐธ๊ฐ ์๊ฒฉ
โข ๋
์ ๊ฒ์ ๋ฒ ํ ํ
์คํธ
โข ๊ธธ๋ ์์ต ๋ฐฐ๋ถ
โข ๊ฑฐ๋ฒ๋์ค ํฌํ๊ถ
๐จ ํฌ๋ฆฌ์์ดํฐ ์ปค๋ฎค๋ํฐ
์๋๋ฆฌ์ค: ์ํฐ์คํธ๋ ํฌ๋ฆฌ์์ดํฐ์ ํฌ ์ปค๋ฎค๋ํฐ
NFT ๋ฉค๋ฒ์ญ ๋ณด์ ์์๊ฒ ๋ค์๊ณผ ๊ฐ์ ํน๋ณ ํํ ์ ๊ณต:
โข ์ ์ ์กฐ๊ธฐ ๊ณต๊ฐ
โข ๋นํ์ธ๋ ์ฌ ์ฝํ
์ธ
โข ํฌ๋ฆฌ์์ดํฐ์์ ์ง์ ์ํต
โข ํ์ ํ ๊ตฟ์ฆ ๊ตฌ๋งค๊ถ
โข ์คํ๋ผ์ธ ํฌ๋ฏธํ
์ฐ์ ์์ฝ
์ฌ๋ฅ๋ท ๊ฐ์ ์ฌ๋ฅ ๊ณต์ ํ๋ซํผ์์๋ ์ด๋ฐ NFT ๋ฉค๋ฒ์ญ ์์คํ ์ ๋์ ํ๋ฉด ์ ๋ง ์ฌ๋ฏธ์์ ๊ฒ ๊ฐ์. ์๋ฅผ ๋ค์ด, ํน์ ๋ถ์ผ์ ์ ๋ฌธ๊ฐ๊ฐ ์์ ๋ง์ NFT ๋ฉค๋ฒ์ญ์ ๋ฐํํ๊ณ , ๊ทธ NFT๋ฅผ ๋ณด์ ํ ์ฌ๋๋ค์๊ฒ๋ง ํ๋ฆฌ๋ฏธ์ ๊ฐ์๋ 1:1 ์ปจ์คํ ์ ์ ๊ณตํ๋ ๊ฑฐ์ง. ๐ฏ
โก ์ฑ๋ฅ ์ต์ ํ ์ ๋ต
๋ธ๋ก์ฒด์ธ ์กฐํ๋ ์๊ฐ์ด ๊ฑธ๋ฆฌ๊ณ ๋น์ฉ์ด ๋ฐ์ํ ์ ์์ด. ๋ฐ๋ผ์ ์ฑ๋ฅ ์ต์ ํ๊ฐ ๋งค์ฐ ์ค์ํด. ๋ช ๊ฐ์ง ํต์ฌ ์ ๋ต์ ์ดํด๋ณด์.
๐๏ธ ์บ์ฑ ์ ๋ต
NFT ์์ ๊ถ ์ ๋ณด๋ ์์ฃผ ๋ณํ์ง ์๊ธฐ ๋๋ฌธ์ ์ ๊ทน์ ์ผ๋ก ์บ์ฑํด์ผ ํด. ๋ผ๋ผ๋ฒจ์ ์บ์ ์์คํ ์ ํ์ฉํ๋ฉด ์ฝ๊ฒ ๊ตฌํํ ์ ์์ด:
// Redis ์บ์ ์ค์ (.env)
CACHE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
// ์บ์ ์ฌ์ฉ ์์
$ownership = Cache::remember("nft_ownership_{$walletAddress}", 300, function() use ($walletAddress) {
return $this->nftService->verifyOwnership($userId, $walletAddress);
});
๐ก ์บ์ฑ ํ:
โข ์ผ๋ฐ ์กฐํ: 5๋ถ ์บ์
โข ์ค์ํ ๊ถํ ํ์ธ: 1๋ถ ์บ์
โข NFT ์ ์ก ํ: ์ฆ์ ์บ์ ๋ฌดํจํ
โข ์ฌ์ฉ์๊ฐ ์๋์ผ๋ก ์๋ก๊ณ ์นจ ์์ฒญ ์: ์บ์ ๋ฌดํจํ
๐ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ธ๋ฑ์ฑ
์์ฃผ ์กฐํ๋๋ ์ปฌ๋ผ์๋ ๋ฐ๋์ ์ธ๋ฑ์ค๋ฅผ ์ถ๊ฐํด์ผ ํด:
Schema::table('nft_ownerships', function (Blueprint $table) {
$table->index('wallet_address');
$table->index(['user_id', 'tier']);
$table->index('last_checked_at');
});
๐ ๋ฐฑ๊ทธ๋ผ์ด๋ ๋๊ธฐํ
์ค์๊ฐ์ผ๋ก ๋ธ๋ก์ฒด์ธ์ ์กฐํํ๋ ๋์ , ๋ฐฑ๊ทธ๋ผ์ด๋ ์์ ์ผ๋ก ์ฃผ๊ธฐ์ ์ผ๋ก ๋๊ธฐํํ๋ ๋ฐฉ๋ฒ๋ ์์ด:
php artisan make:job SyncNFTOwnerships
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use App\Models\User;
use App\Services\NFTVerificationService;
class SyncNFTOwnerships implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle(NFTVerificationService $nftService)
{
// ์ต๊ทผ 24์๊ฐ ๋ด ํ๋ํ ์ฌ์ฉ์๋ค์ NFT ์์ ๊ถ ๋๊ธฐํ
$users = User::where('last_login_at', '>', now()->subDay())
->get();
foreach ($users as $user) {
try {
$nftService->verifyOwnership($user->id, $user->wallet_address);
sleep(1); // API ๋ ์ดํธ ๋ฆฌ๋ฐ ๊ณ ๋ ค
} catch (\Exception $e) {
\Log::error("NFT ๋๊ธฐํ ์คํจ - User {$user->id}: " . $e->getMessage());
}
}
}
}
์ด ์์ ์ ์ค์ผ์ค๋ฌ์ ๋ฑ๋กํ๋ฉด ์๋์ผ๋ก ์คํ๋ผ:
// app/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->job(new SyncNFTOwnerships)
->hourly()
->withoutOverlapping();
}
๐ ๋ณด์ ๊ณ ๋ ค์ฌํญ
๋ธ๋ก์ฒด์ธ ๊ธฐ๋ฐ ์์คํ ์์ ๋ณด์์ ์ ๋์ ์ผ๋ก ์ค์ํด. ๋ช ๊ฐ์ง ํต์ฌ ๋ณด์ ์ฌํญ์ ์ง์ด๋ณด์.
๐ก๏ธ ์๋ช ๊ฒ์ฆ์ ์ค์์ฑ
์ฌ์ฉ์๊ฐ ์ ์ถํ ์๋ช ์ ๋ฐ๋์ ์๋ฒ์์ ๊ฒ์ฆํด์ผ ํด. ํด๋ผ์ด์ธํธ ์ธก ๊ฒ์ฆ๋ง์ผ๋ก๋ ์ถฉ๋ถํ์ง ์์:
โ ๏ธ ๋ณด์ ์ฒดํฌ๋ฆฌ์คํธ
โ
๋
ผ์ค๋ ํ ๋ฒ๋ง ์ฌ์ฉํ๊ณ ์ฆ์ ๋ฌดํจํ
โ
์๋ช
๊ฒ์ฆ์ ๋ฐ๋์ ์๋ฒ์์ ์ํ
โ
ํ์์คํฌํ๋ฅผ ํฌํจํด์ ์ฌ์ ๊ณต๊ฒฉ ๋ฐฉ์ง
โ
HTTPS ํ์ ์ฌ์ฉ
โ
API ๋ ์ดํธ ๋ฆฌ๋ฐ ์ค์
โ
๋ฏผ๊ฐํ ์ ๋ณด๋ ํ๊ฒฝ ๋ณ์๋ก ๊ด๋ฆฌ
โ
์ค๋งํธ ์ปจํธ๋ํธ ๊ฐ์ฌ ๋ฐ๊ธฐ
๐ ํ๊ฒฝ ๋ณ์ ๊ด๋ฆฌ
์ค์ํ ์ค์ ๊ฐ๋ค์ .env ํ์ผ์ ์์ ํ๊ฒ ๋ณด๊ดํด:
# .env
INFURA_PROJECT_ID=your_infura_project_id
INFURA_PROJECT_SECRET=your_infura_secret
NFT_CONTRACT_ADDRESS=0x...
ETHEREUM_NETWORK=mainnet # ๋๋ goerli, sepolia ๋ฑ
# ์ ๋ Git์ ์ปค๋ฐํ์ง ๋ง ๊ฒ!
# .gitignore์ .env ์ถ๊ฐ ํ์ธ
๐จ ์๋ฌ ์ฒ๋ฆฌ
๋ธ๋ก์ฒด์ธ ํต์ ์ ์คํจํ ์ ์์ด. ์ ์ ํ ์๋ฌ ์ฒ๋ฆฌ๊ฐ ํ์์ผ:
try {
$ownership = $this->nftService->verifyOwnership($userId, $walletAddress);
} catch (ConnectionException $e) {
// ๋คํธ์ํฌ ์ฐ๊ฒฐ ์คํจ
Log::error('๋ธ๋ก์ฒด์ธ ์ฐ๊ฒฐ ์คํจ: ' . $e->getMessage());
return response()->json([
'error' => '์ผ์์ ์ธ ๋คํธ์ํฌ ์ค๋ฅ์
๋๋ค. ์ ์ ํ ๋ค์ ์๋ํด์ฃผ์ธ์.'
], 503);
} catch (ContractException $e) {
// ์ปจํธ๋ํธ ํธ์ถ ์คํจ
Log::error('์ปจํธ๋ํธ ์ค๋ฅ: ' . $e->getMessage());
return response()->json([
'error' => '์ค๋งํธ ์ปจํธ๋ํธ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค.'
], 500);
} catch (\Exception $e) {
// ๊ธฐํ ์์ธ
Log::error('์ ์ ์๋ ์ค๋ฅ: ' . $e->getMessage());
return response()->json([
'error' => '์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๊ด๋ฆฌ์์๊ฒ ๋ฌธ์ํด์ฃผ์ธ์.'
], 500);
}
๐ ๋ฐฐํฌ ๋ฐ ์ด์
๊ฐ๋ฐ์ด ์๋ฃ๋๋ฉด ์ค์ ์๋น์ค๋ฅผ ๋ฐฐํฌํ๊ณ ์ด์ํด์ผ ํด. ๋ช ๊ฐ์ง ์ค์ํ ํฌ์ธํธ๋ฅผ ์ดํด๋ณด์.
๐ ํ ์คํธ๋ท ๋ฐฐํฌ
๋ฉ์ธ๋ท์ ๋ฐ๋ก ๋ฐฐํฌํ๊ธฐ ์ ์ ๋ฐ๋์ ํ ์คํธ๋ท์์ ์ถฉ๋ถํ ํ ์คํธํด์ผ ํด. Goerli๋ Sepolia ํ ์คํธ๋ท์ ์ถ์ฒํด:
ํ ์คํธ๋ท ๋ฐฐํฌ ๋จ๊ณ
1๋จ๊ณ: ํ
์คํธ๋ท ETH ๋ฐ๊ธฐ
Goerli Faucet์์ ๋ฌด๋ฃ ํ
์คํธ ETH๋ฅผ ๋ฐ์
2๋จ๊ณ: ์ค๋งํธ ์ปจํธ๋ํธ ๋ฐฐํฌ
Hardhat์ด๋ Truffle์ ์ฌ์ฉํด์ ํ
์คํธ๋ท์ ์ปจํธ๋ํธ ๋ฐฐํฌ
3๋จ๊ณ: ๋ผ๋ผ๋ฒจ ์ค์ ์
๋ฐ์ดํธ
.env ํ์ผ์ ํ
์คํธ๋ท ์ค์ ์
๋ ฅ
4๋จ๊ณ: ํตํฉ ํ
์คํธ
์ค์ ์ฌ์ฉ์ ์๋๋ฆฌ์ค๋๋ก ์ ์ฒด ํ๋ก์ฐ ํ
์คํธ
5๋จ๊ณ: ๋ฒ๊ทธ ์์ ๋ฐ ์ต์ ํ
๋ฐ๊ฒฌ๋ ๋ฌธ์ ๋ค ํด๊ฒฐ
๐ ๋ชจ๋ํฐ๋ง ์ค์
์ด์ ์ค์๋ ์์คํ ์ํ๋ฅผ ์ง์์ ์ผ๋ก ๋ชจ๋ํฐ๋งํด์ผ ํด:
// ๋ชจ๋ํฐ๋ง ๋์๋ณด๋ ๋ผ์ฐํธ
Route::get('/admin/monitoring', function() {
return view('admin.monitoring', [
'totalUsers' => User::count(),
'nftHolders' => NftOwnership::distinct('user_id')->count(),
'tierDistribution' => NftOwnership::select('tier', DB::raw('count(*) as count'))
->groupBy('tier')
->get(),
'recentVerifications' => NftOwnership::orderBy('last_checked_at', 'desc')
->limit(10)
->get(),
'cacheHitRate' => Cache::get('cache_hit_rate', 0),
'apiResponseTime' => Cache::get('avg_api_response_time', 0)
]);
})->middleware(['auth', 'admin']);
๐พ ๋ฐฑ์ ์ ๋ต
๋ฐ์ดํฐ๋ฒ ์ด์ค๋ ์ ๊ธฐ์ ์ผ๋ก ๋ฐฑ์ ํด์ผ ํด:
// ์๋ ๋ฐฑ์
์ค์ผ์ค
protected function schedule(Schedule $schedule)
{
// ๋งค์ผ ์๋ฒฝ 3์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ฐฑ์
$schedule->command('backup:run')
->daily()
->at('03:00');
// ๋งค์ฃผ ์ผ์์ผ ์ ์ฒด ์์คํ
๋ฐฑ์
$schedule->command('backup:run --only-db')
->weekly()
->sundays()
->at('02:00');
}
๐ฏ ๊ณ ๊ธ ๊ธฐ๋ฅ ๊ตฌํ
๊ธฐ๋ณธ ๊ธฐ๋ฅ์ ๋์ด์ ๋ ๊ณ ๊ธ์ค๋ฌ์ด ๊ธฐ๋ฅ๋ค์ ์ถ๊ฐํด๋ณด์.
๐ ์์ด๋๋ ์์คํ
๋ฉค๋ฒ์ญ ๋ณด์ ์๋ค์๊ฒ ํน๋ณ ํํ์ด๋ ํ ํฐ์ ์์ด๋๋ํ๋ ๊ธฐ๋ฅ:
php artisan make:command AirdropRewards
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\NftOwnership;
use App\Services\Web3Service;
class AirdropRewards extends Command
{
protected $signature = 'airdrop:rewards {tier?}';
protected $description = '๋ฉค๋ฒ์ญ ๋ณด์ ์์๊ฒ ๋ฆฌ์๋ ์์ด๋๋';
public function handle(Web3Service $web3Service)
{
$tier = $this->argument('tier');
$query = NftOwnership::with('user');
if ($tier) {
$query->where('tier', $tier);
}
$ownerships = $query->get();
$this->info("์ด {$ownerships->count()}๋ช
์๊ฒ ์์ด๋๋์ ์์ํฉ๋๋ค...");
$bar = $this->output->createProgressBar($ownerships->count());
foreach ($ownerships as $ownership) {
try {
// ์์ด๋๋ ๋ก์ง (์: ํ ํฐ ์ ์ก, ์ฟ ํฐ ๋ฐ๊ธ ๋ฑ)
$this->processAirdrop($ownership);
$bar->advance();
} catch (\Exception $e) {
$this->error("์คํจ: {$ownership->user->wallet_address} - {$e->getMessage()}");
}
}
$bar->finish();
$this->info("\n์์ด๋๋ ์๋ฃ!");
}
private function processAirdrop($ownership)
{
// ์ค์ ์์ด๋๋ ์ฒ๋ฆฌ ๋ก์ง
// ์: ์ฟ ํฐ ์ฝ๋ ์์ฑ, ์ด๋ฉ์ผ ๋ฐ์ก, ํ ํฐ ์ ์ก ๋ฑ
}
}
๐ ๋ ๋ฒจ ์ ๊ทธ๋ ์ด๋ ์์คํ
์ฌ์ฉ์๊ฐ ํ๋์ ๋ฐ๋ผ ๋ฉค๋ฒ์ญ ๋ฑ๊ธ์ ์ ๊ทธ๋ ์ด๋ํ ์ ์๋ ์์คํ :
class MembershipUpgradeService
{
public function checkUpgradeEligibility($userId)
{
$user = User::with('nftOwnership')->find($userId);
if (!$user->nftOwnership) {
return ['eligible' => false, 'reason' => 'NFT ๋ฏธ๋ณด์ '];
}
$currentTier = $user->nftOwnership->tier;
$nextTier = $currentTier + 1;
if ($nextTier > 3) {
return ['eligible' => false, 'reason' => '์ต๊ณ ๋ฑ๊ธ'];
}
// ์
๊ทธ๋ ์ด๋ ์กฐ๊ฑด ํ์ธ
$conditions = $this->getUpgradeConditions($nextTier);
$userStats = $this->getUserStats($userId);
$eligible = true;
$missingConditions = [];
foreach ($conditions as $key => $required) {
if ($userStats[$key] < $required) {
$eligible = false;
$missingConditions[$key] = [
'required' => $required,
'current' => $userStats[$key]
];
}
}
return [
'eligible' => $eligible,
'currentTier' => $this->getTierName($currentTier),
'nextTier' => $this->getTierName($nextTier),
'conditions' => $conditions,
'userStats' => $userStats,
'missingConditions' => $missingConditions
];
}
private function getUpgradeConditions($tier)
{
$conditions = [
1 => [ // Bronze -> Silver
'days_active' => 30,
'content_consumed' => 10,
'community_posts' => 5
],
2 => [ // Silver -> Gold
'days_active' => 90,
'content_consumed' => 50,
'community_posts' => 20,
'referrals' => 3
],
3 => [ // Gold -> Platinum
'days_active' => 180,
'content_consumed' => 100,
'community_posts' => 50,
'referrals' => 10,
'contribution_score' => 1000
]
];
return $conditions[$tier] ?? [];
}
private function getUserStats($userId)
{
// ์ฌ์ฉ์ ํ๋ ํต๊ณ ๊ณ์ฐ
return [
'days_active' => $this->calculateActiveDays($userId),
'content_consumed' => $this->countContentConsumed($userId),
'community_posts' => $this->countCommunityPosts($userId),
'referrals' => $this->countReferrals($userId),
'contribution_score' => $this->calculateContributionScore($userId)
];
}
}
๐จ ๋์ NFT ๋ฉํ๋ฐ์ดํฐ
์ฌ์ฉ์์ ํ๋์ ๋ฐ๋ผ NFT์ ์ธ๊ด์ด๋ ์์ฑ์ด ๋ณํ๋ ๋์ NFT ๊ตฌํ:
Route::get('/api/nft/metadata/{tokenId}', function($tokenId) {
$ownership = NftOwnership::where('token_id', $tokenId)->first();
if (!$ownership) {
return response()->json(['error' => 'Token not found'], 404);
}
$user = $ownership->user;
$stats = app(MembershipUpgradeService::class)->getUserStats($user->id);
// ํ๋ ๋ ๋ฒจ์ ๋ฐ๋ฅธ ์ด๋ฏธ์ง ์ ํ
$imageLevel = $this->calculateImageLevel($stats);
return response()->json([
'name' => "Membership NFT #{$tokenId}",
'description' => "์ฌ๋ฅ๋ท {$ownership->tierName} ๋ฉค๋ฒ์ญ",
'image' => "https://yourdomain.com/nft-images/{$ownership->tier}-{$imageLevel}.png",
'attributes' => [
[
'trait_type' => 'Tier',
'value' => $ownership->tierName
],
[
'trait_type' => 'Active Days',
'value' => $stats['days_active']
],
[
'trait_type' => 'Content Consumed',
'value' => $stats['content_consumed']
],
[
'trait_type' => 'Community Contribution',
'value' => $stats['contribution_score']
],
[
'trait_type' => 'Level',
'value' => $imageLevel,
'max_value' => 10
]
],
'properties' => [
'tier_level' => $ownership->tier,
'issued_date' => $ownership->created_at->toIso8601String(),
'last_updated' => $ownership->updated_at->toIso8601String()
]
]);
});
๐ ์ค์ ์ฌ๋ก์ ๋ฒ ์คํธ ํ๋ํฐ์ค
์ด๋ก ์ ๋์ด์ ์ค์ ๋ก ์ฑ๊ณตํ NFT ๋ฉค๋ฒ์ญ ํ๋ก์ ํธ๋ค์ ์ฌ๋ก๋ฅผ ์ดํด๋ณด๊ณ , ๊ฑฐ๊ธฐ์ ๋ฐฐ์ธ ์ ์ ์ฐพ์๋ณด์.
๐ ์ฑ๊ณต ์ฌ๋ก ๋ถ์
๐ฏ Bored Ape Yacht Club (BAYC)
๊ฐ์ฅ ์ฑ๊ณต์ ์ธ NFT ๋ฉค๋ฒ์ญ ๋ชจ๋ธ ์ค ํ๋. NFT ๋ณด์ ์๋ค์๊ฒ ๋
์ ์ด๋ฒคํธ, ์ํ, ์ถ๊ฐ NFT ์์ด๋๋ ๋ฑ์ ์ ๊ณตํด. ํต์ฌ์ ๊ฐ๋ ฅํ ์ปค๋ฎค๋ํฐ์ ์ง์์ ์ธ ๊ฐ์น ์ ๊ณต์ด์ผ.
๋ฐฐ์ธ ์ :
โข ๋จ์ํ ๋์งํธ ์์ฐ์ด ์๋ '๋ฉค๋ฒ์ญ'์ผ๋ก ํฌ์ง์
๋
โข ์ ๊ธฐ์ ์ธ ํํ๊ณผ ์ด๋ฒคํธ๋ก ๋ณด์ ๊ฐ์น ์ ์ง
โข ์ปค๋ฎค๋ํฐ ์ค์ฌ์ ์ด์
โข ๋ก๋๋งต์ ๊ณต๊ฐํ๊ณ ์ฝ์ ์ดํ
๐ฎ Axie Infinity
๊ฒ์๊ณผ NFT๋ฅผ ๊ฒฐํฉํ ๋ชจ๋ธ. NFT๊ฐ ๊ฒ์ ํ๋ ์ด์ ํ์ ์์์ด๋ฉด์ ๋์์ ์์ฐ ๊ฐ์น๋ฅผ ๊ฐ์ ธ. Play-to-Earn ๋ชจ๋ธ์ ์ ๊ตฌ์์ผ.
๋ฐฐ์ธ ์ :
โข NFT์ ์ค์ง์ ์ธ ์ ํธ๋ฆฌํฐ ๋ถ์ฌ
โข ๊ฒฝ์ ์ํ๊ณ ์ค๊ณ์ ์ค์์ฑ
โข ์ฌ์ฉ์๊ฐ ์์ต์ ์ฐฝ์ถํ ์ ์๋ ๊ตฌ์กฐ
โข ์ง์ ๊ฐ๋ฅํ ํ ํฌ๋
ธ๋ฏน์ค
๐ก ๋ฒ ์คํธ ํ๋ํฐ์ค
1. ๋ช
ํํ ๊ฐ์น ์ ์
NFT๋ฅผ ๊ตฌ๋งคํ๋ฉด ์ ํํ ์ด๋ค ํํ์ ๋ฐ๋์ง ๋ช
ํํ๊ฒ ์ ์ํด์ผ ํด. ๋ชจํธํ ์ฝ์์ ์ ๋ขฐ๋ฅผ ๋จ์ด๋จ๋ ค.
2. ๊ณต์ ํ ๋ฐํ ๋ฐฉ์
ํ์ดํธ๋ฆฌ์คํธ, ํผ๋ธ๋ฆญ ์ธ์ผ ๋ฑ ๊ณต์ ํ ๋ฐฉ์์ผ๋ก NFT๋ฅผ ๋ฐํํด. ๋ด๋ถ์ ๊ฑฐ๋๋ ๋ถ๊ณต์ ํ ๋ฐฉ์์ ์ปค๋ฎค๋ํฐ์ ์ ๋ขฐ๋ฅผ ์๊ฒ ๋ง๋ค์ด.
3. ์ง์์ ์ธ ๊ฐ์น ์ ๊ณต
ํ ๋ฒ ํ๋งคํ๊ณ ๋์ด ์๋๋ผ, ์ง์์ ์ผ๋ก ์๋ก์ด ํํ๊ณผ ์ฝํ
์ธ ๋ฅผ ์ ๊ณตํด์ผ ํด. ์ด๊ฒ ์ฅ๊ธฐ์ ์ธ ์ฑ๊ณต์ ์ด์ ์ผ.
4. ํฌ๋ช
ํ ์ด์
์ค๋งํธ ์ปจํธ๋ํธ ์ฝ๋ ๊ณต๊ฐ, ์ ๊ธฐ์ ์ธ ์ปค๋ฎค๋์ผ์ด์
, ์ฌ๋ฌด ํฌ๋ช
์ฑ ๋ฑ์ด ์ค์ํด.
5. ์ปค๋ฎค๋ํฐ ์ฐธ์ฌ
์ค์ํ ๊ฒฐ์ ์ ์ปค๋ฎค๋ํฐ๋ฅผ ์ฐธ์ฌ์์ผ. DAO(ํ์ค์ํ ์์จ์กฐ์ง) ํํ๋ก ์ด์ํ๋ ๊ฒ๋ ์ข์ ๋ฐฉ๋ฒ์ด์ผ.
๐ฎ ๋ฏธ๋ ์ ๋ง๊ณผ ๋ฐ์ ๋ฐฉํฅ
NFT ๋ฉค๋ฒ์ญ ์์คํ ์ ์์ง ์ด๊ธฐ ๋จ๊ณ์ผ. ์์ผ๋ก ์ด๋ป๊ฒ ๋ฐ์ ํ ์ง ์ ๋งํด๋ณด์.
๐ ํฌ๋ก์ค ํ๋ซํผ ํตํฉ
๋ฏธ๋์๋ ํ๋์ NFT ๋ฉค๋ฒ์ญ์ผ๋ก ์ฌ๋ฌ ํ๋ซํผ์์ ํํ์ ๋ฐ์ ์ ์๊ฒ ๋ ๊ฑฐ์ผ. ์๋ฅผ ๋ค์ด, ์ฌ๋ฅ๋ท์์ ๋ฐํํ NFT๊ฐ ๋ค๋ฅธ ๊ต์ก ํ๋ซํผ์์๋ ์ธ์ ๋ฐ๋ ์์ด์ง.
// ํฌ๋ก์ค ํ๋ซํผ ๊ฒ์ฆ ์์
class CrossPlatformVerifier
{
public function verifyMembership($walletAddress, $platform)
{
// ์ฌ๋ฌ ํ๋ซํผ์ NFT ํ์ธ
$platforms = [
'platform_a' => '0xContractAddressA',
'platform_b' => '0xContractAddressB',
'platform_c' => '0xContractAddressC'
];
$memberships = [];
foreach ($platforms as $name => $contractAddress) {
$ownership = $this->checkOwnership($walletAddress, $contractAddress);
if ($ownership) {
$memberships[$name] = $ownership;
}
}
return [
'hasMembership' => !empty($memberships),
'platforms' => $memberships,
'totalValue' => $this->calculateTotalValue($memberships)
];
}
}
๐ค AI ๊ธฐ๋ฐ ๊ฐ์ธํ
AI๋ฅผ ํ์ฉํด์ ๊ฐ ์ฌ์ฉ์์ ํ๋ ํจํด์ ๋ถ์ํ๊ณ , ๋ง์ถคํ ํํ์ ์ ๊ณตํ๋ ์์คํ :
AI ๊ฐ์ธํ ์๋๋ฆฌ์ค
โข ์ฌ์ฉ์์ ํ์ต ํจํด ๋ถ์ โ ๋ง์ถค ๊ฐ์ ์ถ์ฒ
โข ์ปค๋ฎค๋ํฐ ์ฐธ์ฌ๋ ๋ถ์ โ ์ ์ ํ ์ญํ ๋ถ์ฌ
โข ๊ตฌ๋งค ์ด๋ ฅ ๋ถ์ โ ํน๋ณ ํ ์ธ ์ ๊ณต
โข ํ๋ ์๊ฐ๋ ๋ถ์ โ ์ต์ ์๊ฐ์ ์๋ฆผ ๋ฐ์ก
๐ฎ ๋ฉํ๋ฒ์ค ํตํฉ
NFT ๋ฉค๋ฒ์ญ์ด ๋ฉํ๋ฒ์ค์์ ํน๋ณํ ์๋ฐํ, ๊ณต๊ฐ, ์์ดํ ๋ฑ์ผ๋ก ํํ๋ ์ ์์ด:
๋ฉํ๋ฒ์ค ํ์ฉ ์์
โข Platinum ๋ฉค๋ฒ ์ ์ฉ ๊ฐ์ ๋ผ์ด์ง
โข ๋ฑ๊ธ๋ณ ํน๋ณ ์๋ฐํ ์คํจ
โข VIP ์ ์ฉ ๊ฐ์ ์ด๋ฒคํธ ๊ณต๊ฐ
โข NFT ๊ธฐ๋ฐ ๊ฐ์ ์์ฐ ๊ฑฐ๋
โก Layer 2 ์๋ฃจ์ ํ์ฉ
๊ฐ์ค๋น ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด Polygon, Arbitrum ๊ฐ์ Layer 2 ์๋ฃจ์ ์ ํ์ฉํ๋ ์ถ์ธ์ผ:
// Polygon ๋คํธ์ํฌ ์ค์
const polygonConfig = {
chainId: '0x89', // 137 in decimal
chainName: 'Polygon Mainnet',
nativeCurrency: {
name: 'MATIC',
symbol: 'MATIC',
decimals: 18
},
rpcUrls: ['https://polygon-rpc.com/'],
blockExplorerUrls: ['https://polygonscan.com/']
};
// ๋คํธ์ํฌ ์ ํ ํจ์
async function switchToPolygon() {
try {
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: polygonConfig.chainId }]
});
} catch (error) {
if (error.code === 4902) {
// ๋คํธ์ํฌ๊ฐ ์ถ๊ฐ๋์ง ์์ ๊ฒฝ์ฐ
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [polygonConfig]
});
}
}
}
๐ ํ์ต ๋ฆฌ์์ค์ ๋ค์ ๋จ๊ณ
NFT ๋ฉค๋ฒ์ญ ์์คํ ๊ตฌ์ถ์ ๋ํด ๋ ๊น์ด ๊ณต๋ถํ๊ณ ์ถ๋ค๋ฉด ๋ค์ ๋ฆฌ์์ค๋ค์ ์ถ์ฒํด:
๐ ์ถ์ฒ ํ์ต ์๋ฃ
๊ณต์ ๋ฌธ์
โข Laravel ๊ณต์ ๋ฌธ์: https://laravel.com/docs
โข Web3.js ๋ฌธ์: https://web3js.readthedocs.io
โข OpenZeppelin ๋ฌธ์: https://docs.openzeppelin.com
โข Ethereum ๊ฐ๋ฐ์ ๋ฌธ์: https://ethereum.org/developers
์จ๋ผ์ธ ๊ฐ์
โข Udemy: "Ethereum and Solidity: The Complete Developer's Guide"
โข Coursera: "Blockchain Specialization"
โข YouTube: Patrick Collins์ ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ ์๋ฆฌ์ฆ
์ปค๋ฎค๋ํฐ
โข Ethereum Stack Exchange
โข Reddit: r/ethdev
โข Discord: Ethereum ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ
โข ์ฌ๋ฅ๋ท ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ ๊ทธ๋ฃน
๐ ๋ค์ ๋จ๊ณ ๋ก๋๋งต
์ด๊ธ ๋จ๊ณ (1-2๊ฐ์)
โ
๋ผ๋ผ๋ฒจ ๊ธฐ๋ณธ ๋ง์คํฐ
โ
Web3.js ๊ธฐ์ด ํ์ต
โ
๋ฉํ๋ง์คํฌ ์ฐ๋ ๊ตฌํ
โ
๊ฐ๋จํ NFT ์กฐํ ๊ธฐ๋ฅ ๊ตฌํ
์ค๊ธ ๋จ๊ณ (2-3๊ฐ์)
โ
์ค๋งํธ ์ปจํธ๋ํธ ์์ฑ ๋ฐ ๋ฐฐํฌ
โ
์์ ํ ์ธ์ฆ ์์คํ
๊ตฌ์ถ
โ
๊ถํ ๊ด๋ฆฌ ์์คํ
๊ตฌํ
โ
ํ
์คํธ๋ท์์ ์ ์ฒด ํ๋ก์ฐ ํ
์คํธ
๊ณ ๊ธ ๋จ๊ณ (3-6๊ฐ์)
โ
์ฑ๋ฅ ์ต์ ํ ๋ฐ ์บ์ฑ ์ ๋ต
โ
๋ณด์ ๊ฐํ ๋ฐ ๊ฐ์ฌ
โ
๊ณ ๊ธ ๊ธฐ๋ฅ ์ถ๊ฐ (์์ด๋๋, ์
๊ทธ๋ ์ด๋ ๋ฑ)
โ
๋ฉ์ธ๋ท ๋ฐฐํฌ ๋ฐ ์ด์
์ ๋ฌธ๊ฐ ๋จ๊ณ (6๊ฐ์+)
โ
Layer 2 ์๋ฃจ์
ํตํฉ
โ
ํฌ๋ก์ค์ฒด์ธ ๊ธฐ๋ฅ ๊ตฌํ
โ
DAO ๊ฑฐ๋ฒ๋์ค ์์คํ
โ
๋ฉํ๋ฒ์ค ํตํฉ
๐ฌ ๋ง์น๋ฉฐ
์, ์ฌ๊ธฐ๊น์ง ๋ผ๋ผ๋ฒจ๊ณผ Web3.js๋ฅผ ํ์ฉํ NFT ๋ฉค๋ฒ์ญ ์ฌ์ดํธ ๊ตฌ์ถ์ ๋ํด ์ ๋ง ๋ง์ ๋ด์ฉ์ ๋ค๋ค์ด! ๐
์ฒ์์๋ ๋ณต์กํด ๋ณด์ผ ์ ์์ง๋ง, ํ๋์ฉ ๋จ๊ณ๋ฅผ ๋ฐ์๊ฐ๋ค ๋ณด๋ฉด ์๊ฐ๋ณด๋ค ์ด๋ ต์ง ์์. ์ค์ํ ๊ฑด ๊ธฐ๋ณธ ๊ฐ๋
์ ํ์คํ ์ดํดํ๊ณ , ์์ ํ๋ก์ ํธ๋ถํฐ ์์ํด์ ์ ์ง์ ์ผ๋ก ๊ธฐ๋ฅ์ ์ถ๊ฐํด ๋๊ฐ๋ ๊ฑฐ์ผ.
๋ธ๋ก์ฒด์ธ ๊ธฐ์ ์ ๋น ๋ฅด๊ฒ ๋ฐ์ ํ๊ณ ์๊ณ , NFT ๋ฉค๋ฒ์ญ ์์คํ
๋ ๊ณ์ ์งํํ๊ณ ์์ด. ์ค๋ ๋ฐฐ์ด ๋ด์ฉ์ ๊ธฐ๋ฐ์ผ๋ก ์์ ๋ง์ ์ฐฝ์์ ์ธ ์์ด๋์ด๋ฅผ ๋ํด์ ๋
ํนํ ์๋น์ค๋ฅผ ๋ง๋ค์ด๋ณด๊ธธ ๋ฐ๋ผ!
์ฌ๋ฅ๋ท ๊ฐ์ ํ๋ซํผ์์๋ ์ด๋ฐ ๊ธฐ์ ์ ํ์ฉํ๋ฉด ์ ๋ง ํ์ ์ ์ธ ์๋น์ค๋ฅผ ๋ง๋ค ์ ์์ ๊ฑฐ์ผ. ์ ๋ฌธ๊ฐ๋ค์ด ์์ ๋ง์ NFT ๋ฉค๋ฒ์ญ์ ๋ฐํํ๊ณ , ํฌ๋ค๊ณผ ๋ ๊น์ ๊ด๊ณ๋ฅผ ๋งบ์ ์ ์๋ ์ํ๊ณ๋ฅผ ์์ํด๋ด. ์ ๋ง ๋ฉ์ง์ง ์์? ๐
๊ถ๊ธํ ์ ์ด ์๊ฑฐ๋ ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์ ๋งํ๋ ๋ถ๋ถ์ด ์๋ค๋ฉด, ์ปค๋ฎค๋ํฐ์ ์ง๋ฌธํ๋ ๊ฑธ ๋๋ ค์ํ์ง ๋ง. ๋ธ๋ก์ฒด์ธ ๊ฐ๋ฐ์ ์ปค๋ฎค๋ํฐ๋ ์ ๋ง ์น์ ํ๊ณ ๋์์ ์ฃผ๋ ค๋ ์ฌ๋๋ค์ด ๋ง์.
์ด์ ๋น์ ๋ Web3 ์๋์ ๊ฐ๋ฐ์๋ก์ ์ฒซ ๋ฐ์ ๋ด๋์์ด. ํ์ดํ
! ๐๐ช
๐ ๋น์ ์ NFT ๋ฉค๋ฒ์ญ ํ๋ก์ ํธ๊ฐ ์ฑ๊ณตํ๊ธธ ์์ํด! ๐
๐ก ๋ง์ง๋ง ํ: ์ด ๊ธ์์ ๋ค๋ฃฌ ์ฝ๋๋ค์ ๊ต์ก ๋ชฉ์ ์ ์์์ผ. ์ค์ ํ๋ก๋์ ํ๊ฒฝ์ ๋ฐฐํฌํ๊ธฐ ์ ์๋ ๋ฐ๋์ ๋ณด์ ๊ฐ์ฌ๋ฅผ ๋ฐ๊ณ , ์ถฉ๋ถํ ํ ์คํธ๋ฅผ ๊ฑฐ์ณ์ผ ํด. ํนํ ์ค๋งํธ ์ปจํธ๋ํธ๋ ํ ๋ฒ ๋ฐฐํฌ๋๋ฉด ์์ ์ด ๋ถ๊ฐ๋ฅํ๋๊น ๋์ฑ ์ ์คํด์ผ ํด!
๊ด๋ จ ํค์๋
๋๊ธ ์์ฑ
์ด ๊ธ์ ๋ํ ์ฌ๋ฌ๋ถ์ ์๊ฐ์ ๋ค๋ ค์ฃผ์ธ์
๋ก๊ทธ์ธ์ด ํ์ํฉ๋๋ค
๋๊ธ์ ์์ฑํ๋ ค๋ฉด ๋จผ์ ๋ก๊ทธ์ธํด์ฃผ์ธ์.
๋๊ธ 0
์ง์์ธ์ ์ฒ - ์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
์ง์ ์ฌ์ฐ๊ถ ๋ณดํธ ๊ณ ์ง
- ์ ์๊ถ ๋ฐ ์์ ๊ถ: ๋ณธ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ๋ ์ AI ๊ธฐ์ ๋ก ์์ฑ๋์์ผ๋ฉฐ, ๋ํ๋ฏผ๊ตญ ์ ์๊ถ๋ฒ ๋ฐ ๊ตญ์ ์ ์๊ถ ํ์ฝ์ ์ํด ๋ณดํธ๋ฉ๋๋ค.
- AI ์์ฑ ์ปจํ ์ธ ์ ๋ฒ์ ์ง์: ๋ณธ AI ์์ฑ ์ปจํ ์ธ ๋ ์ฌ๋ฅ๋ท์ ์ง์ ์ฐฝ์๋ฌผ๋ก ์ธ์ ๋๋ฉฐ, ๊ด๋ จ ๋ฒ๊ท์ ๋ฐ๋ผ ์ ์๊ถ ๋ณดํธ๋ฅผ ๋ฐ์ต๋๋ค.
- ์ฌ์ฉ ์ ํ: ์ฌ๋ฅ๋ท์ ๋ช ์์ ์๋ฉด ๋์ ์์ด ๋ณธ ์ปจํ ์ธ ๋ฅผ ๋ณต์ , ์์ , ๋ฐฐํฌ, ๋๋ ์์ ์ ์ผ๋ก ํ์ฉํ๋ ํ์๋ ์๊ฒฉํ ๊ธ์ง๋ฉ๋๋ค.
- ๋ฐ์ดํฐ ์์ง ๊ธ์ง: ๋ณธ ์ปจํ ์ธ ์ ๋ํ ๋ฌด๋จ ์คํฌ๋ํ, ํฌ๋กค๋ง, ๋ฐ ์๋ํ๋ ๋ฐ์ดํฐ ์์ง์ ๋ฒ์ ์ ์ฌ์ ๋์์ด ๋ฉ๋๋ค.
- AI ํ์ต ์ ํ: ์ฌ๋ฅ๋ท์ AI ์์ฑ ์ปจํ ์ธ ๋ฅผ ํ AI ๋ชจ๋ธ ํ์ต์ ๋ฌด๋จ ์ฌ์ฉํ๋ ํ์๋ ๊ธ์ง๋๋ฉฐ, ์ด๋ ์ง์ ์ฌ์ฐ๊ถ ์นจํด๋ก ๊ฐ์ฃผ๋ฉ๋๋ค.
์์ง ๋๊ธ์ด ์์ต๋๋ค.