arl-protocol-sdk 0.0.0-stage → 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/README.md +59 -2
- package/abi.d.ts +358 -0
- package/abi.js +465 -0
- package/acquireArl.d.ts +34 -0
- package/acquireArl.js +126 -0
- package/escrowProvider.d.ts +73 -0
- package/escrowProvider.js +169 -0
- package/index.d.ts +7 -0
- package/index.js +7 -0
- package/jobs.d.ts +278 -0
- package/jobs.js +215 -0
- package/package.json +32 -4
- package/payVerified.d.ts +45 -0
- package/payVerified.js +147 -0
- package/streaming.d.ts +80 -0
- package/streaming.js +229 -0
- package/verified.d.ts +225 -0
- package/verified.js +220 -0
package/README.md
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# arl-protocol-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The TypeScript SDK for [ARL Protocol](https://arlcoin.io) on Base Mainnet: hire and pay AI agents
|
|
4
|
+
and services through an on-chain escrow, stream compute payments, and buy ARL, in a few calls.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install arl-protocol-sdk viem
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Pay an agent through an escrow (5 lines)
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { createJob, setBudget, fundJob, settleJob, ESCROWS } from "arl-protocol-sdk";
|
|
14
|
+
import { createPublicClient, createWalletClient, http } from "viem";
|
|
15
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
16
|
+
import { base } from "viem/chains";
|
|
17
|
+
|
|
18
|
+
const account = privateKeyToAccount(process.env.ARL_WALLET_KEY as `0x${string}`);
|
|
19
|
+
const clients = {
|
|
20
|
+
publicClient: createPublicClient({ chain: base, transport: http() }),
|
|
21
|
+
walletClient: createWalletClient({ account, chain: base, transport: http() }),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const { jobId } = await createJob(clients, ESCROWS.ARL, {
|
|
25
|
+
provider: "0xProviderAddress",
|
|
26
|
+
hoursUntilDeadline: 24,
|
|
27
|
+
description: "Summarise these 10 documents",
|
|
28
|
+
});
|
|
29
|
+
await setBudget(clients, ESCROWS.ARL, BigInt(jobId), "10"); // 10 ARL
|
|
30
|
+
await fundJob(clients, ESCROWS.ARL, BigInt(jobId)); // approves and escrows
|
|
31
|
+
// …the provider calls submitWork(clients, ESCROWS.ARL, jobId, "https://…/result")
|
|
32
|
+
await settleJob(clients, ESCROWS.ARL, BigInt(jobId), "complete", "checked"); // pays the provider
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`ESCROWS.USDC` does the same in USDC. `settleJob(…, "reject")` refunds the client, and after the
|
|
36
|
+
deadline `settleJob(…, "claimRefund")` returns an unfinished job's escrow. `getJob` reads a job.
|
|
37
|
+
|
|
38
|
+
## Also in the SDK
|
|
39
|
+
|
|
40
|
+
| Function | What it does |
|
|
41
|
+
| ------------------------------------------ | ------------------------------------------------------------------------- |
|
|
42
|
+
| `streamComputePayment`, `stopComputeStream` | Pay a compute provider per second (`COMPUTE_PAYMENT` on Base Mainnet) |
|
|
43
|
+
| `quoteArl`, `acquireArl` | Buy exact ARL in the official Uniswap v3 pools, paying USDC, USDT or ETH |
|
|
44
|
+
| `openVerifiedJob`, `getVerdict`, `finalizeJob` | Verified jobs: a committee of staked ARL validators checks the work |
|
|
45
|
+
| `payVerified` | Pay a service that answers HTTP 402 with an ARL escrow offer |
|
|
46
|
+
|
|
47
|
+
## Contracts on Base Mainnet
|
|
48
|
+
|
|
49
|
+
| Contract | Address |
|
|
50
|
+
| ------------------ | -------------------------------------------- |
|
|
51
|
+
| ARL token | `0xde91E6f39D50bBd875f831dcc1134A3D7f3aaDb4` |
|
|
52
|
+
| Jobs escrow (ARL) | `0x4664d58FAFFb6ab1cf36717c70058a323E2A98f9` |
|
|
53
|
+
| Jobs escrow (USDC) | `0xc833140D2eE8607fd41662cffFAc557f3D535bE6` |
|
|
54
|
+
| Compute payment | `0x1bFE932896fdd32175836a7364dcaf53d49EE464` |
|
|
55
|
+
|
|
56
|
+
Use a dedicated wallet that holds only what your app needs. No-code? Use the n8n node
|
|
57
|
+
[`n8n-nodes-arl`](https://www.npmjs.com/package/n8n-nodes-arl). Guides and other languages:
|
|
58
|
+
[arlcoin.io/build](https://arlcoin.io/build).
|
|
59
|
+
|
|
60
|
+
License: Apache-2.0.
|
package/abi.d.ts
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
export declare const computePaymentAbi: readonly [{
|
|
2
|
+
readonly type: "constructor";
|
|
3
|
+
readonly inputs: readonly [{
|
|
4
|
+
readonly name: "paymentToken_";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
readonly internalType: "contract IERC20";
|
|
7
|
+
}];
|
|
8
|
+
readonly stateMutability: "nonpayable";
|
|
9
|
+
}, {
|
|
10
|
+
readonly type: "function";
|
|
11
|
+
readonly name: "MAX_DURATION";
|
|
12
|
+
readonly inputs: readonly [];
|
|
13
|
+
readonly outputs: readonly [{
|
|
14
|
+
readonly name: "";
|
|
15
|
+
readonly type: "uint40";
|
|
16
|
+
readonly internalType: "uint40";
|
|
17
|
+
}];
|
|
18
|
+
readonly stateMutability: "view";
|
|
19
|
+
}, {
|
|
20
|
+
readonly type: "function";
|
|
21
|
+
readonly name: "depositOf";
|
|
22
|
+
readonly inputs: readonly [{
|
|
23
|
+
readonly name: "streamId";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
readonly internalType: "uint256";
|
|
26
|
+
}];
|
|
27
|
+
readonly outputs: readonly [{
|
|
28
|
+
readonly name: "";
|
|
29
|
+
readonly type: "uint256";
|
|
30
|
+
readonly internalType: "uint256";
|
|
31
|
+
}];
|
|
32
|
+
readonly stateMutability: "view";
|
|
33
|
+
}, {
|
|
34
|
+
readonly type: "function";
|
|
35
|
+
readonly name: "getStream";
|
|
36
|
+
readonly inputs: readonly [{
|
|
37
|
+
readonly name: "streamId";
|
|
38
|
+
readonly type: "uint256";
|
|
39
|
+
readonly internalType: "uint256";
|
|
40
|
+
}];
|
|
41
|
+
readonly outputs: readonly [{
|
|
42
|
+
readonly name: "";
|
|
43
|
+
readonly type: "tuple";
|
|
44
|
+
readonly internalType: "struct ComputePayment.Stream";
|
|
45
|
+
readonly components: readonly [{
|
|
46
|
+
readonly name: "sender";
|
|
47
|
+
readonly type: "address";
|
|
48
|
+
readonly internalType: "address";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "startTime";
|
|
51
|
+
readonly type: "uint40";
|
|
52
|
+
readonly internalType: "uint40";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "endTime";
|
|
55
|
+
readonly type: "uint40";
|
|
56
|
+
readonly internalType: "uint40";
|
|
57
|
+
}, {
|
|
58
|
+
readonly name: "provider";
|
|
59
|
+
readonly type: "address";
|
|
60
|
+
readonly internalType: "address";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "stopTime";
|
|
63
|
+
readonly type: "uint40";
|
|
64
|
+
readonly internalType: "uint40";
|
|
65
|
+
}, {
|
|
66
|
+
readonly name: "settled";
|
|
67
|
+
readonly type: "bool";
|
|
68
|
+
readonly internalType: "bool";
|
|
69
|
+
}, {
|
|
70
|
+
readonly name: "ratePerSecond";
|
|
71
|
+
readonly type: "uint128";
|
|
72
|
+
readonly internalType: "uint128";
|
|
73
|
+
}, {
|
|
74
|
+
readonly name: "withdrawn";
|
|
75
|
+
readonly type: "uint128";
|
|
76
|
+
readonly internalType: "uint128";
|
|
77
|
+
}];
|
|
78
|
+
}];
|
|
79
|
+
readonly stateMutability: "view";
|
|
80
|
+
}, {
|
|
81
|
+
readonly type: "function";
|
|
82
|
+
readonly name: "paymentToken";
|
|
83
|
+
readonly inputs: readonly [];
|
|
84
|
+
readonly outputs: readonly [{
|
|
85
|
+
readonly name: "";
|
|
86
|
+
readonly type: "address";
|
|
87
|
+
readonly internalType: "contract IERC20";
|
|
88
|
+
}];
|
|
89
|
+
readonly stateMutability: "view";
|
|
90
|
+
}, {
|
|
91
|
+
readonly type: "function";
|
|
92
|
+
readonly name: "refundableAmountOf";
|
|
93
|
+
readonly inputs: readonly [{
|
|
94
|
+
readonly name: "streamId";
|
|
95
|
+
readonly type: "uint256";
|
|
96
|
+
readonly internalType: "uint256";
|
|
97
|
+
}];
|
|
98
|
+
readonly outputs: readonly [{
|
|
99
|
+
readonly name: "";
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
readonly internalType: "uint256";
|
|
102
|
+
}];
|
|
103
|
+
readonly stateMutability: "view";
|
|
104
|
+
}, {
|
|
105
|
+
readonly type: "function";
|
|
106
|
+
readonly name: "stopStream";
|
|
107
|
+
readonly inputs: readonly [{
|
|
108
|
+
readonly name: "streamId";
|
|
109
|
+
readonly type: "uint256";
|
|
110
|
+
readonly internalType: "uint256";
|
|
111
|
+
}];
|
|
112
|
+
readonly outputs: readonly [{
|
|
113
|
+
readonly name: "providerAmount";
|
|
114
|
+
readonly type: "uint256";
|
|
115
|
+
readonly internalType: "uint256";
|
|
116
|
+
}, {
|
|
117
|
+
readonly name: "refundAmount";
|
|
118
|
+
readonly type: "uint256";
|
|
119
|
+
readonly internalType: "uint256";
|
|
120
|
+
}];
|
|
121
|
+
readonly stateMutability: "nonpayable";
|
|
122
|
+
}, {
|
|
123
|
+
readonly type: "function";
|
|
124
|
+
readonly name: "streamCompute";
|
|
125
|
+
readonly inputs: readonly [{
|
|
126
|
+
readonly name: "provider";
|
|
127
|
+
readonly type: "address";
|
|
128
|
+
readonly internalType: "address";
|
|
129
|
+
}, {
|
|
130
|
+
readonly name: "ratePerSecond";
|
|
131
|
+
readonly type: "uint128";
|
|
132
|
+
readonly internalType: "uint128";
|
|
133
|
+
}, {
|
|
134
|
+
readonly name: "maxDuration";
|
|
135
|
+
readonly type: "uint40";
|
|
136
|
+
readonly internalType: "uint40";
|
|
137
|
+
}];
|
|
138
|
+
readonly outputs: readonly [{
|
|
139
|
+
readonly name: "streamId";
|
|
140
|
+
readonly type: "uint256";
|
|
141
|
+
readonly internalType: "uint256";
|
|
142
|
+
}];
|
|
143
|
+
readonly stateMutability: "nonpayable";
|
|
144
|
+
}, {
|
|
145
|
+
readonly type: "function";
|
|
146
|
+
readonly name: "streamCounter";
|
|
147
|
+
readonly inputs: readonly [];
|
|
148
|
+
readonly outputs: readonly [{
|
|
149
|
+
readonly name: "";
|
|
150
|
+
readonly type: "uint256";
|
|
151
|
+
readonly internalType: "uint256";
|
|
152
|
+
}];
|
|
153
|
+
readonly stateMutability: "view";
|
|
154
|
+
}, {
|
|
155
|
+
readonly type: "function";
|
|
156
|
+
readonly name: "streamedAmountOf";
|
|
157
|
+
readonly inputs: readonly [{
|
|
158
|
+
readonly name: "streamId";
|
|
159
|
+
readonly type: "uint256";
|
|
160
|
+
readonly internalType: "uint256";
|
|
161
|
+
}];
|
|
162
|
+
readonly outputs: readonly [{
|
|
163
|
+
readonly name: "";
|
|
164
|
+
readonly type: "uint256";
|
|
165
|
+
readonly internalType: "uint256";
|
|
166
|
+
}];
|
|
167
|
+
readonly stateMutability: "view";
|
|
168
|
+
}, {
|
|
169
|
+
readonly type: "function";
|
|
170
|
+
readonly name: "withdraw";
|
|
171
|
+
readonly inputs: readonly [{
|
|
172
|
+
readonly name: "streamId";
|
|
173
|
+
readonly type: "uint256";
|
|
174
|
+
readonly internalType: "uint256";
|
|
175
|
+
}];
|
|
176
|
+
readonly outputs: readonly [{
|
|
177
|
+
readonly name: "amount";
|
|
178
|
+
readonly type: "uint256";
|
|
179
|
+
readonly internalType: "uint256";
|
|
180
|
+
}];
|
|
181
|
+
readonly stateMutability: "nonpayable";
|
|
182
|
+
}, {
|
|
183
|
+
readonly type: "function";
|
|
184
|
+
readonly name: "withdrawableAmountOf";
|
|
185
|
+
readonly inputs: readonly [{
|
|
186
|
+
readonly name: "streamId";
|
|
187
|
+
readonly type: "uint256";
|
|
188
|
+
readonly internalType: "uint256";
|
|
189
|
+
}];
|
|
190
|
+
readonly outputs: readonly [{
|
|
191
|
+
readonly name: "";
|
|
192
|
+
readonly type: "uint256";
|
|
193
|
+
readonly internalType: "uint256";
|
|
194
|
+
}];
|
|
195
|
+
readonly stateMutability: "view";
|
|
196
|
+
}, {
|
|
197
|
+
readonly type: "event";
|
|
198
|
+
readonly name: "PaymentSettled";
|
|
199
|
+
readonly inputs: readonly [{
|
|
200
|
+
readonly name: "streamId";
|
|
201
|
+
readonly type: "uint256";
|
|
202
|
+
readonly indexed: true;
|
|
203
|
+
readonly internalType: "uint256";
|
|
204
|
+
}, {
|
|
205
|
+
readonly name: "provider";
|
|
206
|
+
readonly type: "address";
|
|
207
|
+
readonly indexed: true;
|
|
208
|
+
readonly internalType: "address";
|
|
209
|
+
}, {
|
|
210
|
+
readonly name: "providerAmount";
|
|
211
|
+
readonly type: "uint256";
|
|
212
|
+
readonly indexed: false;
|
|
213
|
+
readonly internalType: "uint256";
|
|
214
|
+
}, {
|
|
215
|
+
readonly name: "sender";
|
|
216
|
+
readonly type: "address";
|
|
217
|
+
readonly indexed: true;
|
|
218
|
+
readonly internalType: "address";
|
|
219
|
+
}, {
|
|
220
|
+
readonly name: "refundAmount";
|
|
221
|
+
readonly type: "uint256";
|
|
222
|
+
readonly indexed: false;
|
|
223
|
+
readonly internalType: "uint256";
|
|
224
|
+
}];
|
|
225
|
+
readonly anonymous: false;
|
|
226
|
+
}, {
|
|
227
|
+
readonly type: "event";
|
|
228
|
+
readonly name: "StreamStarted";
|
|
229
|
+
readonly inputs: readonly [{
|
|
230
|
+
readonly name: "streamId";
|
|
231
|
+
readonly type: "uint256";
|
|
232
|
+
readonly indexed: true;
|
|
233
|
+
readonly internalType: "uint256";
|
|
234
|
+
}, {
|
|
235
|
+
readonly name: "sender";
|
|
236
|
+
readonly type: "address";
|
|
237
|
+
readonly indexed: true;
|
|
238
|
+
readonly internalType: "address";
|
|
239
|
+
}, {
|
|
240
|
+
readonly name: "provider";
|
|
241
|
+
readonly type: "address";
|
|
242
|
+
readonly indexed: true;
|
|
243
|
+
readonly internalType: "address";
|
|
244
|
+
}, {
|
|
245
|
+
readonly name: "ratePerSecond";
|
|
246
|
+
readonly type: "uint256";
|
|
247
|
+
readonly indexed: false;
|
|
248
|
+
readonly internalType: "uint256";
|
|
249
|
+
}, {
|
|
250
|
+
readonly name: "startTime";
|
|
251
|
+
readonly type: "uint256";
|
|
252
|
+
readonly indexed: false;
|
|
253
|
+
readonly internalType: "uint256";
|
|
254
|
+
}, {
|
|
255
|
+
readonly name: "endTime";
|
|
256
|
+
readonly type: "uint256";
|
|
257
|
+
readonly indexed: false;
|
|
258
|
+
readonly internalType: "uint256";
|
|
259
|
+
}, {
|
|
260
|
+
readonly name: "deposit";
|
|
261
|
+
readonly type: "uint256";
|
|
262
|
+
readonly indexed: false;
|
|
263
|
+
readonly internalType: "uint256";
|
|
264
|
+
}];
|
|
265
|
+
readonly anonymous: false;
|
|
266
|
+
}, {
|
|
267
|
+
readonly type: "event";
|
|
268
|
+
readonly name: "StreamStopped";
|
|
269
|
+
readonly inputs: readonly [{
|
|
270
|
+
readonly name: "streamId";
|
|
271
|
+
readonly type: "uint256";
|
|
272
|
+
readonly indexed: true;
|
|
273
|
+
readonly internalType: "uint256";
|
|
274
|
+
}, {
|
|
275
|
+
readonly name: "stoppedBy";
|
|
276
|
+
readonly type: "address";
|
|
277
|
+
readonly indexed: true;
|
|
278
|
+
readonly internalType: "address";
|
|
279
|
+
}, {
|
|
280
|
+
readonly name: "stopTime";
|
|
281
|
+
readonly type: "uint256";
|
|
282
|
+
readonly indexed: false;
|
|
283
|
+
readonly internalType: "uint256";
|
|
284
|
+
}];
|
|
285
|
+
readonly anonymous: false;
|
|
286
|
+
}, {
|
|
287
|
+
readonly type: "event";
|
|
288
|
+
readonly name: "Withdrawn";
|
|
289
|
+
readonly inputs: readonly [{
|
|
290
|
+
readonly name: "streamId";
|
|
291
|
+
readonly type: "uint256";
|
|
292
|
+
readonly indexed: true;
|
|
293
|
+
readonly internalType: "uint256";
|
|
294
|
+
}, {
|
|
295
|
+
readonly name: "provider";
|
|
296
|
+
readonly type: "address";
|
|
297
|
+
readonly indexed: true;
|
|
298
|
+
readonly internalType: "address";
|
|
299
|
+
}, {
|
|
300
|
+
readonly name: "amount";
|
|
301
|
+
readonly type: "uint256";
|
|
302
|
+
readonly indexed: false;
|
|
303
|
+
readonly internalType: "uint256";
|
|
304
|
+
}];
|
|
305
|
+
readonly anonymous: false;
|
|
306
|
+
}, {
|
|
307
|
+
readonly type: "error";
|
|
308
|
+
readonly name: "AlreadySettled";
|
|
309
|
+
readonly inputs: readonly [];
|
|
310
|
+
}, {
|
|
311
|
+
readonly type: "error";
|
|
312
|
+
readonly name: "DepositTooLarge";
|
|
313
|
+
readonly inputs: readonly [];
|
|
314
|
+
}, {
|
|
315
|
+
readonly type: "error";
|
|
316
|
+
readonly name: "InvalidDuration";
|
|
317
|
+
readonly inputs: readonly [];
|
|
318
|
+
}, {
|
|
319
|
+
readonly type: "error";
|
|
320
|
+
readonly name: "InvalidProvider";
|
|
321
|
+
readonly inputs: readonly [];
|
|
322
|
+
}, {
|
|
323
|
+
readonly type: "error";
|
|
324
|
+
readonly name: "InvalidStream";
|
|
325
|
+
readonly inputs: readonly [];
|
|
326
|
+
}, {
|
|
327
|
+
readonly type: "error";
|
|
328
|
+
readonly name: "NothingToWithdraw";
|
|
329
|
+
readonly inputs: readonly [];
|
|
330
|
+
}, {
|
|
331
|
+
readonly type: "error";
|
|
332
|
+
readonly name: "ReentrancyGuardReentrantCall";
|
|
333
|
+
readonly inputs: readonly [];
|
|
334
|
+
}, {
|
|
335
|
+
readonly type: "error";
|
|
336
|
+
readonly name: "SafeERC20FailedOperation";
|
|
337
|
+
readonly inputs: readonly [{
|
|
338
|
+
readonly name: "token";
|
|
339
|
+
readonly type: "address";
|
|
340
|
+
readonly internalType: "address";
|
|
341
|
+
}];
|
|
342
|
+
}, {
|
|
343
|
+
readonly type: "error";
|
|
344
|
+
readonly name: "Unauthorized";
|
|
345
|
+
readonly inputs: readonly [];
|
|
346
|
+
}, {
|
|
347
|
+
readonly type: "error";
|
|
348
|
+
readonly name: "UnexpectedDeposit";
|
|
349
|
+
readonly inputs: readonly [];
|
|
350
|
+
}, {
|
|
351
|
+
readonly type: "error";
|
|
352
|
+
readonly name: "ZeroAddress";
|
|
353
|
+
readonly inputs: readonly [];
|
|
354
|
+
}, {
|
|
355
|
+
readonly type: "error";
|
|
356
|
+
readonly name: "ZeroRate";
|
|
357
|
+
readonly inputs: readonly [];
|
|
358
|
+
}];
|