UNPKG

cdp-docs-cli

Version:

CLI tool to set up CDP (Coinbase Developer Platform) documentation and integration in your project

151 lines (117 loc) 5.22 kB
# 🚀 CDP Wallet Integration To-Do List Your Next.js project needs **Coinbase Developer Platform (CDP) Wallet API v2** integration! ## 📋 Implementation Checklist ### Prerequisites Setup - [ ] Verify Node.js 22+ is installed - [ ] Confirm Next.js 15+ with App Router is configured - [ ] Ensure TypeScript is set up and working - [ ] Verify Tailwind CSS is configured ### Dependencies Installation - [ ] Install CDP SDK: `npm install @coinbase/cdp-sdk` - [ ] Install environment utilities: `npm install dotenv` - [ ] Install Ethereum utilities: `npm install viem` - [ ] Install styling utilities: `npm install clsx tailwind-merge` ### Environment Configuration - [ ] Create `.env.local` in project root - [ ] Add `CDP_API_KEY_ID` to environment file - [ ] Add `CDP_API_KEY_SECRET` to environment file - [ ] Add `CDP_WALLET_SECRET` to environment file - [ ] Verify `.env.local` is in `.gitignore` ### Core Files to Create #### Backend Configuration - [ ] Create `src/lib/cdp.ts` - CDP client configuration - [ ] Create `src/lib/wallet-utils.ts` - Wallet utility functions - [ ] Create `src/lib/utils.ts` - Styling utilities (cn function) #### React Components & Hooks - [ ] Create `src/lib/hooks/use-wallet.ts` - Wallet state management hook - [ ] Create `src/components/ui/wallet-dashboard.tsx` - Main dashboard component #### Examples & Documentation - [ ] Create `examples/wallet-demo.ts` - Demo usage example - [ ] Review `/doc/cdp/integration/SETUP-CDP-WALLET.md` - User setup guide (already provided) ### Main Page Integration - [ ] Update `src/app/page.tsx` to use WalletDashboard component - [ ] Verify responsive design works correctly - [ ] Test error handling and loading states ### CDP API Functions to Implement #### Account Management - [ ] Implement `createOrGetEvmAccount()` function - [ ] Implement `importEvmAccount()` function for private key import - [ ] Implement `listAccounts()` function with proper pagination handling - [ ] Implement `createSolanaAccount()` function #### Transaction Functions - [ ] Implement `requestFaucet()` function for testnet funds - [ ] Implement `sendEvmTransaction()` function - [ ] Implement `getAccountBalance()` function - [ ] Implement `requestSolanaFaucet()` function #### Smart Account Features (Advanced) - [ ] Implement `createSmartAccount()` function - [ ] Add gas sponsorship support - [ ] Implement batch transaction support ### UI Components to Build #### Dashboard Layout - [ ] Create account creation form - [ ] Create private key import form - [ ] Create account selection interface - [ ] Create balance display component #### Transaction Interface - [ ] Create faucet request button - [ ] Create send transaction form - [ ] Create transaction history display - [ ] Add explorer link integration #### Error Handling - [ ] Implement error message display - [ ] Add loading states for all operations - [ ] Create validation for form inputs - [ ] Add success notifications ### Testing & Validation #### Development Testing - [ ] Run `npm run build` and verify no errors - [ ] Test account creation flow - [ ] Test private key import functionality - [ ] Test faucet request functionality - [ ] Test transaction sending #### Production Readiness - [ ] Verify all secrets stay server-side - [ ] Confirm no private keys exposed to client - [ ] Test error boundaries and edge cases - [ ] Validate TypeScript compilation - [ ] Check ESLint warnings are resolved ### Documentation & Setup #### User Documentation - [ ] Complete setup instructions for CDP credentials - [ ] Document environment variable requirements - [ ] Create troubleshooting guide - [ ] Add security best practices #### Developer Documentation - [ ] Document all utility functions - [ ] Add TypeScript interface definitions - [ ] Create integration examples - [ ] Document customization options ## 🚨 Critical Issues to Avoid ### TypeScript Safety - [ ] Always handle potentially undefined API responses with fallbacks - [ ] Use `result.accounts || []` pattern for array responses - [ ] Implement proper error type checking ### CDP SDK Integration - [ ] Reference official CDP docs for exact API response formats - [ ] Handle paginated responses correctly (objects, not arrays) - [ ] Use optional chaining (`?.`) for uncertain data structures ### Development Workflow - [ ] Run `npm run build` frequently during development - [ ] Test TypeScript compilation before committing - [ ] Handle unused parameters in mock implementations appropriately ## 🎯 Success Criteria - [ ] `npm run dev` launches without errors - [ ] Dashboard renders at `http://localhost:3000` - [ ] Can create and fund accounts via UI - [ ] Transactions appear on Base Sepolia explorer - [ ] No CDP secrets leaked to client bundle - [ ] All TypeScript/ESLint errors resolved ## 🔐 Security Checklist - [ ] All wallet operations happen server-side - [ ] Private keys never exposed to client code - [ ] Environment variables properly protected - [ ] Server actions secure sensitive operations - [ ] No API keys in client bundle --- **🎯 Goal**: Build a production-ready wallet dashboard with enterprise-grade security using Coinbase's CDP platform for Base, Ethereum, and Solana networks!