@coinbase/cdp-cli 0.0.0 → 2.0.2
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/LICENSE +21 -0
- package/README.md +253 -0
- package/dist/index.js +492 -0
- package/dist/spec.json +1 -0
- package/dist/version.txt +1 -0
- package/package.json +36 -5
- package/scripts/postinstall.mjs +52 -0
- package/skills/cdp-accounts-create/SKILL.md +78 -0
- package/skills/cdp-accounts-import-export/SKILL.md +60 -0
- package/skills/cdp-accounts-send/SKILL.md +102 -0
- package/skills/cdp-accounts-sign/SKILL.md +65 -0
- package/skills/cdp-data/SKILL.md +78 -0
- package/skills/cdp-end-users/SKILL.md +60 -0
- package/skills/cdp-onramp/SKILL.md +60 -0
- package/skills/cdp-policies/SKILL.md +79 -0
- package/skills/cdp-setup/SKILL.md +90 -0
- package/skills/cdp-smart-accounts/SKILL.md +74 -0
- package/skills/cdp-solana/SKILL.md +79 -0
- package/skills/cdp-spend-permissions/SKILL.md +64 -0
- package/skills/cdp-swaps/SKILL.md +91 -0
- package/skills/cdp-x402/SKILL.md +124 -0
- package/index.js +0 -1
package/dist/version.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.0.2
|
package/package.json
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "CLI for the Coinbase Developer Platform API",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cdp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "BUILD=external node scripts/embed-spec.mjs",
|
|
11
|
+
"typecheck": "tsc --noEmit",
|
|
12
|
+
"test": "node --experimental-strip-types --no-warnings --test 'src/**/*.test.ts'",
|
|
13
|
+
"test:keyring": "node --experimental-strip-types --no-warnings --test src/lib/keyring/keyring.integration-test.ts",
|
|
14
|
+
"postinstall": "node scripts/postinstall.mjs"
|
|
15
|
+
},
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=22"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/",
|
|
21
|
+
"skills/",
|
|
22
|
+
"scripts/postinstall.mjs"
|
|
23
|
+
],
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^25.2.3",
|
|
26
|
+
"esbuild": "^0.27.3",
|
|
27
|
+
"typescript": "^5.7.0",
|
|
28
|
+
"yaml": "^2.6.0"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"homepage": "https://docs.cdp.coinbase.com",
|
|
32
|
+
"keywords": [
|
|
33
|
+
"coinbase",
|
|
34
|
+
"cdp",
|
|
35
|
+
"cli",
|
|
36
|
+
"mcp",
|
|
37
|
+
"api"
|
|
38
|
+
]
|
|
8
39
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// postinstall — auto-update skills if skillsDir is configured.
|
|
3
|
+
// NEVER exits non-zero to avoid breaking npm install.
|
|
4
|
+
|
|
5
|
+
import { readFileSync, readdirSync, existsSync, mkdirSync, cpSync } from 'node:fs';
|
|
6
|
+
import { join, dirname } from 'node:path';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
function configPath() {
|
|
11
|
+
if (process.env.CDP_CONFIG_DIR) return join(process.env.CDP_CONFIG_DIR, 'config.json');
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
const appData = process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
|
|
14
|
+
return join(appData, 'cdp', 'config.json');
|
|
15
|
+
}
|
|
16
|
+
return join(homedir(), '.config', 'cdp', 'config.json');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function copySkills(srcDir, destDir) {
|
|
20
|
+
if (!existsSync(srcDir)) return 0;
|
|
21
|
+
mkdirSync(destDir, { recursive: true });
|
|
22
|
+
let count = 0;
|
|
23
|
+
for (const entry of readdirSync(srcDir, { withFileTypes: true })) {
|
|
24
|
+
if (!entry.isDirectory()) continue;
|
|
25
|
+
const skillMd = join(srcDir, entry.name, 'SKILL.md');
|
|
26
|
+
if (!existsSync(skillMd)) continue;
|
|
27
|
+
cpSync(join(srcDir, entry.name), join(destDir, entry.name), { recursive: true, force: true });
|
|
28
|
+
count++;
|
|
29
|
+
}
|
|
30
|
+
return count;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const cfgFile = configPath();
|
|
35
|
+
if (!existsSync(cfgFile)) process.exit(0);
|
|
36
|
+
|
|
37
|
+
const cfg = JSON.parse(readFileSync(cfgFile, 'utf8'));
|
|
38
|
+
const skillsDir = cfg?.settings?.skillsDir;
|
|
39
|
+
if (!skillsDir) process.exit(0);
|
|
40
|
+
|
|
41
|
+
// Resolve bundled skills directory relative to this script
|
|
42
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
43
|
+
const packageRoot = dirname(thisDir);
|
|
44
|
+
const srcDir = join(packageRoot, 'skills');
|
|
45
|
+
|
|
46
|
+
if (!existsSync(srcDir)) process.exit(0);
|
|
47
|
+
|
|
48
|
+
const count = copySkills(srcDir, skillsDir);
|
|
49
|
+
process.stderr.write(`cdp: updated ${count} skills in ${skillsDir}\n`);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
process.stderr.write(`cdp: warning: could not update skills: ${err.message}\n`);
|
|
52
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-accounts-create
|
|
3
|
+
description: Creates and funds CDP server wallets (EVM, Solana, Smart Account) or end-user embedded wallets. Handles testnet faucet funding automatically.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-accounts-create
|
|
7
|
+
|
|
8
|
+
Create a CDP account and optionally fund it.
|
|
9
|
+
|
|
10
|
+
## Preconditions
|
|
11
|
+
|
|
12
|
+
1. CLI configured → `/cdp-setup`
|
|
13
|
+
2. Wallet secret required for server wallets (evm, solana, smart) → `/cdp-setup`
|
|
14
|
+
3. Smart accounts require a funded EOA owner — create one first if needed.
|
|
15
|
+
|
|
16
|
+
## EVM account
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
cdp evm accounts create name=<name>
|
|
20
|
+
```
|
|
21
|
+
With policy: `cdp evm accounts create name=<name> accountPolicy=<policyId>`
|
|
22
|
+
|
|
23
|
+
Verify: `cdp evm accounts get <address>` and `cdp evm accounts by-name <name>`
|
|
24
|
+
|
|
25
|
+
### Fund (testnet)
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
cdp evm faucet address=<address> network=base-sepolia token=eth
|
|
29
|
+
```
|
|
30
|
+
Faucet tokens: eth, usdc, eurc, cbbtc. Wait ~6s, then verify:
|
|
31
|
+
```
|
|
32
|
+
cdp evm token-balances get base-sepolia <address>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Fund (mainnet)
|
|
36
|
+
|
|
37
|
+
Prompt user to send funds manually. Poll balance until it increases.
|
|
38
|
+
|
|
39
|
+
## Solana account
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
cdp solana accounts create name=<name>
|
|
43
|
+
```
|
|
44
|
+
Verify: `cdp solana accounts get <address>` and `cdp solana accounts by-name <name>`
|
|
45
|
+
|
|
46
|
+
### Fund
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
cdp solana faucet address=<address> token=sol
|
|
50
|
+
```
|
|
51
|
+
Faucet tokens: sol, usdc. Verify:
|
|
52
|
+
```
|
|
53
|
+
cdp solana token-balances get solana-devnet <address>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Smart account
|
|
57
|
+
|
|
58
|
+
1. Resolve or create funded EOA owner.
|
|
59
|
+
2. ```
|
|
60
|
+
cdp evm smart-accounts create 'owners:=["<ownerAddress>"]' name=<name>
|
|
61
|
+
```
|
|
62
|
+
Note: `owners` is a string array, NOT objects.
|
|
63
|
+
3. Verify: `cdp evm smart-accounts get <address>` and `cdp evm smart-accounts by-name <name>`
|
|
64
|
+
4. Fund the owner EOA if needed (smart account gas comes from owner or paymaster).
|
|
65
|
+
|
|
66
|
+
## Response fields
|
|
67
|
+
|
|
68
|
+
| Command | Address field |
|
|
69
|
+
|---------|--------------|
|
|
70
|
+
| evm accounts create | `.address` |
|
|
71
|
+
| solana accounts create | `.address` |
|
|
72
|
+
| smart-accounts create | `.address` |
|
|
73
|
+
|
|
74
|
+
## Notes
|
|
75
|
+
|
|
76
|
+
- Faucet amounts are small (~0.0001 ETH, ~0.00125 SOL) — sufficient for testing.
|
|
77
|
+
- Account names must be unique within a project, alphanumeric, 2-36 chars.
|
|
78
|
+
- Use `0.00001ether` for send values to stay under default policy thresholds.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-accounts-import-export
|
|
3
|
+
description: Exports account private keys with RSA encryption and imports external keys using CDP's encrypt-key utility. EVM and Solana.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-accounts-import-export
|
|
7
|
+
|
|
8
|
+
Export or import account private keys.
|
|
9
|
+
|
|
10
|
+
## Export
|
|
11
|
+
|
|
12
|
+
1. Generate RSA keypair:
|
|
13
|
+
```
|
|
14
|
+
openssl genpkey -algorithm RSA -out /tmp/rsa.pem -pkeyopt rsa_keygen_bits:4096 2>/dev/null
|
|
15
|
+
openssl rsa -pubout -in /tmp/rsa.pem -outform DER -out /tmp/rsa.pub.der 2>/dev/null
|
|
16
|
+
PUBKEY=$(base64 < /tmp/rsa.pub.der | tr -d '\n')
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
2. Export:
|
|
20
|
+
- EVM by address: `cdp evm accounts export <address> exportEncryptionKey=$PUBKEY`
|
|
21
|
+
- EVM by name: `cdp evm accounts export by-name <name> exportEncryptionKey=$PUBKEY`
|
|
22
|
+
- Solana by address: `cdp solana accounts export <address> exportEncryptionKey=$PUBKEY`
|
|
23
|
+
- Solana by name: `cdp solana accounts export by-name <name> exportEncryptionKey=$PUBKEY`
|
|
24
|
+
|
|
25
|
+
3. Clean up RSA files.
|
|
26
|
+
|
|
27
|
+
## Import
|
|
28
|
+
|
|
29
|
+
1. Encrypt the private key with CDP's RSA key:
|
|
30
|
+
```
|
|
31
|
+
ENCRYPTED=$(cdp util encrypt-key --file ./private-key.txt)
|
|
32
|
+
```
|
|
33
|
+
Auto-detects hex (EVM) vs base58 (Solana).
|
|
34
|
+
|
|
35
|
+
2. Import:
|
|
36
|
+
- EVM: `cdp evm accounts import encryptedPrivateKey=$ENCRYPTED name=<name>`
|
|
37
|
+
- Solana: `cdp solana accounts import encryptedPrivateKey=$ENCRYPTED name=<name>`
|
|
38
|
+
|
|
39
|
+
3. Verify: `cdp evm accounts get <importedAddress>`
|
|
40
|
+
|
|
41
|
+
## End-user import
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
cdp end-users import encryptedPrivateKey=$ENCRYPTED ...
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Notes
|
|
48
|
+
|
|
49
|
+
- Export encryption uses YOUR RSA key (you decrypt with your private key).
|
|
50
|
+
- Import encryption uses CDP's well-known RSA key (server decrypts in TEE).
|
|
51
|
+
- Test key generation: `openssl rand -hex 32` (EVM) or `cast wallet new` (Foundry).
|
|
52
|
+
|
|
53
|
+
## Compatibility
|
|
54
|
+
|
|
55
|
+
| Account type | Export | Import |
|
|
56
|
+
|-------------|--------|--------|
|
|
57
|
+
| EVM EOA | yes | yes |
|
|
58
|
+
| Solana | yes | yes |
|
|
59
|
+
| Smart account | no (contract-based) | no |
|
|
60
|
+
| End-user | no | import only |
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-accounts-send
|
|
3
|
+
description: Sends EVM and Solana transactions using the encode-sign-send pipeline. Handles native transfers, ERC-20 transfers, and contract calls.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-accounts-send
|
|
7
|
+
|
|
8
|
+
Send a transaction from a server wallet. Encode → sign → send pipeline.
|
|
9
|
+
|
|
10
|
+
## Preconditions
|
|
11
|
+
|
|
12
|
+
1. CLI configured → `/cdp-setup`
|
|
13
|
+
2. Account exists and funded → `/cdp-accounts-create`
|
|
14
|
+
3. Mainnet: confirm with user before sending.
|
|
15
|
+
|
|
16
|
+
## EVM — native transfer
|
|
17
|
+
|
|
18
|
+
1. Check balance:
|
|
19
|
+
```
|
|
20
|
+
cdp evm token-balances get <network> <from>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Encode:
|
|
24
|
+
```
|
|
25
|
+
cdp util tx-encode --network <network> --to <to> --value 0.00001ether --from <from>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
3. Decode and verify:
|
|
29
|
+
```
|
|
30
|
+
cdp util tx-decode <0x_hex>
|
|
31
|
+
```
|
|
32
|
+
Assert: `to`, `value`, `chainId` match intent.
|
|
33
|
+
|
|
34
|
+
4. Sign:
|
|
35
|
+
```
|
|
36
|
+
cdp evm accounts sign transaction <from> transaction=<tx>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
5. Send:
|
|
40
|
+
```
|
|
41
|
+
cdp evm accounts send transaction <from> network=<network> transaction=<signedTransaction>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
6. Verify balance changed:
|
|
45
|
+
```
|
|
46
|
+
cdp evm token-balances get <network> <from>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## EVM — ERC-20 transfer
|
|
50
|
+
|
|
51
|
+
Encode calldata with abi-encode:
|
|
52
|
+
```
|
|
53
|
+
DATA=$(cdp util abi-encode "transfer(address,uint256)" <recipient> <amount_atomic>)
|
|
54
|
+
```
|
|
55
|
+
Then send with `to=<token_contract>`, `data=$DATA`, `value=0`.
|
|
56
|
+
|
|
57
|
+
## EVM — contract call with approval
|
|
58
|
+
|
|
59
|
+
For Permit2 or other approvals:
|
|
60
|
+
```
|
|
61
|
+
APPROVE_DATA=$(cdp util abi-encode "approve(address,uint256)" <spender> 115792089237316195423570985008687907853269984665640564039457584007913129639935)
|
|
62
|
+
```
|
|
63
|
+
Send with `to=<token_contract>`, `data=$APPROVE_DATA`, `value=0`.
|
|
64
|
+
|
|
65
|
+
## Solana — SOL transfer
|
|
66
|
+
|
|
67
|
+
1. Encode:
|
|
68
|
+
```
|
|
69
|
+
cdp util tx-encode --network solana-devnet --to <to> --value <lamports> --from <from>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. Sign:
|
|
73
|
+
```
|
|
74
|
+
cdp solana accounts sign transaction <from> transaction=<base64>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
3. Send:
|
|
78
|
+
```
|
|
79
|
+
cdp solana accounts send transaction network=solana-devnet transaction=<signedTransaction>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
4. Verify:
|
|
83
|
+
```
|
|
84
|
+
cdp solana token-balances get solana-devnet <from>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
If `InsufficientFundsForRent` → reduce amount.
|
|
88
|
+
|
|
89
|
+
## Solana — SPL token transfer
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
cdp util tx-encode --network solana-devnet --to <recipient> --value <atomic_units> --from <sender> --token <mint_address>
|
|
93
|
+
```
|
|
94
|
+
Value is in atomic token units (e.g., 1000000 for 1 USDC with 6 decimals).
|
|
95
|
+
|
|
96
|
+
Then sign and send as above.
|
|
97
|
+
|
|
98
|
+
## Notes
|
|
99
|
+
|
|
100
|
+
- Use `0.00001ether` (not `0.0001ether`) for test sends — stays under default policy threshold of 50000000000000 wei.
|
|
101
|
+
- Smart accounts cannot use encode→sign→send. Use `cdp evm smart-accounts user-operations prepare-and-send` instead.
|
|
102
|
+
- Always verify balance after send to confirm the transaction landed.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-accounts-sign
|
|
3
|
+
description: Signs messages, hashes, typed data (EIP-712), and transactions with CDP server wallet accounts. Covers EVM and Solana signing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-accounts-sign
|
|
7
|
+
|
|
8
|
+
Sign data with a server wallet account.
|
|
9
|
+
|
|
10
|
+
## EVM — sign message (EIP-191)
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
cdp evm accounts sign message <address> message="<message>"
|
|
14
|
+
```
|
|
15
|
+
Response: `.signature`
|
|
16
|
+
|
|
17
|
+
## EVM — sign hash
|
|
18
|
+
|
|
19
|
+
`hash` must be exactly 64 hex characters after the `0x` prefix (32 bytes).
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
cdp evm accounts sign <address> hash=<0x + 64 hex chars>
|
|
23
|
+
```
|
|
24
|
+
Response: `.signature`
|
|
25
|
+
|
|
26
|
+
## EVM — sign typed data (EIP-712)
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
cdp evm accounts sign typed-data <address> primaryType=<type> \
|
|
30
|
+
'types:={"EIP712Domain":[...],"<type>":[...]}' \
|
|
31
|
+
'message:={...}' \
|
|
32
|
+
'domain:={...}'
|
|
33
|
+
```
|
|
34
|
+
`EIP712Domain` MUST be included in `types`.
|
|
35
|
+
Response: `.signature`
|
|
36
|
+
|
|
37
|
+
## EVM — sign transaction
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
cdp evm accounts sign transaction <address> transaction=<0x_hex>
|
|
41
|
+
```
|
|
42
|
+
Response: `.signedTransaction`
|
|
43
|
+
|
|
44
|
+
## Solana — sign message
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
cdp solana accounts sign message <address> message="<message>"
|
|
48
|
+
```
|
|
49
|
+
Response: `.signature`
|
|
50
|
+
|
|
51
|
+
## Solana — sign transaction
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
cdp solana accounts sign transaction <address> transaction=<base64>
|
|
55
|
+
```
|
|
56
|
+
Response: `.signedTransaction`
|
|
57
|
+
|
|
58
|
+
## Compatibility
|
|
59
|
+
|
|
60
|
+
| Account type | message | hash | typed-data | transaction |
|
|
61
|
+
|-------------|---------|------|------------|-------------|
|
|
62
|
+
| EVM EOA | yes | yes | yes | yes |
|
|
63
|
+
| Solana | yes | no | no | yes |
|
|
64
|
+
| Smart account | no | no | no | no |
|
|
65
|
+
| End-user | no — requires CDP SDK | | | |
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-data
|
|
3
|
+
description: Queries on-chain data with CDP's SQL API, checks EVM/Solana token balances, and discovers available tables via the grammar endpoint.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-data
|
|
7
|
+
|
|
8
|
+
On-chain data queries and token balances.
|
|
9
|
+
|
|
10
|
+
## SQL queries
|
|
11
|
+
|
|
12
|
+
### Discover tables
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
cdp data query grammar
|
|
16
|
+
```
|
|
17
|
+
Returns available tables, columns, and SQL dialect.
|
|
18
|
+
|
|
19
|
+
### Run query
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
cdp data query run 'sql=SELECT block_number, timestamp FROM base.blocks LIMIT 5'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Tables are namespaced by network (e.g., `base.blocks`, `base.transactions`, `ethereum.blocks`).
|
|
26
|
+
|
|
27
|
+
## Token balances
|
|
28
|
+
|
|
29
|
+
### EVM
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
cdp evm token-balances get <network> <address>
|
|
33
|
+
```
|
|
34
|
+
Also available via data group:
|
|
35
|
+
```
|
|
36
|
+
cdp data evm token-balances <network> <address>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Token ownership (EVM)
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
cdp data evm token-ownership <network> <address>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Solana
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
cdp solana token-balances get <network> <address>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Webhooks
|
|
52
|
+
|
|
53
|
+
### Create subscription
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
cdp data webhooks subscriptions create target.url=<url> 'eventTypes:=["wallet.activity.detected"]' 'isEnabled:=true' 'labels:={"params.to":"<address>"}'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
- `wallet.activity.detected` requires `labels` with `params.to` or `params.from` — omitting labels returns a 400 error.
|
|
60
|
+
|
|
61
|
+
### Update subscription
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
cdp data webhooks subscriptions update <id> 'eventTypes:=["wallet.activity.detected"]' 'isEnabled:=false' target.url=<url> 'labels:={"params.to":"<address>"}'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- `update` requires ALL fields (eventTypes, target, isEnabled), not just changed fields — it's a full replace. Omitting any field causes an error.
|
|
68
|
+
|
|
69
|
+
### Delete subscription
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
cdp data webhooks subscriptions delete <id>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Notes
|
|
76
|
+
|
|
77
|
+
- Both `cdp evm token-balances` and `cdp data evm token-balances` return the same data.
|
|
78
|
+
- Use token balances to verify mutations (funding, sends, swaps).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-end-users
|
|
3
|
+
description: Creates end-user embedded wallets with email authentication and adds EVM, Solana, or smart account sub-accounts to them.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-end-users
|
|
7
|
+
|
|
8
|
+
End-user CRUD and sub-account management.
|
|
9
|
+
|
|
10
|
+
## Create end user
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
cdp end-users create \
|
|
14
|
+
'authenticationMethods:=[{"type":"email","email":"<email>"}]' userId=<userId>
|
|
15
|
+
```
|
|
16
|
+
If `already_exists` → email in use, try different email.
|
|
17
|
+
|
|
18
|
+
Verify: `cdp end-users get <userId>`
|
|
19
|
+
|
|
20
|
+
## Add sub-accounts
|
|
21
|
+
|
|
22
|
+
### EVM
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
cdp end-users evm <userId> 'createSmartAccount:=false'
|
|
26
|
+
```
|
|
27
|
+
Response: `.evmAccount.address`
|
|
28
|
+
|
|
29
|
+
### Solana
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
cdp end-users solana <userId>
|
|
33
|
+
```
|
|
34
|
+
Response: `.solanaAccount.address`
|
|
35
|
+
|
|
36
|
+
### Smart account
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
cdp end-users evm-smart-account <userId> 'enableSpendPermissions:=false'
|
|
40
|
+
```
|
|
41
|
+
Response: `.evmSmartAccount.address`
|
|
42
|
+
|
|
43
|
+
## Import key for end user
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
ENCRYPTED=$(cdp util encrypt-key <privateKey>)
|
|
47
|
+
cdp end-users import encryptedPrivateKey=$ENCRYPTED ...
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## List end users
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
cdp end-users list
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Notes
|
|
57
|
+
|
|
58
|
+
- End-user accounts are in a separate namespace — `cdp evm accounts sign <endUserAddr>` returns 404.
|
|
59
|
+
- End-user signing requires the CDP SDK, not the CLI.
|
|
60
|
+
- `userId` must be unique within your project.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-onramp
|
|
3
|
+
description: Creates onramp sessions for fiat-to-crypto purchases, checks user purchase limits, and manages headless orders with sandbox testing support.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-onramp
|
|
7
|
+
|
|
8
|
+
Onramp sessions, limits, and orders.
|
|
9
|
+
|
|
10
|
+
## Create session (no enrollment needed)
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
cdp onramp sessions destinationAddress=<address> destinationNetwork=base \
|
|
14
|
+
purchaseCurrency=USDC partnerUserRef=<userId>
|
|
15
|
+
```
|
|
16
|
+
Returns `.session.onrampUrl` — user opens this in browser to complete purchase.
|
|
17
|
+
|
|
18
|
+
After user completes payment, poll balance:
|
|
19
|
+
```
|
|
20
|
+
cdp evm token-balances get base <address>
|
|
21
|
+
```
|
|
22
|
+
Settlement takes 1-5 minutes.
|
|
23
|
+
|
|
24
|
+
## Check limits
|
|
25
|
+
|
|
26
|
+
Use a real phone number format (e.g., +12025551234). Test/fictitious numbers like 555-xxx are rejected.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
cdp onramp limits userIdType=phone_number userId=<phone> paymentMethodType=GUEST_CHECKOUT_APPLE_PAY
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Headless order (requires merchant enrollment)
|
|
33
|
+
|
|
34
|
+
Use `partnerUserRef=sandbox-<id>` to enable sandbox mode:
|
|
35
|
+
```
|
|
36
|
+
cdp onramp orders destinationAddress=<address> destinationNetwork=base \
|
|
37
|
+
paymentMethod=GUEST_CHECKOUT_APPLE_PAY purchaseCurrency=USDC \
|
|
38
|
+
purchaseAmount=10.000000 paymentCurrency=USD paymentAmount=10.00 \
|
|
39
|
+
email=<email> phoneNumber=<phone> \
|
|
40
|
+
phoneNumberVerifiedAt=<recent_iso> agreementAcceptedAt=<recent_iso> \
|
|
41
|
+
partnerUserRef=sandbox-e2e-<timestamp> 'isQuote:=false'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
If 403 "not authorized": extract app ID from error → contact onramp team to enroll.
|
|
45
|
+
|
|
46
|
+
Poll order status:
|
|
47
|
+
```
|
|
48
|
+
cdp onramp orders get <orderId>
|
|
49
|
+
```
|
|
50
|
+
Until `ONRAMP_TRANSACTION_STATUS_SUCCESS` or terminal.
|
|
51
|
+
|
|
52
|
+
Verify funds:
|
|
53
|
+
```
|
|
54
|
+
cdp evm token-balances get base <address>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Notes
|
|
58
|
+
|
|
59
|
+
- Sessions and limits work without merchant enrollment.
|
|
60
|
+
- Headless orders require enrollment and payment completion (sandbox: Apple Pay always succeeds, card 4242 4242 4242 4242).
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cdp-policies
|
|
3
|
+
description: Creates transaction policies with accept/reject rules, attaches them to accounts, and tests enforcement. Supports value, address, and network criteria.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# cdp-policies
|
|
7
|
+
|
|
8
|
+
Policy CRUD and enforcement testing.
|
|
9
|
+
|
|
10
|
+
## Create policy
|
|
11
|
+
|
|
12
|
+
MUST include both accept AND reject rules (default when no rule matches is deny):
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
cdp policy-engine policies create scope=account \
|
|
16
|
+
'rules:=[
|
|
17
|
+
{"action":"accept","operation":"sendEvmTransaction","criteria":[{"type":"ethValue","ethValue":"50000000000000","operator":"<"}]},
|
|
18
|
+
{"action":"reject","operation":"sendEvmTransaction","criteria":[{"type":"ethValue","ethValue":"50000000000000","operator":">="}]}
|
|
19
|
+
]'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Project-scoped policy
|
|
23
|
+
|
|
24
|
+
Only one project-level policy can exist at a time. Applies to all accounts.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
cdp policy-engine policies create scope=project \
|
|
28
|
+
'rules:=[{"action":"accept","operation":"sendEvmTransaction","criteria":[{"type":"ethValue","ethValue":"100000000000000","operator":"<"}]}]'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Attach to account
|
|
32
|
+
|
|
33
|
+
On create: `cdp evm accounts create name=<name> accountPolicy=<policyId>`
|
|
34
|
+
On existing: `cdp evm accounts update <address> accountPolicy=<policyId>`
|
|
35
|
+
|
|
36
|
+
Verify attachment: `cdp evm accounts get <address>` — check `accountPolicy` field.
|
|
37
|
+
|
|
38
|
+
## Test enforcement
|
|
39
|
+
|
|
40
|
+
1. Fund the account → `/cdp-accounts-create`
|
|
41
|
+
2. Under threshold (should PASS):
|
|
42
|
+
Send `0.00001ether` via `/cdp-accounts-send` → assert `transactionHash` returned.
|
|
43
|
+
3. At/over threshold (should REJECT):
|
|
44
|
+
Send `0.0001ether` via `/cdp-accounts-send` → assert `policy_violation` error.
|
|
45
|
+
|
|
46
|
+
## Update policy
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
cdp policy-engine policies update <policyId> 'rules:=[...]'
|
|
50
|
+
```
|
|
51
|
+
Re-test: previously rejected value should now succeed (re-encode tx for fresh nonce).
|
|
52
|
+
|
|
53
|
+
## CRUD
|
|
54
|
+
|
|
55
|
+
- List: `cdp policy-engine policies list scope==account` (note: `==` for query param)
|
|
56
|
+
- Get: `cdp policy-engine policies get <policyId>`
|
|
57
|
+
- Delete: detach first (`cdp evm accounts update <address> accountPolicy=""`), then:
|
|
58
|
+
```
|
|
59
|
+
cdp policy-engine policies delete <policyId>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Supported operations
|
|
63
|
+
|
|
64
|
+
`signEvmTransaction`, `sendEvmTransaction`, `signEvmMessage`, `signEvmTypedData`, `signEvmHash`,
|
|
65
|
+
`signSolTransaction`, `sendSolTransaction`, `signSolMessage`,
|
|
66
|
+
`prepareUserOperation`, `sendUserOperation`,
|
|
67
|
+
`signEndUserEvmTransaction`, `sendEndUserEvmTransaction` (and Solana equivalents)
|
|
68
|
+
|
|
69
|
+
## Criteria types
|
|
70
|
+
|
|
71
|
+
`ethValue` (operators: `<`, `<=`, `>`, `>=`, `==`), `evmAddress` (`in`, `notIn`),
|
|
72
|
+
`evmNetwork`, `evmData` (`startsWith`, `equals`), `netUSDChange`,
|
|
73
|
+
`solValue`, `solAddress`, `solNetwork`, `solData`, `programId`, `splAddress`, `splValue`,
|
|
74
|
+
`evmMessage`, `solMessage`
|
|
75
|
+
|
|
76
|
+
## Notes
|
|
77
|
+
|
|
78
|
+
- Rules are chain-specific: `ethValue` on `sendSolTransaction` will not match.
|
|
79
|
+
- Default threshold of 50000000000000 wei = 0.00005 ETH. Use `0.00001ether` for passing sends.
|