@coinbase/agentkit 0.8.2 → 0.9.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 +373 -234
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
- package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
- package/dist/action-providers/cdp/index.d.ts +0 -1
- package/dist/action-providers/cdp/index.js +0 -1
- package/dist/action-providers/cdp/schemas.d.ts +9 -70
- package/dist/action-providers/cdp/schemas.js +12 -61
- package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
- package/dist/action-providers/{cdp-v2 → cdp-legacy}/index.js +2 -1
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
- package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
- package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
- package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
- package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
- package/dist/action-providers/cdp-legacy/schemas.js +77 -0
- package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
- package/dist/action-providers/index.d.ts +1 -1
- package/dist/action-providers/index.js +1 -1
- package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
- package/dist/action-providers/x402/schemas.d.ts +58 -11
- package/dist/action-providers/x402/schemas.js +60 -8
- package/dist/action-providers/x402/x402ActionProvider.d.ts +33 -16
- package/dist/action-providers/x402/x402ActionProvider.js +203 -153
- package/dist/action-providers/x402/x402ActionProvider.test.js +78 -225
- package/dist/agentkit.d.ts +1 -0
- package/dist/agentkit.js +3 -2
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +263 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +287 -0
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/index.d.ts +6 -6
- package/dist/wallet-providers/index.js +6 -6
- package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
- package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
- package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
- package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
- package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
- package/package.json +3 -2
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
- package/dist/action-providers/cdp-v2/index.d.ts +0 -2
- package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
- package/dist/action-providers/cdp-v2/schemas.js +0 -13
- package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
- package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
- /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
- /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
- /package/dist/wallet-providers/{cdpWalletProvider.test.d.ts → cdpSmartWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpSolanaWalletProvider.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -18,14 +18,27 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
|
|
|
18
18
|
- [Adding Actions to your Action Provider that use a Wallet Provider](#adding-actions-to-your-action-provider-that-use-a-wallet-provider)
|
|
19
19
|
- [Adding an Action Provider to your AgentKit instance](#adding-an-action-provider-to-your-agentkit-instance)
|
|
20
20
|
- [EVM Wallet Providers](#evm-wallet-providers)
|
|
21
|
-
- [
|
|
22
|
-
|
|
21
|
+
- [CdpEvmWalletProvider](#cdpevmwalletprovider)
|
|
22
|
+
- [Basic Configuration](#basic-configuration)
|
|
23
|
+
- [Using an existing wallet](#using-an-existing-wallet)
|
|
24
|
+
- [Creating a new wallet](#creating-a-new-wallet)
|
|
25
|
+
- [Environment Variables](#environment-variables)
|
|
26
|
+
- [Exporting a wallet](#exporting-a-wallet)
|
|
27
|
+
- [CdpSmartWalletProvider](#cdpsmartwalletprovider)
|
|
28
|
+
- [Basic Configuration](#basic-configuration-1)
|
|
29
|
+
- [Using an Existing Smart Wallet](#using-an-existing-smart-wallet)
|
|
30
|
+
- [Specifying an Owner Account](#specifying-an-owner-account)
|
|
31
|
+
- [Creating a New Smart Wallet](#creating-a-new-smart-wallet)
|
|
32
|
+
- [Environment Variables](#environment-variables-1)
|
|
33
|
+
- [Exporting Smart Wallet Information](#exporting-smart-wallet-information)
|
|
34
|
+
- [Key Differences from Regular Wallets](#key-differences-from-regular-wallets)
|
|
35
|
+
- [LegacyCdpWalletProvider](#legacycdpwalletprovider)
|
|
23
36
|
- [Network Configuration](#network-configuration)
|
|
24
37
|
- [Configuring from an existing CDP API Wallet](#configuring-from-an-existing-cdp-api-wallet)
|
|
25
38
|
- [Configuring from a mnemonic phrase](#configuring-from-a-mnemonic-phrase)
|
|
26
39
|
- [Exporting a wallet](#exporting-a-wallet)
|
|
27
40
|
- [Importing a wallet from WalletData JSON string](#importing-a-wallet-from-walletdata-json-string)
|
|
28
|
-
- [Configuring gas parameters](#configuring-
|
|
41
|
+
- [Configuring gas parameters](#configuring-legacycdpwalletprovider-gas-parameters)
|
|
29
42
|
- [ViemWalletProvider](#viemwalletprovider)
|
|
30
43
|
- [Configuring gas parameters](#configuring-viemwalletprovider-gas-parameters)
|
|
31
44
|
- [PrivyWalletProvider](#privywalletprovider)
|
|
@@ -37,7 +50,7 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
|
|
|
37
50
|
- [Configuring from PrivyWalletProvider](#configuring-from-privywalletprovider)
|
|
38
51
|
- [Configuring from ViemWalletProvider](#configuring-from-viemwalletprovider)
|
|
39
52
|
- [SVM Wallet Providers](#svm-wallet-providers)
|
|
40
|
-
- [
|
|
53
|
+
- [CdpSolanaWalletProvider](#cdpsolanawalletprovider)
|
|
41
54
|
- [SolanaKeypairWalletProvider](#solanakeypairwalletprovider)
|
|
42
55
|
- [Network Configuration](#solana-network-configuration)
|
|
43
56
|
- [RPC URL Configuration](#rpc-url-configuration)
|
|
@@ -49,7 +62,8 @@ AgentKit is a framework for easily enabling AI agents to take actions onchain. I
|
|
|
49
62
|
|
|
50
63
|
## Getting Started
|
|
51
64
|
|
|
52
|
-
|
|
65
|
+
_Prerequisites_:
|
|
66
|
+
|
|
53
67
|
- [Node.js 18+](https://nodejs.org/en/download/)
|
|
54
68
|
- [CDP Secret API Key](https://docs.cdp.coinbase.com/get-started/docs/cdp-api-keys#creating-secret-api-keys)
|
|
55
69
|
|
|
@@ -66,7 +80,7 @@ npm install @coinbase/agentkit
|
|
|
66
80
|
```typescript
|
|
67
81
|
const agentKit = await AgentKit.from({
|
|
68
82
|
cdpApiKeyId: "CDP API KEY NAME",
|
|
69
|
-
|
|
83
|
+
cdpApiKeySecret: "CDP API KEY SECRET",
|
|
70
84
|
});
|
|
71
85
|
```
|
|
72
86
|
|
|
@@ -77,7 +91,7 @@ If no wallet or action provider are specified, the agent will use the `CdpWallet
|
|
|
77
91
|
```typescript
|
|
78
92
|
const agentKit = await AgentKit.from({
|
|
79
93
|
cdpApiKeyId: "CDP API KEY NAME",
|
|
80
|
-
|
|
94
|
+
cdpApiKeySecret: "CDP API KEY SECRET",
|
|
81
95
|
});
|
|
82
96
|
```
|
|
83
97
|
|
|
@@ -87,13 +101,13 @@ const agentKit = await AgentKit.from({
|
|
|
87
101
|
import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
88
102
|
|
|
89
103
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
apiKeyId: "CDP API KEY NAME",
|
|
105
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
106
|
+
networkId: "base-mainnet",
|
|
93
107
|
});
|
|
94
108
|
|
|
95
109
|
const agentKit = await AgentKit.from({
|
|
96
|
-
|
|
110
|
+
walletProvider,
|
|
97
111
|
});
|
|
98
112
|
```
|
|
99
113
|
|
|
@@ -103,20 +117,21 @@ const agentKit = await AgentKit.from({
|
|
|
103
117
|
import { cdpApiActionProvider, pythActionProvider } from "@coinbase/agentkit";
|
|
104
118
|
|
|
105
119
|
const agentKit = await AgentKit.from({
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
120
|
+
walletProvider,
|
|
121
|
+
actionProviders: [
|
|
122
|
+
cdpApiActionProvider({
|
|
123
|
+
apiKeyId: "CDP API KEY NAME",
|
|
124
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
125
|
+
}),
|
|
126
|
+
pythActionProvider(),
|
|
127
|
+
],
|
|
114
128
|
});
|
|
115
129
|
```
|
|
116
130
|
|
|
117
131
|
### Use the agent's actions with a framework extension. For example, using LangChain + OpenAI.
|
|
118
132
|
|
|
119
|
-
|
|
133
|
+
_Prerequisites_:
|
|
134
|
+
|
|
120
135
|
- [OpenAI API Key](https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key)
|
|
121
136
|
- Set `OPENAI_API_KEY` environment variable.
|
|
122
137
|
|
|
@@ -132,16 +147,17 @@ import { ChatOpenAI } from "@langchain/openai";
|
|
|
132
147
|
const tools = await getLangChainTools(agentKit);
|
|
133
148
|
|
|
134
149
|
const llm = new ChatOpenAI({
|
|
135
|
-
|
|
150
|
+
model: "gpt-4o-mini",
|
|
136
151
|
});
|
|
137
152
|
|
|
138
153
|
const agent = createReactAgent({
|
|
139
|
-
|
|
140
|
-
|
|
154
|
+
llm,
|
|
155
|
+
tools,
|
|
141
156
|
});
|
|
142
157
|
```
|
|
143
158
|
|
|
144
159
|
## Action Providers
|
|
160
|
+
|
|
145
161
|
<details>
|
|
146
162
|
<summary><strong>Across</strong></summary>
|
|
147
163
|
<table width="100%">
|
|
@@ -165,27 +181,6 @@ const agent = createReactAgent({
|
|
|
165
181
|
</table>
|
|
166
182
|
</details>
|
|
167
183
|
<details>
|
|
168
|
-
<summary><strong>CDP Wallet</strong></summary>
|
|
169
|
-
<table width="100%">
|
|
170
|
-
<tr>
|
|
171
|
-
<td width="200"><code>deploy_contract</code></td>
|
|
172
|
-
<td width="768">Deploys a custom smart contract using specified Solidity version and constructor arguments.</td>
|
|
173
|
-
</tr>
|
|
174
|
-
<tr>
|
|
175
|
-
<td width="200"><code>deploy_nft</code></td>
|
|
176
|
-
<td width="768">Deploys a standard ERC-721 NFT contract with configurable name, symbol, and metadata URI.</td>
|
|
177
|
-
</tr>
|
|
178
|
-
<tr>
|
|
179
|
-
<td width="200"><code>deploy_token</code></td>
|
|
180
|
-
<td width="768">Deploys a standard ERC-20 token contract with configurable name, symbol, and initial supply.</td>
|
|
181
|
-
</tr>
|
|
182
|
-
<tr>
|
|
183
|
-
<td width="200"><code>trade</code></td>
|
|
184
|
-
<td width="768">Executes a token swap between two assets at current market rates on mainnet networks.</td>
|
|
185
|
-
</tr>
|
|
186
|
-
</table>
|
|
187
|
-
</details>
|
|
188
|
-
<details>
|
|
189
184
|
<summary><strong>Compound</strong></summary>
|
|
190
185
|
<table width="100%">
|
|
191
186
|
<tr>
|
|
@@ -418,15 +413,20 @@ const agent = createReactAgent({
|
|
|
418
413
|
</table>
|
|
419
414
|
</details>
|
|
420
415
|
<details>
|
|
421
|
-
<summary><strong>
|
|
416
|
+
<summary><strong>x402</strong></summary>
|
|
422
417
|
<table width="100%">
|
|
423
418
|
<tr>
|
|
424
|
-
<td width="200"><code>
|
|
425
|
-
<td width="768">Makes HTTP
|
|
419
|
+
<td width="200"><code>make_http_request</code></td>
|
|
420
|
+
<td width="768">Makes a basic HTTP request to an API endpoint. If the endpoint requires payment (returns 402),
|
|
421
|
+
it will return payment details that can be used on retry.</td>
|
|
422
|
+
</tr>
|
|
423
|
+
<tr>
|
|
424
|
+
<td width="200"><code>retry_http_request_with_x402</code></td>
|
|
425
|
+
<td width="768">Retries an HTTP request with x402 payment after receiving a 402 Payment Required response.</td>
|
|
426
426
|
</tr>
|
|
427
427
|
<tr>
|
|
428
|
-
<td width="200"><code>
|
|
429
|
-
<td width="768">
|
|
428
|
+
<td width="200"><code>make_http_request_with_x402</code></td>
|
|
429
|
+
<td width="768">Combines make_http_request and retry_http_request_with_x402 into a single step.</td>
|
|
430
430
|
</tr>
|
|
431
431
|
</table>
|
|
432
432
|
</details>
|
|
@@ -449,12 +449,12 @@ import { ActionProvider, WalletProvider, Network } from "@coinbase/agentkit";
|
|
|
449
449
|
|
|
450
450
|
// Define an action provider that uses a wallet provider.
|
|
451
451
|
class MyActionProvider extends ActionProvider<WalletProvider> {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
452
|
+
constructor() {
|
|
453
|
+
super("my-action-provider", []);
|
|
454
|
+
}
|
|
455
455
|
|
|
456
|
-
|
|
457
|
-
|
|
456
|
+
// Define if the action provider supports the given network
|
|
457
|
+
supportsNetwork = (network: Network) => true;
|
|
458
458
|
}
|
|
459
459
|
```
|
|
460
460
|
|
|
@@ -468,11 +468,11 @@ Creating actions with the `@CreateAction` decorator requires the following compi
|
|
|
468
468
|
|
|
469
469
|
```json
|
|
470
470
|
{
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
}
|
|
471
|
+
"compilerOptions": {
|
|
472
|
+
"experimentalDecorators": true,
|
|
473
|
+
"emitDecoratorMetadata": true
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
476
|
```
|
|
477
477
|
|
|
478
478
|
#### Steps to create an action
|
|
@@ -493,20 +493,20 @@ export const MyActionSchema = z.object({
|
|
|
493
493
|
import { ActionProvider, WalletProvider, Network, CreateAction } from "@coinbase/agentkit";
|
|
494
494
|
|
|
495
495
|
class MyActionProvider extends ActionProvider<WalletProvider> {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
496
|
+
constructor() {
|
|
497
|
+
super("my-action-provider", []);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
@CreateAction({
|
|
501
|
+
name: "my-action",
|
|
502
|
+
description: "My action description",
|
|
503
|
+
schema: MyActionSchema,
|
|
504
|
+
})
|
|
505
|
+
async myAction(args: z.infer<typeof MyActionSchema>): Promise<string> {
|
|
506
|
+
return args.myField;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
supportsNetwork = (network: Network) => true;
|
|
510
510
|
}
|
|
511
511
|
|
|
512
512
|
export const myActionProvider = () => new MyActionProvider();
|
|
@@ -518,31 +518,34 @@ Actions that use a wallet provider can be defined as instance methods on the act
|
|
|
518
518
|
|
|
519
519
|
```typescript
|
|
520
520
|
class MyActionProvider extends ActionProvider<WalletProvider> {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
521
|
+
constructor() {
|
|
522
|
+
super("my-action-provider", []);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
@CreateAction({
|
|
526
|
+
name: "my-action",
|
|
527
|
+
description: "My action description",
|
|
528
|
+
schema: MyActionSchema,
|
|
529
|
+
})
|
|
530
|
+
async myAction(
|
|
531
|
+
walletProvider: WalletProvider,
|
|
532
|
+
args: z.infer<typeof MyActionSchema>,
|
|
533
|
+
): Promise<string> {
|
|
534
|
+
return walletProvider.signMessage(args.myField);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
supportsNetwork = (network: Network) => true;
|
|
535
538
|
}
|
|
536
539
|
```
|
|
537
540
|
|
|
538
|
-
### Adding an Action Provider to your AgentKit instance.
|
|
541
|
+
### Adding an Action Provider to your AgentKit instance.
|
|
539
542
|
|
|
540
543
|
This gives your agent access to the actions defined in the action provider.
|
|
541
544
|
|
|
542
545
|
```typescript
|
|
543
546
|
const agentKit = new AgentKit({
|
|
544
547
|
cdpApiKeyId: "CDP API KEY NAME",
|
|
545
|
-
|
|
548
|
+
cdpApiKeySecret: "CDP API KEY SECRET",
|
|
546
549
|
actionProviders: [myActionProvider()],
|
|
547
550
|
});
|
|
548
551
|
```
|
|
@@ -552,26 +555,27 @@ const agentKit = new AgentKit({
|
|
|
552
555
|
Wallet providers give an agent access to a wallet. AgentKit currently supports the following wallet providers:
|
|
553
556
|
|
|
554
557
|
EVM:
|
|
555
|
-
|
|
556
|
-
- [
|
|
558
|
+
|
|
559
|
+
- [CdpEvmWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpEvmWalletProvider.ts)
|
|
560
|
+
- [CdpSmartWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpSmartWalletProvider.ts)
|
|
557
561
|
- [ViemWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/viemWalletProvider.ts)
|
|
558
562
|
- [PrivyWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/privyWalletProvider.ts)
|
|
559
563
|
- [ZeroDevWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/zeroDevWalletProvider.ts)
|
|
560
564
|
|
|
561
|
-
###
|
|
565
|
+
### CdpEvmWalletProvider
|
|
562
566
|
|
|
563
|
-
The `
|
|
567
|
+
The `CdpEvmWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [v2 Wallet API](https://docs.cdp.coinbase.com/wallet-api/v2/introduction/welcome). It provides a more modern and streamlined interface for interacting with CDP wallets.
|
|
564
568
|
|
|
565
569
|
#### Basic Configuration
|
|
566
570
|
|
|
567
571
|
```typescript
|
|
568
|
-
import {
|
|
572
|
+
import { CdpEvmWalletProvider } from "@coinbase/agentkit";
|
|
569
573
|
|
|
570
|
-
const walletProvider = await
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
574
|
+
const walletProvider = await CdpEvmWalletProvider.configureWithWallet({
|
|
575
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
576
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
577
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
578
|
+
networkId: "base-sepolia", // Optional, defaults to "base-sepolia"
|
|
575
579
|
});
|
|
576
580
|
```
|
|
577
581
|
|
|
@@ -580,14 +584,14 @@ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet({
|
|
|
580
584
|
You can configure the provider with an existing wallet by providing the wallet's address:
|
|
581
585
|
|
|
582
586
|
```typescript
|
|
583
|
-
import {
|
|
584
|
-
|
|
585
|
-
const walletProvider = await
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
587
|
+
import { CdpEvmWalletProvider } from "@coinbase/agentkit";
|
|
588
|
+
|
|
589
|
+
const walletProvider = await CdpEvmWalletProvider.configureWithWallet({
|
|
590
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
591
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
592
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
593
|
+
address: "0x...", // The address of an existing wallet
|
|
594
|
+
networkId: "base-sepolia",
|
|
591
595
|
});
|
|
592
596
|
```
|
|
593
597
|
|
|
@@ -596,14 +600,124 @@ const walletProvider = await CdpV2EvmWalletProvider.configureWithWallet({
|
|
|
596
600
|
To create a new wallet, you can provide an idempotency key. The same idempotency key will always generate the same wallet address, and these keys are valid for 24 hours:
|
|
597
601
|
|
|
598
602
|
```typescript
|
|
599
|
-
import {
|
|
600
|
-
|
|
601
|
-
const walletProvider = await
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
603
|
+
import { CdpEvmWalletProvider } from "@coinbase/agentkit";
|
|
604
|
+
|
|
605
|
+
const walletProvider = await CdpEvmWalletProvider.configureWithWallet({
|
|
606
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
607
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
608
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
609
|
+
idempotencyKey: "unique-key-123", // Optional, if not provided a new wallet will be created
|
|
610
|
+
networkId: "base-sepolia",
|
|
611
|
+
});
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
#### Environment Variables
|
|
615
|
+
|
|
616
|
+
The provider can also be configured using environment variables:
|
|
617
|
+
|
|
618
|
+
```typescript
|
|
619
|
+
// Environment variables:
|
|
620
|
+
// CDP_API_KEY_ID=your_api_key_id
|
|
621
|
+
// CDP_API_KEY_SECRET=your_api_key_secret
|
|
622
|
+
// CDP_WALLET_SECRET=your_wallet_secret
|
|
623
|
+
// NETWORK_ID=base-sepolia (optional)
|
|
624
|
+
// IDEMPOTENCY_KEY=unique-key-123 (optional)
|
|
625
|
+
|
|
626
|
+
const walletProvider = await CdpEvmWalletProvider.configureWithWallet();
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
#### Exporting a wallet
|
|
630
|
+
|
|
631
|
+
The `CdpEvmWalletProvider` can export a wallet by calling the `exportWallet` method:
|
|
632
|
+
|
|
633
|
+
```typescript
|
|
634
|
+
const walletData = await walletProvider.exportWallet();
|
|
635
|
+
```
|
|
636
|
+
|
|
637
|
+
### CdpSmartWalletProvider
|
|
638
|
+
|
|
639
|
+
The `CdpSmartWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [Smart Wallets](https://docs.cdp.coinbase.com/wallet-api/docs/smart-wallets). Smart wallets are ERC-4337 compliant smart contract wallets that provide enhanced features like gasless transactions, batch operations, and account recovery.
|
|
640
|
+
|
|
641
|
+
**Note:** Smart wallets are currently only supported on Base networks (base-sepolia and base-mainnet).
|
|
642
|
+
|
|
643
|
+
#### Basic Configuration
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
import { CdpSmartWalletProvider } from "@coinbase/agentkit";
|
|
647
|
+
|
|
648
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
649
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
650
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
651
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
652
|
+
networkId: "base-sepolia", // Optional, defaults to "base-sepolia"
|
|
653
|
+
});
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
#### Using an Existing Smart Wallet
|
|
657
|
+
|
|
658
|
+
You can configure the provider with an existing smart wallet by providing either the wallet's address or name:
|
|
659
|
+
|
|
660
|
+
```typescript
|
|
661
|
+
import { CdpSmartWalletProvider } from "@coinbase/agentkit";
|
|
662
|
+
|
|
663
|
+
// Using smart wallet address
|
|
664
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
665
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
666
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
667
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
668
|
+
address: "0x...", // The address of an existing smart wallet
|
|
669
|
+
networkId: "base-sepolia",
|
|
670
|
+
});
|
|
671
|
+
|
|
672
|
+
// Or using smart wallet name
|
|
673
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
674
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
675
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
676
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
677
|
+
smartAccountName: "my-smart-wallet", // The name of an existing smart wallet
|
|
678
|
+
networkId: "base-sepolia",
|
|
679
|
+
});
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
#### Specifying an Owner Account
|
|
683
|
+
|
|
684
|
+
Smart wallets require an owner account. You can specify an existing owner account by providing its address or the account object itself:
|
|
685
|
+
|
|
686
|
+
```typescript
|
|
687
|
+
import { CdpSmartWalletProvider } from "@coinbase/agentkit";
|
|
688
|
+
|
|
689
|
+
// Using owner address
|
|
690
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
691
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
692
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
693
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
694
|
+
owner: "0x...", // The address of the owner account
|
|
695
|
+
networkId: "base-sepolia",
|
|
696
|
+
});
|
|
697
|
+
|
|
698
|
+
// Using owner account object
|
|
699
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
700
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
701
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
702
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
703
|
+
owner: ownerAccount, // An EvmServerAccount or PrivateKeyAccount object
|
|
704
|
+
networkId: "base-sepolia",
|
|
705
|
+
});
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
#### Creating a New Smart Wallet
|
|
709
|
+
|
|
710
|
+
To create a new smart wallet, provide an idempotency key. The same idempotency key will always generate the same owner account address, and these keys are valid for 24 hours:
|
|
711
|
+
|
|
712
|
+
```typescript
|
|
713
|
+
import { CdpSmartWalletProvider } from "@coinbase/agentkit";
|
|
714
|
+
|
|
715
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet({
|
|
716
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
717
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
718
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
719
|
+
idempotencyKey: "unique-key-123", // Optional, if not provided a new owner account will be created
|
|
720
|
+
networkId: "base-sepolia",
|
|
607
721
|
});
|
|
608
722
|
```
|
|
609
723
|
|
|
@@ -619,64 +733,87 @@ The provider can also be configured using environment variables:
|
|
|
619
733
|
// NETWORK_ID=base-sepolia (optional)
|
|
620
734
|
// IDEMPOTENCY_KEY=unique-key-123 (optional)
|
|
621
735
|
|
|
622
|
-
const walletProvider = await
|
|
736
|
+
const walletProvider = await CdpSmartWalletProvider.configureWithWallet();
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
#### Exporting Smart Wallet Information
|
|
740
|
+
|
|
741
|
+
The `CdpSmartWalletProvider` can export wallet information by calling the `exportWallet` method:
|
|
742
|
+
|
|
743
|
+
```typescript
|
|
744
|
+
const walletData = await walletProvider.exportWallet();
|
|
745
|
+
|
|
746
|
+
// walletData will be in the following format:
|
|
747
|
+
{
|
|
748
|
+
name: string | undefined; // The smart wallet name (if set)
|
|
749
|
+
address: string; // The smart wallet address
|
|
750
|
+
ownerAddress: string; // The owner account address
|
|
751
|
+
}
|
|
623
752
|
```
|
|
624
753
|
|
|
625
|
-
|
|
754
|
+
#### Key Differences from Regular Wallets
|
|
755
|
+
|
|
756
|
+
1. **User Operations**: Smart wallets use ERC-4337 user operations instead of regular transactions
|
|
757
|
+
2. **No Direct Transaction Signing**: Smart wallets cannot sign transactions directly; all operations go through the user operation flow
|
|
758
|
+
3. **Gasless Transactions**: Smart wallets can be configured to use paymasters for sponsored transactions
|
|
759
|
+
4. **Batch Operations**: Multiple operations can be bundled into a single user operation
|
|
760
|
+
5. **Base Networks Only**: Currently limited to base-sepolia and base-mainnet
|
|
761
|
+
|
|
762
|
+
### LegacyCdpWalletProvider
|
|
626
763
|
|
|
627
|
-
The `
|
|
764
|
+
The `LegacyCdpWalletProvider` is a wallet provider that uses the Coinbase Developer Platform (CDP) [v1 Wallet API](https://docs.cdp.coinbase.com/wallet-api/v1/introduction/welcome).
|
|
628
765
|
|
|
629
766
|
#### Network Configuration
|
|
630
767
|
|
|
631
|
-
The `
|
|
768
|
+
The `LegacyCdpWalletProvider` can be configured to use a specific network by passing the `networkId` parameter to the `configureWithWallet` method. The `networkId` is the ID of the network you want to use. You can find a list of [supported networks on the CDP API docs](https://docs.cdp.coinbase.com/cdp-apis/docs/networks).
|
|
632
769
|
|
|
633
770
|
```typescript
|
|
634
|
-
import {
|
|
771
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
635
772
|
|
|
636
773
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
774
|
+
apiKeyId: "CDP API KEY NAME",
|
|
775
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
776
|
+
networkId: "base-mainnet",
|
|
640
777
|
});
|
|
641
778
|
```
|
|
642
779
|
|
|
643
780
|
#### Configuring from an existing CDP API Wallet
|
|
644
781
|
|
|
645
|
-
If you already have a CDP API Wallet, you can configure the `
|
|
782
|
+
If you already have a CDP API Wallet, you can configure the `LegacyCdpWalletProvider` by passing the `wallet` parameter to the `configureWithWallet` method.
|
|
646
783
|
|
|
647
784
|
```typescript
|
|
648
|
-
import {
|
|
785
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
649
786
|
import { Wallet } from "@coinbase/coinbase-sdk";
|
|
650
|
-
const walletProvider = await
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
787
|
+
const walletProvider = await LegacyCdpWalletProvider.configureWithWallet({
|
|
788
|
+
wallet,
|
|
789
|
+
apiKeyId: "CDP API KEY NAME",
|
|
790
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
654
791
|
});
|
|
655
792
|
```
|
|
656
793
|
|
|
657
794
|
#### Configuring from a mnemonic phrase
|
|
658
795
|
|
|
659
|
-
The `
|
|
796
|
+
The `LegacyCdpWalletProvider` can be configured from a mnemonic phrase by passing the `mnemonicPhrase` and `networkId` parameters to the `configureWithWallet` method. If `networkId` is not defined, the `LegacyCdpWalletProvider` will fall back to the env var `NETWORK_ID`, and if that is not defined, it will default to `base-sepolia`.
|
|
660
797
|
|
|
661
798
|
```typescript
|
|
662
|
-
import {
|
|
799
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
663
800
|
|
|
664
|
-
const walletProvider = await
|
|
665
|
-
|
|
666
|
-
|
|
801
|
+
const walletProvider = await LegacyCdpWalletProvider.configureWithWallet({
|
|
802
|
+
mnemonicPhrase: "MNEMONIC PHRASE",
|
|
803
|
+
networkId: "base-sepolia",
|
|
667
804
|
});
|
|
668
805
|
```
|
|
669
806
|
|
|
670
807
|
#### Exporting a wallet
|
|
671
808
|
|
|
672
|
-
The `
|
|
809
|
+
The `LegacyCdpWalletProvider` can export a wallet by calling the `exportWallet` method.
|
|
673
810
|
|
|
674
811
|
```typescript
|
|
675
|
-
import {
|
|
812
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
676
813
|
|
|
677
|
-
const walletProvider = await
|
|
678
|
-
|
|
679
|
-
|
|
814
|
+
const walletProvider = await LegacyCdpWalletProvider.configureWithWallet({
|
|
815
|
+
mnemonicPhrase: "MNEMONIC PHRASE",
|
|
816
|
+
networkId: "base-sepolia",
|
|
680
817
|
});
|
|
681
818
|
|
|
682
819
|
const walletData = await walletProvider.exportWallet();
|
|
@@ -684,39 +821,38 @@ const walletData = await walletProvider.exportWallet();
|
|
|
684
821
|
|
|
685
822
|
#### Importing a wallet from `WalletData` JSON string
|
|
686
823
|
|
|
687
|
-
The `
|
|
824
|
+
The `LegacyCdpWalletProvider` can import a wallet from a `WalletData` JSON string by passing the `cdpWalletData` parameter to the `configureWithWallet` method.
|
|
688
825
|
|
|
689
826
|
```typescript
|
|
690
|
-
import {
|
|
827
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
691
828
|
|
|
692
|
-
const walletProvider = await
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
829
|
+
const walletProvider = await LegacyCdpWalletProvider.configureWithWallet({
|
|
830
|
+
cdpWalletData: "WALLET DATA JSON STRING",
|
|
831
|
+
apiKeyId: "CDP API KEY NAME",
|
|
832
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
696
833
|
});
|
|
697
834
|
```
|
|
698
835
|
|
|
699
|
-
#### Configuring
|
|
836
|
+
#### Configuring LegacyCdpWalletProvider gas parameters
|
|
700
837
|
|
|
701
|
-
The `
|
|
838
|
+
The `LegacyCdpWalletProvider` also exposes parameters for effecting the gas calculations.
|
|
702
839
|
|
|
703
840
|
```typescript
|
|
704
|
-
import {
|
|
705
|
-
|
|
706
|
-
const walletProvider = await
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
841
|
+
import { LegacyCdpWalletProvider } from "@coinbase/agentkit";
|
|
842
|
+
|
|
843
|
+
const walletProvider = await LegacyCdpWalletProvider.configureWithWallet({
|
|
844
|
+
cdpWalletData: "WALLET DATA JSON STRING",
|
|
845
|
+
apiKeyId: "CDP API KEY NAME",
|
|
846
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
847
|
+
gas: {
|
|
848
|
+
gasLimitMultiplier: 2.0, // Adjusts gas limit estimation
|
|
849
|
+
feePerGasMultiplier: 2.0, // Adjusts max fee per gas
|
|
850
|
+
},
|
|
714
851
|
});
|
|
715
852
|
```
|
|
716
853
|
|
|
717
854
|
**Note**: Gas parameters only impact the `walletProvider.sendTransaction` behavior. Actions that do not rely on direct transaction calls, such as `deploy_token`, `deploy_contract`, and `native_transfer`, remain unaffected.
|
|
718
855
|
|
|
719
|
-
|
|
720
856
|
### ViemWalletProvider
|
|
721
857
|
|
|
722
858
|
The `ViemWalletProvider` is a wallet provider that uses the [Viem library](https://viem.sh/docs/getting-started). It is useful for interacting with any EVM-compatible chain.
|
|
@@ -763,8 +899,8 @@ const client = createWalletClient({
|
|
|
763
899
|
});
|
|
764
900
|
|
|
765
901
|
const walletProvider = new ViemWalletProvider(client, {
|
|
766
|
-
|
|
767
|
-
|
|
902
|
+
gasLimitMultiplier: 2.0, // Adjusts gas limit estimation
|
|
903
|
+
feePerGasMultiplier: 2.0, // Adjusts max fee per gas
|
|
768
904
|
});
|
|
769
905
|
```
|
|
770
906
|
|
|
@@ -779,12 +915,12 @@ import { PrivyWalletProvider } from "@coinbase/agentkit";
|
|
|
779
915
|
|
|
780
916
|
// Configure Server Wallet Provider
|
|
781
917
|
const config = {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
918
|
+
appId: "PRIVY_APP_ID",
|
|
919
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
920
|
+
chainId: "84532", // base-sepolia
|
|
921
|
+
walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
|
|
922
|
+
authorizationPrivateKey: "PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY", // optional, required if your account is using authorization keys
|
|
923
|
+
authorizationKeyId: "PRIVY_WALLET_AUTHORIZATION_KEY_ID", // optional, only required to create a new wallet if walletId is not provided
|
|
788
924
|
};
|
|
789
925
|
|
|
790
926
|
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
@@ -799,12 +935,12 @@ import { PrivyWalletProvider } from "@coinbase/agentkit";
|
|
|
799
935
|
|
|
800
936
|
// Configure Embedded Wallet Provider
|
|
801
937
|
const config = {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
938
|
+
appId: "PRIVY_APP_ID",
|
|
939
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
940
|
+
authorizationPrivateKey: "PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY",
|
|
941
|
+
walletId: "PRIVY_DELEGATED_WALLET_ID", // The ID of the wallet that was delegated to your server
|
|
942
|
+
networkId: "base-mainnet", // or any supported network
|
|
943
|
+
walletType: "embedded", // Specify "embedded" to use the embedded wallet provider
|
|
808
944
|
};
|
|
809
945
|
|
|
810
946
|
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
@@ -835,23 +971,23 @@ When using authorization keys, you must provide the `authorizationPrivateKey` an
|
|
|
835
971
|
|
|
836
972
|
#### Exporting Privy Wallet information
|
|
837
973
|
|
|
838
|
-
The `PrivyWalletProvider` can export wallet information by calling the `exportWallet` method.
|
|
974
|
+
The `PrivyWalletProvider` can export wallet information by calling the `exportWallet` method.
|
|
839
975
|
|
|
840
976
|
```typescript
|
|
841
977
|
const walletData = await walletProvider.exportWallet();
|
|
842
978
|
|
|
843
979
|
// For server wallets, walletData will be in the following format:
|
|
844
980
|
{
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
981
|
+
walletId: string;
|
|
982
|
+
authorizationKey: string | undefined;
|
|
983
|
+
chainId: string | undefined;
|
|
848
984
|
}
|
|
849
985
|
|
|
850
986
|
// For embedded wallets, walletData will be in the following format:
|
|
851
987
|
{
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
988
|
+
walletId: string;
|
|
989
|
+
networkId: string;
|
|
990
|
+
chainId: string | undefined;
|
|
855
991
|
}
|
|
856
992
|
```
|
|
857
993
|
|
|
@@ -879,11 +1015,11 @@ const walletProvider = await SmartWalletProvider.configureWithWallet({
|
|
|
879
1015
|
|
|
880
1016
|
### ZeroDevWalletProvider
|
|
881
1017
|
|
|
882
|
-
The `ZeroDevWalletProvider` is a wallet provider that uses [ZeroDev](https://docs.zerodev.app/) smart accounts.
|
|
1018
|
+
The `ZeroDevWalletProvider` is a wallet provider that uses [ZeroDev](https://docs.zerodev.app/) smart accounts. It supports features like chain abstraction, gasless transactions, batched transactions, and more.
|
|
883
1019
|
|
|
884
|
-
In the context of Agent Kit, "chain abstraction" means that the agent can spend funds across chains without explicitly bridging.
|
|
1020
|
+
In the context of Agent Kit, "chain abstraction" means that the agent can spend funds across chains without explicitly bridging. For example, if you send funds to the agent's address on Base, the agent will be able to spend the funds on any supported EVM chains such as Arbitrum and Optimism.
|
|
885
1021
|
|
|
886
|
-
The ZeroDev wallet provider does not itself manage keys.
|
|
1022
|
+
The ZeroDev wallet provider does not itself manage keys. Rather, it can be used with any EVM wallet provider (e.g. CDP/Privy/Viem) which serves as the "signer" for the ZeroDev smart account.
|
|
887
1023
|
|
|
888
1024
|
#### Configuring from CdpWalletProvider
|
|
889
1025
|
|
|
@@ -892,17 +1028,17 @@ import { ZeroDevWalletProvider, CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
892
1028
|
|
|
893
1029
|
// First create a CDP wallet provider as the signer
|
|
894
1030
|
const cdpWalletProvider = await CdpWalletProvider.configureWithWallet({
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
1031
|
+
apiKeyId: "CDP API KEY NAME",
|
|
1032
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
1033
|
+
networkId: "base-mainnet",
|
|
898
1034
|
});
|
|
899
1035
|
|
|
900
1036
|
// Configure ZeroDev Wallet Provider with CDP signer
|
|
901
1037
|
const walletProvider = await ZeroDevWalletProvider.configureWithWallet({
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
1038
|
+
signer: cdpWalletProvider.toSigner(),
|
|
1039
|
+
projectId: "ZERODEV_PROJECT_ID",
|
|
1040
|
+
entryPointVersion: "0.7" as const,
|
|
1041
|
+
networkId: "base-mainnet",
|
|
906
1042
|
});
|
|
907
1043
|
```
|
|
908
1044
|
|
|
@@ -913,17 +1049,17 @@ import { ZeroDevWalletProvider, PrivyWalletProvider } from "@coinbase/agentkit";
|
|
|
913
1049
|
|
|
914
1050
|
// First create a Privy wallet provider as the signer
|
|
915
1051
|
const privyWalletProvider = await PrivyWalletProvider.configureWithWallet({
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
1052
|
+
appId: "PRIVY_APP_ID",
|
|
1053
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
1054
|
+
chainId: "8453", // base-mainnet
|
|
919
1055
|
});
|
|
920
1056
|
|
|
921
1057
|
// Configure ZeroDev Wallet Provider with Privy signer
|
|
922
1058
|
const walletProvider = await ZeroDevWalletProvider.configureWithWallet({
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1059
|
+
signer: privyWalletProvider.toSigner(),
|
|
1060
|
+
projectId: "ZERODEV_PROJECT_ID",
|
|
1061
|
+
entryPointVersion: "0.7" as const,
|
|
1062
|
+
networkId: "base-mainnet",
|
|
927
1063
|
});
|
|
928
1064
|
```
|
|
929
1065
|
|
|
@@ -943,15 +1079,15 @@ const viemWalletProvider = new ViemWalletProvider(
|
|
|
943
1079
|
account,
|
|
944
1080
|
chain: base,
|
|
945
1081
|
transport: http(),
|
|
946
|
-
})
|
|
1082
|
+
}),
|
|
947
1083
|
);
|
|
948
1084
|
|
|
949
1085
|
// Configure ZeroDev Wallet Provider with Viem signer
|
|
950
1086
|
const walletProvider = await ZeroDevWalletProvider.configureWithWallet({
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1087
|
+
signer: viemWalletProvider.toSigner(),
|
|
1088
|
+
projectId: "ZERODEV_PROJECT_ID",
|
|
1089
|
+
entryPointVersion: "0.7" as const,
|
|
1090
|
+
networkId: "base-mainnet",
|
|
955
1091
|
});
|
|
956
1092
|
```
|
|
957
1093
|
|
|
@@ -960,6 +1096,7 @@ const walletProvider = await ZeroDevWalletProvider.configureWithWallet({
|
|
|
960
1096
|
Wallet providers give an agent access to a wallet. AgentKit currently supports the following wallet providers:
|
|
961
1097
|
|
|
962
1098
|
SVM:
|
|
1099
|
+
|
|
963
1100
|
- [CdpV2SolanaWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/cdpV2SolanaWalletProvider.ts)
|
|
964
1101
|
- [SolanaKeypairWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/solanaKeypairWalletProvider.ts)
|
|
965
1102
|
- [PrivyWalletProvider](https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/wallet-providers/privySvmWalletProvider.ts)
|
|
@@ -974,10 +1111,10 @@ The `CdpV2SolanaWalletProvider` is a wallet provider that uses the Coinbase Deve
|
|
|
974
1111
|
import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
|
|
975
1112
|
|
|
976
1113
|
const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1114
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
1115
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
1116
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
1117
|
+
networkId: "solana-devnet", // Optional, defaults to "solana-devnet"
|
|
981
1118
|
});
|
|
982
1119
|
```
|
|
983
1120
|
|
|
@@ -989,11 +1126,11 @@ You can configure the provider with an existing wallet by providing the wallet's
|
|
|
989
1126
|
import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
|
|
990
1127
|
|
|
991
1128
|
const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
1129
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
1130
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
1131
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
1132
|
+
address: "your-solana-address", // The address of an existing wallet
|
|
1133
|
+
networkId: "solana-devnet",
|
|
997
1134
|
});
|
|
998
1135
|
```
|
|
999
1136
|
|
|
@@ -1005,11 +1142,11 @@ To create a new wallet, you can provide an idempotency key. The same idempotency
|
|
|
1005
1142
|
import { CdpV2SolanaWalletProvider } from "@coinbase/agentkit";
|
|
1006
1143
|
|
|
1007
1144
|
const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet({
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1145
|
+
apiKeyId: "CDP_API_KEY_ID",
|
|
1146
|
+
apiKeySecret: "CDP_API_KEY_SECRET",
|
|
1147
|
+
walletSecret: "CDP_WALLET_SECRET",
|
|
1148
|
+
idempotencyKey: "unique-key-123", // Optional, if not provided a new wallet will be created
|
|
1149
|
+
networkId: "solana-devnet",
|
|
1013
1150
|
});
|
|
1014
1151
|
```
|
|
1015
1152
|
|
|
@@ -1031,6 +1168,7 @@ const walletProvider = await CdpV2SolanaWalletProvider.configureWithWallet();
|
|
|
1031
1168
|
#### Supported Networks
|
|
1032
1169
|
|
|
1033
1170
|
The `CdpV2SolanaWalletProvider` supports the following Solana networks:
|
|
1171
|
+
|
|
1034
1172
|
- `solana-mainnet`
|
|
1035
1173
|
- `solana-devnet`
|
|
1036
1174
|
- `solana-testnet`
|
|
@@ -1046,6 +1184,7 @@ NOTE: It is highly recommended to use a dedicated RPC provider. See [here](https
|
|
|
1046
1184
|
The `SolanaKeypairWalletProvider` can be configured to use a specific network by passing the `networkId` parameter to the `fromNetwork` method. The `networkId` is the ID of the Solana network you want to use. Valid values are `solana-mainnet`, `solana-devnet` and `solana-testnet`.
|
|
1047
1185
|
|
|
1048
1186
|
The default RPC endpoints for each network are as follows:
|
|
1187
|
+
|
|
1049
1188
|
- `solana-mainnet`: `https://api.mainnet-beta.solana.com`
|
|
1050
1189
|
- `solana-devnet`: `https://api.devnet.solana.com`
|
|
1051
1190
|
- `solana-testnet`: `https://api.testnet.solana.com`
|
|
@@ -1083,14 +1222,14 @@ import { PrivyWalletProvider, PrivyWalletConfig } from "@coinbase/agentkit";
|
|
|
1083
1222
|
|
|
1084
1223
|
// Configure Wallet Provider
|
|
1085
1224
|
const config: PrivyWalletConfig = {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1225
|
+
appId: "PRIVY_APP_ID",
|
|
1226
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
1227
|
+
connection,
|
|
1228
|
+
chainType: "solana", // optional, defaults to "evm". Make sure to set this to "solana" if you want to use Solana!
|
|
1229
|
+
networkId: "solana-devnet", // optional, defaults to "solana-devnet"
|
|
1230
|
+
walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
|
|
1231
|
+
authorizationPrivateKey: PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY, // optional, required if your account is using authorization keys
|
|
1232
|
+
authorizationKeyId: PRIVY_WALLET_AUTHORIZATION_KEY_ID, // optional, only required to create a new wallet if walletId is not provided
|
|
1094
1233
|
};
|
|
1095
1234
|
|
|
1096
1235
|
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
@@ -1107,14 +1246,14 @@ const connection = new Connection("YOUR_RPC_URL");
|
|
|
1107
1246
|
|
|
1108
1247
|
// Configure Wallet Provider
|
|
1109
1248
|
const config: PrivyWalletConfig = {
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1249
|
+
appId: "PRIVY_APP_ID",
|
|
1250
|
+
appSecret: "PRIVY_APP_SECRET",
|
|
1251
|
+
connection,
|
|
1252
|
+
chainType: "solana", // optional, defaults to "evm". Make sure to set this to "solana" if you want to use Solana!
|
|
1253
|
+
networkId: "solana-devnet", // optional, defaults to "solana-devnet"
|
|
1254
|
+
walletId: "PRIVY_WALLET_ID", // optional, otherwise a new wallet will be created
|
|
1255
|
+
authorizationPrivateKey: PRIVY_WALLET_AUTHORIZATION_PRIVATE_KEY, // optional, required if your account is using authorization keys
|
|
1256
|
+
authorizationKeyId: PRIVY_WALLET_AUTHORIZATION_KEY_ID, // optional, only required to create a new wallet if walletId is not provided
|
|
1118
1257
|
};
|
|
1119
1258
|
|
|
1120
1259
|
const walletProvider = await PrivyWalletProvider.configureWithWallet(config);
|
|
@@ -1137,9 +1276,9 @@ const walletData = await walletProvider.exportWallet();
|
|
|
1137
1276
|
|
|
1138
1277
|
// walletData will be in the following format:
|
|
1139
1278
|
{
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1279
|
+
walletId: string;
|
|
1280
|
+
authorizationKey: string | undefined;
|
|
1281
|
+
networkId: string | undefined;
|
|
1143
1282
|
}
|
|
1144
1283
|
```
|
|
1145
1284
|
|