@orbserv-labs/orb-wallet 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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 orbserv Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # orb-wallet
2
+
3
+ **`@orbserv-labs/orb-wallet`** — TypeScript SDK for the orbserv agent wallet API.
4
+ Give your AI agents a multi-chain crypto wallet with built-in spending policies and x402 auto-pay in minutes.
5
+
6
+ ---
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @orbserv-labs/orb-wallet
12
+ # or
13
+ pnpm add @orbserv-labs/orb-wallet
14
+ # or
15
+ yarn add @orbserv-labs/orb-wallet
16
+ ```
17
+
18
+ **Requirements**: Node.js >= 18 (uses native `fetch`). No runtime dependencies.
19
+
20
+ ---
21
+
22
+ ## Quick start
23
+
24
+ ```typescript
25
+ import { OrbWallet } from '@orbserv-labs/orb-wallet'
26
+
27
+ const orb = new OrbWallet({ apiKey: process.env.ORB_API_KEY! })
28
+
29
+ // Create a wallet
30
+ const wallet = await orb.wallet.create({
31
+ name: "my-agent",
32
+ chains: ["solana", "base", "ethereum", "arbitrum"],
33
+ policy: {
34
+ dailyLimit: 50, // USDC per day
35
+ maxPerTx: 10, // USDC per transaction
36
+ whitelist: ["x402", "inference"],
37
+ alertAbove: 20 // alert when a single tx exceeds this
38
+ }
39
+ })
40
+
41
+ console.log(wallet.solana.address) // Sol address
42
+ console.log(wallet.evm.address) // 0x EVM address (Base / ETH / Arbitrum)
43
+
44
+ // Send tokens
45
+ await wallet.send({
46
+ to: "0xRecipient",
47
+ amount: 5,
48
+ token: "USDC",
49
+ chain: "base",
50
+ privacy: true // ZK shielded transfer
51
+ })
52
+
53
+ // Transaction history
54
+ const history = await wallet.history({ limit: 20 })
55
+ history.transactions.forEach(tx => console.log(tx.txHash, tx.amount))
56
+
57
+ // Balance across all chains
58
+ const balance = await wallet.balance()
59
+ console.log(`Total: $${balance.totalUsdValue}`)
60
+
61
+ // x402 auto-pay fetch — handles 402 Payment Required automatically
62
+ const { response } = await wallet.fetch("https://api.service.com/data")
63
+ const data = await response.json()
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Policy management
69
+
70
+ ```typescript
71
+ // Update spending limits
72
+ await wallet.policy.update({ dailyLimit: 100, maxPerTx: 25 })
73
+
74
+ // Pause all outgoing transactions
75
+ await wallet.policy.pause()
76
+
77
+ // Re-enable transactions
78
+ await wallet.policy.resume()
79
+
80
+ // Read current policy
81
+ const policy = await wallet.policy.get()
82
+ console.log(policy.dailyLimit, policy.status)
83
+ ```
84
+
85
+ ---
86
+
87
+ ## x402 service discovery
88
+
89
+ ```typescript
90
+ // Discover x402-compatible services on the orbserv marketplace
91
+ const services = await orb.x402.discover({ category: "inference" })
92
+ services.services.forEach(s => console.log(s.name, s.baseUrl))
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Wallet management
98
+
99
+ ```typescript
100
+ // Retrieve an existing wallet by ID
101
+ const wallet = await orb.wallet.get("wal_abc123")
102
+
103
+ // List all wallets for this API key
104
+ const wallets = await orb.wallet.list()
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Error handling
110
+
111
+ ```typescript
112
+ import { OrbApiError, OrbAuthError } from '@orbserv-labs/orb-wallet'
113
+
114
+ try {
115
+ const wallet = await orb.wallet.create({ name: "agent", chains: ["base"] })
116
+ } catch (err) {
117
+ if (err instanceof OrbAuthError) {
118
+ // 401 or 403 — check your API key
119
+ console.error("Auth failed:", err.statusCode, err.body)
120
+ } else if (err instanceof OrbApiError) {
121
+ // Any other non-2xx response
122
+ console.error("API error:", err.statusCode, err.body)
123
+ } else {
124
+ throw err
125
+ }
126
+ }
127
+ ```
128
+
129
+ ---
130
+
131
+ ## API reference
132
+
133
+ ### `new OrbWallet(options)`
134
+
135
+ | Option | Type | Required | Description |
136
+ |-----------|----------|----------|-------------------------------------------------------|
137
+ | `apiKey` | `string` | Yes | Your orbserv API key |
138
+ | `baseUrl` | `string` | No | Override base URL (default: `https://api.orbserv.co/v1`) |
139
+
140
+ ### `orb.wallet`
141
+
142
+ | Method | Returns | Description |
143
+ |---------------------------|------------------|-------------------------------------|
144
+ | `create(options)` | `AgentWallet` | Create a new wallet |
145
+ | `get(id)` | `AgentWallet` | Fetch an existing wallet by ID |
146
+ | `list()` | `AgentWallet[]` | List all wallets for this API key |
147
+
148
+ ### `wallet` (AgentWallet)
149
+
150
+ | Method / Property | Returns | Description |
151
+ |---------------------------|----------------------|-----------------------------------------------|
152
+ | `id` | `string` | Wallet ID |
153
+ | `name` | `string` | Wallet name |
154
+ | `solana.address` | `string` | Solana address |
155
+ | `evm.address` | `string` | EVM address (0x…) |
156
+ | `send(options)` | `Transaction` | Send tokens |
157
+ | `history(options?)` | `HistoryResponse` | Paginated transaction history |
158
+ | `balance()` | `BalanceResponse` | Per-chain, per-token balances |
159
+ | `fetch(url, init?)` | `X402FetchResult` | x402 auto-pay HTTP fetch |
160
+ | `policy` | `PolicyModule` | Spending policy manager |
161
+
162
+ ### `wallet.policy`
163
+
164
+ | Method | Returns | Description |
165
+ |------------------|---------------|------------------------------------|
166
+ | `get()` | `PolicyData` | Read current policy |
167
+ | `update(opts)` | `PolicyData` | Update policy fields |
168
+ | `pause()` | `PolicyData` | Block all outgoing transactions |
169
+ | `resume()` | `PolicyData` | Re-enable outgoing transactions |
170
+
171
+ ### `orb.x402`
172
+
173
+ | Method | Returns | Description |
174
+ |--------------------|--------------------------|-------------------------------------|
175
+ | `discover(opts?)` | `X402DiscoverResponse` | Discover x402-compatible services |
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ MIT
@@ -0,0 +1,49 @@
1
+ import type { OrbWalletOptions } from "./types.js";
2
+ import { WalletModule } from "./modules/wallet.js";
3
+ import { X402Module } from "./modules/x402.js";
4
+ /**
5
+ * Main entry point for the `@orbserv-labs/orb-wallet` SDK.
6
+ *
7
+ * Construct a single instance per application and reuse it.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import { OrbWallet } from '@orbserv-labs/orb-wallet'
12
+ *
13
+ * const orb = new OrbWallet({ apiKey: process.env.ORB_API_KEY! })
14
+ *
15
+ * // Create a wallet
16
+ * const wallet = await orb.wallet.create({
17
+ * name: "my-agent",
18
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
19
+ * policy: { dailyLimit: 50, maxPerTx: 10 }
20
+ * })
21
+ *
22
+ * // Discover x402 services
23
+ * const services = await orb.x402.discover({ category: "inference" })
24
+ * ```
25
+ */
26
+ export declare class OrbWallet {
27
+ /**
28
+ * Wallet lifecycle operations: create, get, list.
29
+ *
30
+ * @see {@link WalletModule}
31
+ */
32
+ readonly wallet: WalletModule;
33
+ /**
34
+ * x402 protocol operations: service discovery and auto-pay fetch.
35
+ *
36
+ * @see {@link X402Module}
37
+ */
38
+ readonly x402: X402Module;
39
+ private readonly http;
40
+ /**
41
+ * @param options.apiKey - Your orbserv API key (required).
42
+ * @param options.baseUrl - Override the API base URL. Defaults to
43
+ * `https://api.orbserv.co/v1`.
44
+ *
45
+ * @throws {TypeError} When `apiKey` is missing or empty.
46
+ */
47
+ constructor(options: OrbWalletOptions);
48
+ }
49
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK/C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;IAElC;;;;;;OAMG;gBACS,OAAO,EAAE,gBAAgB;CAiBtC"}
package/dist/client.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrbWallet = void 0;
4
+ const http_js_1 = require("./utils/http.js");
5
+ const wallet_js_1 = require("./modules/wallet.js");
6
+ const x402_js_1 = require("./modules/x402.js");
7
+ /** Default API base URL. Override via `OrbWalletOptions.baseUrl`. */
8
+ const DEFAULT_BASE_URL = "https://api.orbserv.co/v1";
9
+ /**
10
+ * Main entry point for the `@orbserv-labs/orb-wallet` SDK.
11
+ *
12
+ * Construct a single instance per application and reuse it.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { OrbWallet } from '@orbserv-labs/orb-wallet'
17
+ *
18
+ * const orb = new OrbWallet({ apiKey: process.env.ORB_API_KEY! })
19
+ *
20
+ * // Create a wallet
21
+ * const wallet = await orb.wallet.create({
22
+ * name: "my-agent",
23
+ * chains: ["solana", "base", "ethereum", "arbitrum"],
24
+ * policy: { dailyLimit: 50, maxPerTx: 10 }
25
+ * })
26
+ *
27
+ * // Discover x402 services
28
+ * const services = await orb.x402.discover({ category: "inference" })
29
+ * ```
30
+ */
31
+ class OrbWallet {
32
+ /**
33
+ * @param options.apiKey - Your orbserv API key (required).
34
+ * @param options.baseUrl - Override the API base URL. Defaults to
35
+ * `https://api.orbserv.co/v1`.
36
+ *
37
+ * @throws {TypeError} When `apiKey` is missing or empty.
38
+ */
39
+ constructor(options) {
40
+ if (!options.apiKey) {
41
+ throw new TypeError("OrbWallet: `apiKey` is required. " +
42
+ "Pass it via `new OrbWallet({ apiKey: '...' })` or set the " +
43
+ "ORB_API_KEY environment variable.");
44
+ }
45
+ this.http = new http_js_1.HttpClient(options.baseUrl ?? DEFAULT_BASE_URL, options.apiKey);
46
+ this.wallet = new wallet_js_1.WalletModule(this.http);
47
+ this.x402 = new x402_js_1.X402Module(this.http);
48
+ }
49
+ }
50
+ exports.OrbWallet = OrbWallet;
51
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AACA,6CAA6C;AAC7C,mDAAmD;AACnD,+CAA+C;AAE/C,qEAAqE;AACrE,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,SAAS;IAiBpB;;;;;;OAMG;IACH,YAAY,OAAyB;QACnC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,SAAS,CACjB,mCAAmC;gBACjC,4DAA4D;gBAC5D,mCAAmC,CACtC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,oBAAU,CACxB,OAAO,CAAC,OAAO,IAAI,gBAAgB,EACnC,OAAO,CAAC,MAAM,CACf,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AAzCD,8BAyCC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @orbserv-labs/orb-wallet
3
+ *
4
+ * TypeScript SDK for the orbserv agent wallet API.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { OrbWallet } from '@orbserv-labs/orb-wallet'
9
+ *
10
+ * const orb = new OrbWallet({ apiKey: process.env.ORB_API_KEY! })
11
+ * const wallet = await orb.wallet.create({ name: "my-agent", chains: ["solana", "base"] })
12
+ * ```
13
+ *
14
+ * @module
15
+ */
16
+ export { OrbWallet } from "./client.js";
17
+ export { WalletModule } from "./modules/wallet.js";
18
+ export { AgentWallet } from "./modules/agent-wallet.js";
19
+ export { PolicyModule } from "./modules/policy.js";
20
+ export { X402Module } from "./modules/x402.js";
21
+ export { OrbError, OrbApiError, OrbAuthError } from "./utils/errors.js";
22
+ export { HttpClient } from "./utils/http.js";
23
+ export type { Chain, Token, OrbWalletOptions, CreateWalletOptions, WalletData, ChainAddress, PolicyConfig, SendOptions, Transaction, HistoryOptions, HistoryResponse, BalanceEntry, BalanceResponse, PolicyData, UpdatePolicyOptions, X402DiscoverOptions, X402DiscoverResponse, X402Service, X402FetchResult, } from "./types.js";
24
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,YAAY,EAEV,KAAK,EACL,KAAK,EAEL,gBAAgB,EAChB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,YAAY,EAEZ,WAAW,EACX,WAAW,EAEX,cAAc,EACd,eAAe,EAEf,YAAY,EACZ,eAAe,EAEf,UAAU,EACV,mBAAmB,EAEnB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * @orbserv-labs/orb-wallet
4
+ *
5
+ * TypeScript SDK for the orbserv agent wallet API.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * import { OrbWallet } from '@orbserv-labs/orb-wallet'
10
+ *
11
+ * const orb = new OrbWallet({ apiKey: process.env.ORB_API_KEY! })
12
+ * const wallet = await orb.wallet.create({ name: "my-agent", chains: ["solana", "base"] })
13
+ * ```
14
+ *
15
+ * @module
16
+ */
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.HttpClient = exports.OrbAuthError = exports.OrbApiError = exports.OrbError = exports.X402Module = exports.PolicyModule = exports.AgentWallet = exports.WalletModule = exports.OrbWallet = void 0;
19
+ // Main client
20
+ var client_js_1 = require("./client.js");
21
+ Object.defineProperty(exports, "OrbWallet", { enumerable: true, get: function () { return client_js_1.OrbWallet; } });
22
+ // Modules (useful for typing constructor params / DI)
23
+ var wallet_js_1 = require("./modules/wallet.js");
24
+ Object.defineProperty(exports, "WalletModule", { enumerable: true, get: function () { return wallet_js_1.WalletModule; } });
25
+ var agent_wallet_js_1 = require("./modules/agent-wallet.js");
26
+ Object.defineProperty(exports, "AgentWallet", { enumerable: true, get: function () { return agent_wallet_js_1.AgentWallet; } });
27
+ var policy_js_1 = require("./modules/policy.js");
28
+ Object.defineProperty(exports, "PolicyModule", { enumerable: true, get: function () { return policy_js_1.PolicyModule; } });
29
+ var x402_js_1 = require("./modules/x402.js");
30
+ Object.defineProperty(exports, "X402Module", { enumerable: true, get: function () { return x402_js_1.X402Module; } });
31
+ // Error classes
32
+ var errors_js_1 = require("./utils/errors.js");
33
+ Object.defineProperty(exports, "OrbError", { enumerable: true, get: function () { return errors_js_1.OrbError; } });
34
+ Object.defineProperty(exports, "OrbApiError", { enumerable: true, get: function () { return errors_js_1.OrbApiError; } });
35
+ Object.defineProperty(exports, "OrbAuthError", { enumerable: true, get: function () { return errors_js_1.OrbAuthError; } });
36
+ // HTTP client (exposed for advanced use, e.g. testing)
37
+ var http_js_1 = require("./utils/http.js");
38
+ Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_js_1.HttpClient; } });
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,cAAc;AACd,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAElB,sDAAsD;AACtD,iDAAmD;AAA1C,yGAAA,YAAY,OAAA;AACrB,6DAAwD;AAA/C,8GAAA,WAAW,OAAA;AACpB,iDAAmD;AAA1C,yGAAA,YAAY,OAAA;AACrB,6CAA+C;AAAtC,qGAAA,UAAU,OAAA;AAEnB,gBAAgB;AAChB,+CAAwE;AAA/D,qGAAA,QAAQ,OAAA;AAAE,wGAAA,WAAW,OAAA;AAAE,yGAAA,YAAY,OAAA;AAE5C,uDAAuD;AACvD,2CAA6C;AAApC,qGAAA,UAAU,OAAA"}
@@ -0,0 +1,118 @@
1
+ import type { HttpClient } from "../utils/http.js";
2
+ import type { WalletData, ChainAddress, SendOptions, Transaction, HistoryOptions, HistoryResponse, BalanceResponse, X402FetchResult } from "../types.js";
3
+ import { PolicyModule } from "./policy.js";
4
+ /**
5
+ * Represents a live agent wallet instance.
6
+ *
7
+ * Returned by `orb.wallet.create()`, `orb.wallet.get()`, and `orb.wallet.list()`.
8
+ * Provides direct methods for sending funds, querying history/balance, and
9
+ * managing the wallet's spending policy.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const wallet = await orb.wallet.create({ name: "my-agent", chains: ["solana", "base"] })
14
+ *
15
+ * wallet.solana.address // Sol address
16
+ * wallet.evm.address // 0x address
17
+ *
18
+ * await wallet.send({ to: "0xRecipient", amount: 5, token: "USDC", chain: "base" })
19
+ * ```
20
+ */
21
+ export declare class AgentWallet {
22
+ /** Unique wallet identifier. */
23
+ readonly id: string;
24
+ /** Human-readable wallet name. */
25
+ readonly name: string;
26
+ /**
27
+ * Solana address details.
28
+ * Present only when the wallet was created with `chains: ["solana", ...]`.
29
+ */
30
+ readonly solana: ChainAddress;
31
+ /**
32
+ * EVM address details (shared across Base, Ethereum, Arbitrum).
33
+ * Present only when at least one EVM chain was included at creation.
34
+ */
35
+ readonly evm: ChainAddress;
36
+ /** ISO 8601 timestamp of wallet creation. */
37
+ readonly createdAt: string;
38
+ /** Current wallet status. */
39
+ readonly status: WalletData["status"];
40
+ /**
41
+ * Spending policy manager for this wallet.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * await wallet.policy.update({ dailyLimit: 100 })
46
+ * await wallet.policy.pause()
47
+ * await wallet.policy.resume()
48
+ * ```
49
+ */
50
+ readonly policy: PolicyModule;
51
+ private readonly http;
52
+ private readonly x402Module;
53
+ constructor(data: WalletData, http: HttpClient);
54
+ /**
55
+ * Send tokens from this wallet to another address.
56
+ *
57
+ * @param options - Transfer parameters including recipient, amount, token, chain,
58
+ * and optional ZK-shielding via `privacy: true`.
59
+ * @returns The resulting {@link Transaction} record.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * await wallet.send({
64
+ * to: "0xRecipient",
65
+ * amount: 5,
66
+ * token: "USDC",
67
+ * chain: "base",
68
+ * privacy: true
69
+ * })
70
+ * ```
71
+ */
72
+ send(options: SendOptions): Promise<Transaction>;
73
+ /**
74
+ * Retrieve paginated transaction history for this wallet.
75
+ *
76
+ * @param options - Optional filters and pagination parameters.
77
+ * @returns A {@link HistoryResponse} containing transactions and cursor.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const history = await wallet.history({ limit: 20 })
82
+ * history.transactions.forEach(tx => console.log(tx.txHash))
83
+ * ```
84
+ */
85
+ history(options?: HistoryOptions): Promise<HistoryResponse>;
86
+ /**
87
+ * Get the current token balances for this wallet across all active chains.
88
+ *
89
+ * @returns A {@link BalanceResponse} with per-chain, per-token balances and
90
+ * a total USD value.
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const balance = await wallet.balance()
95
+ * console.log(`Total: $${balance.totalUsdValue}`)
96
+ * ```
97
+ */
98
+ balance(): Promise<BalanceResponse>;
99
+ /**
100
+ * Perform an HTTP request with automatic x402 payment handling.
101
+ *
102
+ * If the target URL returns `HTTP 402 Payment Required`, the SDK
103
+ * automatically negotiates and submits a micro-payment from this wallet
104
+ * and retries the request — no manual intervention needed.
105
+ *
106
+ * @param url - The URL to fetch.
107
+ * @param init - Optional fetch `RequestInit` options.
108
+ * @returns An {@link X402FetchResult} with the final Response.
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const { response } = await wallet.fetch("https://api.service.com/data")
113
+ * const json = await response.json()
114
+ * ```
115
+ */
116
+ fetch(url: string, init?: RequestInit): Promise<X402FetchResult>;
117
+ }
118
+ //# sourceMappingURL=agent-wallet.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-wallet.d.ts","sourceRoot":"","sources":["../../src/modules/agent-wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EACV,UAAU,EAC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exports.AgentWallet = void 0;
4
+ const policy_js_1 = require("./policy.js");
5
+ const x402_js_1 = require("./x402.js");
6
+ /**
7
+ * Represents a live agent wallet instance.
8
+ *
9
+ * Returned by `orb.wallet.create()`, `orb.wallet.get()`, and `orb.wallet.list()`.
10
+ * Provides direct methods for sending funds, querying history/balance, and
11
+ * managing the wallet's spending policy.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const wallet = await orb.wallet.create({ name: "my-agent", chains: ["solana", "base"] })
16
+ *
17
+ * wallet.solana.address // Sol address
18
+ * wallet.evm.address // 0x address
19
+ *
20
+ * await wallet.send({ to: "0xRecipient", amount: 5, token: "USDC", chain: "base" })
21
+ * ```
22
+ */
23
+ class AgentWallet {
24
+ constructor(data, http) {
25
+ this.id = data.id;
26
+ this.name = data.name;
27
+ this.createdAt = data.createdAt;
28
+ this.status = data.status;
29
+ // Provide safe defaults so that callers using TypeScript strict mode can
30
+ // rely on these being defined — the API always returns addresses for the
31
+ // chains that were activated at creation time.
32
+ this.solana = data.solana ?? { address: "", chain: "solana" };
33
+ this.evm = data.evm ?? { address: "", chain: "base" };
34
+ this.http = http;
35
+ this.policy = new policy_js_1.PolicyModule(http, data.id);
36
+ this.x402Module = new x402_js_1.X402Module(http);
37
+ }
38
+ // -------------------------------------------------------------------------
39
+ // Funds
40
+ // -------------------------------------------------------------------------
41
+ /**
42
+ * Send tokens from this wallet to another address.
43
+ *
44
+ * @param options - Transfer parameters including recipient, amount, token, chain,
45
+ * and optional ZK-shielding via `privacy: true`.
46
+ * @returns The resulting {@link Transaction} record.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * await wallet.send({
51
+ * to: "0xRecipient",
52
+ * amount: 5,
53
+ * token: "USDC",
54
+ * chain: "base",
55
+ * privacy: true
56
+ * })
57
+ * ```
58
+ */
59
+ async send(options) {
60
+ return this.http.post(`/wallets/${this.id}/send`, {
61
+ to: options.to,
62
+ amount: options.amount,
63
+ token: options.token ?? "USDC",
64
+ chain: options.chain,
65
+ privacy: options.privacy ?? false,
66
+ });
67
+ }
68
+ // -------------------------------------------------------------------------
69
+ // History & balance
70
+ // -------------------------------------------------------------------------
71
+ /**
72
+ * Retrieve paginated transaction history for this wallet.
73
+ *
74
+ * @param options - Optional filters and pagination parameters.
75
+ * @returns A {@link HistoryResponse} containing transactions and cursor.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const history = await wallet.history({ limit: 20 })
80
+ * history.transactions.forEach(tx => console.log(tx.txHash))
81
+ * ```
82
+ */
83
+ async history(options = {}) {
84
+ const params = new URLSearchParams();
85
+ if (options.limit !== undefined)
86
+ params.set("limit", String(options.limit));
87
+ if (options.cursor)
88
+ params.set("cursor", options.cursor);
89
+ if (options.chain)
90
+ params.set("chain", options.chain);
91
+ if (options.token)
92
+ params.set("token", options.token);
93
+ const query = params.toString();
94
+ return this.http.get(`/wallets/${this.id}/history${query ? `?${query}` : ""}`);
95
+ }
96
+ /**
97
+ * Get the current token balances for this wallet across all active chains.
98
+ *
99
+ * @returns A {@link BalanceResponse} with per-chain, per-token balances and
100
+ * a total USD value.
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const balance = await wallet.balance()
105
+ * console.log(`Total: $${balance.totalUsdValue}`)
106
+ * ```
107
+ */
108
+ async balance() {
109
+ return this.http.get(`/wallets/${this.id}/balance`);
110
+ }
111
+ // -------------------------------------------------------------------------
112
+ // x402 auto-pay
113
+ // -------------------------------------------------------------------------
114
+ /**
115
+ * Perform an HTTP request with automatic x402 payment handling.
116
+ *
117
+ * If the target URL returns `HTTP 402 Payment Required`, the SDK
118
+ * automatically negotiates and submits a micro-payment from this wallet
119
+ * and retries the request — no manual intervention needed.
120
+ *
121
+ * @param url - The URL to fetch.
122
+ * @param init - Optional fetch `RequestInit` options.
123
+ * @returns An {@link X402FetchResult} with the final Response.
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * const { response } = await wallet.fetch("https://api.service.com/data")
128
+ * const json = await response.json()
129
+ * ```
130
+ */
131
+ async fetch(url, init) {
132
+ return this.x402Module.fetch(this.id, url, init);
133
+ }
134
+ }
135
+ exports.AgentWallet = AgentWallet;
136
+ //# sourceMappingURL=agent-wallet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-wallet.js","sourceRoot":"","sources":["../../src/modules/agent-wallet.ts"],"names":[],"mappings":";;;AAWA,2CAA2C;AAC3C,uCAAuC;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,WAAW;IAwCtB,YAAY,IAAgB,EAAE,IAAgB;QAC5C,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE1B,yEAAyE;QACzE,yEAAyE;QACzE,+CAA+C;QAC/C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;QAC9D,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAEtD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAY,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9C,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,4EAA4E;IAC5E,QAAQ;IACR,4EAA4E;IAE5E;;;;;;;;;;;;;;;;;OAiBG;IACH,KAAK,CAAC,IAAI,CAAC,OAAoB;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAc,YAAY,IAAI,CAAC,EAAE,OAAO,EAAE;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