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.
@@ -0,0 +1,105 @@
1
+ # CDP Wallet Quick Context
2
+
3
+ This file condenses **all wallet-related docs** so the assistant can grasp core concepts without reading individual markdown files.
4
+
5
+ ---
6
+ ## SDK & Auth
7
+ - Library: `@coinbase/cdp-sdk` (TypeScript) / `cdp-sdk` (Python).
8
+ - Required secrets (env):
9
+ - `CDP_API_KEY_ID`, `CDP_API_KEY_SECRET` – API key pair created in CDP Portal.
10
+ - `CDP_WALLET_SECRET` – Wallet secret enabling signing.
11
+
12
+ ---
13
+ ## Account Types
14
+ | Type | Networks | Notes |
15
+ |------|----------|-------|
16
+ | **EOA** | All EVM compatible | Standard private-key account. Pays its own gas. |
17
+ | **Smart Account (EIP-4337)** | Base Sepolia/Mainnet | Contract wallet with owner EOA; supports gas sponsorship & batching. One SA per owner. |
18
+ | **Solana Account** | Solana mainnet/devnet | Keypair account; signing handled through CDP SDK. |
19
+
20
+ ---
21
+ ## Common Operations (TS syntax, mirror in Python)
22
+ ### Create or fetch account
23
+ ```ts
24
+ const account = await cdp.evm.getOrCreateAccount({ name: 'MyAccount' })
25
+ ```
26
+ ### Create Smart Account
27
+ ```ts
28
+ const sa = await cdp.evm.getOrCreateSmartAccount({ owner: account, name: 'MySA' })
29
+ ```
30
+ ### Import private key
31
+ ```ts
32
+ await cdp.evm.importAccount({ privateKey: '0xabc…', name: 'Imported' })
33
+ ```
34
+ ### Fund with fiat (beta)
35
+ ```ts
36
+ const quote = await account.quoteFund({ network: 'base', token: 'eth', amount: 5n * 10n**14n })
37
+ await quote.execute()
38
+ ```
39
+ Or directly:
40
+ ```ts
41
+ await account.fund({ network: 'base', token: 'eth', amount: 500000000000000n })
42
+ ```
43
+ ### Request test tokens
44
+ ```ts
45
+ await cdp.evm.requestFaucet({ address: account.address, network: 'base-sepolia', token: 'eth' })
46
+ ```
47
+ ### Send transaction
48
+ ```ts
49
+ await cdp.evm.sendTransaction({
50
+ address: account.address,
51
+ network: 'base-sepolia',
52
+ transaction: { to: '0x…', value: parseEther('0.001') }
53
+ })
54
+ ```
55
+ ### Sign message / hash (Solana & EVM)
56
+ ```ts
57
+ await cdp.solana.signMessage({ address, message: 'hello' })
58
+ ```
59
+
60
+ ---
61
+ ## Managing Accounts
62
+ - `listAccounts`, pagination via `pageToken`.
63
+ - `updateAccount` allows renaming and attaching `accountPolicy`.
64
+ - Portal UI: https://portal.cdp.coinbase.com/products/wallet-api/accounts
65
+
66
+ ---
67
+ ## Policies (Governance Engine)
68
+ - JSON document with `scope` (`project`|`account`), array `rules`.
69
+ - Rule fields: `action` (`accept`|`reject`), `operation` (`signEvmTransaction`, `sendEvmTransaction`, `signEvmMessage`, `signEvmHash`, `signSolTransaction`), `criteria` array.
70
+ - Common criteria helpers: `evmAddress` (allow/deny lists), `ethValue`, `evmNetwork`, `evmData` (ABI-aware), `evmMessage` (regex).
71
+ - Apply policy:
72
+ ```ts
73
+ const policy = await cdp.policies.createPolicy({ policy: {/* ... */} })
74
+ await cdp.evm.updateAccount({ address, update: { accountPolicy: policy.id } })
75
+ ```
76
+
77
+ ---
78
+ ## Import/Export Keys
79
+ - Imports supported for:
80
+ - EVM private key (hex string)
81
+ - Solana private key (base58 or raw 32-byte array)
82
+ - Exports require secure enclave; exporting doc currently placeholder.
83
+
84
+ ---
85
+ ## Funding (Fiat → Crypto)
86
+ - Beta `quoteFund`/`fund` methods; requires Coinbase consumer account w/ US debit card (non-3DS).
87
+ - Outputs fees & fiat amount, expiration 10 min.
88
+
89
+ ---
90
+ ## Quickstart Workflow
91
+ 1. **Install**: `npm i @coinbase/cdp-sdk dotenv`.
92
+ 2. **Env**: add keys to `.env.local`.
93
+ 3. **Instantiate**: `const cdp = new CdpClient()` (auto-reads env vars).
94
+ 4. **Create account** → **Faucet** → **Send transaction**.
95
+ 5. For SA gas sponsorship or base mainnet deployment, read Smart Accounts guide.
96
+ 6. Use faucets sparingly – see rate limits.
97
+
98
+ ---
99
+ ## Useful Links
100
+ - Docs home: https://docs.cloud.coinbase.com/wallet-api
101
+ - Policy Engine reference: `/api-reference/v2/rest-api/policy-engine/policy-engine`
102
+ - Discord: https://discord.com/invite/cdp
103
+
104
+ ---
105
+ This summary should provide enough information for an assistant to implement CDP wallet features without reopening the individual docs.
@@ -0,0 +1,97 @@
1
+ # CDP Wallet Documentation Directory
2
+
3
+ Use this file as a roadmap for extracting the **exact snippets** needed to implement wallet functionality according to `wallet.md`.
4
+
5
+ ---
6
+ ## 1. Quick Overview First
7
+ • **File**: `context.md`
8
+ • **Lines**: *entire file*
9
+ • **Why**: Gives a compact summary of SDK auth, account types, operations, policies.
10
+
11
+ > Read this first to orient yourself—no code yet.
12
+
13
+ ---
14
+ ## 2. Project Setup
15
+ | Task | Doc & Section | Lines |
16
+ |------|---------------|-------|
17
+ | Node/Env prerequisites | `/wallet/wallet-start.md` – *Prerequisites* | 20-60 |
18
+ | API Key & Wallet Secret creation | same file – *Create keys* | 65-95 |
19
+ | npm / pip install commands | same file – *Project setup* (TypeScript tab) | 100-150 |
20
+
21
+ Copy the install commands into your project as described in `wallet.md` → *Installation*.
22
+
23
+ ---
24
+ ## 3. Instantiate SDK
25
+ | Task | Doc | Lines |
26
+ |------|-----|-------|
27
+ | Sample instantiation (TS) | `/wallet/wallet-start.md` – first TS code block under *1. Create an account* | 160-180 |
28
+ | Python version (optional) | same file – Python block | 185-205 |
29
+
30
+ Use the TS snippet to populate `src/lib/cdp.ts` boilerplate.
31
+
32
+ ---
33
+ ## 4. Account Workflows
34
+ | Feature | Doc | Lines |
35
+ |---------|-----|-------|
36
+ | Create or fetch EOA | `cdp/wallet/managing-accounts.md` – *EVM Accounts* | 20-55 |
37
+ | Create Smart Account | same file – *Smart Accounts* | 70-115 |
38
+ | Create Solana Account | same file – *Solana Accounts* | 120-160 |
39
+ | List / Update accounts | same file – *Managing Existing Accounts* | 165-260 |
40
+
41
+ Merge these patterns into helper functions (`createEvmAccount`, `createSmartAccount`, etc.).
42
+
43
+ ---
44
+ ## 5. Import / Export Keys
45
+ • **File**: `/wallet/importing.md`
46
+ – Use the TS examples under *EVM Accounts* (lines 25-55) and *Solana Accounts* (lines 65-115) to build an `importAccount` utility.
47
+
48
+ ---
49
+ ## 6. Funding Accounts
50
+ | Method | Doc | Lines |
51
+ |--------|-----|-------|
52
+ | Testnet Faucet (ETH & SOL) | `/wallet/wallet-start.md` – *2. Fund account with test funds* | 210-315 |
53
+ | Fiat → Crypto (beta) | `/wallet/fund.md` – *Get a quote* & *Execute a quote* | 30-110 |
54
+
55
+ Implement faucet call in demo; leave fiat-funding optional behind a feature flag.
56
+
57
+ ---
58
+ ## 7. Sending Transactions
59
+ | Chain | Doc | Lines |
60
+ |-------|-----|-------|
61
+ | EVM example (viem) | `/wallet/wallet-start.md` – *3. Send a transaction → EVM → TypeScript* | 320-400 |
62
+ | Solana example | same file – *Solana TypeScript* | 405-560 |
63
+
64
+ Wrap these in `sendEvmTx` and `sendSolTx` helpers.
65
+
66
+ ---
67
+ ## 8. Policies (Optional Governance)
68
+ • **File**: `/wallet/policies.md`
69
+ – Read *Overview* (lines 1-60) for concept.
70
+ – For code, copy TS snippet under *Programmatically* (lines 260-350) to see how to `createPolicy` and `updateAccount`.
71
+
72
+ Attach policies only if required by product spec.
73
+
74
+ ---
75
+ ## 9. Smart Account Gas Sponsorship (Advanced)
76
+ • **File**: `/wallet/wallet-accounts.md`
77
+ – Table under *EOA vs Smart Accounts* (lines 40-110) explains benefits.
78
+
79
+ Use when enabling paymaster / bundler.
80
+
81
+ ---
82
+ ## 10. Putting It All Together
83
+ Follow the sequence below aligning with sections in `wallet.md`:
84
+ 1. **Install & Env** → Section *Installation* ↔ Docs in step 2.
85
+ 2. **Boilerplate Helper** → Section *Boilerplate Code* ↔ Docs in step 3.
86
+ 3. **Demo Flow (`demoWallet`)** → Section *Example Usage* ↔ Docs 4-7.
87
+ 4. **Questions & Policies** → Use step 8 if needed.
88
+
89
+ Complete the checklist at the end of `wallet.md`. When each box is satisfied, you've integrated wallets successfully.
90
+
91
+ ---
92
+ ### Tips for Efficient Navigation
93
+ 1. Use search (`⌘⇧F`) with keywords: `createAccount(`, `requestFaucet(`, `sendTransaction(` to jump quickly.
94
+ 2. When copying code, remove `dotenv.config()` if already handled globally.
95
+ 3. Keep server-side functions inside the **app router** or `src/lib` to avoid leaking secrets.
96
+
97
+ Happy building! :rocket: