n8n-nodes-coinbase-cdp-agentkit 0.1.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.
Files changed (98) hide show
  1. package/README.md +703 -0
  2. package/dist/credentials/CoinbaseCdpApi.credentials.d.ts +8 -0
  3. package/dist/credentials/CoinbaseCdpApi.credentials.d.ts.map +1 -0
  4. package/dist/credentials/CoinbaseCdpApi.credentials.js +37 -0
  5. package/dist/credentials/CoinbaseCdpApi.credentials.js.map +1 -0
  6. package/dist/icons/coinbase.svg +4 -0
  7. package/dist/nodes/CoinbaseAgentTool/CoinbaseAgentTool.node.d.ts +6 -0
  8. package/dist/nodes/CoinbaseAgentTool/CoinbaseAgentTool.node.d.ts.map +1 -0
  9. package/dist/nodes/CoinbaseAgentTool/CoinbaseAgentTool.node.js +110 -0
  10. package/dist/nodes/CoinbaseAgentTool/CoinbaseAgentTool.node.js.map +1 -0
  11. package/dist/nodes/CoinbaseAgentTool/CoinbaseAgentTool.node.json +17 -0
  12. package/dist/nodes/CoinbaseAgentTool/actions/erc20Balance.d.ts +3 -0
  13. package/dist/nodes/CoinbaseAgentTool/actions/erc20Balance.d.ts.map +1 -0
  14. package/dist/nodes/CoinbaseAgentTool/actions/erc20Balance.js +46 -0
  15. package/dist/nodes/CoinbaseAgentTool/actions/erc20Balance.js.map +1 -0
  16. package/dist/nodes/CoinbaseAgentTool/actions/erc20Transfer.d.ts +3 -0
  17. package/dist/nodes/CoinbaseAgentTool/actions/erc20Transfer.d.ts.map +1 -0
  18. package/dist/nodes/CoinbaseAgentTool/actions/erc20Transfer.js +44 -0
  19. package/dist/nodes/CoinbaseAgentTool/actions/erc20Transfer.js.map +1 -0
  20. package/dist/nodes/CoinbaseAgentTool/actions/getSwapPrice.d.ts +3 -0
  21. package/dist/nodes/CoinbaseAgentTool/actions/getSwapPrice.d.ts.map +1 -0
  22. package/dist/nodes/CoinbaseAgentTool/actions/getSwapPrice.js +57 -0
  23. package/dist/nodes/CoinbaseAgentTool/actions/getSwapPrice.js.map +1 -0
  24. package/dist/nodes/CoinbaseAgentTool/actions/nativeTransfer.d.ts +3 -0
  25. package/dist/nodes/CoinbaseAgentTool/actions/nativeTransfer.d.ts.map +1 -0
  26. package/dist/nodes/CoinbaseAgentTool/actions/nativeTransfer.js +41 -0
  27. package/dist/nodes/CoinbaseAgentTool/actions/nativeTransfer.js.map +1 -0
  28. package/dist/nodes/CoinbaseAgentTool/actions/requestFaucet.d.ts +3 -0
  29. package/dist/nodes/CoinbaseAgentTool/actions/requestFaucet.d.ts.map +1 -0
  30. package/dist/nodes/CoinbaseAgentTool/actions/requestFaucet.js +50 -0
  31. package/dist/nodes/CoinbaseAgentTool/actions/requestFaucet.js.map +1 -0
  32. package/dist/nodes/CoinbaseAgentTool/actions/swap.d.ts +3 -0
  33. package/dist/nodes/CoinbaseAgentTool/actions/swap.d.ts.map +1 -0
  34. package/dist/nodes/CoinbaseAgentTool/actions/swap.js +49 -0
  35. package/dist/nodes/CoinbaseAgentTool/actions/swap.js.map +1 -0
  36. package/dist/nodes/CoinbaseAgentTool/actions/walletDetails.d.ts +3 -0
  37. package/dist/nodes/CoinbaseAgentTool/actions/walletDetails.d.ts.map +1 -0
  38. package/dist/nodes/CoinbaseAgentTool/actions/walletDetails.js +25 -0
  39. package/dist/nodes/CoinbaseAgentTool/actions/walletDetails.js.map +1 -0
  40. package/dist/nodes/CoinbaseAgentTool/coinbase.svg +4 -0
  41. package/dist/nodes/CoinbaseCdp/CoinbaseCdp.node.d.ts +6 -0
  42. package/dist/nodes/CoinbaseCdp/CoinbaseCdp.node.d.ts.map +1 -0
  43. package/dist/nodes/CoinbaseCdp/CoinbaseCdp.node.js +97 -0
  44. package/dist/nodes/CoinbaseCdp/CoinbaseCdp.node.js.map +1 -0
  45. package/dist/nodes/CoinbaseCdp/CoinbaseCdp.node.json +17 -0
  46. package/dist/nodes/CoinbaseCdp/coinbase.svg +4 -0
  47. package/dist/nodes/CoinbaseCdp/resources/account.d.ts +29 -0
  48. package/dist/nodes/CoinbaseCdp/resources/account.d.ts.map +1 -0
  49. package/dist/nodes/CoinbaseCdp/resources/account.js +119 -0
  50. package/dist/nodes/CoinbaseCdp/resources/account.js.map +1 -0
  51. package/dist/nodes/CoinbaseCdp/resources/balance.d.ts +12 -0
  52. package/dist/nodes/CoinbaseCdp/resources/balance.d.ts.map +1 -0
  53. package/dist/nodes/CoinbaseCdp/resources/balance.js +60 -0
  54. package/dist/nodes/CoinbaseCdp/resources/balance.js.map +1 -0
  55. package/dist/nodes/CoinbaseCdp/resources/policy.d.ts +13 -0
  56. package/dist/nodes/CoinbaseCdp/resources/policy.d.ts.map +1 -0
  57. package/dist/nodes/CoinbaseCdp/resources/policy.js +95 -0
  58. package/dist/nodes/CoinbaseCdp/resources/policy.js.map +1 -0
  59. package/dist/nodes/CoinbaseCdp/resources/smartAccount.d.ts +10 -0
  60. package/dist/nodes/CoinbaseCdp/resources/smartAccount.d.ts.map +1 -0
  61. package/dist/nodes/CoinbaseCdp/resources/smartAccount.js +56 -0
  62. package/dist/nodes/CoinbaseCdp/resources/smartAccount.js.map +1 -0
  63. package/dist/nodes/CoinbaseCdp/resources/solanaAccount.d.ts +17 -0
  64. package/dist/nodes/CoinbaseCdp/resources/solanaAccount.d.ts.map +1 -0
  65. package/dist/nodes/CoinbaseCdp/resources/solanaAccount.js +75 -0
  66. package/dist/nodes/CoinbaseCdp/resources/solanaAccount.js.map +1 -0
  67. package/dist/nodes/CoinbaseCdp/resources/swap.d.ts +32 -0
  68. package/dist/nodes/CoinbaseCdp/resources/swap.d.ts.map +1 -0
  69. package/dist/nodes/CoinbaseCdp/resources/swap.js +124 -0
  70. package/dist/nodes/CoinbaseCdp/resources/swap.js.map +1 -0
  71. package/dist/nodes/CoinbaseCdp/resources/transfer.d.ts +12 -0
  72. package/dist/nodes/CoinbaseCdp/resources/transfer.d.ts.map +1 -0
  73. package/dist/nodes/CoinbaseCdp/resources/transfer.js +116 -0
  74. package/dist/nodes/CoinbaseCdp/resources/transfer.js.map +1 -0
  75. package/dist/nodes/CoinbaseTrigger/CoinbaseTrigger.node.d.ts +6 -0
  76. package/dist/nodes/CoinbaseTrigger/CoinbaseTrigger.node.d.ts.map +1 -0
  77. package/dist/nodes/CoinbaseTrigger/CoinbaseTrigger.node.js +106 -0
  78. package/dist/nodes/CoinbaseTrigger/CoinbaseTrigger.node.js.map +1 -0
  79. package/dist/nodes/CoinbaseTrigger/CoinbaseTrigger.node.json +17 -0
  80. package/dist/nodes/CoinbaseTrigger/coinbase.svg +4 -0
  81. package/dist/shared/cdpClientFactory.d.ts +6 -0
  82. package/dist/shared/cdpClientFactory.d.ts.map +1 -0
  83. package/dist/shared/cdpClientFactory.js +13 -0
  84. package/dist/shared/cdpClientFactory.js.map +1 -0
  85. package/dist/shared/networkOptions.d.ts +7 -0
  86. package/dist/shared/networkOptions.d.ts.map +1 -0
  87. package/dist/shared/networkOptions.js +36 -0
  88. package/dist/shared/networkOptions.js.map +1 -0
  89. package/dist/shared/toolFactory.d.ts +10 -0
  90. package/dist/shared/toolFactory.d.ts.map +1 -0
  91. package/dist/shared/toolFactory.js +21 -0
  92. package/dist/shared/toolFactory.js.map +1 -0
  93. package/dist/shared/types.d.ts +34 -0
  94. package/dist/shared/types.d.ts.map +1 -0
  95. package/dist/shared/types.js +3 -0
  96. package/dist/shared/types.js.map +1 -0
  97. package/dist/src/icons/coinbase.svg +4 -0
  98. package/package.json +78 -0
package/README.md ADDED
@@ -0,0 +1,703 @@
1
+ # n8n-nodes-coinbase-cdp
2
+
3
+ n8n community node package for [Coinbase Developer Platform (CDP)](https://docs.cdp.coinbase.com/). Create wallets, transfer tokens, swap assets, and build AI-powered blockchain agents — all from n8n workflows.
4
+
5
+ > **First AI agent + blockchain integration for any workflow automation platform.**
6
+
7
+ **3 nodes | 7 resources | 16 operations | 7 AI Agent tools | 12 networks | 100% test coverage**
8
+
9
+ [![npm](https://img.shields.io/npm/v/n8n-nodes-coinbase-cdp)](https://www.npmjs.com/package/n8n-nodes-coinbase-cdp)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
11
+
12
+ ---
13
+
14
+ ## Table of Contents
15
+
16
+ - [Architecture](#architecture)
17
+ - [Installation](#installation)
18
+ - [Credentials](#credentials)
19
+ - [Nodes](#nodes)
20
+ - [Coinbase CDP (Action Node)](#coinbase-cdp-action-node)
21
+ - [Coinbase CDP Tool (AI Agent)](#coinbase-cdp-tool-ai-agent)
22
+ - [Coinbase CDP Trigger](#coinbase-cdp-trigger)
23
+ - [Supported Networks](#supported-networks)
24
+ - [Example Workflows](#example-workflows)
25
+ - [Development](#development)
26
+ - [Design Decisions](#design-decisions)
27
+ - [Links & References](#links--references)
28
+ - [License](#license)
29
+
30
+ ---
31
+
32
+ ## Architecture
33
+
34
+ ### AgentKit-First Strategy
35
+
36
+ This package uses an **AgentKit-first** architecture: 3 focused nodes + 1 shared credential, designed to align with [Coinbase AgentKit](https://docs.cdp.coinbase.com/agent-kit/welcome) conventions while keeping the bundle lightweight by using [`@coinbase/cdp-sdk`](https://github.com/coinbase/cdp-sdk) directly.
37
+
38
+ ```mermaid
39
+ graph TB
40
+ subgraph Package["n8n-nodes-coinbase-cdp"]
41
+ subgraph Credential["CoinbaseCdpApi Credential"]
42
+ AK["API Key ID"]
43
+ AS["API Secret"]
44
+ WS["Wallet Secret<br/><i>(optional)</i>"]
45
+ end
46
+
47
+ Credential -->|shared auth| AT["CoinbaseAgentTool<br/><b>AI Tool Node</b><br/>supplyData → 7 tools"]
48
+ Credential -->|shared auth| CD["CoinbaseCdp<br/><b>Action Node</b><br/>execute → 7 resources"]
49
+ Credential -->|shared auth| CT["CoinbaseTrigger<br/><b>Polling Trigger</b><br/>poll → balance changes"]
50
+
51
+ subgraph Shared["Shared Layer"]
52
+ CF["cdpClientFactory"]
53
+ NO["networkOptions"]
54
+ TF["toolFactory"]
55
+ TY["types"]
56
+ end
57
+
58
+ AT --> Shared
59
+ CD --> Shared
60
+ CT --> Shared
61
+ end
62
+
63
+ Shared -->|initializes| SDK["@coinbase/cdp-sdk"]
64
+ AT -->|creates| LC["DynamicStructuredTool<br/><i>@langchain/core</i>"]
65
+ TF -->|validates with| ZD["Zod Schemas"]
66
+ ```
67
+
68
+ ### Data Flow Between Nodes
69
+
70
+ ```mermaid
71
+ flowchart LR
72
+ subgraph Inputs
73
+ MT["Manual Trigger"]
74
+ CH["Chat Trigger"]
75
+ SC["Schedule / Cron"]
76
+ end
77
+
78
+ subgraph Processing
79
+ AI["AI Agent<br/><i>Claude / GPT</i>"]
80
+ CDP["Coinbase CDP<br/><i>Action Node</i>"]
81
+ TRG["Coinbase Trigger<br/><i>Balance Monitor</i>"]
82
+ end
83
+
84
+ subgraph Tools["AI Tools (supplyData)"]
85
+ T1["Wallet Details"]
86
+ T2["Native Transfer"]
87
+ T3["ERC-20 Transfer"]
88
+ T4["Get Balance"]
89
+ T5["Swap Tokens"]
90
+ T6["Get Swap Price"]
91
+ T7["Request Faucet"]
92
+ end
93
+
94
+ MT --> CDP
95
+ CH --> AI
96
+ SC --> TRG
97
+
98
+ AI -.->|tool calls| T1 & T2 & T3 & T4 & T5 & T6 & T7
99
+ T1 & T2 & T3 & T4 & T5 & T6 & T7 -.->|results| AI
100
+
101
+ CDP --> |json output| Next["Next Node"]
102
+ AI --> |chat response| Resp["Chat Response"]
103
+ TRG --> |balance change event| Alert["Alert / Notification"]
104
+ ```
105
+
106
+ ### Source File Map
107
+
108
+ ```mermaid
109
+ graph TD
110
+ subgraph src["src/"]
111
+ subgraph cred["credentials/"]
112
+ C1["CoinbaseCdpApi.credentials.ts<br/><i>3-field credential type</i>"]
113
+ end
114
+ subgraph icons["icons/"]
115
+ I1["coinbase.svg"]
116
+ end
117
+ subgraph nodes["nodes/"]
118
+ subgraph agent["CoinbaseAgentTool/"]
119
+ A1["CoinbaseAgentTool.node.ts<br/><i>supplyData method</i>"]
120
+ A2["CoinbaseAgentTool.node.json<br/><i>AI codex metadata</i>"]
121
+ subgraph actions["actions/"]
122
+ AA1["walletDetails.ts"]
123
+ AA2["nativeTransfer.ts"]
124
+ AA3["erc20Transfer.ts"]
125
+ AA4["erc20Balance.ts"]
126
+ AA5["swap.ts"]
127
+ AA6["getSwapPrice.ts"]
128
+ AA7["requestFaucet.ts"]
129
+ end
130
+ end
131
+ subgraph cdp["CoinbaseCdp/"]
132
+ B1["CoinbaseCdp.node.ts<br/><i>execute method, usableAsTool</i>"]
133
+ B2["CoinbaseCdp.node.json"]
134
+ subgraph resources["resources/"]
135
+ R1["account.ts"]
136
+ R2["solanaAccount.ts"]
137
+ R3["smartAccount.ts"]
138
+ R4["transfer.ts"]
139
+ R5["swap.ts"]
140
+ R6["policy.ts"]
141
+ R7["balance.ts"]
142
+ end
143
+ end
144
+ subgraph trigger["CoinbaseTrigger/"]
145
+ D1["CoinbaseTrigger.node.ts<br/><i>poll method</i>"]
146
+ D2["CoinbaseTrigger.node.json"]
147
+ end
148
+ end
149
+ subgraph shared["shared/"]
150
+ S1["cdpClientFactory.ts"]
151
+ S2["networkOptions.ts"]
152
+ S3["toolFactory.ts"]
153
+ S4["types.ts"]
154
+ end
155
+ end
156
+ ```
157
+
158
+ ---
159
+
160
+ ## Installation
161
+
162
+ ### n8n Community Nodes (Recommended)
163
+
164
+ 1. Go to **Settings > Community Nodes** in your n8n instance
165
+ 2. Enter `n8n-nodes-coinbase-cdp`
166
+ 3. Click **Install**
167
+
168
+ See the [n8n community nodes installation guide](https://docs.n8n.io/integrations/community-nodes/installation/gui-install/) for details.
169
+
170
+ ### Manual Installation
171
+
172
+ ```bash
173
+ cd ~/.n8n/custom
174
+ npm install n8n-nodes-coinbase-cdp
175
+ ```
176
+
177
+ Restart n8n after installation. See [manual install docs](https://docs.n8n.io/integrations/community-nodes/installation/manual-install/).
178
+
179
+ ---
180
+
181
+ ## Credentials
182
+
183
+ You need a **Coinbase CDP API key** from the [CDP Portal](https://portal.cdp.coinbase.com/). See [CDP API Keys documentation](https://docs.cdp.coinbase.com/get-started/docs/cdp-api-keys) for details.
184
+
185
+ | Field | Required | Description |
186
+ |-------|----------|-------------|
187
+ | API Key ID | Yes | Your CDP API Key ID (UUID format) |
188
+ | API Key Secret | Yes | Your CDP API Key Secret (base64-encoded ES256 private key) |
189
+ | Wallet Secret | No | Required for signing transactions (transfers, swaps). Leave empty for read-only operations |
190
+
191
+ ### Getting Your Credentials
192
+
193
+ 1. Go to [portal.cdp.coinbase.com](https://portal.cdp.coinbase.com/)
194
+ 2. Create a new project (or use an existing one)
195
+ 3. Navigate to **API Keys** and create a new key
196
+ 4. Copy the **API Key ID** and **API Key Secret**
197
+ 5. For transaction signing, also copy the **Wallet Secret** from the key creation screen
198
+
199
+ > **Note**: The Wallet Secret is only shown once during key creation. If you lose it, you'll need to create a new API key.
200
+
201
+ ### Credential Flow
202
+
203
+ ```mermaid
204
+ sequenceDiagram
205
+ participant User
206
+ participant Portal as CDP Portal
207
+ participant n8n
208
+ participant SDK as CDP SDK
209
+
210
+ User->>Portal: Create API Key
211
+ Portal-->>User: API Key ID + Secret + Wallet Secret
212
+ User->>n8n: Configure CoinbaseCdpApi credential
213
+ n8n->>SDK: CdpClient({ apiKeyId, apiKeySecret, walletSecret })
214
+ SDK-->>n8n: Authenticated client
215
+ n8n->>SDK: Execute blockchain operations
216
+ SDK-->>n8n: Results
217
+ ```
218
+
219
+ ---
220
+
221
+ ## Nodes
222
+
223
+ ### Coinbase CDP (Action Node)
224
+
225
+ The primary node for deterministic blockchain operations. Processes items through a resource/operation pattern. Supports [`usableAsTool: true`](https://docs.n8n.io/integrations/creating-nodes/build/declarative-style-node/#usable-as-tool), so it can also be used directly as an AI Agent tool.
226
+
227
+ ```mermaid
228
+ flowchart LR
229
+ Input["Input Items"] --> Execute["execute()"]
230
+
231
+ Execute --> Router{Resource?}
232
+ Router -->|account| ACC["Account Ops"]
233
+ Router -->|solanaAccount| SOL["Solana Ops"]
234
+ Router -->|smartAccount| SMA["Smart Account"]
235
+ Router -->|transfer| TRN["Transfer Ops"]
236
+ Router -->|swap| SWP["Swap Ops"]
237
+ Router -->|policy| POL["Policy CRUD"]
238
+ Router -->|balance| BAL["Balance Query"]
239
+
240
+ ACC & SOL & SMA & TRN & SWP & POL & BAL --> SDK["CDP SDK"]
241
+ SDK --> Output["Output Items"]
242
+ ```
243
+
244
+ #### Resources & Operations
245
+
246
+ **Account** (EVM)
247
+
248
+ | Operation | Description | Key Parameters |
249
+ |-----------|-------------|----------------|
250
+ | Get or Create | Get existing or create new EVM account | `accountName` |
251
+ | List Balances | List all token balances for an address | `address`, `network` |
252
+ | Request Faucet | Request testnet tokens | `address`, `faucetNetwork`, `faucetToken` |
253
+
254
+ **Solana Account**
255
+
256
+ | Operation | Description | Key Parameters |
257
+ |-----------|-------------|----------------|
258
+ | Get or Create | Get or create a Solana account | `accountName` |
259
+ | Request Faucet | Request Solana devnet tokens | `address`, `faucetToken` |
260
+
261
+ **Smart Account**
262
+
263
+ | Operation | Description | Key Parameters |
264
+ |-----------|-------------|----------------|
265
+ | Get or Create | Create an ERC-4337 smart account | `ownerAccountName`, `smartAccountName` |
266
+
267
+ **Transfer**
268
+
269
+ | Operation | Description | Key Parameters |
270
+ |-----------|-------------|----------------|
271
+ | Send Native Token | Transfer ETH, MATIC, AVAX, etc. | `accountName`, `to`, `amount`, `network` |
272
+ | Send ERC-20 Token | Transfer USDC, DAI, or any ERC-20 | `accountName`, `to`, `amount`, `token`, `network` |
273
+
274
+ **Swap** (Base & Ethereum only)
275
+
276
+ | Operation | Description | Key Parameters |
277
+ |-----------|-------------|----------------|
278
+ | Execute Swap | Swap tokens via DEX | `accountName`, `fromToken`, `toToken`, `fromAmount`, `network` |
279
+ | Get Quote | Get swap quote without executing | `accountName`, `fromToken`, `toToken`, `fromAmount`, `network` |
280
+
281
+ **Policy** (see [CDP Policy docs](https://docs.cdp.coinbase.com/cdp-apis/docs/welcome))
282
+
283
+ | Operation | Description | Key Parameters |
284
+ |-----------|-------------|----------------|
285
+ | List | List all policies | — |
286
+ | Get | Get a policy by ID | `policyId` |
287
+ | Create | Create a new policy | `policyJson` |
288
+ | Update | Update a policy | `policyId`, `policyJson` |
289
+ | Delete | Delete a policy | `policyId` |
290
+
291
+ **Balance**
292
+
293
+ | Operation | Description | Key Parameters |
294
+ |-----------|-------------|----------------|
295
+ | List Token Balances | List all token balances for an address | `address`, `network` |
296
+
297
+ ---
298
+
299
+ ### Coinbase CDP Tool (AI Agent)
300
+
301
+ Connect blockchain operations to n8n's AI Agent node. Each tool is a [LangChain `DynamicStructuredTool`](https://v03.api.js.langchain.com/classes/_langchain_core.tools.DynamicStructuredTool.html) that an LLM can invoke autonomously. Tool names and schemas are compatible with [Coinbase AgentKit](https://docs.cdp.coinbase.com/agent-kit/welcome) conventions.
302
+
303
+ #### AI Agent Workflow
304
+
305
+ ```mermaid
306
+ flowchart TB
307
+ Chat["Chat Trigger<br/><i>User message</i>"] --> Agent["AI Agent<br/><i>Claude / GPT / Gemini</i>"]
308
+ Agent --> Response["Chat Response"]
309
+
310
+ Agent -.->|"tool call"| T1["CDP Tool:<br/>Wallet Details"]
311
+ Agent -.->|"tool call"| T2["CDP Tool:<br/>Native Transfer"]
312
+ Agent -.->|"tool call"| T3["CDP Tool:<br/>ERC-20 Transfer"]
313
+ Agent -.->|"tool call"| T4["CDP Tool:<br/>Get Balance"]
314
+ Agent -.->|"tool call"| T5["CDP Tool:<br/>Swap Tokens"]
315
+ Agent -.->|"tool call"| T6["CDP Tool:<br/>Get Swap Price"]
316
+ Agent -.->|"tool call"| T7["CDP Tool:<br/>Request Faucet"]
317
+
318
+ T1 -.->|"result"| Agent
319
+ T2 -.->|"result"| Agent
320
+ T3 -.->|"result"| Agent
321
+ T4 -.->|"result"| Agent
322
+ T5 -.->|"result"| Agent
323
+ T6 -.->|"result"| Agent
324
+ T7 -.->|"result"| Agent
325
+ ```
326
+
327
+ #### Available Tools
328
+
329
+ | Tool | LangChain Name | Zod Schema | Description |
330
+ |------|---------------|------------|-------------|
331
+ | Get Wallet Details | `get_wallet_details` | `{ name: string }` | Get or create an EVM account, return address |
332
+ | Native Transfer | `native_transfer` | `{ accountName, to, amount, network }` | Transfer ETH/native tokens to an address |
333
+ | ERC-20 Transfer | `erc20_transfer` | `{ accountName, to, amount, token, network }` | Transfer ERC-20 tokens (USDC, DAI, etc.) |
334
+ | Get Balance | `get_balance` | `{ address, token, network }` | Check token balance for any wallet address |
335
+ | Swap Tokens | `swap_tokens` | `{ accountName, fromToken, toToken, fromAmount, network }` | Swap one token for another on Base/Ethereum |
336
+ | Get Swap Price | `get_swap_price` | `{ accountName, fromToken, toToken, fromAmount, network }` | Get price quote without executing |
337
+ | Request Faucet | `request_faucet` | `{ address, token, network }` | Request testnet tokens (ETH, USDC, SOL) |
338
+
339
+ #### Tool Creation Flow
340
+
341
+ ```mermaid
342
+ sequenceDiagram
343
+ participant n8n as n8n AI Agent
344
+ participant Node as CoinbaseAgentTool
345
+ participant TF as toolFactory
346
+ participant LC as DynamicStructuredTool
347
+ participant SDK as CDP SDK
348
+
349
+ n8n->>Node: supplyData(itemIndex)
350
+ Node->>Node: getNodeParameter('tool')
351
+ Node->>Node: getCdpClient(credentials)
352
+ Node->>TF: createAgentTool({ name, schema, func })
353
+ TF->>LC: new DynamicStructuredTool({ name, schema, func })
354
+ TF-->>Node: tool instance
355
+ Node-->>n8n: { response: tool }
356
+
357
+ Note over n8n,SDK: Later, when LLM decides to call the tool:
358
+ n8n->>LC: invoke({ param1, param2 })
359
+ LC->>SDK: CDP API call
360
+ SDK-->>LC: result
361
+ LC-->>n8n: JSON string (or error string)
362
+ ```
363
+
364
+ #### AI Agent Setup
365
+
366
+ 1. Add a **Chat Trigger** node
367
+ 2. Add an **AI Agent** node with your preferred LLM (OpenAI, Anthropic, etc.)
368
+ 3. Add **Coinbase CDP Tool** nodes for each capability you want the agent to have
369
+ 4. Connect the CDP Tool nodes to the AI Agent's `ai_tool` input
370
+ 5. The LLM will decide when and how to use each tool based on the conversation
371
+
372
+ ---
373
+
374
+ ### Coinbase CDP Trigger
375
+
376
+ Polls for balance changes on any EVM address. Fires when any token balance increases, decreases, or a new token appears.
377
+
378
+ #### Polling Mechanism
379
+
380
+ ```mermaid
381
+ stateDiagram-v2
382
+ [*] --> FirstPoll: n8n scheduler triggers
383
+
384
+ FirstPoll --> StoreBaseline: Fetch balances from CDP SDK
385
+ StoreBaseline --> WaitForNext: Store in staticData, return null
386
+
387
+ WaitForNext --> SubsequentPoll: n8n scheduler triggers
388
+
389
+ SubsequentPoll --> FetchCurrent: Fetch balances from CDP SDK
390
+ FetchCurrent --> Compare: Load previous from staticData
391
+
392
+ Compare --> NoChange: Balances identical
393
+ Compare --> Changed: Differences found
394
+
395
+ NoChange --> UpdateState: Update staticData
396
+ UpdateState --> WaitForNext: Return null (no trigger)
397
+
398
+ Changed --> EmitEvents: Build change events
399
+ EmitEvents --> UpdateState2: Update staticData
400
+ UpdateState2 --> WaitForNext: Return events (trigger fires)
401
+ ```
402
+
403
+ #### Configuration
404
+
405
+ | Parameter | Description |
406
+ |-----------|-------------|
407
+ | Event | `Balance Changed` — triggers on any token balance change |
408
+ | Address | The EVM wallet address to monitor (`0x...`) |
409
+ | Network | Which network to monitor (any of the 12 supported networks) |
410
+
411
+ #### Output Format
412
+
413
+ Each trigger event contains:
414
+
415
+ ```json
416
+ {
417
+ "address": "0x1234...abcd",
418
+ "network": "base-sepolia",
419
+ "token": "ETH",
420
+ "previousBalance": "1000000000000000000",
421
+ "currentBalance": "2000000000000000000",
422
+ "timestamp": "2026-01-15T10:30:00.000Z"
423
+ }
424
+ ```
425
+
426
+ The trigger stores the last known balances in n8n's workflow static data and compares on each poll. The first poll captures a baseline without triggering.
427
+
428
+ ---
429
+
430
+ ## Supported Networks
431
+
432
+ | Network | Chain | Transfer | Swap | Faucet |
433
+ |---------|-------|:---:|:---:|:---:|
434
+ | Base | EVM | Yes | Yes | — |
435
+ | Base Sepolia | EVM | Yes | — | Yes |
436
+ | Ethereum | EVM | Yes | Yes | — |
437
+ | Ethereum Sepolia | EVM | Yes | — | Yes |
438
+ | Ethereum Holesky | EVM | Yes | — | Yes |
439
+ | Polygon | EVM | Yes | — | — |
440
+ | Arbitrum | EVM | Yes | — | — |
441
+ | Optimism | EVM | Yes | — | — |
442
+ | Avalanche C-Chain | EVM | Yes | — | — |
443
+ | BNB Chain | EVM | Yes | — | — |
444
+ | Solana Mainnet | Solana | Yes | — | — |
445
+ | Solana Devnet | Solana | Yes | — | Yes |
446
+
447
+ See the [CDP SDK documentation](https://docs.cdp.coinbase.com/get-started/docs/use-sdks) for the latest network support.
448
+
449
+ ---
450
+
451
+ ## Example Workflows
452
+
453
+ Import these from the `examples/` directory into your n8n instance.
454
+
455
+ ### 1. Account & Balance Check
456
+
457
+ ```mermaid
458
+ flowchart LR
459
+ A["Manual Trigger"] --> B["Get/Create Account<br/><i>account.getOrCreate</i>"]
460
+ B --> C["Check Balance<br/><i>balance.listTokens</i>"]
461
+ ```
462
+
463
+ Create an EVM account on Base Sepolia and query its token balances.
464
+
465
+ ### 2. Faucet & Transfer
466
+
467
+ ```mermaid
468
+ flowchart LR
469
+ A["Manual Trigger"] --> B["Create Sender<br/><i>account.getOrCreate</i>"]
470
+ B --> C["Request Faucet ETH<br/><i>account.requestFaucet</i>"]
471
+ C --> D["Check Balance<br/><i>balance.listTokens</i>"]
472
+ ```
473
+
474
+ Request testnet ETH from the faucet and verify receipt.
475
+
476
+ ### 3. Swap Tokens
477
+
478
+ ```mermaid
479
+ flowchart LR
480
+ A["Manual Trigger"] --> B["Get Account"]
481
+ B --> C["Get Swap Quote<br/><i>WETH → USDC</i>"]
482
+ C --> D{"Liquidity<br/>Available?"}
483
+ D -->|Yes| E["Execute Swap"]
484
+ D -->|No| F["Stop"]
485
+ ```
486
+
487
+ Quote a WETH→USDC swap on Base, check liquidity, execute if available.
488
+
489
+ ### 4. AI Agent Blockchain
490
+
491
+ ```mermaid
492
+ flowchart TB
493
+ A["Chat Trigger"] --> B["AI Agent<br/><i>Claude / GPT</i>"]
494
+ B --> C["Chat Response"]
495
+ B -.->|tools| D["Wallet Details"]
496
+ B -.->|tools| E["Get Balance"]
497
+ B -.->|tools| F["Native Transfer"]
498
+ B -.->|tools| G["Request Faucet"]
499
+ ```
500
+
501
+ Chat-driven blockchain operations via LLM tool calling.
502
+
503
+ ### 5. Balance Monitor
504
+
505
+ ```mermaid
506
+ flowchart LR
507
+ A["CoinbaseTrigger<br/><i>polls every 5min</i>"] --> B{"Is ETH?"}
508
+ B -->|Yes| C["Format Alert"]
509
+ C --> D["Send Notification<br/><i>Slack / Email</i>"]
510
+ B -->|No| E["Skip"]
511
+ ```
512
+
513
+ Event-driven balance monitoring with configurable alerts.
514
+
515
+ ### 6. Multi-Chain Accounts
516
+
517
+ ```mermaid
518
+ flowchart TB
519
+ A["Manual Trigger"] --> B["EVM Account<br/><i>base-sepolia</i>"]
520
+ A --> C["Solana Account<br/><i>solana-devnet</i>"]
521
+ B --> D["EVM Faucet"]
522
+ C --> E["Solana Faucet"]
523
+ E --> F["Smart Account<br/><i>ERC-4337</i>"]
524
+ ```
525
+
526
+ Parallel account creation across EVM and Solana with testnet funding.
527
+
528
+ ### 7. Policy Management
529
+
530
+ ```mermaid
531
+ flowchart LR
532
+ A["Manual Trigger"] --> B["List All Policies<br/><i>policy.list</i>"]
533
+ ```
534
+
535
+ Query CDP governance policies for the organization.
536
+
537
+ ---
538
+
539
+ ## Development
540
+
541
+ ### Prerequisites
542
+
543
+ - Node.js 22+ (required by [`@coinbase/cdp-sdk`](https://github.com/coinbase/cdp-sdk))
544
+ - npm
545
+
546
+ ### Setup
547
+
548
+ ```bash
549
+ git clone https://github.com/pvdyck/n8n-nodes-coinbase-cdp
550
+ cd n8n-nodes-coinbase-cdp
551
+ npm install
552
+ ```
553
+
554
+ ### Development Server
555
+
556
+ ```bash
557
+ npm run dev
558
+ ```
559
+
560
+ Uses [`@n8n/node-cli`](https://www.npmjs.com/package/@n8n/node-cli) to symlink the package into n8n's custom extensions, run the TypeScript compiler in watch mode, and start n8n with hot reload. Open `http://localhost:5678` to access the editor.
561
+
562
+ ### Scripts
563
+
564
+ | Command | Description |
565
+ |---------|-------------|
566
+ | `npm run build` | Compile TypeScript + copy icons (`tsc && gulp build:icons`) |
567
+ | `npm test` | Run all 116 unit tests |
568
+ | `npm run test:coverage` | Run with coverage report (100% across all metrics) |
569
+ | `npm run test:watch` | Run in watch mode |
570
+ | `npm run test:e2e` | Run E2E workflows against live n8n (requires `.env` + running n8n) |
571
+ | `npm run test:all` | Unit tests + E2E combined |
572
+ | `npm run lint` | ESLint check |
573
+ | `npm run lint:fix` | ESLint auto-fix |
574
+
575
+ ### Environment Variables
576
+
577
+ Copy `.env.example` to `.env` for E2E testing:
578
+
579
+ ```bash
580
+ cp .env.example .env
581
+ ```
582
+
583
+ ```
584
+ CDP_API_KEY_ID=your-key-id
585
+ CDP_API_KEY_SECRET=your-key-secret
586
+ CDP_WALLET_SECRET=your-wallet-secret
587
+ ```
588
+
589
+ ### Test Coverage
590
+
591
+ 116 tests across 8 suites with **100% coverage** on all metrics:
592
+
593
+ ```
594
+ ---------------------------------|---------|----------|---------|---------|
595
+ File | % Stmts | % Branch | % Funcs | % Lines |
596
+ ---------------------------------|---------|----------|---------|---------|
597
+ All files | 100 | 100 | 100 | 100 |
598
+ ---------------------------------|---------|----------|---------|---------|
599
+ ```
600
+
601
+ | Suite | Tests | Covers |
602
+ |-------|:-----:|--------|
603
+ | CoinbaseAgentTool.test.ts | 30 | All 7 AI tool actions, error handling, edge cases |
604
+ | CoinbaseAgentToolNode.test.ts | 10 | `supplyData` integration, tool invocation, metadata |
605
+ | CoinbaseCdp.test.ts | 35 | All 7 resource operations, error branches, fallbacks |
606
+ | CoinbaseCdpNode.test.ts | 15 | `execute()`, `continueOnFail`, multi-item, unknown resource |
607
+ | CoinbaseTrigger.test.ts | 14 | Polling, balance change detection, null fallbacks |
608
+ | toolFactory.test.ts | 4 | Error wrapper (Error, string, object throws) |
609
+ | cdpClientFactory.test.ts | 3 | Client creation with/without walletSecret |
610
+ | credentials.test.ts | 5 | Credential metadata validation |
611
+
612
+ ### E2E Tests
613
+
614
+ Run against a live n8n instance with real CDP credentials:
615
+
616
+ | Workflow | Result | What it validates |
617
+ |----------|:------:|---|
618
+ | account-and-balance | PASS | Account creation + balance query on Base Sepolia |
619
+ | faucet-and-transfer | PASS | Faucet request + balance verification |
620
+ | multi-chain-accounts | PASS | Parallel EVM + Solana account creation |
621
+ | policy-management | PASS | Policy listing via CDP API |
622
+ | ai-agent-blockchain | VALID | Structure validation (needs AI model) |
623
+ | balance-monitor | VALID | Structure validation (needs trigger activation) |
624
+ | swap-tokens | VALID | Structure validation (needs funded wallet) |
625
+
626
+ ---
627
+
628
+ ## Design Decisions
629
+
630
+ ### AgentKit-Compatible Without the Dependency
631
+
632
+ Tool names (`get_wallet_details`, `native_transfer`, etc.) and schemas match [Coinbase AgentKit](https://github.com/coinbase/agentkit) conventions, but we use [`@coinbase/cdp-sdk`](https://github.com/coinbase/cdp-sdk) directly. This gives a 10x lighter bundle while staying compatible with AgentKit tutorials and documentation.
633
+
634
+ ### Triple-Pathway Usage via `usableAsTool`
635
+
636
+ The `CoinbaseCdp` action node sets `usableAsTool: true`, enabling three usage modes:
637
+
638
+ ```mermaid
639
+ flowchart TB
640
+ Node["CoinbaseCdp Node"]
641
+
642
+ Node -->|"1. Direct"| D["Trigger → CoinbaseCdp → Next Node<br/><i>Resource/operation UI</i>"]
643
+ Node -->|"2. AI Tool"| A["AI Agent ─ tools ─► CoinbaseCdp<br/><i>LLM selects operation</i>"]
644
+ Node -->|"3. Expression"| E["$('CoinbaseCdp').item.json.address<br/><i>Reference in other nodes</i>"]
645
+ ```
646
+
647
+ ### Error-Safe Agent Tools
648
+
649
+ The [`toolFactory`](src/shared/toolFactory.ts) wraps every tool function in try/catch, returning error messages as strings instead of throwing. This allows the LLM to recover gracefully and try alternative approaches.
650
+
651
+ ### Polling Trigger with Static Data
652
+
653
+ n8n supports polling natively. The [`@coinbase/cdp-sdk`](https://github.com/coinbase/cdp-sdk) doesn't expose WebSocket balance streams, so polling with n8n's `getWorkflowStaticData('node')` persistence is the pragmatic choice. The first poll stores a baseline; subsequent polls compare and emit change events.
654
+
655
+ ### `DynamicStructuredTool` with `any` Typed Schema
656
+
657
+ Complex Zod schemas trigger TypeScript error TS2589 (deep instantiation) in LangChain's type system. Typing the schema as `any` in the `ToolDefinition` interface avoids this while keeping runtime validation intact via Zod.
658
+
659
+ ---
660
+
661
+ ## Links & References
662
+
663
+ ### Coinbase Developer Platform
664
+
665
+ | Resource | URL |
666
+ |----------|-----|
667
+ | CDP Documentation | [docs.cdp.coinbase.com](https://docs.cdp.coinbase.com/) |
668
+ | CDP Portal (API Keys) | [portal.cdp.coinbase.com](https://portal.cdp.coinbase.com/) |
669
+ | CDP API Keys Guide | [docs.cdp.coinbase.com/get-started/docs/cdp-api-keys](https://docs.cdp.coinbase.com/get-started/docs/cdp-api-keys) |
670
+ | CDP SDK Guide | [docs.cdp.coinbase.com/get-started/docs/use-sdks](https://docs.cdp.coinbase.com/get-started/docs/use-sdks) |
671
+ | CDP API Reference | [docs.cdp.coinbase.com/cdp-apis/docs/welcome](https://docs.cdp.coinbase.com/cdp-apis/docs/welcome) |
672
+ | AgentKit Documentation | [docs.cdp.coinbase.com/agent-kit/welcome](https://docs.cdp.coinbase.com/agent-kit/welcome) |
673
+
674
+ ### GitHub Repositories
675
+
676
+ | Repository | URL |
677
+ |------------|-----|
678
+ | CDP SDK (TypeScript/Python) | [github.com/coinbase/cdp-sdk](https://github.com/coinbase/cdp-sdk) |
679
+ | AgentKit | [github.com/coinbase/agentkit](https://github.com/coinbase/agentkit) |
680
+ | This Package | [github.com/pvdyck/n8n-nodes-coinbase-cdp](https://github.com/pvdyck/n8n-nodes-coinbase-cdp) |
681
+
682
+ ### n8n
683
+
684
+ | Resource | URL |
685
+ |----------|-----|
686
+ | Community Nodes Install (GUI) | [docs.n8n.io/integrations/community-nodes/installation/gui-install](https://docs.n8n.io/integrations/community-nodes/installation/gui-install/) |
687
+ | Community Nodes Install (Manual) | [docs.n8n.io/integrations/community-nodes/installation/manual-install](https://docs.n8n.io/integrations/community-nodes/installation/manual-install/) |
688
+ | Creating Nodes Guide | [docs.n8n.io/integrations/creating-nodes](https://docs.n8n.io/integrations/creating-nodes/) |
689
+
690
+ ### Dependencies
691
+
692
+ | Package | Version | Purpose | Docs |
693
+ |---------|---------|---------|------|
694
+ | [`@coinbase/cdp-sdk`](https://www.npmjs.com/package/@coinbase/cdp-sdk) | ^1.44.0 | CDP SDK v2 — blockchain operations | [GitHub](https://github.com/coinbase/cdp-sdk) |
695
+ | [`@langchain/core`](https://www.npmjs.com/package/@langchain/core) | ^0.3.0 | `DynamicStructuredTool` for AI Agent integration | [API Docs](https://v03.api.js.langchain.com/classes/_langchain_core.tools.DynamicStructuredTool.html) |
696
+ | [`zod`](https://www.npmjs.com/package/zod) | ^3.24.0 | Schema validation for tool parameters | [zod.dev](https://zod.dev) |
697
+ | [`n8n-workflow`](https://www.npmjs.com/package/n8n-workflow) | * (peer) | n8n node interfaces | [n8n docs](https://docs.n8n.io/) |
698
+
699
+ ---
700
+
701
+ ## License
702
+
703
+ [MIT](LICENSE)