Installation
Install and set up CreateKit (BaseMint SDK) in your project
Package Installation
Install CreateKit using your preferred package manager:
bashnpm install @b3dotfun/basemint
bashyarn add @b3dotfun/basemint
bashpnpm add @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:
bashnpm install viem @wagmi/core
bashyarn add viem @wagmi/core
bashpnpm add viem @wagmi/core
Environment Setup
1. Configure Chain Networks
CreateKit provides pre-configured chain definitions for B3 Mainnet:
typescriptimport { b3Mainnet } from '@b3dotfun/basemint'console.log('Chain ID:', b3Mainnet.id) // 8333console.log('Name:', b3Mainnet.name)console.log('RPC URL:', b3Mainnet.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 { b3Mainnet } from '@b3dotfun/basemint'// Public client for reading dataexport const publicClient = createPublicClient({ chain: b3Mainnet, transport: http()})// Wallet client for transactions (for server-side usage)export const walletClient = createWalletClient({ chain: b3Mainnet, 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 transactionsPRIVATE_KEY=0x...# Optional: Custom RPC endpointB3_MAINNET_RPC=https://your-custom-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 { b3Mainnet } from '@b3dotfun/basemint'import { CollectionManager, RewardTracker, BaseMintStorage} from '@b3dotfun/basemint'// Initialize clientsexport const publicClient = createPublicClient({ chain: b3Mainnet, transport: http()})// Initialize CreateKit managersexport 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 { b3Mainnet } from '@b3dotfun/basemint'import { CollectionManager } from '@b3dotfun/basemint'export const publicClient = createPublicClient({ chain: b3Mainnet, transport: http(import.meta.env.VITE_RPC_URL)})export const collectionManager = new CollectionManager(publicClient)
Verify Installation
Test your installation with a simple script:
typescriptimport { b3Mainnet, CollectionManager } from '@b3dotfun/basemint'import { createPublicClient, http } from 'viem'async function testInstallation() { try { // Create client const client = createPublicClient({ chain: b3Mainnet, transport: http() }) // Initialize manager const manager = new CollectionManager(client) // Test connection const blockNumber = await client.getBlockNumber() console.log('✅ Successfully connected to B3 Mainnet') 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:
bashnpx tsx test-installation.ts
bashyarn tsx test-installation.ts
bashpnpm tsx test-installation.ts
TypeScript 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.