Installation
Install and set up CreateKit (BaseMint SDK) in your project
Package Installation
Install CreateKit using your preferred package manager:
npm install @b3dotfun/basemintyarn add @b3dotfun/basemintpnpm add @b3dotfun/basemintCreateKit 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/coreyarn add viem @wagmi/corepnpm add viem @wagmi/coreEnvironment Setup
1. Configure Chain Networks
CreateKit provides pre-configured chain definitions for B3 networks:
typescriptimport { 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:
typescriptimport { 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:
bash# 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:
typescriptimport { 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
typescriptimport { 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:
typescriptimport { 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.tsyarn tsx test-installation.tspnpm tsx test-installation.tsTypeScript Configuration
Ensure your tsconfig.json includes the necessary configurations:
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
Ensure all peer dependencies are installed:
bashnpm install viem @wagmi/core
Make sure your TypeScript configuration includes the necessary lib entries and that skipLibCheck is enabled.
Verify your RPC endpoints are correct and accessible. Use the default B3 RPC endpoints if custom ones fail.
Ensure your private key is in the correct format (0x prefixed) and has sufficient funds for gas fees.