agentwallet-sdk 3.4.2 → 3.5.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 +46 -9
- package/dist/plugins/elizaos.d.ts +51 -0
- package/dist/plugins/elizaos.d.ts.map +1 -0
- package/dist/plugins/elizaos.js +89 -0
- package/dist/plugins/elizaos.js.map +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -286,6 +286,40 @@ const client = createX402Client(wallet, {
|
|
|
286
286
|
});
|
|
287
287
|
```text
|
|
288
288
|
|
|
289
|
+
### Etherlink x402 - Non-Custodial ERC-20 Payments via Permit2
|
|
290
|
+
|
|
291
|
+
Etherlink (Tezos L2) launched x402 support in March 2026 with a Permit2 proxy that lets agents pay in ERC-20 tokens without pre-approvals. `agentwallet-sdk` supports this directly:
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { createWallet, createX402Client } from 'agentwallet-sdk';
|
|
295
|
+
import { createWalletClient, http } from 'viem';
|
|
296
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
297
|
+
|
|
298
|
+
const walletClient = createWalletClient({
|
|
299
|
+
account: privateKeyToAccount(process.env.AGENT_KEY!),
|
|
300
|
+
transport: http('https://node.mainnet.etherlink.com'),
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const wallet = createWallet({
|
|
304
|
+
accountAddress: '0xYOUR_AGENT_CONTRACT',
|
|
305
|
+
chain: 'etherlink',
|
|
306
|
+
walletClient,
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// x402 client on Etherlink -- same API, different chain
|
|
310
|
+
const client = createX402Client(wallet, {
|
|
311
|
+
preferredChain: 'etherlink', // near-zero fees on Tezos L2
|
|
312
|
+
globalDailyLimit: 100_000_000n, // 100 USDC/day
|
|
313
|
+
globalPerRequestMax: 2_000_000n, // 2 USDC max per request
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
// Fetch x402-gated resources -- 402 payment handled automatically
|
|
317
|
+
const response = await client.fetch('https://api.example.com/agent-data');
|
|
318
|
+
// The client: parsed the 402, checked budget, signed via Permit2, retried with proof
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Unlike custodial x402 implementations (Coinbase, OKX OnchainOS), the key never leaves your environment. The Permit2 proxy handles the ERC-20 approval flow, but authorization is still signed locally.
|
|
322
|
+
|
|
289
323
|
### How x402 Works
|
|
290
324
|
|
|
291
325
|
```text
|
|
@@ -310,15 +344,18 @@ Every major AI company launched an agent wallet in early 2026. Coinbase Agentic
|
|
|
310
344
|
|
|
311
345
|
Here's the direct comparison:
|
|
312
346
|
|
|
313
|
-
| | Coinbase
|
|
314
|
-
|
|
315
|
-
| **Key custody** | Coinbase servers | MoonPay servers | Your environment only |
|
|
316
|
-
| **Spend limits** | Session caps (off-chain API) | None | Per-tx + daily, on-chain contract |
|
|
317
|
-
| **x402 support** | Yes (Base/USDC) | No | Yes (Base
|
|
318
|
-
| **Cross-chain** | Base only | Limited | 5 chains via CCTP |
|
|
319
|
-
| **Freeze risk** | Yes (KYC, compliance) | Yes | None -- contract on-chain |
|
|
320
|
-
| **Audit trail** | API logs (centralized) | API logs | On-chain events, self-queryable |
|
|
321
|
-
| **Open source** | No | No | Yes (MIT) |
|
|
347
|
+
| | Coinbase AgentKit | MoonPay Agents | Circuit & Chisel ATXP | agent-wallet-sdk |
|
|
348
|
+
|---|---|---|---|---|
|
|
349
|
+
| **Key custody** | Coinbase servers | MoonPay servers | Enterprise custodian | Your environment only |
|
|
350
|
+
| **Spend limits** | Session caps (off-chain API) | None | Nested policy layer | Per-tx + daily, on-chain contract |
|
|
351
|
+
| **x402 support** | Yes (Base/USDC) | No | Partial | Yes (Base, Etherlink, full spec) |
|
|
352
|
+
| **Cross-chain** | Base only | Limited | EVM-only | 5 chains via CCTP V2 |
|
|
353
|
+
| **Freeze risk** | Yes (KYC, compliance) | Yes | Yes (enterprise terms) | None -- contract on-chain |
|
|
354
|
+
| **Audit trail** | API logs (centralized) | API logs | Enterprise dashboard | On-chain events, self-queryable |
|
|
355
|
+
| **Open source** | No | No | No | Yes (MIT) |
|
|
356
|
+
| **KYC required** | Yes | Yes | Yes | No |
|
|
357
|
+
| **Micropayments** | Limited | No | Yes (nested) | Yes (x402 + sub-cent via L2) |
|
|
358
|
+
| **Agent-sovereign** | No | No | No | Yes |
|
|
322
359
|
|
|
323
360
|
**The three questions that matter:**
|
|
324
361
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @elizaos/plugin-agentwallet
|
|
3
|
+
*
|
|
4
|
+
* ElizaOS plugin for agentwallet-sdk — non-custodial AI agent wallet with
|
|
5
|
+
* x402 payment support, CCTP V2 cross-chain transfers, and on-chain spend limits.
|
|
6
|
+
*
|
|
7
|
+
* Your agent holds its own private key. No custodian. No KYC.
|
|
8
|
+
*/
|
|
9
|
+
import type { Plugin } from '@elizaos/core';
|
|
10
|
+
import { type AgentWallet } from 'agentwallet-sdk';
|
|
11
|
+
export interface AgentWalletPluginConfig {
|
|
12
|
+
/** Agent private key — stays in your environment, never transmitted */
|
|
13
|
+
privateKey: `0x${string}`;
|
|
14
|
+
/** Deployed AgentAccountV2 contract address */
|
|
15
|
+
accountAddress: `0x${string}`;
|
|
16
|
+
/** Chain to connect to (default: 'base') */
|
|
17
|
+
chain?: 'base' | 'base-sepolia' | 'ethereum' | 'arbitrum' | 'polygon' | 'etherlink';
|
|
18
|
+
/** Optional custom RPC URL */
|
|
19
|
+
rpcUrl?: string;
|
|
20
|
+
/** Optional daily x402 spend limit in USDC base units (default: 50 USDC = 50_000_000n) */
|
|
21
|
+
x402DailyLimit?: bigint;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get or create the agent wallet singleton.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getAgentWallet(config: AgentWalletPluginConfig): AgentWallet;
|
|
27
|
+
/**
|
|
28
|
+
* Create an x402-enabled fetch function for the agent to pay APIs automatically.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createAgentFetch(config: AgentWalletPluginConfig): any;
|
|
31
|
+
/**
|
|
32
|
+
* ElizaOS Plugin definition for agentwallet-sdk.
|
|
33
|
+
*
|
|
34
|
+
* Usage in your Eliza character config:
|
|
35
|
+
*
|
|
36
|
+
* ```json
|
|
37
|
+
* {
|
|
38
|
+
* "plugins": ["@elizaos/plugin-agentwallet"],
|
|
39
|
+
* "settings": {
|
|
40
|
+
* "AGENT_PRIVATE_KEY": "0x...",
|
|
41
|
+
* "AGENT_ACCOUNT_ADDRESS": "0x...",
|
|
42
|
+
* "AGENT_CHAIN": "base",
|
|
43
|
+
* "X402_DAILY_LIMIT": "50000000"
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
declare const AgentWalletPlugin: Plugin;
|
|
49
|
+
export default AgentWalletPlugin;
|
|
50
|
+
export { AgentWalletPlugin };
|
|
51
|
+
//# sourceMappingURL=elizaos.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elizaos.d.ts","sourceRoot":"","sources":["../../src/plugins/elizaos.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,WAAW,uBAAuB;IACtC,uEAAuE;IACvE,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,+CAA+C;IAC/C,cAAc,EAAE,KAAK,MAAM,EAAE,CAAC;IAC9B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,GAAG,cAAc,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;IACpF,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0FAA0F;IAC1F,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAID;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,uBAAuB,GAAG,WAAW,CAuB3E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,OAK/D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,iBAAiB,EAAE,MAiCxB,CAAC;AAEF,eAAe,iBAAiB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createWallet, createX402Fetch, } from 'agentwallet-sdk';
|
|
2
|
+
import { createWalletClient, http } from 'viem';
|
|
3
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
4
|
+
let walletInstance = null;
|
|
5
|
+
/**
|
|
6
|
+
* Get or create the agent wallet singleton.
|
|
7
|
+
*/
|
|
8
|
+
export function getAgentWallet(config) {
|
|
9
|
+
if (!walletInstance) {
|
|
10
|
+
const account = privateKeyToAccount(config.privateKey);
|
|
11
|
+
const rpcUrls = {
|
|
12
|
+
base: 'https://mainnet.base.org',
|
|
13
|
+
'base-sepolia': 'https://sepolia.base.org',
|
|
14
|
+
ethereum: 'https://eth.llamarpc.com',
|
|
15
|
+
arbitrum: 'https://arb1.arbitrum.io/rpc',
|
|
16
|
+
polygon: 'https://polygon-rpc.com',
|
|
17
|
+
etherlink: 'https://node.mainnet.etherlink.com',
|
|
18
|
+
};
|
|
19
|
+
const chain = config.chain ?? 'base';
|
|
20
|
+
const walletClient = createWalletClient({
|
|
21
|
+
account,
|
|
22
|
+
transport: http(config.rpcUrl ?? rpcUrls[chain] ?? rpcUrls.base),
|
|
23
|
+
});
|
|
24
|
+
walletInstance = createWallet({
|
|
25
|
+
accountAddress: config.accountAddress,
|
|
26
|
+
chain,
|
|
27
|
+
walletClient,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return walletInstance;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Create an x402-enabled fetch function for the agent to pay APIs automatically.
|
|
34
|
+
*/
|
|
35
|
+
export function createAgentFetch(config) {
|
|
36
|
+
const wallet = getAgentWallet(config);
|
|
37
|
+
return createX402Fetch(wallet, {
|
|
38
|
+
globalDailyLimit: config.x402DailyLimit ?? 50000000n, // 50 USDC default
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* ElizaOS Plugin definition for agentwallet-sdk.
|
|
43
|
+
*
|
|
44
|
+
* Usage in your Eliza character config:
|
|
45
|
+
*
|
|
46
|
+
* ```json
|
|
47
|
+
* {
|
|
48
|
+
* "plugins": ["@elizaos/plugin-agentwallet"],
|
|
49
|
+
* "settings": {
|
|
50
|
+
* "AGENT_PRIVATE_KEY": "0x...",
|
|
51
|
+
* "AGENT_ACCOUNT_ADDRESS": "0x...",
|
|
52
|
+
* "AGENT_CHAIN": "base",
|
|
53
|
+
* "X402_DAILY_LIMIT": "50000000"
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
const AgentWalletPlugin = {
|
|
59
|
+
name: '@elizaos/plugin-agentwallet',
|
|
60
|
+
description: 'Non-custodial agent wallet for ElizaOS — x402 payments, CCTP cross-chain, on-chain spend limits. Agent holds its own keys.',
|
|
61
|
+
actions: [],
|
|
62
|
+
providers: [
|
|
63
|
+
{
|
|
64
|
+
name: 'agentWallet',
|
|
65
|
+
description: 'Provides agent wallet and x402 fetch capability to the runtime',
|
|
66
|
+
async get(runtime) {
|
|
67
|
+
const privateKey = runtime.getSetting('AGENT_PRIVATE_KEY');
|
|
68
|
+
const accountAddress = runtime.getSetting('AGENT_ACCOUNT_ADDRESS');
|
|
69
|
+
const chain = (runtime.getSetting('AGENT_CHAIN') ?? 'base');
|
|
70
|
+
const dailyLimitStr = runtime.getSetting('X402_DAILY_LIMIT');
|
|
71
|
+
const x402DailyLimit = dailyLimitStr ? BigInt(dailyLimitStr) : 50000000n;
|
|
72
|
+
if (!privateKey || !accountAddress) {
|
|
73
|
+
return 'AgentWallet not configured: AGENT_PRIVATE_KEY and AGENT_ACCOUNT_ADDRESS required.';
|
|
74
|
+
}
|
|
75
|
+
const config = { privateKey, accountAddress, chain, x402DailyLimit };
|
|
76
|
+
const wallet = getAgentWallet(config);
|
|
77
|
+
const x402Fetch = createAgentFetch(config);
|
|
78
|
+
// Expose on runtime for actions to use
|
|
79
|
+
runtime.agentWallet = wallet;
|
|
80
|
+
runtime.x402Fetch = x402Fetch;
|
|
81
|
+
return `AgentWallet ready — non-custodial, keys stay local. Chain: ${chain}. x402 daily limit: ${x402DailyLimit / 1000000n} USDC.`;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
evaluators: [],
|
|
86
|
+
};
|
|
87
|
+
export default AgentWalletPlugin;
|
|
88
|
+
export { AgentWalletPlugin };
|
|
89
|
+
//# sourceMappingURL=elizaos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elizaos.js","sourceRoot":"","sources":["../../src/plugins/elizaos.ts"],"names":[],"mappings":"AASA,OAAO,EACL,YAAY,EAEZ,eAAe,GAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAepD,IAAI,cAAc,GAAuB,IAAI,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAA+B;IAC5D,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACvD,MAAM,OAAO,GAA2B;YACtC,IAAI,EAAE,0BAA0B;YAChC,cAAc,EAAE,0BAA0B;YAC1C,QAAQ,EAAE,0BAA0B;YACpC,QAAQ,EAAE,8BAA8B;YACxC,OAAO,EAAE,yBAAyB;YAClC,SAAS,EAAE,oCAAo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C,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAW,CAAC;gBAE3E,IAAI,CAAC,UAAU,IAAI,CAAC,cAAc,EAAE,CAAC;oBACnC,OAAO,mFAAmF,CAAC;gBAC7F,CAAC;gBAED,MAAM,MAAM,GAA4B,EAAE,UAAU,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;gBAC9F,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACtC,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBAE3C,uCAAuC;gBACtC,OAAe,CAAC,WAAW,GAAG,MAAM,CAAC;gBACrC,OAAe,CAAC,SAAS,GAAG,SAAS,CAAC;gBAEvC,OAAO,8DAA8D,KAAK,uBAAuB,cAAc,GAAG,QAAU,QAAQ,CAAC;YACvI,CAAC;SACF;KACF;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,eAAe,iBAAiB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentwallet-sdk",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Non-custodial TypeScript SDK for AI agent wallets
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "Non-custodial TypeScript SDK for AI agent wallets \u2014 x402 payments (Solana, Base, Abstract, Polygon), CCTP cross-chain, token swaps. Private keys never leave your environment.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
"typescript": "5.3.3",
|
|
43
43
|
"vitest": "4.0.18"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|