@axonfi/sdk 0.3.6 → 0.4.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 +40 -0
- package/dist/abis/AxonRegistry.d.ts +294 -0
- package/dist/abis/AxonRegistry.d.ts.map +1 -0
- package/dist/abis/AxonRegistry.js +381 -0
- package/dist/abis/AxonRegistry.js.map +1 -0
- package/dist/abis/AxonVault.d.ts +1577 -0
- package/dist/abis/AxonVault.d.ts.map +1 -0
- package/dist/abis/AxonVault.js +2026 -0
- package/dist/abis/AxonVault.js.map +1 -0
- package/dist/abis/AxonVaultFactory.d.ts +207 -0
- package/dist/abis/AxonVaultFactory.d.ts.map +1 -0
- package/dist/abis/AxonVaultFactory.js +269 -0
- package/dist/abis/AxonVaultFactory.js.map +1 -0
- package/dist/amounts.d.ts +37 -0
- package/dist/amounts.d.ts.map +1 -0
- package/dist/amounts.js +72 -0
- package/dist/amounts.js.map +1 -0
- package/dist/amounts.spec.d.ts +2 -0
- package/dist/amounts.spec.d.ts.map +1 -0
- package/dist/amounts.spec.js +92 -0
- package/dist/amounts.spec.js.map +1 -0
- package/dist/client.d.ts +196 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +621 -0
- package/dist/client.js.map +1 -0
- package/dist/client.spec.d.ts +2 -0
- package/dist/client.spec.d.ts.map +1 -0
- package/dist/client.spec.js +437 -0
- package/dist/client.spec.js.map +1 -0
- package/dist/constants.d.ts +110 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +172 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.spec.d.ts +2 -0
- package/dist/constants.spec.d.ts.map +1 -0
- package/dist/constants.spec.js +95 -0
- package/dist/constants.spec.js.map +1 -0
- package/dist/eip3009.d.ts +45 -0
- package/dist/eip3009.d.ts.map +1 -0
- package/dist/eip3009.js +85 -0
- package/dist/eip3009.js.map +1 -0
- package/dist/index.d.ts +21 -3020
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -3903
- package/dist/index.js.map +1 -1
- package/dist/keystore.d.ts +60 -0
- package/dist/keystore.d.ts.map +1 -0
- package/dist/keystore.js +182 -0
- package/dist/keystore.js.map +1 -0
- package/dist/keystore.spec.d.ts +2 -0
- package/dist/keystore.spec.d.ts.map +1 -0
- package/dist/keystore.spec.js +71 -0
- package/dist/keystore.spec.js.map +1 -0
- package/dist/permit2.d.ts +45 -0
- package/dist/permit2.d.ts.map +1 -0
- package/dist/permit2.js +81 -0
- package/dist/permit2.js.map +1 -0
- package/dist/signer.d.ts +35 -0
- package/dist/signer.d.ts.map +1 -0
- package/dist/signer.js +132 -0
- package/dist/signer.js.map +1 -0
- package/dist/signer.spec.d.ts +2 -0
- package/dist/signer.spec.d.ts.map +1 -0
- package/dist/signer.spec.js +94 -0
- package/dist/signer.spec.js.map +1 -0
- package/dist/tokens.d.ts +215 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +247 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +302 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +29 -0
- package/dist/utils.js.map +1 -0
- package/dist/vault.d.ts +60 -0
- package/dist/vault.d.ts.map +1 -0
- package/dist/vault.js +267 -0
- package/dist/vault.js.map +1 -0
- package/dist/vault.spec.d.ts +2 -0
- package/dist/vault.spec.d.ts.map +1 -0
- package/dist/vault.spec.js +162 -0
- package/dist/vault.spec.js.map +1 -0
- package/dist/x402.d.ts +88 -0
- package/dist/x402.d.ts.map +1 -0
- package/dist/x402.js +124 -0
- package/dist/x402.js.map +1 -0
- package/dist/x402.spec.d.ts +2 -0
- package/dist/x402.spec.d.ts.map +1 -0
- package/dist/x402.spec.js +411 -0
- package/dist/x402.spec.js.map +1 -0
- package/package.json +1 -1
- package/dist/index.cjs +0 -3954
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -3020
package/README.md
CHANGED
|
@@ -24,6 +24,24 @@ Your agents pay. You stay in control.
|
|
|
24
24
|
npm install @axonfi/sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
## Prerequisites
|
|
28
|
+
|
|
29
|
+
Before using the SDK, you need an Axon vault with a registered bot:
|
|
30
|
+
|
|
31
|
+
1. **Deploy a vault** — Go to [app.axonfi.xyz](https://app.axonfi.xyz), connect your wallet, and deploy a vault on your target chain. The vault is a non-custodial smart contract — only you (the owner) can withdraw funds.
|
|
32
|
+
|
|
33
|
+
2. **Fund the vault** — Send USDC (or any ERC-20) to your vault address. Anyone can deposit directly to the contract.
|
|
34
|
+
|
|
35
|
+
3. **Register a bot** — In the dashboard, go to your vault → Bots → Add Bot. You can either:
|
|
36
|
+
- **Generate a new keypair** (recommended) — the dashboard creates a key and downloads an encrypted keystore JSON file. You set the passphrase.
|
|
37
|
+
- **Bring your own key** — paste an existing public key if you manage keys externally.
|
|
38
|
+
|
|
39
|
+
4. **Configure policies** — Set per-transaction caps, daily spending limits, velocity windows, and destination whitelists. The bot can only operate within these bounds.
|
|
40
|
+
|
|
41
|
+
5. **Get the bot key** — Your agent needs the bot's private key to sign payment intents. Use the keystore file + passphrase (recommended) or export the raw private key for quick testing.
|
|
42
|
+
|
|
43
|
+
The vault owner's wallet stays secure — the bot key can only sign intents within the policies you configure, and can be revoked instantly from the dashboard.
|
|
44
|
+
|
|
27
45
|
## Quick Start
|
|
28
46
|
|
|
29
47
|
### With Encrypted Keystore (recommended)
|
|
@@ -167,6 +185,28 @@ Payments resolve through one of three paths:
|
|
|
167
185
|
| **AI Scan** | Exceeds AI threshold | ~30s | `status: "approved"` or routes to review |
|
|
168
186
|
| **Human Review** | No AI consensus | Async | `status: "pending_review"`, poll for result |
|
|
169
187
|
|
|
188
|
+
## HTTP 402 Paywalls (x402)
|
|
189
|
+
|
|
190
|
+
The SDK handles [x402](https://www.x402.org/) paywalls — APIs that charge per-request via HTTP 402 Payment Required. When a bot hits a paywall, the SDK parses the payment requirements, funds the bot from the vault, signs a token authorization, and returns a header for the retry.
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const response = await fetch('https://api.example.com/data');
|
|
194
|
+
|
|
195
|
+
if (response.status === 402) {
|
|
196
|
+
// SDK handles everything: parse header, fund bot from vault, sign authorization
|
|
197
|
+
const result = await axon.x402.handlePaymentRequired(response.headers);
|
|
198
|
+
|
|
199
|
+
// Retry with the payment signature
|
|
200
|
+
const data = await fetch('https://api.example.com/data', {
|
|
201
|
+
headers: { 'PAYMENT-SIGNATURE': result.paymentSignature },
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The full pipeline applies — spending limits, AI verification, human review — even for 402 payments. Vault owners see every paywall payment in the dashboard with the resource URL, merchant address, and amount.
|
|
207
|
+
|
|
208
|
+
Supports EIP-3009 (USDC, gasless) and Permit2 (any ERC-20) settlement schemes.
|
|
209
|
+
|
|
170
210
|
## Security Model
|
|
171
211
|
|
|
172
212
|
- **Owners** control everything: bot whitelist, spending limits, withdrawal. Hardware wallet recommended.
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
export declare const AxonRegistryAbi: readonly [{
|
|
2
|
+
readonly type: "constructor";
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly name: "initialOwner";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
readonly internalType: "address";
|
|
7
|
+
}];
|
|
8
|
+
readonly stateMutability: "nonpayable";
|
|
9
|
+
}, {
|
|
10
|
+
readonly type: "function";
|
|
11
|
+
readonly name: "acceptOwnership";
|
|
12
|
+
readonly inputs: readonly [];
|
|
13
|
+
readonly outputs: readonly [];
|
|
14
|
+
readonly stateMutability: "nonpayable";
|
|
15
|
+
}, {
|
|
16
|
+
readonly type: "function";
|
|
17
|
+
readonly name: "addRelayer";
|
|
18
|
+
readonly inputs: readonly [{
|
|
19
|
+
readonly name: "relayer";
|
|
20
|
+
readonly type: "address";
|
|
21
|
+
readonly internalType: "address";
|
|
22
|
+
}];
|
|
23
|
+
readonly outputs: readonly [];
|
|
24
|
+
readonly stateMutability: "nonpayable";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "function";
|
|
27
|
+
readonly name: "addSwapRouter";
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly name: "router";
|
|
30
|
+
readonly type: "address";
|
|
31
|
+
readonly internalType: "address";
|
|
32
|
+
}];
|
|
33
|
+
readonly outputs: readonly [];
|
|
34
|
+
readonly stateMutability: "nonpayable";
|
|
35
|
+
}, {
|
|
36
|
+
readonly type: "function";
|
|
37
|
+
readonly name: "isApprovedSwapRouter";
|
|
38
|
+
readonly inputs: readonly [{
|
|
39
|
+
readonly name: "router";
|
|
40
|
+
readonly type: "address";
|
|
41
|
+
readonly internalType: "address";
|
|
42
|
+
}];
|
|
43
|
+
readonly outputs: readonly [{
|
|
44
|
+
readonly name: "";
|
|
45
|
+
readonly type: "bool";
|
|
46
|
+
readonly internalType: "bool";
|
|
47
|
+
}];
|
|
48
|
+
readonly stateMutability: "view";
|
|
49
|
+
}, {
|
|
50
|
+
readonly type: "function";
|
|
51
|
+
readonly name: "isAuthorized";
|
|
52
|
+
readonly inputs: readonly [{
|
|
53
|
+
readonly name: "relayer";
|
|
54
|
+
readonly type: "address";
|
|
55
|
+
readonly internalType: "address";
|
|
56
|
+
}];
|
|
57
|
+
readonly outputs: readonly [{
|
|
58
|
+
readonly name: "";
|
|
59
|
+
readonly type: "bool";
|
|
60
|
+
readonly internalType: "bool";
|
|
61
|
+
}];
|
|
62
|
+
readonly stateMutability: "view";
|
|
63
|
+
}, {
|
|
64
|
+
readonly type: "function";
|
|
65
|
+
readonly name: "owner";
|
|
66
|
+
readonly inputs: readonly [];
|
|
67
|
+
readonly outputs: readonly [{
|
|
68
|
+
readonly name: "";
|
|
69
|
+
readonly type: "address";
|
|
70
|
+
readonly internalType: "address";
|
|
71
|
+
}];
|
|
72
|
+
readonly stateMutability: "view";
|
|
73
|
+
}, {
|
|
74
|
+
readonly type: "function";
|
|
75
|
+
readonly name: "pendingOwner";
|
|
76
|
+
readonly inputs: readonly [];
|
|
77
|
+
readonly outputs: readonly [{
|
|
78
|
+
readonly name: "";
|
|
79
|
+
readonly type: "address";
|
|
80
|
+
readonly internalType: "address";
|
|
81
|
+
}];
|
|
82
|
+
readonly stateMutability: "view";
|
|
83
|
+
}, {
|
|
84
|
+
readonly type: "function";
|
|
85
|
+
readonly name: "removeRelayer";
|
|
86
|
+
readonly inputs: readonly [{
|
|
87
|
+
readonly name: "relayer";
|
|
88
|
+
readonly type: "address";
|
|
89
|
+
readonly internalType: "address";
|
|
90
|
+
}];
|
|
91
|
+
readonly outputs: readonly [];
|
|
92
|
+
readonly stateMutability: "nonpayable";
|
|
93
|
+
}, {
|
|
94
|
+
readonly type: "function";
|
|
95
|
+
readonly name: "removeSwapRouter";
|
|
96
|
+
readonly inputs: readonly [{
|
|
97
|
+
readonly name: "router";
|
|
98
|
+
readonly type: "address";
|
|
99
|
+
readonly internalType: "address";
|
|
100
|
+
}];
|
|
101
|
+
readonly outputs: readonly [];
|
|
102
|
+
readonly stateMutability: "nonpayable";
|
|
103
|
+
}, {
|
|
104
|
+
readonly type: "function";
|
|
105
|
+
readonly name: "renounceOwnership";
|
|
106
|
+
readonly inputs: readonly [];
|
|
107
|
+
readonly outputs: readonly [];
|
|
108
|
+
readonly stateMutability: "nonpayable";
|
|
109
|
+
}, {
|
|
110
|
+
readonly type: "function";
|
|
111
|
+
readonly name: "setOracleConfig";
|
|
112
|
+
readonly inputs: readonly [{
|
|
113
|
+
readonly name: "uniV3Factory";
|
|
114
|
+
readonly type: "address";
|
|
115
|
+
readonly internalType: "address";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "usdc";
|
|
118
|
+
readonly type: "address";
|
|
119
|
+
readonly internalType: "address";
|
|
120
|
+
}, {
|
|
121
|
+
readonly name: "weth";
|
|
122
|
+
readonly type: "address";
|
|
123
|
+
readonly internalType: "address";
|
|
124
|
+
}];
|
|
125
|
+
readonly outputs: readonly [];
|
|
126
|
+
readonly stateMutability: "nonpayable";
|
|
127
|
+
}, {
|
|
128
|
+
readonly type: "function";
|
|
129
|
+
readonly name: "transferOwnership";
|
|
130
|
+
readonly inputs: readonly [{
|
|
131
|
+
readonly name: "newOwner";
|
|
132
|
+
readonly type: "address";
|
|
133
|
+
readonly internalType: "address";
|
|
134
|
+
}];
|
|
135
|
+
readonly outputs: readonly [];
|
|
136
|
+
readonly stateMutability: "nonpayable";
|
|
137
|
+
}, {
|
|
138
|
+
readonly type: "function";
|
|
139
|
+
readonly name: "uniswapV3Factory";
|
|
140
|
+
readonly inputs: readonly [];
|
|
141
|
+
readonly outputs: readonly [{
|
|
142
|
+
readonly name: "";
|
|
143
|
+
readonly type: "address";
|
|
144
|
+
readonly internalType: "address";
|
|
145
|
+
}];
|
|
146
|
+
readonly stateMutability: "view";
|
|
147
|
+
}, {
|
|
148
|
+
readonly type: "function";
|
|
149
|
+
readonly name: "usdcAddress";
|
|
150
|
+
readonly inputs: readonly [];
|
|
151
|
+
readonly outputs: readonly [{
|
|
152
|
+
readonly name: "";
|
|
153
|
+
readonly type: "address";
|
|
154
|
+
readonly internalType: "address";
|
|
155
|
+
}];
|
|
156
|
+
readonly stateMutability: "view";
|
|
157
|
+
}, {
|
|
158
|
+
readonly type: "function";
|
|
159
|
+
readonly name: "wethAddress";
|
|
160
|
+
readonly inputs: readonly [];
|
|
161
|
+
readonly outputs: readonly [{
|
|
162
|
+
readonly name: "";
|
|
163
|
+
readonly type: "address";
|
|
164
|
+
readonly internalType: "address";
|
|
165
|
+
}];
|
|
166
|
+
readonly stateMutability: "view";
|
|
167
|
+
}, {
|
|
168
|
+
readonly type: "event";
|
|
169
|
+
readonly name: "OracleConfigUpdated";
|
|
170
|
+
readonly inputs: readonly [{
|
|
171
|
+
readonly name: "uniswapV3Factory";
|
|
172
|
+
readonly type: "address";
|
|
173
|
+
readonly indexed: false;
|
|
174
|
+
readonly internalType: "address";
|
|
175
|
+
}, {
|
|
176
|
+
readonly name: "usdc";
|
|
177
|
+
readonly type: "address";
|
|
178
|
+
readonly indexed: false;
|
|
179
|
+
readonly internalType: "address";
|
|
180
|
+
}, {
|
|
181
|
+
readonly name: "weth";
|
|
182
|
+
readonly type: "address";
|
|
183
|
+
readonly indexed: false;
|
|
184
|
+
readonly internalType: "address";
|
|
185
|
+
}];
|
|
186
|
+
readonly anonymous: false;
|
|
187
|
+
}, {
|
|
188
|
+
readonly type: "event";
|
|
189
|
+
readonly name: "OwnershipTransferStarted";
|
|
190
|
+
readonly inputs: readonly [{
|
|
191
|
+
readonly name: "previousOwner";
|
|
192
|
+
readonly type: "address";
|
|
193
|
+
readonly indexed: true;
|
|
194
|
+
readonly internalType: "address";
|
|
195
|
+
}, {
|
|
196
|
+
readonly name: "newOwner";
|
|
197
|
+
readonly type: "address";
|
|
198
|
+
readonly indexed: true;
|
|
199
|
+
readonly internalType: "address";
|
|
200
|
+
}];
|
|
201
|
+
readonly anonymous: false;
|
|
202
|
+
}, {
|
|
203
|
+
readonly type: "event";
|
|
204
|
+
readonly name: "OwnershipTransferred";
|
|
205
|
+
readonly inputs: readonly [{
|
|
206
|
+
readonly name: "previousOwner";
|
|
207
|
+
readonly type: "address";
|
|
208
|
+
readonly indexed: true;
|
|
209
|
+
readonly internalType: "address";
|
|
210
|
+
}, {
|
|
211
|
+
readonly name: "newOwner";
|
|
212
|
+
readonly type: "address";
|
|
213
|
+
readonly indexed: true;
|
|
214
|
+
readonly internalType: "address";
|
|
215
|
+
}];
|
|
216
|
+
readonly anonymous: false;
|
|
217
|
+
}, {
|
|
218
|
+
readonly type: "event";
|
|
219
|
+
readonly name: "RelayerAdded";
|
|
220
|
+
readonly inputs: readonly [{
|
|
221
|
+
readonly name: "relayer";
|
|
222
|
+
readonly type: "address";
|
|
223
|
+
readonly indexed: true;
|
|
224
|
+
readonly internalType: "address";
|
|
225
|
+
}];
|
|
226
|
+
readonly anonymous: false;
|
|
227
|
+
}, {
|
|
228
|
+
readonly type: "event";
|
|
229
|
+
readonly name: "RelayerRemoved";
|
|
230
|
+
readonly inputs: readonly [{
|
|
231
|
+
readonly name: "relayer";
|
|
232
|
+
readonly type: "address";
|
|
233
|
+
readonly indexed: true;
|
|
234
|
+
readonly internalType: "address";
|
|
235
|
+
}];
|
|
236
|
+
readonly anonymous: false;
|
|
237
|
+
}, {
|
|
238
|
+
readonly type: "event";
|
|
239
|
+
readonly name: "SwapRouterAdded";
|
|
240
|
+
readonly inputs: readonly [{
|
|
241
|
+
readonly name: "router";
|
|
242
|
+
readonly type: "address";
|
|
243
|
+
readonly indexed: true;
|
|
244
|
+
readonly internalType: "address";
|
|
245
|
+
}];
|
|
246
|
+
readonly anonymous: false;
|
|
247
|
+
}, {
|
|
248
|
+
readonly type: "event";
|
|
249
|
+
readonly name: "SwapRouterRemoved";
|
|
250
|
+
readonly inputs: readonly [{
|
|
251
|
+
readonly name: "router";
|
|
252
|
+
readonly type: "address";
|
|
253
|
+
readonly indexed: true;
|
|
254
|
+
readonly internalType: "address";
|
|
255
|
+
}];
|
|
256
|
+
readonly anonymous: false;
|
|
257
|
+
}, {
|
|
258
|
+
readonly type: "error";
|
|
259
|
+
readonly name: "AlreadyApproved";
|
|
260
|
+
readonly inputs: readonly [];
|
|
261
|
+
}, {
|
|
262
|
+
readonly type: "error";
|
|
263
|
+
readonly name: "AlreadyAuthorized";
|
|
264
|
+
readonly inputs: readonly [];
|
|
265
|
+
}, {
|
|
266
|
+
readonly type: "error";
|
|
267
|
+
readonly name: "NotApproved";
|
|
268
|
+
readonly inputs: readonly [];
|
|
269
|
+
}, {
|
|
270
|
+
readonly type: "error";
|
|
271
|
+
readonly name: "NotAuthorized";
|
|
272
|
+
readonly inputs: readonly [];
|
|
273
|
+
}, {
|
|
274
|
+
readonly type: "error";
|
|
275
|
+
readonly name: "OwnableInvalidOwner";
|
|
276
|
+
readonly inputs: readonly [{
|
|
277
|
+
readonly name: "owner";
|
|
278
|
+
readonly type: "address";
|
|
279
|
+
readonly internalType: "address";
|
|
280
|
+
}];
|
|
281
|
+
}, {
|
|
282
|
+
readonly type: "error";
|
|
283
|
+
readonly name: "OwnableUnauthorizedAccount";
|
|
284
|
+
readonly inputs: readonly [{
|
|
285
|
+
readonly name: "account";
|
|
286
|
+
readonly type: "address";
|
|
287
|
+
readonly internalType: "address";
|
|
288
|
+
}];
|
|
289
|
+
}, {
|
|
290
|
+
readonly type: "error";
|
|
291
|
+
readonly name: "ZeroAddress";
|
|
292
|
+
readonly inputs: readonly [];
|
|
293
|
+
}];
|
|
294
|
+
//# sourceMappingURL=AxonRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AxonRegistry.d.ts","sourceRoot":"","sources":["../../src/abis/AxonRegistry.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2XlB,CAAC"}
|