개요

이 가이드는 CreateKit을 사용하여 첫 번째 NFT 컬렉션을 만드는 방법을 안내합니다. 다음을 배울 수 있습니다:
  • 컬렉션 메타데이터 및 서명 생성
  • 컬렉션 배포
  • 첫 번째 NFT 민팅
  • 보상 추적
이 퀵스타트는 B3 테스트넷을 사용합니다. 가스 비용을 위한 테스트넷 자금이 있는지 확인하세요.

1단계: 기본 설정

먼저 기본 인프라를 설정합시다:
quickstart.ts
import { 
  CollectionManager, 
  RewardTracker,
  BaseMintStorage,
  b3Testnet 
} from '@b3dotfun/basemint'
import { createPublicClient, createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'

// 클라이언트 초기화
const publicClient = createPublicClient({
  chain: b3Testnet,
  transport: http()
})

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  chain: b3Testnet,
  transport: http(),
  account
})

// CreateKit 서비스 초기화
const collectionManager = new CollectionManager(publicClient)
const rewardTracker = new RewardTracker(publicClient)
const storage = new BaseMintStorage({
  baseUrl: 'https://api.basemint.fun'
})

2단계: 컬렉션 메타데이터 생성

컬렉션 파라미터를 정의하세요:
Create Collection
const collectionMetadata = {
  // 필수 파라미터
  name: "My First Collection",
  symbol: "MFC",
  creator: account.address,
  gameOwner: account.address, // 다른 주소일 수 있음
  
  // 선택적 파라미터
  maxSupply: 1000n,
  mintPrice: 0n, // 무료 민팅
  maxPerWallet: 10n,
  description: "B3에서의 나의 첫 NFT 컬렉션",
  image: "https://example.com/collection-image.png",
  
  // 타이밍
  startTime: 0n, // 즉시 시작
  endTime: BigInt(Math.floor(Date.now() / 1000) + 86400 * 30), // 30일
  
  // 토큰 표준
  tokenStandard: "ERC721" as const,
  chainId: 1993 // B3 테스트넷
}

3단계: 서명 생성

배포를 위한 필요한 서명을 생성하세요:
Generate Signatures
// 생성자 서명 생성
const creatorSignature = await collectionManager.generateCreatorSignature(
  walletClient,
  collectionMetadata
)

// 컬렉션 주소 예측
const predictedAddress = collectionManager.predictCollectionAddress(
  collectionMetadata,
  creatorSignature
)

console.log(`📍 예측된 컬렉션 주소: ${predictedAddress}`)

4단계: 저장소에 제출

컬렉션 메타데이터를 오프체인에 저장하세요:
Submit to Storage
try {
  await storage.submitCollection(collectionMetadata, creatorSignature)
  console.log("✅ 컬렉션 메타데이터가 성공적으로 저장되었습니다")
} catch (error) {
  console.error("❌ 컬렉션 저장 실패:", error)
}

5단계: 배포 및 민팅

이제 가장 흥미로운 부분 - 컬렉션을 배포하고 첫 번째 NFT를 민팅합니다:
Deploy and Mint
// 배포자 서명 생성
const deployerSignature = await collectionManager.generateDeployerSignature(
  walletClient,
  predictedAddress
)

// 컬렉션 인스턴스 생성
const collection = collectionManager.createCollection(
  predictedAddress,
  collectionMetadata.tokenStandard
)

// 한 번의 트랜잭션으로 배포 및 첫 NFT 민팅
const mintTx = await collection.mint(
  walletClient,
  1n, // 수량
  undefined, // 메타데이터 URI (baseURI 사용)
  0n, // 민팅 가격
  [], // 화이트리스트 증명 (공개 민팅을 위한 빈 배열)
  creatorSignature,
  deployerSignature
)

console.log(`🎉 컬렉션이 배포되었고 첫 NFT가 민팅되었습니다!`)
console.log(`📋 트랜잭션 해시: ${mintTx}`)

6단계: 배포 확인

모든 것이 올바르게 작동했는지 확인합시다:
Verify Deployment
// 컬렉션이 배포되었는지 확인
const isDeployed = await collection.isDeployed()
console.log(`🏭 컬렉션 배포됨: ${isDeployed}`)

// 컬렉션 정보 가져오기
const info = await collection.getCollectionInfo()
console.log("📊 컬렉션 정보:", {
  name: info.name,
  symbol: info.symbol,
  totalSupply: info.totalSupply.toString(),
  maxSupply: info.maxSupply.toString()
})

// 토큰 소유권 확인
const balance = await collection.balanceOf(account.address)
console.log(`💰 당신의 토큰 잔액: ${balance.toString()}`)

7단계: 보상 추적

민팅에서 생성된 보상을 확인하세요:
Track Rewards
// 보상을 위한 에스크로 계약 가져오기
const escrowAddress = collectionManager.getEscrowAddress()

// 이 컬렉션에 대한 보상 추적
const collectionRewards = await rewardTracker.getCollectionRewards(
  escrowAddress,
  predictedAddress
)

console.log("💎 컬렉션 보상:", {
  totalRewards: collectionRewards.totalRewards.toString(),
  unclaimedRewards: collectionRewards.unclaimedRewards.toString(),
  totalMints: collectionRewards.totalMints.toString()
})

// 개별 수령인 보상 가져오기
const creatorRewards = await rewardTracker.getRecipientRewards(
  escrowAddress,
  predictedAddress,
  "CREATOR",
  account.address
)

console.log(`🎨 창작자 보상: ${creatorRewards.toString()}`)

완성된 예제

여기 완성된 퀵스타트 스크립트가 있습니다:

예제 실행

완성된 예제를 quickstart.ts로 저장하고 실행하세요:
npx tsx quickstart.ts

예상 출력

퀵스타트 스크립트를 실행하면 다음과 비슷한 출력을 볼 수 있습니다:
📍 예측된 컬렉션 주소: 0x1234567890abcdef...
✅ 컬렉션 메타데이터가 성공적으로 저장되었습니다
🎉 컬렉션이 배포되었고 첫 NFT가 민팅되었습니다!
📋 트랜잭션 해시: 0xabcdef1234567890...
🏭 컬렉션 배포됨: true
💎 컬렉션 보상: {
  totalRewards: "1000000000000000000",
  unclaimedRewards: "1000000000000000000", 
  totalMints: "1"
}

다음 단계는?

축하합니다! CreateKit을 사용하여 첫 번째 NFT 컬렉션을 성공적으로 생성했습니다. 탐색할 다음 단계는 다음과 같습니다:

문제 해결