cdp-docs-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -0
- package/bin/cdp-docs.js +48 -0
- package/bin/cdp-setup.js +91 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
- package/src/templates/docs/exporting.md +0 -0
- package/src/templates/docs/fund.md +122 -0
- package/src/templates/docs/importing.md +273 -0
- package/src/templates/docs/managing-accounts.md +366 -0
- package/src/templates/docs/policies.md +730 -0
- package/src/templates/docs/transfer.md +366 -0
- package/src/templates/docs/wallet-accounts.md +203 -0
- package/src/templates/docs/wallet-start.md +741 -0
- package/src/templates/prompt/INTEGRATION-SUMMARY.md +151 -0
- package/src/templates/prompt/SETUP-CDP-WALLET.md +142 -0
- package/src/templates/prompt/cdp-wallet.md +1155 -0
- package/src/templates/prompt/context.md +105 -0
- package/src/templates/prompt/directory.md +97 -0
@@ -0,0 +1,151 @@
|
|
1
|
+
# 🚀 CDP Wallet Integration To-Do List
|
2
|
+
|
3
|
+
Your Next.js project needs **Coinbase Developer Platform (CDP) Wallet API v2** integration!
|
4
|
+
|
5
|
+
## 📋 Implementation Checklist
|
6
|
+
|
7
|
+
### Prerequisites Setup
|
8
|
+
- [ ] Verify Node.js 22+ is installed
|
9
|
+
- [ ] Confirm Next.js 15+ with App Router is configured
|
10
|
+
- [ ] Ensure TypeScript is set up and working
|
11
|
+
- [ ] Verify Tailwind CSS is configured
|
12
|
+
|
13
|
+
### Dependencies Installation
|
14
|
+
- [ ] Install CDP SDK: `npm install @coinbase/cdp-sdk`
|
15
|
+
- [ ] Install environment utilities: `npm install dotenv`
|
16
|
+
- [ ] Install Ethereum utilities: `npm install viem`
|
17
|
+
- [ ] Install styling utilities: `npm install clsx tailwind-merge`
|
18
|
+
|
19
|
+
### Environment Configuration
|
20
|
+
- [ ] Create `.env.local` in project root
|
21
|
+
- [ ] Add `CDP_API_KEY_ID` to environment file
|
22
|
+
- [ ] Add `CDP_API_KEY_SECRET` to environment file
|
23
|
+
- [ ] Add `CDP_WALLET_SECRET` to environment file
|
24
|
+
- [ ] Verify `.env.local` is in `.gitignore`
|
25
|
+
|
26
|
+
### Core Files to Create
|
27
|
+
|
28
|
+
#### Backend Configuration
|
29
|
+
- [ ] Create `src/lib/cdp.ts` - CDP client configuration
|
30
|
+
- [ ] Create `src/lib/wallet-utils.ts` - Wallet utility functions
|
31
|
+
- [ ] Create `src/lib/utils.ts` - Styling utilities (cn function)
|
32
|
+
|
33
|
+
#### React Components & Hooks
|
34
|
+
- [ ] Create `src/lib/hooks/use-wallet.ts` - Wallet state management hook
|
35
|
+
- [ ] Create `src/components/ui/wallet-dashboard.tsx` - Main dashboard component
|
36
|
+
|
37
|
+
#### Examples & Documentation
|
38
|
+
- [ ] Create `examples/wallet-demo.ts` - Demo usage example
|
39
|
+
- [ ] Create `SETUP-CDP-WALLET.md` - User setup guide
|
40
|
+
|
41
|
+
### Main Page Integration
|
42
|
+
- [ ] Update `src/app/page.tsx` to use WalletDashboard component
|
43
|
+
- [ ] Verify responsive design works correctly
|
44
|
+
- [ ] Test error handling and loading states
|
45
|
+
|
46
|
+
### CDP API Functions to Implement
|
47
|
+
|
48
|
+
#### Account Management
|
49
|
+
- [ ] Implement `createOrGetEvmAccount()` function
|
50
|
+
- [ ] Implement `importEvmAccount()` function for private key import
|
51
|
+
- [ ] Implement `listAccounts()` function with proper pagination handling
|
52
|
+
- [ ] Implement `createSolanaAccount()` function
|
53
|
+
|
54
|
+
#### Transaction Functions
|
55
|
+
- [ ] Implement `requestFaucet()` function for testnet funds
|
56
|
+
- [ ] Implement `sendEvmTransaction()` function
|
57
|
+
- [ ] Implement `getAccountBalance()` function
|
58
|
+
- [ ] Implement `requestSolanaFaucet()` function
|
59
|
+
|
60
|
+
#### Smart Account Features (Advanced)
|
61
|
+
- [ ] Implement `createSmartAccount()` function
|
62
|
+
- [ ] Add gas sponsorship support
|
63
|
+
- [ ] Implement batch transaction support
|
64
|
+
|
65
|
+
### UI Components to Build
|
66
|
+
|
67
|
+
#### Dashboard Layout
|
68
|
+
- [ ] Create account creation form
|
69
|
+
- [ ] Create private key import form
|
70
|
+
- [ ] Create account selection interface
|
71
|
+
- [ ] Create balance display component
|
72
|
+
|
73
|
+
#### Transaction Interface
|
74
|
+
- [ ] Create faucet request button
|
75
|
+
- [ ] Create send transaction form
|
76
|
+
- [ ] Create transaction history display
|
77
|
+
- [ ] Add explorer link integration
|
78
|
+
|
79
|
+
#### Error Handling
|
80
|
+
- [ ] Implement error message display
|
81
|
+
- [ ] Add loading states for all operations
|
82
|
+
- [ ] Create validation for form inputs
|
83
|
+
- [ ] Add success notifications
|
84
|
+
|
85
|
+
### Testing & Validation
|
86
|
+
|
87
|
+
#### Development Testing
|
88
|
+
- [ ] Run `npm run build` and verify no errors
|
89
|
+
- [ ] Test account creation flow
|
90
|
+
- [ ] Test private key import functionality
|
91
|
+
- [ ] Test faucet request functionality
|
92
|
+
- [ ] Test transaction sending
|
93
|
+
|
94
|
+
#### Production Readiness
|
95
|
+
- [ ] Verify all secrets stay server-side
|
96
|
+
- [ ] Confirm no private keys exposed to client
|
97
|
+
- [ ] Test error boundaries and edge cases
|
98
|
+
- [ ] Validate TypeScript compilation
|
99
|
+
- [ ] Check ESLint warnings are resolved
|
100
|
+
|
101
|
+
### Documentation & Setup
|
102
|
+
|
103
|
+
#### User Documentation
|
104
|
+
- [ ] Complete setup instructions for CDP credentials
|
105
|
+
- [ ] Document environment variable requirements
|
106
|
+
- [ ] Create troubleshooting guide
|
107
|
+
- [ ] Add security best practices
|
108
|
+
|
109
|
+
#### Developer Documentation
|
110
|
+
- [ ] Document all utility functions
|
111
|
+
- [ ] Add TypeScript interface definitions
|
112
|
+
- [ ] Create integration examples
|
113
|
+
- [ ] Document customization options
|
114
|
+
|
115
|
+
## 🚨 Critical Issues to Avoid
|
116
|
+
|
117
|
+
### TypeScript Safety
|
118
|
+
- [ ] Always handle potentially undefined API responses with fallbacks
|
119
|
+
- [ ] Use `result.accounts || []` pattern for array responses
|
120
|
+
- [ ] Implement proper error type checking
|
121
|
+
|
122
|
+
### CDP SDK Integration
|
123
|
+
- [ ] Reference official CDP docs for exact API response formats
|
124
|
+
- [ ] Handle paginated responses correctly (objects, not arrays)
|
125
|
+
- [ ] Use optional chaining (`?.`) for uncertain data structures
|
126
|
+
|
127
|
+
### Development Workflow
|
128
|
+
- [ ] Run `npm run build` frequently during development
|
129
|
+
- [ ] Test TypeScript compilation before committing
|
130
|
+
- [ ] Handle unused parameters in mock implementations appropriately
|
131
|
+
|
132
|
+
## 🎯 Success Criteria
|
133
|
+
|
134
|
+
- [ ] `npm run dev` launches without errors
|
135
|
+
- [ ] Dashboard renders at `http://localhost:3000`
|
136
|
+
- [ ] Can create and fund accounts via UI
|
137
|
+
- [ ] Transactions appear on Base Sepolia explorer
|
138
|
+
- [ ] No CDP secrets leaked to client bundle
|
139
|
+
- [ ] All TypeScript/ESLint errors resolved
|
140
|
+
|
141
|
+
## 🔐 Security Checklist
|
142
|
+
|
143
|
+
- [ ] All wallet operations happen server-side
|
144
|
+
- [ ] Private keys never exposed to client code
|
145
|
+
- [ ] Environment variables properly protected
|
146
|
+
- [ ] Server actions secure sensitive operations
|
147
|
+
- [ ] No API keys in client bundle
|
148
|
+
|
149
|
+
---
|
150
|
+
|
151
|
+
**🎯 Goal**: Build a production-ready wallet dashboard with enterprise-grade security using Coinbase's CDP platform for Base, Ethereum, and Solana networks!
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# 🔧 CDP Wallet Setup Guide
|
2
|
+
|
3
|
+
Follow these steps to configure your Coinbase Developer Platform (CDP) wallet integration.
|
4
|
+
|
5
|
+
## Step 1: Get CDP API Credentials
|
6
|
+
|
7
|
+
1. **Visit the CDP Portal**: Go to [https://portal.cdp.coinbase.com/](https://portal.cdp.coinbase.com/)
|
8
|
+
|
9
|
+
2. **Sign in** with your Coinbase account or create a new one
|
10
|
+
|
11
|
+
3. **Create API Keys**:
|
12
|
+
- Navigate to the "API Keys" section
|
13
|
+
- Click "Create API Key"
|
14
|
+
- Give your key a descriptive name (e.g., "My Wallet App")
|
15
|
+
- Save both the **API Key ID** and **API Key Secret** - you'll need these later
|
16
|
+
|
17
|
+
4. **Generate Wallet Secret**:
|
18
|
+
- This is used for signing transactions
|
19
|
+
- Generate a secure random string or use the CDP portal's generator
|
20
|
+
- Keep this secret safe - it's like your master password
|
21
|
+
|
22
|
+
## Step 2: Configure Environment Variables
|
23
|
+
|
24
|
+
1. **Create Environment File**:
|
25
|
+
```bash
|
26
|
+
# In your project root, create .env.local
|
27
|
+
touch .env.local
|
28
|
+
```
|
29
|
+
|
30
|
+
2. **Add Your Credentials**:
|
31
|
+
Open `.env.local` and add your CDP credentials:
|
32
|
+
```bash
|
33
|
+
CDP_API_KEY_ID=your_actual_key_id_here
|
34
|
+
CDP_API_KEY_SECRET=your_actual_key_secret_here
|
35
|
+
CDP_WALLET_SECRET=your_actual_wallet_secret_here
|
36
|
+
```
|
37
|
+
|
38
|
+
**Replace the placeholder values** with your actual credentials from Step 1.
|
39
|
+
|
40
|
+
3. **Verify Security**:
|
41
|
+
- Confirm `.env.local` is in your `.gitignore` file
|
42
|
+
- Never commit this file to version control
|
43
|
+
- Never share these credentials publicly
|
44
|
+
|
45
|
+
## Step 3: Test the Integration
|
46
|
+
|
47
|
+
1. **Start the Development Server**:
|
48
|
+
```bash
|
49
|
+
npm run dev
|
50
|
+
```
|
51
|
+
|
52
|
+
2. **Open Your Browser**:
|
53
|
+
- Navigate to [http://localhost:3000](http://localhost:3000)
|
54
|
+
- You should see the CDP Wallet Dashboard
|
55
|
+
|
56
|
+
3. **Create Your First Account**:
|
57
|
+
- Enter a name for your account (e.g., "My First Wallet")
|
58
|
+
- Click "Create Account"
|
59
|
+
- You should see your new account appear in the list
|
60
|
+
|
61
|
+
4. **Request Test Funds**:
|
62
|
+
- Select your account
|
63
|
+
- Click "Request Test ETH"
|
64
|
+
- Wait a few seconds for the transaction to complete
|
65
|
+
- Your balance should update to show testnet ETH
|
66
|
+
|
67
|
+
5. **Send a Test Transaction**:
|
68
|
+
- Enter a recipient address (you can use your own account address)
|
69
|
+
- Enter a small amount (e.g., 0.001)
|
70
|
+
- Click "Send Transaction"
|
71
|
+
- View the transaction on the Base Sepolia explorer
|
72
|
+
|
73
|
+
## 🎉 Success Criteria
|
74
|
+
|
75
|
+
Your integration is working correctly if:
|
76
|
+
|
77
|
+
- ✅ Dashboard loads without errors
|
78
|
+
- ✅ You can create new accounts
|
79
|
+
- ✅ Faucet requests work and fund your accounts
|
80
|
+
- ✅ You can send transactions successfully
|
81
|
+
- ✅ Transaction links open on BaseScan explorer
|
82
|
+
|
83
|
+
## 🔒 Security Best Practices
|
84
|
+
|
85
|
+
- **Never commit** `.env.local` to version control
|
86
|
+
- **Use testnet only** for development and testing
|
87
|
+
- **Keep your API keys secure** - treat them like passwords
|
88
|
+
- **Use different keys** for development vs production
|
89
|
+
- **Rotate keys regularly** if building production apps
|
90
|
+
|
91
|
+
## 🚨 Troubleshooting
|
92
|
+
|
93
|
+
### Environment Variable Issues
|
94
|
+
- Ensure `.env.local` is in your project root directory
|
95
|
+
- Restart your development server after changing environment variables
|
96
|
+
- Double-check there are no extra spaces in your credential values
|
97
|
+
|
98
|
+
### API Connection Issues
|
99
|
+
- Verify your API credentials are correct
|
100
|
+
- Check your internet connection
|
101
|
+
- Ensure you're using the correct CDP portal account
|
102
|
+
|
103
|
+
### Transaction Failures
|
104
|
+
- Make sure your account has sufficient testnet ETH
|
105
|
+
- Verify recipient addresses are valid Ethereum addresses
|
106
|
+
- Check that you're using reasonable gas amounts
|
107
|
+
|
108
|
+
### Build Errors
|
109
|
+
- Run `npm run build` to check for TypeScript errors
|
110
|
+
- Ensure all dependencies are installed: `npm install`
|
111
|
+
- Clear your `.next` cache: `rm -rf .next` then restart
|
112
|
+
|
113
|
+
## 📚 Next Steps
|
114
|
+
|
115
|
+
Once your basic integration is working:
|
116
|
+
|
117
|
+
1. **Explore Advanced Features**:
|
118
|
+
- Smart accounts with gas sponsorship
|
119
|
+
- Batch transactions
|
120
|
+
- Multi-network support (Ethereum, Solana)
|
121
|
+
|
122
|
+
2. **Build Custom Features**:
|
123
|
+
- Custom transaction types
|
124
|
+
- Transaction history
|
125
|
+
- Address book functionality
|
126
|
+
- Portfolio tracking
|
127
|
+
|
128
|
+
3. **Prepare for Production**:
|
129
|
+
- Set up mainnet credentials
|
130
|
+
- Implement proper error handling
|
131
|
+
- Add comprehensive testing
|
132
|
+
- Security audit your implementation
|
133
|
+
|
134
|
+
## 🆘 Need Help?
|
135
|
+
|
136
|
+
- **CDP Documentation**: [https://docs.cdp.coinbase.com/](https://docs.cdp.coinbase.com/)
|
137
|
+
- **Base Network**: [https://base.org/](https://base.org/)
|
138
|
+
- **Support**: Contact Coinbase Developer Support
|
139
|
+
|
140
|
+
---
|
141
|
+
|
142
|
+
**Happy Building! 🚀**
|