Package Installation

Install CreateKit using your preferred package manager:
npm install @b3dotfun/basemint
CreateKit is built with TypeScript and provides full type definitions out of the box.

Dependencies

CreateKit is built on top of modern web3 technologies and requires the following peer dependencies:
npm install viem @wagmi/core

Environment Setup

1. Configure Chain Networks

CreateKit provides pre-configured chain definitions for B3 networks:
chains.ts
import { b3Mainnet, b3Testnet } from '@b3dotfun/basemint'

// B3 Mainnet (Production)
console.log('Chain ID:', b3Mainnet.id) // 8333
console.log('Name:', b3Mainnet.name)
console.log('RPC URL:', b3Mainnet.rpcUrls.default.http[0])

// B3 Testnet (Development)
console.log('Chain ID:', b3Testnet.id) // 1993
console.log('Name:', b3Testnet.name)
console.log('RPC URL:', b3Testnet.rpcUrls.default.http[0])

2. Initialize Viem Client

Set up your viem client for interacting with the blockchain:
client.ts
import { createPublicClient, createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { b3Testnet } from '@b3dotfun/basemint'

// Public client for reading data
export const publicClient = createPublicClient({
  chain: b3Testnet,
  transport: http()
})

// Wallet client for transactions (for server-side usage)
export const walletClient = createWalletClient({
  chain: b3Testnet,
  transport: http(),
  account: privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
})

3. Environment Variables

Create a .env file in your project root:
.env
# Required for signing transactions
PRIVATE_KEY=0x...

# Optional: Custom RPC endpoints
B3_MAINNET_RPC=https://your-custom-rpc.com
B3_TESTNET_RPC=https://your-custom-testnet-rpc.com
Never commit private keys to version control. Use environment variables or secure key management solutions.

Framework Integration

Next.js Setup

For Next.js applications, create a configuration file:
lib/createkit.ts
import { createPublicClient, http } from 'viem'
import { b3Testnet } from '@b3dotfun/basemint'
import { 
  CollectionManager, 
  RewardTracker, 
  BaseMintStorage 
} from '@b3dotfun/basemint'

// Initialize clients
export const publicClient = createPublicClient({
  chain: b3Testnet,
  transport: http()
})

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

React/Vite Setup

src/lib/createkit.ts
import { createPublicClient, http } from 'viem'
import { b3Testnet } from '@b3dotfun/basemint'
import { CollectionManager } from '@b3dotfun/basemint'

export const publicClient = createPublicClient({
  chain: b3Testnet,
  transport: http(import.meta.env.VITE_RPC_URL)
})

export const collectionManager = new CollectionManager(publicClient)

Verify Installation

Test your installation with a simple script:
test-installation.ts
import { b3Testnet, CollectionManager } from '@b3dotfun/basemint'
import { createPublicClient, http } from 'viem'

async function testInstallation() {
  try {
    // Create client
    const client = createPublicClient({
      chain: b3Testnet,
      transport: http()
    })

    // Initialize manager
    const manager = new CollectionManager(client)
    
    // Test connection
    const blockNumber = await client.getBlockNumber()
    console.log('✅ Successfully connected to B3 Testnet')
    console.log(`📊 Current block number: ${blockNumber}`)
    
    // Test contract interaction
    const factoryAddress = manager.getFactoryAddress()
    console.log(`🏭 Factory address: ${factoryAddress}`)
    
    console.log('🎉 CreateKit installation successful!')
  } catch (error) {
    console.error('❌ Installation test failed:', error)
  }
}

testInstallation()
Run the test script:
npx tsx test-installation.ts

TypeScript Configuration

Ensure your tsconfig.json includes the necessary configurations:
tsconfig.json
{
  "compilerOptions": {
    "strict": true,
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "target": "ES2020",
    "module": "ESNext",
    "lib": ["ES2020", "DOM"]
  }
}

Next Steps

Now that you have CreateKit installed and configured, you’re ready to start building:

Troubleshooting