@cra-agent/escrow 0.0.1

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/dist/abi.d.ts ADDED
@@ -0,0 +1,370 @@
1
+ /**
2
+ * ERC-8183 AgenticCommerce, subset we use. Taken from the verified implementation behind the Arc testnet
3
+ * proxy 0x0747EEf0706327138c69792bF28Cd525089e4583 (impl 0xa316fd02827242d537f84730f8a37d0ba5fd351a), 2026-09-15.
4
+ */
5
+ export declare const AGENTIC_COMMERCE_ABI: readonly [{
6
+ readonly type: "function";
7
+ readonly name: "createJob";
8
+ readonly stateMutability: "nonpayable";
9
+ readonly inputs: readonly [{
10
+ readonly name: "provider";
11
+ readonly type: "address";
12
+ }, {
13
+ readonly name: "evaluator";
14
+ readonly type: "address";
15
+ }, {
16
+ readonly name: "expiredAt";
17
+ readonly type: "uint256";
18
+ }, {
19
+ readonly name: "description";
20
+ readonly type: "string";
21
+ }, {
22
+ readonly name: "hook";
23
+ readonly type: "address";
24
+ }];
25
+ readonly outputs: readonly [{
26
+ readonly name: "jobId";
27
+ readonly type: "uint256";
28
+ }];
29
+ }, {
30
+ readonly type: "function";
31
+ readonly name: "setBudget";
32
+ readonly stateMutability: "nonpayable";
33
+ readonly inputs: readonly [{
34
+ readonly name: "jobId";
35
+ readonly type: "uint256";
36
+ }, {
37
+ readonly name: "amount";
38
+ readonly type: "uint256";
39
+ }, {
40
+ readonly name: "optParams";
41
+ readonly type: "bytes";
42
+ }];
43
+ readonly outputs: readonly [];
44
+ }, {
45
+ readonly type: "function";
46
+ readonly name: "fund";
47
+ readonly stateMutability: "nonpayable";
48
+ readonly inputs: readonly [{
49
+ readonly name: "jobId";
50
+ readonly type: "uint256";
51
+ }, {
52
+ readonly name: "optParams";
53
+ readonly type: "bytes";
54
+ }];
55
+ readonly outputs: readonly [];
56
+ }, {
57
+ readonly type: "function";
58
+ readonly name: "submit";
59
+ readonly stateMutability: "nonpayable";
60
+ readonly inputs: readonly [{
61
+ readonly name: "jobId";
62
+ readonly type: "uint256";
63
+ }, {
64
+ readonly name: "deliverable";
65
+ readonly type: "bytes32";
66
+ }, {
67
+ readonly name: "optParams";
68
+ readonly type: "bytes";
69
+ }];
70
+ readonly outputs: readonly [];
71
+ }, {
72
+ readonly type: "function";
73
+ readonly name: "complete";
74
+ readonly stateMutability: "nonpayable";
75
+ readonly inputs: readonly [{
76
+ readonly name: "jobId";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly name: "reason";
80
+ readonly type: "bytes32";
81
+ }, {
82
+ readonly name: "optParams";
83
+ readonly type: "bytes";
84
+ }];
85
+ readonly outputs: readonly [];
86
+ }, {
87
+ readonly type: "function";
88
+ readonly name: "reject";
89
+ readonly stateMutability: "nonpayable";
90
+ readonly inputs: readonly [{
91
+ readonly name: "jobId";
92
+ readonly type: "uint256";
93
+ }, {
94
+ readonly name: "reason";
95
+ readonly type: "bytes32";
96
+ }, {
97
+ readonly name: "optParams";
98
+ readonly type: "bytes";
99
+ }];
100
+ readonly outputs: readonly [];
101
+ }, {
102
+ readonly type: "function";
103
+ readonly name: "claimRefund";
104
+ readonly stateMutability: "nonpayable";
105
+ readonly inputs: readonly [{
106
+ readonly name: "jobId";
107
+ readonly type: "uint256";
108
+ }];
109
+ readonly outputs: readonly [];
110
+ }, {
111
+ readonly type: "function";
112
+ readonly name: "getJob";
113
+ readonly stateMutability: "view";
114
+ readonly inputs: readonly [{
115
+ readonly name: "jobId";
116
+ readonly type: "uint256";
117
+ }];
118
+ readonly outputs: readonly [{
119
+ readonly name: "";
120
+ readonly type: "tuple";
121
+ readonly components: readonly [{
122
+ readonly name: "id";
123
+ readonly type: "uint256";
124
+ }, {
125
+ readonly name: "client";
126
+ readonly type: "address";
127
+ }, {
128
+ readonly name: "provider";
129
+ readonly type: "address";
130
+ }, {
131
+ readonly name: "evaluator";
132
+ readonly type: "address";
133
+ }, {
134
+ readonly name: "description";
135
+ readonly type: "string";
136
+ }, {
137
+ readonly name: "budget";
138
+ readonly type: "uint256";
139
+ }, {
140
+ readonly name: "expiredAt";
141
+ readonly type: "uint256";
142
+ }, {
143
+ readonly name: "status";
144
+ readonly type: "uint8";
145
+ }, {
146
+ readonly name: "hook";
147
+ readonly type: "address";
148
+ }];
149
+ }];
150
+ }, {
151
+ readonly type: "function";
152
+ readonly name: "jobCounter";
153
+ readonly stateMutability: "view";
154
+ readonly inputs: readonly [];
155
+ readonly outputs: readonly [{
156
+ readonly type: "uint256";
157
+ }];
158
+ }, {
159
+ readonly type: "function";
160
+ readonly name: "jobHasBudget";
161
+ readonly stateMutability: "view";
162
+ readonly inputs: readonly [{
163
+ readonly name: "jobId";
164
+ readonly type: "uint256";
165
+ }];
166
+ readonly outputs: readonly [{
167
+ readonly type: "bool";
168
+ }];
169
+ }, {
170
+ readonly type: "function";
171
+ readonly name: "paymentToken";
172
+ readonly stateMutability: "view";
173
+ readonly inputs: readonly [];
174
+ readonly outputs: readonly [{
175
+ readonly type: "address";
176
+ }];
177
+ }, {
178
+ readonly type: "function";
179
+ readonly name: "platformFeeBP";
180
+ readonly stateMutability: "view";
181
+ readonly inputs: readonly [];
182
+ readonly outputs: readonly [{
183
+ readonly type: "uint256";
184
+ }];
185
+ }, {
186
+ readonly type: "function";
187
+ readonly name: "evaluatorFeeBP";
188
+ readonly stateMutability: "view";
189
+ readonly inputs: readonly [];
190
+ readonly outputs: readonly [{
191
+ readonly type: "uint256";
192
+ }];
193
+ }, {
194
+ readonly type: "event";
195
+ readonly name: "JobCreated";
196
+ readonly inputs: readonly [{
197
+ readonly name: "jobId";
198
+ readonly type: "uint256";
199
+ readonly indexed: true;
200
+ }, {
201
+ readonly name: "client";
202
+ readonly type: "address";
203
+ readonly indexed: true;
204
+ }, {
205
+ readonly name: "provider";
206
+ readonly type: "address";
207
+ readonly indexed: true;
208
+ }, {
209
+ readonly name: "evaluator";
210
+ readonly type: "address";
211
+ readonly indexed: false;
212
+ }, {
213
+ readonly name: "expiredAt";
214
+ readonly type: "uint256";
215
+ readonly indexed: false;
216
+ }, {
217
+ readonly name: "hook";
218
+ readonly type: "address";
219
+ readonly indexed: false;
220
+ }];
221
+ }, {
222
+ readonly type: "event";
223
+ readonly name: "BudgetSet";
224
+ readonly inputs: readonly [{
225
+ readonly name: "jobId";
226
+ readonly type: "uint256";
227
+ readonly indexed: true;
228
+ }, {
229
+ readonly name: "amount";
230
+ readonly type: "uint256";
231
+ readonly indexed: false;
232
+ }];
233
+ }, {
234
+ readonly type: "event";
235
+ readonly name: "JobFunded";
236
+ readonly inputs: readonly [{
237
+ readonly name: "jobId";
238
+ readonly type: "uint256";
239
+ readonly indexed: true;
240
+ }, {
241
+ readonly name: "client";
242
+ readonly type: "address";
243
+ readonly indexed: true;
244
+ }, {
245
+ readonly name: "amount";
246
+ readonly type: "uint256";
247
+ readonly indexed: false;
248
+ }];
249
+ }, {
250
+ readonly type: "event";
251
+ readonly name: "JobSubmitted";
252
+ readonly inputs: readonly [{
253
+ readonly name: "jobId";
254
+ readonly type: "uint256";
255
+ readonly indexed: true;
256
+ }, {
257
+ readonly name: "provider";
258
+ readonly type: "address";
259
+ readonly indexed: true;
260
+ }, {
261
+ readonly name: "deliverable";
262
+ readonly type: "bytes32";
263
+ readonly indexed: false;
264
+ }];
265
+ }, {
266
+ readonly type: "event";
267
+ readonly name: "JobCompleted";
268
+ readonly inputs: readonly [{
269
+ readonly name: "jobId";
270
+ readonly type: "uint256";
271
+ readonly indexed: true;
272
+ }, {
273
+ readonly name: "evaluator";
274
+ readonly type: "address";
275
+ readonly indexed: true;
276
+ }, {
277
+ readonly name: "reason";
278
+ readonly type: "bytes32";
279
+ readonly indexed: false;
280
+ }];
281
+ }, {
282
+ readonly type: "event";
283
+ readonly name: "JobRejected";
284
+ readonly inputs: readonly [{
285
+ readonly name: "jobId";
286
+ readonly type: "uint256";
287
+ readonly indexed: true;
288
+ }, {
289
+ readonly name: "rejector";
290
+ readonly type: "address";
291
+ readonly indexed: true;
292
+ }, {
293
+ readonly name: "reason";
294
+ readonly type: "bytes32";
295
+ readonly indexed: false;
296
+ }];
297
+ }, {
298
+ readonly type: "event";
299
+ readonly name: "PaymentReleased";
300
+ readonly inputs: readonly [{
301
+ readonly name: "jobId";
302
+ readonly type: "uint256";
303
+ readonly indexed: true;
304
+ }, {
305
+ readonly name: "provider";
306
+ readonly type: "address";
307
+ readonly indexed: true;
308
+ }, {
309
+ readonly name: "amount";
310
+ readonly type: "uint256";
311
+ readonly indexed: false;
312
+ }];
313
+ }, {
314
+ readonly type: "event";
315
+ readonly name: "Refunded";
316
+ readonly inputs: readonly [{
317
+ readonly name: "jobId";
318
+ readonly type: "uint256";
319
+ readonly indexed: true;
320
+ }, {
321
+ readonly name: "client";
322
+ readonly type: "address";
323
+ readonly indexed: true;
324
+ }, {
325
+ readonly name: "amount";
326
+ readonly type: "uint256";
327
+ readonly indexed: false;
328
+ }];
329
+ }];
330
+ export declare const ERC20_ABI: readonly [{
331
+ readonly type: "function";
332
+ readonly name: "approve";
333
+ readonly stateMutability: "nonpayable";
334
+ readonly inputs: readonly [{
335
+ readonly name: "spender";
336
+ readonly type: "address";
337
+ }, {
338
+ readonly name: "amount";
339
+ readonly type: "uint256";
340
+ }];
341
+ readonly outputs: readonly [{
342
+ readonly type: "bool";
343
+ }];
344
+ }, {
345
+ readonly type: "function";
346
+ readonly name: "allowance";
347
+ readonly stateMutability: "view";
348
+ readonly inputs: readonly [{
349
+ readonly name: "owner";
350
+ readonly type: "address";
351
+ }, {
352
+ readonly name: "spender";
353
+ readonly type: "address";
354
+ }];
355
+ readonly outputs: readonly [{
356
+ readonly type: "uint256";
357
+ }];
358
+ }, {
359
+ readonly type: "function";
360
+ readonly name: "balanceOf";
361
+ readonly stateMutability: "view";
362
+ readonly inputs: readonly [{
363
+ readonly name: "account";
364
+ readonly type: "address";
365
+ }];
366
+ readonly outputs: readonly [{
367
+ readonly type: "uint256";
368
+ }];
369
+ }];
370
+ //# sourceMappingURL=abi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.d.ts","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsBvB,CAAC;AAEX,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIZ,CAAC"}
package/dist/abi.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * ERC-8183 AgenticCommerce, subset we use. Taken from the verified implementation behind the Arc testnet
3
+ * proxy 0x0747EEf0706327138c69792bF28Cd525089e4583 (impl 0xa316fd02827242d537f84730f8a37d0ba5fd351a), 2026-09-15.
4
+ */
5
+ export const AGENTIC_COMMERCE_ABI = [
6
+ { type: "function", name: "createJob", stateMutability: "nonpayable", inputs: [{ name: "provider", type: "address" }, { name: "evaluator", type: "address" }, { name: "expiredAt", type: "uint256" }, { name: "description", type: "string" }, { name: "hook", type: "address" }], outputs: [{ name: "jobId", type: "uint256" }] },
7
+ { type: "function", name: "setBudget", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }, { name: "amount", type: "uint256" }, { name: "optParams", type: "bytes" }], outputs: [] },
8
+ { type: "function", name: "fund", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }, { name: "optParams", type: "bytes" }], outputs: [] },
9
+ { type: "function", name: "submit", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }, { name: "deliverable", type: "bytes32" }, { name: "optParams", type: "bytes" }], outputs: [] },
10
+ { type: "function", name: "complete", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }, { name: "reason", type: "bytes32" }, { name: "optParams", type: "bytes" }], outputs: [] },
11
+ { type: "function", name: "reject", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }, { name: "reason", type: "bytes32" }, { name: "optParams", type: "bytes" }], outputs: [] },
12
+ { type: "function", name: "claimRefund", stateMutability: "nonpayable", inputs: [{ name: "jobId", type: "uint256" }], outputs: [] },
13
+ { type: "function", name: "getJob", stateMutability: "view", inputs: [{ name: "jobId", type: "uint256" }], outputs: [{ name: "", type: "tuple", components: [{ name: "id", type: "uint256" }, { name: "client", type: "address" }, { name: "provider", type: "address" }, { name: "evaluator", type: "address" }, { name: "description", type: "string" }, { name: "budget", type: "uint256" }, { name: "expiredAt", type: "uint256" }, { name: "status", type: "uint8" }, { name: "hook", type: "address" }] }] },
14
+ { type: "function", name: "jobCounter", stateMutability: "view", inputs: [], outputs: [{ type: "uint256" }] },
15
+ { type: "function", name: "jobHasBudget", stateMutability: "view", inputs: [{ name: "jobId", type: "uint256" }], outputs: [{ type: "bool" }] },
16
+ { type: "function", name: "paymentToken", stateMutability: "view", inputs: [], outputs: [{ type: "address" }] },
17
+ { type: "function", name: "platformFeeBP", stateMutability: "view", inputs: [], outputs: [{ type: "uint256" }] },
18
+ { type: "function", name: "evaluatorFeeBP", stateMutability: "view", inputs: [], outputs: [{ type: "uint256" }] },
19
+ { type: "event", name: "JobCreated", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "client", type: "address", indexed: true }, { name: "provider", type: "address", indexed: true }, { name: "evaluator", type: "address", indexed: false }, { name: "expiredAt", type: "uint256", indexed: false }, { name: "hook", type: "address", indexed: false }] },
20
+ { type: "event", name: "BudgetSet", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "amount", type: "uint256", indexed: false }] },
21
+ { type: "event", name: "JobFunded", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "client", type: "address", indexed: true }, { name: "amount", type: "uint256", indexed: false }] },
22
+ { type: "event", name: "JobSubmitted", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "provider", type: "address", indexed: true }, { name: "deliverable", type: "bytes32", indexed: false }] },
23
+ { type: "event", name: "JobCompleted", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "evaluator", type: "address", indexed: true }, { name: "reason", type: "bytes32", indexed: false }] },
24
+ { type: "event", name: "JobRejected", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "rejector", type: "address", indexed: true }, { name: "reason", type: "bytes32", indexed: false }] },
25
+ { type: "event", name: "PaymentReleased", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "provider", type: "address", indexed: true }, { name: "amount", type: "uint256", indexed: false }] },
26
+ { type: "event", name: "Refunded", inputs: [{ name: "jobId", type: "uint256", indexed: true }, { name: "client", type: "address", indexed: true }, { name: "amount", type: "uint256", indexed: false }] },
27
+ ];
28
+ export const ERC20_ABI = [
29
+ { type: "function", name: "approve", stateMutability: "nonpayable", inputs: [{ name: "spender", type: "address" }, { name: "amount", type: "uint256" }], outputs: [{ type: "bool" }] },
30
+ { type: "function", name: "allowance", stateMutability: "view", inputs: [{ name: "owner", type: "address" }, { name: "spender", type: "address" }], outputs: [{ type: "uint256" }] },
31
+ { type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ type: "uint256" }] },
32
+ ];
33
+ //# sourceMappingURL=abi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.js","sourceRoot":"","sources":["../src/abi.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,EAAE,C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WAAW,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE;CACxI,CAAC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @cra-agent/escrow — the ERC-8183 rail for jobs that are too large or too slow for a nanopayment.
3
+ *
4
+ * Client → Provider → Evaluator. State machine: Open → Funded → Submitted → Completed | Rejected | Expired.
5
+ * The evaluator is an injected address (brief: never hardcoded); by default the client evaluates its own jobs.
6
+ * Escrowed USDC lives in the contract, separate from the agent's operating balance (phase 3 can invest it).
7
+ */
8
+ import { type Usdc6 } from "@cra-agent/accounting";
9
+ import { type ArcNetwork, type RailSigner } from "@cra-agent/identity";
10
+ import { type Address, type Hex } from "viem";
11
+ export { AGENTIC_COMMERCE_ABI, ERC20_ABI } from "./abi.js";
12
+ /** From docs.arc.io/arc/tutorials/create-your-first-erc-8183-job (2026-09-14). Mainnet: no bytecode at this address
13
+ * on chain 5042 (checked 2026-09-16), so the escrow rail is testnet-only until Circle deploys it. */
14
+ export declare const AGENTIC_COMMERCE: Record<ArcNetwork, Address | null>;
15
+ export declare const ARC_USDC: Address;
16
+ export declare const ZERO_ADDRESS: Address;
17
+ export type JobStatus = "Open" | "Funded" | "Submitted" | "Completed" | "Rejected" | "Expired";
18
+ export declare function jobStatusFromCode(code: number): JobStatus;
19
+ export interface Job {
20
+ readonly id: bigint;
21
+ readonly client: Address;
22
+ readonly provider: Address;
23
+ readonly evaluator: Address;
24
+ readonly description: string;
25
+ readonly budget: Usdc6;
26
+ readonly budgetUsdc: string;
27
+ readonly expiredAt: number;
28
+ readonly status: JobStatus;
29
+ readonly hook: Address;
30
+ }
31
+ /** Reasons are bytes32: keccak256 of a short string, so they stay cheap and greppable in logs. */
32
+ export declare const reasonHash: (text: string) => Hex;
33
+ export interface EscrowConfig {
34
+ readonly network: ArcNetwork;
35
+ readonly signer: RailSigner;
36
+ readonly rpcUrl?: string;
37
+ readonly contract?: Address;
38
+ /** Default evaluator for jobs this agent creates. Omit = the agent itself. */
39
+ readonly evaluator?: Address;
40
+ }
41
+ export interface EscrowClient {
42
+ readonly address: Address;
43
+ readonly contract: Address;
44
+ readonly evaluator: Address;
45
+ createJob(input: {
46
+ provider: Address;
47
+ description: string;
48
+ expiresInSeconds: number;
49
+ evaluator?: Address;
50
+ hook?: Address;
51
+ }): Promise<{
52
+ jobId: bigint;
53
+ txHash: Hex;
54
+ }>;
55
+ setBudget(jobId: bigint, budget: Usdc6): Promise<{
56
+ txHash: Hex;
57
+ }>;
58
+ /** Approves USDC for the contract if needed, then funds. Client only. */
59
+ fund(jobId: bigint): Promise<{
60
+ txHash: Hex;
61
+ approveTxHash: Hex | null;
62
+ amount: Usdc6;
63
+ }>;
64
+ submit(jobId: bigint, deliverable: Hex): Promise<{
65
+ txHash: Hex;
66
+ }>;
67
+ complete(jobId: bigint, reason: string): Promise<{
68
+ txHash: Hex;
69
+ }>;
70
+ reject(jobId: bigint, reason: string): Promise<{
71
+ txHash: Hex;
72
+ }>;
73
+ claimRefund(jobId: bigint): Promise<{
74
+ txHash: Hex;
75
+ }>;
76
+ getJob(jobId: bigint): Promise<Job>;
77
+ jobCount(): Promise<bigint>;
78
+ fees(): Promise<{
79
+ platformBp: bigint;
80
+ evaluatorBp: bigint;
81
+ }>;
82
+ }
83
+ export declare function createEscrowClient(cfg: EscrowConfig): EscrowClient;
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAsB,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAwF,KAAK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E,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IACrD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACpC,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,IAAI,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,GAAG,YAAY,CAkFlE"}
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @cra-agent/escrow — the ERC-8183 rail for jobs that are too large or too slow for a nanopayment.
3
+ *
4
+ * Client → Provider → Evaluator. State machine: Open → Funded → Submitted → Completed | Rejected | Expired.
5
+ * The evaluator is an injected address (brief: never hardcoded); by default the client evaluates its own jobs.
6
+ * Escrowed USDC lives in the contract, separate from the agent's operating balance (phase 3 can invest it).
7
+ */
8
+ import { formatUsdc6, usdc6 } from "@cra-agent/accounting";
9
+ import { CHAINS } from "@cra-agent/identity";
10
+ import { createPublicClient, createWalletClient, http, keccak256, parseEventLogs, stringToHex } from "viem";
11
+ import { AGENTIC_COMMERCE_ABI, ERC20_ABI } from "./abi.js";
12
+ export { AGENTIC_COMMERCE_ABI, ERC20_ABI } from "./abi.js";
13
+ /** From docs.arc.io/arc/tutorials/create-your-first-erc-8183-job (2026-09-14). Mainnet: no bytecode at this address
14
+ * on chain 5042 (checked 2026-09-16), so the escrow rail is testnet-only until Circle deploys it. */
15
+ export const AGENTIC_COMMERCE = {
16
+ arcTestnet: "0x0747EEf0706327138c69792bF28Cd525089e4583",
17
+ arc: null,
18
+ };
19
+ export const ARC_USDC = "0x3600000000000000000000000000000000000000";
20
+ export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
21
+ const STATUS = ["Open", "Funded", "Submitted", "Completed", "Rejected", "Expired"];
22
+ export function jobStatusFromCode(code) {
23
+ const s = STATUS[code];
24
+ if (!s)
25
+ throw new Error(`unknown ERC-8183 job status ${code}`);
26
+ return s;
27
+ }
28
+ /** Reasons are bytes32: keccak256 of a short string, so they stay cheap and greppable in logs. */
29
+ export const reasonHash = (text) => keccak256(stringToHex(text));
30
+ export function createEscrowClient(cfg) {
31
+ const known = cfg.contract ?? AGENTIC_COMMERCE[cfg.network];
32
+ if (!known)
33
+ throw new Error(`no ERC-8183 contract known for ${cfg.network}; pass contract explicitly`);
34
+ const contract = known;
35
+ const chain = CHAINS[cfg.network];
36
+ const transport = http(cfg.rpcUrl);
37
+ const pub = createPublicClient({ chain, transport });
38
+ const wallet = createWalletClient({ chain, transport, account: cfg.signer.account });
39
+ const evaluator = cfg.evaluator ?? cfg.signer.address;
40
+ async function write(functionName, args) {
41
+ const { request } = await pub.simulateContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName, args: args, account: cfg.signer.account });
42
+ const hash = await wallet.writeContract(request);
43
+ const receipt = await pub.waitForTransactionReceipt({ hash });
44
+ if (receipt.status !== "success")
45
+ throw new Error(`${functionName} reverted in ${hash}`);
46
+ return hash;
47
+ }
48
+ return {
49
+ address: cfg.signer.address,
50
+ contract,
51
+ evaluator,
52
+ async createJob({ provider, description, expiresInSeconds, evaluator: ev, hook }) {
53
+ const expiredAt = BigInt(Math.floor(Date.now() / 1000) + expiresInSeconds);
54
+ const { request } = await pub.simulateContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName: "createJob", args: [provider, ev ?? evaluator, expiredAt, description, hook ?? ZERO_ADDRESS], account: cfg.signer.account });
55
+ const txHash = await wallet.writeContract(request);
56
+ const receipt = await pub.waitForTransactionReceipt({ hash: txHash });
57
+ if (receipt.status !== "success")
58
+ throw new Error(`createJob reverted in ${txHash}`);
59
+ const [created] = parseEventLogs({ abi: AGENTIC_COMMERCE_ABI, eventName: "JobCreated", logs: receipt.logs });
60
+ if (!created)
61
+ throw new Error("createJob: no JobCreated event in receipt");
62
+ return { jobId: created.args.jobId, txHash };
63
+ },
64
+ async setBudget(jobId, budget) {
65
+ return { txHash: await write("setBudget", [jobId, budget, "0x"]) };
66
+ },
67
+ async fund(jobId) {
68
+ const job = await this.getJob(jobId);
69
+ if (job.status !== "Open")
70
+ throw new Error(`job ${jobId} is ${job.status}, not Open`);
71
+ if (job.budget === 0n)
72
+ throw new Error(`job ${jobId} has no budget yet (the provider must call setBudget first)`);
73
+ const allowance = await pub.readContract({ address: ARC_USDC, abi: ERC20_ABI, functionName: "allowance", args: [cfg.signer.address, contract] });
74
+ let approveTxHash = null;
75
+ if (allowance < job.budget) {
76
+ const { request } = await pub.simulateContract({ address: ARC_USDC, abi: ERC20_ABI, functionName: "approve", args: [contract, job.budget], account: cfg.signer.account });
77
+ approveTxHash = await wallet.writeContract(request);
78
+ await pub.waitForTransactionReceipt({ hash: approveTxHash });
79
+ }
80
+ const txHash = await write("fund", [jobId, "0x"]);
81
+ return { txHash, approveTxHash, amount: job.budget };
82
+ },
83
+ async submit(jobId, deliverable) {
84
+ return { txHash: await write("submit", [jobId, deliverable, "0x"]) };
85
+ },
86
+ async complete(jobId, reason) {
87
+ return { txHash: await write("complete", [jobId, reasonHash(reason), "0x"]) };
88
+ },
89
+ async reject(jobId, reason) {
90
+ return { txHash: await write("reject", [jobId, reasonHash(reason), "0x"]) };
91
+ },
92
+ async claimRefund(jobId) {
93
+ return { txHash: await write("claimRefund", [jobId]) };
94
+ },
95
+ async getJob(jobId) {
96
+ const j = await pub.readContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName: "getJob", args: [jobId] });
97
+ const budget = usdc6(j.budget);
98
+ return { id: j.id, client: j.client, provider: j.provider, evaluator: j.evaluator, description: j.description, budget, budgetUsdc: formatUsdc6(budget), expiredAt: Number(j.expiredAt), status: jobStatusFromCode(j.status), hook: j.hook };
99
+ },
100
+ async jobCount() {
101
+ return pub.readContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName: "jobCounter" });
102
+ },
103
+ async fees() {
104
+ const [platformBp, evaluatorBp] = await Promise.all([
105
+ pub.readContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName: "platformFeeBP" }),
106
+ pub.readContract({ address: contract, abi: AGENTIC_COMMERCE_ABI, functionName: "evaluatorFeeBP" }),
107
+ ]);
108
+ return { platformBp, evaluatorBp };
109
+ },
110
+ };
111
+ }
112
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,WAAW,EAAE,KAAK,EAAc,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAoC,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAA0B,MAAM,MAAM,CAAC;AACpI,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE3D;qGACqG;AACrG,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,UAAU,EAAE,4CAA4C;IACxD,GAAG,EAAE,IAAI;CACV,CAAC;AACF,MAAM,CAAC,MAAM,QAAQ,GAAY,4CAA4C,CAAC;AAC9E,MAAM,CAAC,MAAM,YAAY,GAAY,4CAA4C,CAAC;AAGlF,MAAM,MAAM,GAAyB,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAEzG,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,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H,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@cra-agent/escrow",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ }
12
+ },
13
+ "scripts": {
14
+ "build": "tsc -b"
15
+ },
16
+ "dependencies": {
17
+ "@cra-agent/accounting": "0.0.1",
18
+ "@cra-agent/identity": "0.0.1",
19
+ "viem": "^2.31.0"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "README.md"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "license": "MIT",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/giupy997/arcagentx402.git",
32
+ "directory": "packages/escrow"
33
+ },
34
+ "homepage": "https://cra-agent.tech"
35
+ }