Overview

This guide will walk you through creating your first NFT collection using CreateKit. You’ll learn how to:
  • Create collection metadata and signatures
  • Deploy a collection
  • Mint your first NFT
  • Track rewards
This quickstart uses B3 Testnet. Make sure you have testnet funds for gas fees.

Step 1: Basic Setup

First, let’s set up the basic infrastructure:
quickstart.ts
import { 
  CollectionManager, 
  RewardTracker,
  BaseMintStorage,
  b3Testnet 
} from '@b3dotfun/basemint'
import { createPublicClient, createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'

// Initialize clients
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
})

// Initialize CreateKit services
const collectionManager = new CollectionManager(publicClient)
const rewardTracker = new RewardTracker(publicClient)
const storage = new BaseMintStorage({
  baseUrl: 'https://api.basemint.fun'
})

Step 2: Create Collection Metadata

Define your collection parameters:
Create Collection
const collectionMetadata = {
  // Required parameters
  name: "My First Collection",
  symbol: "MFC",
  creator: account.address,
  gameOwner: account.address, // Can be different address
  
  // Optional parameters
  maxSupply: 1000n,
  mintPrice: 0n, // Free mint
  maxPerWallet: 10n,
  description: "My first NFT collection on B3",
  image: "https://example.com/collection-image.png",
  
  // Timing
  startTime: 0n, // Start immediately
  endTime: BigInt(Math.floor(Date.now() / 1000) + 86400 * 30), // 30 days
  
  // Token standard
  tokenStandard: "ERC721" as const,
  chainId: 1993 // B3 Testnet
}

Step 3: Generate Signatures

Create the required signatures for deployment:
Generate Signatures
// Generate creator signature
const creatorSignature = await collectionManager.generateCreatorSignature(
  walletClient,
  collectionMetadata
)

// Predict collection address
const predictedAddress = collectionManager.predictCollectionAddress(
  collectionMetadata,
  creatorSignature
)

console.log(`📍 Predicted collection address: ${predictedAddress}`)

Step 4: Submit to Storage

Store your collection metadata off-chain:
Submit to Storage
try {
  await storage.submitCollection(collectionMetadata, creatorSignature)
  console.log("✅ Collection metadata stored successfully")
} catch (error) {
  console.error("❌ Failed to store collection:", error)
}

Step 5: Deploy and Mint

Now comes the exciting part - deploying your collection and minting the first NFT:
Deploy and Mint
// Generate deployer signature
const deployerSignature = await collectionManager.generateDeployerSignature(
  walletClient,
  predictedAddress
)

// Create collection instance
const collection = collectionManager.createCollection(
  predictedAddress,
  collectionMetadata.tokenStandard
)

// Deploy and mint first NFT in one transaction
const mintTx = await collection.mint(
  walletClient,
  1n, // quantity
  undefined, // metadata URI (will use baseURI)
  0n, // mint price
  [], // whitelist proof (empty for public mint)
  creatorSignature,
  deployerSignature
)

console.log(`🎉 Collection deployed and first NFT minted!`)
console.log(`📋 Transaction hash: ${mintTx}`)

Step 6: Verify Deployment

Let’s verify that everything worked correctly:
Verify Deployment
// Check if collection is deployed
const isDeployed = await collection.isDeployed()
console.log(`🏭 Collection deployed: ${isDeployed}`)

// Get collection info
const info = await collection.getCollectionInfo()
console.log("📊 Collection Info:", {
  name: info.name,
  symbol: info.symbol,
  totalSupply: info.totalSupply.toString(),
  maxSupply: info.maxSupply.toString()
})

// Check token ownership
const balance = await collection.balanceOf(account.address)
console.log(`💰 Your token balance: ${balance.toString()}`)

Step 7: Track Rewards

Check the rewards generated from your mint:
Track Rewards
// Get escrow contract for rewards
const escrowAddress = collectionManager.getEscrowAddress()

// Track rewards for this collection
const collectionRewards = await rewardTracker.getCollectionRewards(
  escrowAddress,
  predictedAddress
)

console.log("💎 Collection Rewards:", {
  totalRewards: collectionRewards.totalRewards.toString(),
  unclaimedRewards: collectionRewards.unclaimedRewards.toString(),
  totalMints: collectionRewards.totalMints.toString()
})

// Get individual recipient rewards
const creatorRewards = await rewardTracker.getRecipientRewards(
  escrowAddress,
  predictedAddress,
  "CREATOR",
  account.address
)

console.log(`🎨 Creator rewards: ${creatorRewards.toString()}`)

Complete Example

Here’s the complete quickstart script:

Run the Example

Save the complete example as quickstart.ts and run it:
npx tsx quickstart.ts

Expected Output

When you run the quickstart script, you should see output similar to:
📍 Predicted collection address: 0x1234567890abcdef...
✅ Collection metadata stored successfully
🎉 Collection deployed and first NFT minted!
📋 Transaction hash: 0xabcdef1234567890...
🏭 Collection deployed: true
💎 Collection Rewards: {
  totalRewards: "1000000000000000000",
  unclaimedRewards: "1000000000000000000", 
  totalMints: "1"
}

What’s Next?

Congratulations! You’ve successfully created your first NFT collection with CreateKit. Here are some next steps to explore:

Troubleshooting