@chaoschain/sdk 0.2.2 → 0.2.3
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 -3
- package/dist/IPFSLocal-BCIADaOU.d.ts +38 -0
- package/dist/IPFSLocal-DqzD3Y7I.d.cts +38 -0
- package/dist/{index.mjs → index.cjs} +610 -131
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2576 -0
- package/dist/index.d.ts +2576 -0
- package/dist/index.js +522 -208
- package/dist/index.js.map +1 -1
- package/dist/providers/compute/{index.mjs → index.cjs} +5 -3
- package/dist/providers/compute/index.cjs.map +1 -0
- package/dist/providers/compute/index.d.cts +17 -0
- package/dist/providers/compute/index.d.ts +17 -0
- package/dist/providers/compute/index.js +1 -3
- package/dist/providers/compute/index.js.map +1 -1
- package/dist/providers/storage/{index.mjs → index.cjs} +23 -15
- package/dist/providers/storage/index.cjs.map +1 -0
- package/dist/providers/storage/index.d.cts +82 -0
- package/dist/providers/storage/index.d.ts +82 -0
- package/dist/providers/storage/index.js +13 -21
- package/dist/providers/storage/index.js.map +1 -1
- package/dist/types-CEFAgoAM.d.cts +756 -0
- package/dist/types-CEFAgoAM.d.ts +756 -0
- package/package.json +10 -9
- package/dist/index.mjs.map +0 -1
- package/dist/providers/compute/index.mjs.map +0 -1
- package/dist/providers/storage/index.mjs.map +0 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2576 @@
|
|
|
1
|
+
import { N as NetworkConfig, I as IntegrityProof, W as WalletConfig, a as NetworkInfo, C as ContractAddresses, G as GatewayClientConfig, b as GatewayHealthResponse, c as WorkflowStatus, S as ScoreSubmissionMode, P as PendingWorkResponse, d as WorkEvidenceResponse, A as AgentRole, e as ChaosChainSDKConfig, f as AgentMetadata, g as AgentRegistration, F as FeedbackParams, h as PaymentMethod, U as UploadOptions, i as UploadResult, j as WorkflowError } from './types-CEFAgoAM.js';
|
|
2
|
+
export { M as AgencySignals, o as ComputeProvider, D as DKGNodeData, R as EngineeringStudioPolicy, J as EvidencePackage, k as FeedbackRecord, u as PendingWorkItem, Q as ScoreRange, Z as SignalExtractionContext, n as StorageProvider, T as TEEAttestation, p as TransactionResult, l as ValidationRequest, V as ValidationRequestParams, q as ValidationStatus, O as VerifierAssessment, K as WorkEvidenceVerificationResult, Y as WorkMandate, L as WorkVerificationResult, t as WorkflowProgress, s as WorkflowState, r as WorkflowType, m as X402Payment, X as X402PaymentParams, v as XMTPMessageData, E as composeScoreVector, w as computeDepth, x as derivePoAScores, B as extractAgencySignals, H as rangeFit, y as validateEvidenceGraph, z as verifyWorkEvidence } from './types-CEFAgoAM.js';
|
|
3
|
+
import { ethers } from 'ethers';
|
|
4
|
+
export { I as IPFSLocalStorage } from './IPFSLocal-BCIADaOU.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* X402 Payment Manager for ChaosChain SDK
|
|
8
|
+
*
|
|
9
|
+
* This module implements the Coinbase x402 HTTP 402 payment protocol with EIP-3009,
|
|
10
|
+
* enabling seamless, gasless cryptocurrency payments between AI agents via facilitators.
|
|
11
|
+
*
|
|
12
|
+
* Based on: https://www.x402.org/ and https://github.com/coinbase/x402
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface X402PaymentRequest$1 {
|
|
16
|
+
payment_id: string;
|
|
17
|
+
from_agent: string;
|
|
18
|
+
to_agent: string;
|
|
19
|
+
amount: number;
|
|
20
|
+
currency: string;
|
|
21
|
+
service_description: string;
|
|
22
|
+
network: NetworkConfig;
|
|
23
|
+
protocol_fee: number;
|
|
24
|
+
created_at: string;
|
|
25
|
+
settlement_address?: string;
|
|
26
|
+
}
|
|
27
|
+
interface X402PaymentProof {
|
|
28
|
+
payment_id: string;
|
|
29
|
+
transaction_hash: string;
|
|
30
|
+
main_transaction_hash: string;
|
|
31
|
+
fee_transaction_hash?: string;
|
|
32
|
+
from_address: string;
|
|
33
|
+
to_address: string;
|
|
34
|
+
treasury_address: string;
|
|
35
|
+
amount: number;
|
|
36
|
+
currency: string;
|
|
37
|
+
protocol_fee: number;
|
|
38
|
+
network: NetworkConfig;
|
|
39
|
+
chain_id: number;
|
|
40
|
+
block_number?: number;
|
|
41
|
+
timestamp: Date;
|
|
42
|
+
status: string;
|
|
43
|
+
confirmations: number;
|
|
44
|
+
fee_amount?: string;
|
|
45
|
+
net_amount?: string;
|
|
46
|
+
evidence_hash?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Official x402 Payment Requirements schema
|
|
50
|
+
* Spec: https://github.com/coinbase/x402
|
|
51
|
+
*/
|
|
52
|
+
interface X402PaymentRequirements {
|
|
53
|
+
scheme: string;
|
|
54
|
+
network: string;
|
|
55
|
+
maxAmountRequired: string;
|
|
56
|
+
resource: string;
|
|
57
|
+
description: string;
|
|
58
|
+
mimeType: string;
|
|
59
|
+
outputSchema?: object | null;
|
|
60
|
+
payTo: string;
|
|
61
|
+
maxTimeoutSeconds: number;
|
|
62
|
+
asset: string;
|
|
63
|
+
extra: object | null;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* EIP-3009 Payment Header
|
|
67
|
+
* Transmitted as base64-encoded JSON in X-PAYMENT header
|
|
68
|
+
*/
|
|
69
|
+
interface PaymentHeader {
|
|
70
|
+
sender: string;
|
|
71
|
+
nonce: string;
|
|
72
|
+
validAfter?: string;
|
|
73
|
+
validBefore?: string;
|
|
74
|
+
signature?: string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* EIP-3009 Transfer Authorization Parameters
|
|
78
|
+
* Used for signing and on-chain execution
|
|
79
|
+
*/
|
|
80
|
+
interface TransferAuthorizationParams {
|
|
81
|
+
from: string;
|
|
82
|
+
to: string;
|
|
83
|
+
value: bigint;
|
|
84
|
+
validAfter: bigint;
|
|
85
|
+
validBefore: bigint;
|
|
86
|
+
nonce: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Facilitator Configuration
|
|
90
|
+
*/
|
|
91
|
+
interface X402FacilitatorConfig {
|
|
92
|
+
facilitatorUrl?: string;
|
|
93
|
+
apiKey?: string;
|
|
94
|
+
mode?: 'managed' | 'decentralized';
|
|
95
|
+
agentId?: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Facilitator Settlement Request
|
|
99
|
+
*/
|
|
100
|
+
interface SettleRequest {
|
|
101
|
+
x402Version: number;
|
|
102
|
+
paymentHeader: PaymentHeader | string;
|
|
103
|
+
paymentRequirements: X402PaymentRequirements;
|
|
104
|
+
agentId?: string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Facilitator Settlement Response
|
|
108
|
+
*/
|
|
109
|
+
interface SettleResponse {
|
|
110
|
+
success: boolean;
|
|
111
|
+
error: string | null;
|
|
112
|
+
txHash: string | null;
|
|
113
|
+
txHashFee?: string;
|
|
114
|
+
networkId: string | null;
|
|
115
|
+
consensusProof?: string;
|
|
116
|
+
timestamp?: number;
|
|
117
|
+
feeAmount?: string;
|
|
118
|
+
netAmount?: string;
|
|
119
|
+
status?: 'pending' | 'partial_settlement' | 'confirmed' | 'failed';
|
|
120
|
+
evidenceHash?: string;
|
|
121
|
+
proofOfAgency?: string;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* X402 Payment Manager - Coinbase HTTP 402 protocol with EIP-3009
|
|
125
|
+
*
|
|
126
|
+
* Features:
|
|
127
|
+
* - ✅ EIP-3009 gasless transfers via facilitator
|
|
128
|
+
* - ✅ Signature-based payment authorization
|
|
129
|
+
* - ✅ Automatic protocol fee collection
|
|
130
|
+
* - ✅ Multi-network support (Base, Ethereum, Optimism, Linea)
|
|
131
|
+
* - ✅ ChaosChain Proof-of-Agency integration
|
|
132
|
+
*/
|
|
133
|
+
declare class X402PaymentManager {
|
|
134
|
+
private wallet;
|
|
135
|
+
private provider;
|
|
136
|
+
private network;
|
|
137
|
+
private treasuryAddress;
|
|
138
|
+
private protocolFeePercentage;
|
|
139
|
+
private usdcAddresses;
|
|
140
|
+
private facilitatorUrl;
|
|
141
|
+
private facilitatorApiKey?;
|
|
142
|
+
private facilitatorMode;
|
|
143
|
+
private agentId?;
|
|
144
|
+
constructor(wallet: ethers.Wallet | ethers.HDNodeWallet, network: NetworkConfig, facilitatorConfig?: X402FacilitatorConfig);
|
|
145
|
+
/**
|
|
146
|
+
* Get ChaosChain treasury address for network
|
|
147
|
+
*/
|
|
148
|
+
private getTreasuryAddress;
|
|
149
|
+
/**
|
|
150
|
+
* Get chain ID for network
|
|
151
|
+
*/
|
|
152
|
+
private getChainId;
|
|
153
|
+
/**
|
|
154
|
+
* Generate unique nonce for EIP-3009 transfer authorization
|
|
155
|
+
* Returns 32-byte hex string (0x-prefixed)
|
|
156
|
+
*/
|
|
157
|
+
private generateNonce;
|
|
158
|
+
/**
|
|
159
|
+
* Sign EIP-3009 Transfer Authorization
|
|
160
|
+
*
|
|
161
|
+
* This creates an EIP-712 signature for USDC's transferWithAuthorization function.
|
|
162
|
+
* The facilitator will use this signature to execute a gasless transfer on-chain.
|
|
163
|
+
*
|
|
164
|
+
* Spec: https://eips.ethereum.org/EIPS/eip-3009
|
|
165
|
+
*/
|
|
166
|
+
signTransferAuthorization(params: TransferAuthorizationParams): Promise<string>;
|
|
167
|
+
/**
|
|
168
|
+
* Call facilitator API endpoint
|
|
169
|
+
*/
|
|
170
|
+
private callFacilitator;
|
|
171
|
+
/**
|
|
172
|
+
* Settle payment with facilitator (EIP-3009 execution)
|
|
173
|
+
*
|
|
174
|
+
* The facilitator will:
|
|
175
|
+
* 1. Verify the EIP-712 signature
|
|
176
|
+
* 2. Call USDC.transferWithAuthorization() on-chain
|
|
177
|
+
* 3. Sponsor the gas fees
|
|
178
|
+
* 4. Return the transaction hash
|
|
179
|
+
*/
|
|
180
|
+
settleWithFacilitator(paymentHeader: PaymentHeader, paymentRequirements: X402PaymentRequirements): Promise<SettleResponse>;
|
|
181
|
+
/**
|
|
182
|
+
* Create x402 payment request
|
|
183
|
+
*/
|
|
184
|
+
createPaymentRequest(fromAgent: string, toAgent: string, amount: number, currency?: string, serviceDescription?: string): X402PaymentRequest$1;
|
|
185
|
+
/**
|
|
186
|
+
* Execute x402 payment (EIP-3009 mode)
|
|
187
|
+
*
|
|
188
|
+
* This method uses EIP-3009 + facilitator for gasless, signature-based payments
|
|
189
|
+
*/
|
|
190
|
+
executePayment(paymentRequest: X402PaymentRequest$1, recipientAddress: string): Promise<X402PaymentProof>;
|
|
191
|
+
/**
|
|
192
|
+
* Execute native token (ETH) payment
|
|
193
|
+
*/
|
|
194
|
+
private executeNativePayment;
|
|
195
|
+
/**
|
|
196
|
+
* Execute USDC payment using EIP-3009 + Facilitator
|
|
197
|
+
*
|
|
198
|
+
* NEW FLOW (EIP-3009 compliant):
|
|
199
|
+
* 1. Generate EIP-712 signature for transferWithAuthorization
|
|
200
|
+
* 2. Send signature to facilitator
|
|
201
|
+
* 3. Facilitator executes on-chain (gas-sponsored)
|
|
202
|
+
* 4. Return transaction hash
|
|
203
|
+
*
|
|
204
|
+
* Benefits:
|
|
205
|
+
* - ✅ Gasless (facilitator pays gas)
|
|
206
|
+
* - ✅ Single signature (no approve + transfer)
|
|
207
|
+
* - ✅ Facilitator manages fee collection
|
|
208
|
+
*/
|
|
209
|
+
private executeUsdcPayment;
|
|
210
|
+
/**
|
|
211
|
+
* Verify x402 payment on-chain
|
|
212
|
+
*/
|
|
213
|
+
verifyPayment(paymentProof: X402PaymentProof): Promise<boolean>;
|
|
214
|
+
/**
|
|
215
|
+
* Create payment requirements for receiving payments
|
|
216
|
+
* Official x402 spec: https://github.com/coinbase/x402
|
|
217
|
+
* Aligned with Python SDK
|
|
218
|
+
*/
|
|
219
|
+
createPaymentRequirements(amount: number, currency?: string, serviceDescription?: string, evidenceCid?: string): X402PaymentRequirements;
|
|
220
|
+
/**
|
|
221
|
+
* Get payment history (from on-chain events)
|
|
222
|
+
*/
|
|
223
|
+
getPaymentHistory(limit?: number): Promise<X402PaymentProof[]>;
|
|
224
|
+
/**
|
|
225
|
+
* Create cryptographic receipt for payment
|
|
226
|
+
*/
|
|
227
|
+
createPaymentReceipt(paymentProof: X402PaymentProof): Record<string, any>;
|
|
228
|
+
/**
|
|
229
|
+
* Get payment statistics
|
|
230
|
+
*/
|
|
231
|
+
getPaymentStats(): Record<string, any>;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* X402 Paywall Server for ChaosChain SDK
|
|
236
|
+
*
|
|
237
|
+
* This module implements an HTTP 402 paywall server for protecting API endpoints
|
|
238
|
+
* with cryptocurrency payments.
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
interface X402PaywallConfig {
|
|
242
|
+
port: number;
|
|
243
|
+
host?: string;
|
|
244
|
+
defaultCurrency?: string;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* X402 Paywall Server - HTTP 402 payment-protected API
|
|
248
|
+
*
|
|
249
|
+
* Features:
|
|
250
|
+
* - HTTP 402 Payment Required responses
|
|
251
|
+
* - Automatic payment verification
|
|
252
|
+
* - Per-endpoint payment requirements
|
|
253
|
+
* - Payment receipt generation
|
|
254
|
+
*/
|
|
255
|
+
declare class X402Server {
|
|
256
|
+
private paymentManager;
|
|
257
|
+
private server;
|
|
258
|
+
private endpoints;
|
|
259
|
+
private paymentCache;
|
|
260
|
+
private config;
|
|
261
|
+
constructor(paymentManager: X402PaymentManager, config: X402PaywallConfig);
|
|
262
|
+
/**
|
|
263
|
+
* Register a payment-protected endpoint
|
|
264
|
+
*/
|
|
265
|
+
requirePayment(amount: number, description: string, currency?: string): (handler: (data: any) => any) => (data: any) => any;
|
|
266
|
+
/**
|
|
267
|
+
* Start the HTTP 402 server
|
|
268
|
+
*/
|
|
269
|
+
start(): void;
|
|
270
|
+
/**
|
|
271
|
+
* Stop the server
|
|
272
|
+
*/
|
|
273
|
+
stop(): Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Handle incoming HTTP requests
|
|
276
|
+
*/
|
|
277
|
+
private handleRequest;
|
|
278
|
+
/**
|
|
279
|
+
* Send HTTP 402 Payment Required response
|
|
280
|
+
* Official x402 spec: https://github.com/coinbase/x402
|
|
281
|
+
*/
|
|
282
|
+
private sendPaymentRequired;
|
|
283
|
+
/**
|
|
284
|
+
* Verify payment from X-PAYMENT header
|
|
285
|
+
* Spec: X-PAYMENT contains base64 encoded JSON with:
|
|
286
|
+
* { x402Version: number, scheme: string, network: string, payload: <scheme-specific> }
|
|
287
|
+
*/
|
|
288
|
+
private verifyPayment;
|
|
289
|
+
/**
|
|
290
|
+
* Get server statistics
|
|
291
|
+
*/
|
|
292
|
+
getServerStats(): Record<string, any>;
|
|
293
|
+
/**
|
|
294
|
+
* Clear payment cache
|
|
295
|
+
*/
|
|
296
|
+
clearPaymentCache(): void;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Google AP2 Integration for ChaosChain SDK
|
|
301
|
+
*
|
|
302
|
+
* This module integrates Google's official AP2 types with the ChaosChain protocol,
|
|
303
|
+
* providing real AP2 intent verification and mandate management.
|
|
304
|
+
*/
|
|
305
|
+
interface IntentMandate {
|
|
306
|
+
user_cart_confirmation_required: boolean;
|
|
307
|
+
natural_language_description: string;
|
|
308
|
+
merchants?: string[];
|
|
309
|
+
skus?: string[];
|
|
310
|
+
requires_refundability: boolean;
|
|
311
|
+
intent_expiry: string;
|
|
312
|
+
}
|
|
313
|
+
interface CartMandate {
|
|
314
|
+
contents: CartContents;
|
|
315
|
+
merchant_authorization: string;
|
|
316
|
+
}
|
|
317
|
+
interface CartContents {
|
|
318
|
+
id: string;
|
|
319
|
+
user_cart_confirmation_required: boolean;
|
|
320
|
+
payment_request: PaymentRequest;
|
|
321
|
+
cart_expiry: string;
|
|
322
|
+
merchant_name: string;
|
|
323
|
+
}
|
|
324
|
+
interface PaymentRequest {
|
|
325
|
+
method_data: PaymentMethodData[];
|
|
326
|
+
details: PaymentDetailsInit;
|
|
327
|
+
}
|
|
328
|
+
interface PaymentMethodData {
|
|
329
|
+
supported_methods: string;
|
|
330
|
+
data: Record<string, any>;
|
|
331
|
+
}
|
|
332
|
+
interface PaymentDetailsInit {
|
|
333
|
+
id: string;
|
|
334
|
+
display_items: PaymentItem[];
|
|
335
|
+
total: PaymentItem;
|
|
336
|
+
}
|
|
337
|
+
interface PaymentItem {
|
|
338
|
+
label: string;
|
|
339
|
+
amount: PaymentCurrencyAmount;
|
|
340
|
+
}
|
|
341
|
+
interface PaymentCurrencyAmount {
|
|
342
|
+
currency: string;
|
|
343
|
+
value: number | string;
|
|
344
|
+
}
|
|
345
|
+
interface GoogleAP2IntegrationResult {
|
|
346
|
+
intent_mandate?: IntentMandate;
|
|
347
|
+
cart_mandate?: CartMandate;
|
|
348
|
+
payment_mandate?: any;
|
|
349
|
+
jwt_token?: string;
|
|
350
|
+
success: boolean;
|
|
351
|
+
error?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Production Google AP2 integration for ChaosChain SDK
|
|
355
|
+
*
|
|
356
|
+
* This integrates Google's official AP2 library for real intent verification
|
|
357
|
+
* and mandate management with production-grade security.
|
|
358
|
+
*/
|
|
359
|
+
declare class GoogleAP2Integration {
|
|
360
|
+
private agentName;
|
|
361
|
+
private privateKey;
|
|
362
|
+
private publicKey;
|
|
363
|
+
private merchantPrivateKeyValue;
|
|
364
|
+
constructor(agentName: string, merchantPrivateKey?: string);
|
|
365
|
+
/**
|
|
366
|
+
* Get merchant private key (for future use in payment verification)
|
|
367
|
+
*/
|
|
368
|
+
getMerchantPrivateKey(): string;
|
|
369
|
+
/**
|
|
370
|
+
* Generate or load RSA keypair for production JWT signing
|
|
371
|
+
*/
|
|
372
|
+
private getOrGenerateRsaKeypair;
|
|
373
|
+
/**
|
|
374
|
+
* Create an IntentMandate using Google's official AP2 types
|
|
375
|
+
*/
|
|
376
|
+
createIntentMandate(userDescription: string, merchants?: string[], skus?: string[], requiresRefundability?: boolean, expiryMinutes?: number): GoogleAP2IntegrationResult;
|
|
377
|
+
/**
|
|
378
|
+
* Create a CartMandate using Google's official AP2 types with JWT signing
|
|
379
|
+
*/
|
|
380
|
+
createCartMandate(cartId: string, items: Array<{
|
|
381
|
+
name: string;
|
|
382
|
+
price: number;
|
|
383
|
+
}>, totalAmount: number, currency?: string, merchantName?: string, expiryMinutes?: number): Promise<GoogleAP2IntegrationResult>;
|
|
384
|
+
/**
|
|
385
|
+
* Create a JWT token for merchant authorization as per Google's AP2 spec
|
|
386
|
+
*/
|
|
387
|
+
private createMerchantJwt;
|
|
388
|
+
/**
|
|
389
|
+
* Verify a JWT token (for validation purposes)
|
|
390
|
+
*/
|
|
391
|
+
verifyJwtToken(token: string): Promise<Record<string, any>>;
|
|
392
|
+
/**
|
|
393
|
+
* Get a summary of the Google AP2 integration capabilities
|
|
394
|
+
*/
|
|
395
|
+
getIntegrationSummary(): Record<string, any>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* A2A-x402 Extension Implementation for ChaosChain SDK
|
|
400
|
+
*
|
|
401
|
+
* This module implements Google's A2A-x402 extension for cryptocurrency payments,
|
|
402
|
+
* enabling seamless crypto settlement within the AP2 framework.
|
|
403
|
+
*
|
|
404
|
+
* Based on: https://github.com/google-agentic-commerce/a2a-x402/blob/main/v0.1/spec.md
|
|
405
|
+
*/
|
|
406
|
+
|
|
407
|
+
interface X402PaymentMethod {
|
|
408
|
+
supported_methods: string[];
|
|
409
|
+
supported_networks: string[];
|
|
410
|
+
payment_endpoint: string;
|
|
411
|
+
verification_endpoint: string;
|
|
412
|
+
method_data?: Record<string, any>;
|
|
413
|
+
}
|
|
414
|
+
interface TraditionalPaymentResponse {
|
|
415
|
+
payment_id: string;
|
|
416
|
+
method: string;
|
|
417
|
+
amount: number;
|
|
418
|
+
currency: string;
|
|
419
|
+
status: string;
|
|
420
|
+
transaction_id?: string;
|
|
421
|
+
authorization_code?: string;
|
|
422
|
+
timestamp: string;
|
|
423
|
+
receipt_data?: Record<string, any>;
|
|
424
|
+
}
|
|
425
|
+
interface X402PaymentRequest {
|
|
426
|
+
id: string;
|
|
427
|
+
total: Record<string, any>;
|
|
428
|
+
display_items: Array<Record<string, any>>;
|
|
429
|
+
x402_methods: X402PaymentMethod[];
|
|
430
|
+
settlement_address: string;
|
|
431
|
+
network: string;
|
|
432
|
+
expires_at: string;
|
|
433
|
+
}
|
|
434
|
+
interface X402PaymentResponse {
|
|
435
|
+
payment_id: string;
|
|
436
|
+
transaction_hash: string;
|
|
437
|
+
network: string;
|
|
438
|
+
amount: number;
|
|
439
|
+
currency: string;
|
|
440
|
+
settlement_address: string;
|
|
441
|
+
confirmation_blocks: number;
|
|
442
|
+
status: string;
|
|
443
|
+
timestamp: string;
|
|
444
|
+
gas_fee?: number;
|
|
445
|
+
protocol_fee?: number;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* A2A-x402 Extension for cryptocurrency payments within AP2 framework
|
|
449
|
+
*
|
|
450
|
+
* This class bridges Google's AP2 protocol with x402 crypto payments,
|
|
451
|
+
* enabling seamless crypto settlement for agent-to-agent commerce.
|
|
452
|
+
*/
|
|
453
|
+
declare class A2AX402Extension {
|
|
454
|
+
private agentName;
|
|
455
|
+
private network;
|
|
456
|
+
private paymentManager;
|
|
457
|
+
private supportedCryptoMethods;
|
|
458
|
+
private supportedNetworks;
|
|
459
|
+
private w3cPaymentMethods;
|
|
460
|
+
constructor(agentName: string, network: NetworkConfig, paymentManager: any);
|
|
461
|
+
/**
|
|
462
|
+
* Initialize W3C Payment Request API compliant payment methods
|
|
463
|
+
*/
|
|
464
|
+
private initializeW3cPaymentMethods;
|
|
465
|
+
/**
|
|
466
|
+
* Create x402 payment method descriptor with W3C compliance
|
|
467
|
+
*/
|
|
468
|
+
createX402PaymentMethod(settlementAddress: string): X402PaymentMethod;
|
|
469
|
+
/**
|
|
470
|
+
* Create enhanced payment request with x402 crypto support
|
|
471
|
+
*/
|
|
472
|
+
createEnhancedPaymentRequest(cartId: string, totalAmount: number, currency: string, items: Array<Record<string, any>>, settlementAddress: string): X402PaymentRequest;
|
|
473
|
+
/**
|
|
474
|
+
* Execute x402 crypto payment using the real payment manager
|
|
475
|
+
*/
|
|
476
|
+
executeX402Payment(paymentRequest: X402PaymentRequest, payerAgent: string, serviceDescription?: string): Promise<X402PaymentResponse>;
|
|
477
|
+
/**
|
|
478
|
+
* Execute traditional payment (cards, Google Pay, Apple Pay, etc.)
|
|
479
|
+
*/
|
|
480
|
+
executeTraditionalPayment(paymentMethod: string, amount: number, currency: string, paymentData: Record<string, any>): TraditionalPaymentResponse;
|
|
481
|
+
/**
|
|
482
|
+
* Verify x402 payment on-chain
|
|
483
|
+
*/
|
|
484
|
+
verifyX402Payment(paymentResponse: X402PaymentResponse): boolean;
|
|
485
|
+
/**
|
|
486
|
+
* Create cryptographic proof of x402 payment
|
|
487
|
+
*/
|
|
488
|
+
createPaymentProof(paymentResponse: X402PaymentResponse): Record<string, any>;
|
|
489
|
+
/**
|
|
490
|
+
* Get A2A-x402 extension capabilities with W3C Payment Request API compliance
|
|
491
|
+
*/
|
|
492
|
+
getExtensionCapabilities(): Record<string, any>;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Production-ready process integrity verification for ChaosChain agents.
|
|
497
|
+
*
|
|
498
|
+
* This module provides cryptographic proof of correct code execution,
|
|
499
|
+
* ensuring that agents perform work as intended with verifiable evidence.
|
|
500
|
+
*
|
|
501
|
+
* Features:
|
|
502
|
+
* - Local code hashing (SHA-256)
|
|
503
|
+
* - Optional TEE attestations (0G Compute, AWS Nitro, etc.)
|
|
504
|
+
* - Dual-layer verification: Code + Execution
|
|
505
|
+
* - Pluggable compute providers for maximum flexibility
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
interface StorageProvider {
|
|
509
|
+
uploadJson(data: any, filename: string): Promise<string>;
|
|
510
|
+
}
|
|
511
|
+
interface ComputeProvider {
|
|
512
|
+
submit(task: any): Promise<string>;
|
|
513
|
+
status(jobId: string): Promise<{
|
|
514
|
+
state: string;
|
|
515
|
+
[key: string]: any;
|
|
516
|
+
}>;
|
|
517
|
+
result(jobId: string): Promise<{
|
|
518
|
+
success: boolean;
|
|
519
|
+
execution_hash: string;
|
|
520
|
+
verification_method: {
|
|
521
|
+
value: string;
|
|
522
|
+
};
|
|
523
|
+
proof?: Buffer;
|
|
524
|
+
metadata?: any;
|
|
525
|
+
error?: string;
|
|
526
|
+
}>;
|
|
527
|
+
attestation(jobId: string): Promise<any>;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Production-ready process integrity verifier for ChaosChain agents.
|
|
531
|
+
*
|
|
532
|
+
* Provides dual-layer cryptographic proof:
|
|
533
|
+
* 1. Local code hashing (SHA-256 of function code)
|
|
534
|
+
* 2. Optional TEE attestations (hardware-verified execution from 0G Compute, AWS Nitro, etc.)
|
|
535
|
+
*
|
|
536
|
+
* This enables the "Process Integrity" layer of the Triple-Verified Stack:
|
|
537
|
+
* - Layer 1: AP2 Intent Verification (Google)
|
|
538
|
+
* - Layer 2: Process Integrity (ChaosChain + TEE attestations) ← THIS MODULE
|
|
539
|
+
* - Layer 3: Accountability
|
|
540
|
+
*/
|
|
541
|
+
declare class ProcessIntegrity {
|
|
542
|
+
private agentName;
|
|
543
|
+
private storageManager;
|
|
544
|
+
private computeProvider;
|
|
545
|
+
private registeredFunctions;
|
|
546
|
+
private functionHashes;
|
|
547
|
+
constructor(agentName: string, storageManager?: StorageProvider | null, computeProvider?: ComputeProvider | null);
|
|
548
|
+
/**
|
|
549
|
+
* Register a function for integrity checking.
|
|
550
|
+
*/
|
|
551
|
+
registerFunction(func: Function, functionName?: string): string;
|
|
552
|
+
/**
|
|
553
|
+
* Execute a registered function with integrity proof generation.
|
|
554
|
+
*/
|
|
555
|
+
executeWithProof(functionName: string, inputs: Record<string, any>, requireProof?: boolean, useTee?: boolean): Promise<[any, IntegrityProof | null]>;
|
|
556
|
+
/**
|
|
557
|
+
* Generate a hash of the function's code.
|
|
558
|
+
*/
|
|
559
|
+
private generateCodeHash;
|
|
560
|
+
/**
|
|
561
|
+
* Get TEE attestation from compute provider (e.g., 0G Compute).
|
|
562
|
+
*/
|
|
563
|
+
private getTeeAttestation;
|
|
564
|
+
/**
|
|
565
|
+
* Generate a cryptographic integrity proof.
|
|
566
|
+
*/
|
|
567
|
+
private generateIntegrityProof;
|
|
568
|
+
/**
|
|
569
|
+
* Store integrity proof on IPFS for persistence.
|
|
570
|
+
*/
|
|
571
|
+
private storeProofOnIpfs;
|
|
572
|
+
/**
|
|
573
|
+
* Serialize function result for hashing.
|
|
574
|
+
*/
|
|
575
|
+
private serializeResult;
|
|
576
|
+
/**
|
|
577
|
+
* Create a process insurance policy for a function.
|
|
578
|
+
*/
|
|
579
|
+
createInsurancePolicy(functionName: string, coverageAmount: number, conditions: Record<string, any>): Record<string, any>;
|
|
580
|
+
/**
|
|
581
|
+
* Configure autonomous agent capabilities with integrity verification.
|
|
582
|
+
*/
|
|
583
|
+
configureAutonomousAgent(capabilities: string[], constraints: Record<string, any>): Record<string, any>;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Wallet management for ChaosChain SDK
|
|
588
|
+
* Handles private keys, HD wallets, and secure key storage
|
|
589
|
+
*/
|
|
590
|
+
|
|
591
|
+
declare class WalletManager {
|
|
592
|
+
private wallet;
|
|
593
|
+
private provider?;
|
|
594
|
+
constructor(config: WalletConfig, provider?: ethers.Provider);
|
|
595
|
+
/**
|
|
596
|
+
* Initialize wallet from various sources
|
|
597
|
+
*/
|
|
598
|
+
private initializeWallet;
|
|
599
|
+
/**
|
|
600
|
+
* Load wallet from encrypted file
|
|
601
|
+
*/
|
|
602
|
+
private loadFromFile;
|
|
603
|
+
/**
|
|
604
|
+
* Save wallet to encrypted file
|
|
605
|
+
*/
|
|
606
|
+
saveToFile(filePath: string, password?: string): Promise<void>;
|
|
607
|
+
/**
|
|
608
|
+
* Get wallet instance
|
|
609
|
+
*/
|
|
610
|
+
getWallet(): ethers.Wallet | ethers.HDNodeWallet;
|
|
611
|
+
/**
|
|
612
|
+
* Get wallet address
|
|
613
|
+
*/
|
|
614
|
+
getAddress(): string;
|
|
615
|
+
/**
|
|
616
|
+
* Get private key (use with caution)
|
|
617
|
+
*/
|
|
618
|
+
getPrivateKey(): string;
|
|
619
|
+
/**
|
|
620
|
+
* Get mnemonic phrase (if available)
|
|
621
|
+
*/
|
|
622
|
+
getMnemonic(): string | undefined;
|
|
623
|
+
/**
|
|
624
|
+
* Sign a message
|
|
625
|
+
*/
|
|
626
|
+
signMessage(message: string): Promise<string>;
|
|
627
|
+
/**
|
|
628
|
+
* Sign typed data (EIP-712)
|
|
629
|
+
*/
|
|
630
|
+
signTypedData(domain: ethers.TypedDataDomain, types: Record<string, ethers.TypedDataField[]>, value: Record<string, unknown>): Promise<string>;
|
|
631
|
+
/**
|
|
632
|
+
* Get balance
|
|
633
|
+
*/
|
|
634
|
+
getBalance(): Promise<bigint>;
|
|
635
|
+
/**
|
|
636
|
+
* Get nonce
|
|
637
|
+
*/
|
|
638
|
+
getNonce(): Promise<number>;
|
|
639
|
+
/**
|
|
640
|
+
* Connect to a new provider
|
|
641
|
+
*/
|
|
642
|
+
connect(provider: ethers.Provider): void;
|
|
643
|
+
/**
|
|
644
|
+
* Generate a new random wallet
|
|
645
|
+
*/
|
|
646
|
+
static createRandom(): WalletManager;
|
|
647
|
+
/**
|
|
648
|
+
* Create from mnemonic
|
|
649
|
+
*/
|
|
650
|
+
static fromMnemonic(mnemonic: string, provider?: ethers.Provider): WalletManager;
|
|
651
|
+
/**
|
|
652
|
+
* Create from private key
|
|
653
|
+
*/
|
|
654
|
+
static fromPrivateKey(privateKey: string, provider?: ethers.Provider): WalletManager;
|
|
655
|
+
/**
|
|
656
|
+
* Generate new mnemonic
|
|
657
|
+
*/
|
|
658
|
+
static generateMnemonic(): string;
|
|
659
|
+
/**
|
|
660
|
+
* Validate mnemonic
|
|
661
|
+
*/
|
|
662
|
+
static isValidMnemonic(mnemonic: string): boolean;
|
|
663
|
+
/**
|
|
664
|
+
* Validate private key
|
|
665
|
+
*/
|
|
666
|
+
static isValidPrivateKey(privateKey: string): boolean;
|
|
667
|
+
/**
|
|
668
|
+
* Derive child wallet from HD path
|
|
669
|
+
*/
|
|
670
|
+
static deriveChild(mnemonic: string, path: string): WalletManager;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
declare class MandateManager {
|
|
674
|
+
private readonly agentName;
|
|
675
|
+
private readonly walletManager;
|
|
676
|
+
private readonly agentCaip10;
|
|
677
|
+
private readonly chainId;
|
|
678
|
+
private readonly mandatesCore;
|
|
679
|
+
constructor(agentName: string, walletManager: WalletManager, chainId: number);
|
|
680
|
+
get agent_caip10(): string;
|
|
681
|
+
get chain_id(): number;
|
|
682
|
+
private toCaip10;
|
|
683
|
+
buildCore(kind: string, payload: Record<string, unknown>, baseUrl?: string): Record<string, unknown>;
|
|
684
|
+
createMandate(params: {
|
|
685
|
+
intent: string;
|
|
686
|
+
core: Record<string, unknown>;
|
|
687
|
+
deadline: string;
|
|
688
|
+
client: string;
|
|
689
|
+
server?: string;
|
|
690
|
+
version?: string;
|
|
691
|
+
mandateId?: string;
|
|
692
|
+
createdAt?: string;
|
|
693
|
+
}): any;
|
|
694
|
+
mandateFromDict(data: any): any;
|
|
695
|
+
signAsServer(mandate: any, privateKey?: string): any;
|
|
696
|
+
signAsClient(mandate: any, privateKey: string): any;
|
|
697
|
+
verify(mandate: any): {
|
|
698
|
+
client_ok: boolean;
|
|
699
|
+
server_ok: boolean;
|
|
700
|
+
all_ok: boolean;
|
|
701
|
+
mandate_hash: string;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Network configurations for supported chains
|
|
707
|
+
*/
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Get network info by name
|
|
711
|
+
*/
|
|
712
|
+
declare function getNetworkInfo(network: NetworkConfig | string): NetworkInfo;
|
|
713
|
+
/**
|
|
714
|
+
* Get contract addresses for a network
|
|
715
|
+
*/
|
|
716
|
+
declare function getContractAddresses(network: NetworkConfig | string): ContractAddresses;
|
|
717
|
+
|
|
718
|
+
declare class GatewayClient {
|
|
719
|
+
private gatewayUrl;
|
|
720
|
+
private timeout;
|
|
721
|
+
private maxPollTime;
|
|
722
|
+
private pollInterval;
|
|
723
|
+
private defaultHeaders?;
|
|
724
|
+
private auth?;
|
|
725
|
+
private retryConfig?;
|
|
726
|
+
constructor(config: GatewayClientConfig);
|
|
727
|
+
private _resolveTimeout;
|
|
728
|
+
private _resolveAuthMode;
|
|
729
|
+
private _buildHeaders;
|
|
730
|
+
private _classifyStatusCode;
|
|
731
|
+
private _normalizeError;
|
|
732
|
+
private _getRetryDelayMs;
|
|
733
|
+
private _sleep;
|
|
734
|
+
/**
|
|
735
|
+
* Make HTTP request to Gateway.
|
|
736
|
+
* Handles errors and transforms them to Gateway exceptions.
|
|
737
|
+
*/
|
|
738
|
+
private _request;
|
|
739
|
+
/**
|
|
740
|
+
* Parse workflow status from API response.
|
|
741
|
+
*/
|
|
742
|
+
private _parseWorkflowStatus;
|
|
743
|
+
healthCheck(): Promise<GatewayHealthResponse>;
|
|
744
|
+
isHealthy(): Promise<boolean>;
|
|
745
|
+
/**
|
|
746
|
+
* Create a work submission workflow.
|
|
747
|
+
* POST /workflows/work-submission
|
|
748
|
+
*
|
|
749
|
+
* SDK prepares inputs; Gateway handles:
|
|
750
|
+
* - Evidence upload to Arweave
|
|
751
|
+
* - Transaction submission
|
|
752
|
+
* - Confirmation waiting
|
|
753
|
+
*
|
|
754
|
+
* @param studioAddress - Ethereum address of the studio
|
|
755
|
+
* @param epoch - Epoch number
|
|
756
|
+
* @param agentAddress - Ethereum address of the submitting agent
|
|
757
|
+
* @param dataHash - Bytes32 hash of the work (as hex string)
|
|
758
|
+
* @param threadRoot - Bytes32 DKG thread root (as hex string)
|
|
759
|
+
* @param evidenceRoot - Bytes32 evidence Merkle root (as hex string)
|
|
760
|
+
* @param evidenceContent - Raw evidence bytes (will be base64 encoded)
|
|
761
|
+
* @param signerAddress - Ethereum address of the signer (must be registered in Gateway)
|
|
762
|
+
* @returns WorkflowStatus - Initial status of the created workflow
|
|
763
|
+
*/
|
|
764
|
+
submitWork(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string): Promise<WorkflowStatus>;
|
|
765
|
+
/**
|
|
766
|
+
* Create a score submission workflow.
|
|
767
|
+
* POST /workflows/score-submission
|
|
768
|
+
*
|
|
769
|
+
* Supports two modes:
|
|
770
|
+
* - DIRECT (default): Simple direct scoring, requires workerAddress
|
|
771
|
+
* - COMMIT_REVEAL: Commit-reveal pattern, requires salt
|
|
772
|
+
*
|
|
773
|
+
* @param studioAddress - Ethereum address of the studio
|
|
774
|
+
* @param epoch - Epoch number
|
|
775
|
+
* @param validatorAddress - Ethereum address of the validator
|
|
776
|
+
* @param dataHash - Bytes32 hash of the work being scored (as hex string)
|
|
777
|
+
* @param scores - Array of dimension scores (0-10000 basis points)
|
|
778
|
+
* @param signerAddress - Ethereum address of the signer
|
|
779
|
+
* @param options - Additional options (workerAddress, salt, mode)
|
|
780
|
+
*/
|
|
781
|
+
submitScore(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
|
|
782
|
+
workerAddress?: string;
|
|
783
|
+
salt?: string;
|
|
784
|
+
mode?: ScoreSubmissionMode;
|
|
785
|
+
}): Promise<WorkflowStatus>;
|
|
786
|
+
/**
|
|
787
|
+
* Create a close epoch workflow.
|
|
788
|
+
* POST /workflows/close-epoch
|
|
789
|
+
*
|
|
790
|
+
* This is economically final — cannot be undone.
|
|
791
|
+
*
|
|
792
|
+
* @param studioAddress - Ethereum address of the studio
|
|
793
|
+
* @param epoch - Epoch number to close
|
|
794
|
+
* @param signerAddress - Ethereum address of the signer
|
|
795
|
+
*/
|
|
796
|
+
closeEpoch(studioAddress: string, epoch: number, signerAddress: string): Promise<WorkflowStatus>;
|
|
797
|
+
/**
|
|
798
|
+
* Get workflow status by ID.
|
|
799
|
+
* GET /workflows/{id}
|
|
800
|
+
*/
|
|
801
|
+
getWorkflow(workflowId: string): Promise<WorkflowStatus>;
|
|
802
|
+
/**
|
|
803
|
+
* List workflows with optional filters.
|
|
804
|
+
* GET /workflows?studio=&state=&type=
|
|
805
|
+
*/
|
|
806
|
+
listWorkflows(options?: {
|
|
807
|
+
studio?: string;
|
|
808
|
+
state?: string;
|
|
809
|
+
workflowType?: string;
|
|
810
|
+
}): Promise<WorkflowStatus[]>;
|
|
811
|
+
/**
|
|
812
|
+
* Poll workflow until it reaches a terminal state.
|
|
813
|
+
*
|
|
814
|
+
* @param workflowId - UUID of the workflow
|
|
815
|
+
* @param options - Polling options
|
|
816
|
+
* @throws WorkflowFailedError - If workflow reaches FAILED state
|
|
817
|
+
* @throws GatewayTimeoutError - If maxWait exceeded
|
|
818
|
+
*/
|
|
819
|
+
waitForCompletion(workflowId: string, options?: {
|
|
820
|
+
maxWait?: number;
|
|
821
|
+
pollInterval?: number;
|
|
822
|
+
onProgress?: (status: WorkflowStatus) => void;
|
|
823
|
+
}): Promise<WorkflowStatus>;
|
|
824
|
+
/**
|
|
825
|
+
* Submit work and wait for completion.
|
|
826
|
+
*/
|
|
827
|
+
submitWorkAndWait(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string, options?: {
|
|
828
|
+
onProgress?: (status: WorkflowStatus) => void;
|
|
829
|
+
}): Promise<WorkflowStatus>;
|
|
830
|
+
/**
|
|
831
|
+
* Submit score and wait for completion.
|
|
832
|
+
*/
|
|
833
|
+
submitScoreAndWait(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
|
|
834
|
+
workerAddress?: string;
|
|
835
|
+
workAddress?: string;
|
|
836
|
+
salt?: string;
|
|
837
|
+
mode?: ScoreSubmissionMode;
|
|
838
|
+
onProgress?: (status: WorkflowStatus) => void;
|
|
839
|
+
}): Promise<WorkflowStatus>;
|
|
840
|
+
/**
|
|
841
|
+
* Close epoch and wait for completion.
|
|
842
|
+
*/
|
|
843
|
+
closeEpochAndWait(studioAddress: string, epoch: number, signerAddress: string, options?: {
|
|
844
|
+
onProgress?: (status: WorkflowStatus) => void;
|
|
845
|
+
}): Promise<WorkflowStatus>;
|
|
846
|
+
/**
|
|
847
|
+
* Fetch pending (unfinalized) work for a studio from the gateway.
|
|
848
|
+
*
|
|
849
|
+
* @param studioAddress - 0x-prefixed studio contract address
|
|
850
|
+
* @param options - Optional limit/offset for pagination
|
|
851
|
+
* @returns Typed pending work response
|
|
852
|
+
*/
|
|
853
|
+
getPendingWork(studioAddress: string, options?: {
|
|
854
|
+
limit?: number;
|
|
855
|
+
offset?: number;
|
|
856
|
+
}): Promise<PendingWorkResponse>;
|
|
857
|
+
/**
|
|
858
|
+
* Fetch full evidence graph for a work submission.
|
|
859
|
+
* Endpoint: GET /v1/work/{hash}/evidence
|
|
860
|
+
*/
|
|
861
|
+
getWorkEvidence(workHash: string): Promise<WorkEvidenceResponse>;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
interface StudioClientConfig {
|
|
865
|
+
provider: ethers.Provider;
|
|
866
|
+
signer: ethers.Signer;
|
|
867
|
+
network: string;
|
|
868
|
+
}
|
|
869
|
+
declare class StudioClient {
|
|
870
|
+
private provider;
|
|
871
|
+
private signer;
|
|
872
|
+
private network;
|
|
873
|
+
constructor(config: StudioClientConfig);
|
|
874
|
+
/**
|
|
875
|
+
* Create a new Studio on the ChaosChain protocol.
|
|
876
|
+
*
|
|
877
|
+
* @param name - Name for the studio
|
|
878
|
+
* @param logicModuleAddress - Address of deployed LogicModule contract
|
|
879
|
+
* @returns Studio proxy address and studioId
|
|
880
|
+
*/
|
|
881
|
+
createStudio(name: string, logicModuleAddress: string): Promise<{
|
|
882
|
+
proxyAddress: string;
|
|
883
|
+
studioId: bigint;
|
|
884
|
+
}>;
|
|
885
|
+
/**
|
|
886
|
+
* Register this agent with a Studio.
|
|
887
|
+
*
|
|
888
|
+
* @param studioAddress - Address of the Studio proxy
|
|
889
|
+
* @param agentId - Agent's ERC-8004 ID
|
|
890
|
+
* @param role - Agent role (1=WORKER, 2=VERIFIER, 3=CLIENT, etc.)
|
|
891
|
+
* @param stakeAmount - Amount to stake in wei (default: 0.0001 ETH)
|
|
892
|
+
*/
|
|
893
|
+
registerWithStudio(studioAddress: string, agentId: string, role: number, stakeAmount?: bigint): Promise<string>;
|
|
894
|
+
/**
|
|
895
|
+
* Submit work to a Studio (direct, deprecated).
|
|
896
|
+
* @deprecated Use Gateway for production. Direct submission lacks crash recovery.
|
|
897
|
+
*
|
|
898
|
+
* @param studioAddress - Address of the Studio proxy
|
|
899
|
+
* @param dataHash - EIP-712 DataHash of the work (bytes32)
|
|
900
|
+
* @param threadRoot - VLC/Merkle root of XMTP thread (bytes32)
|
|
901
|
+
* @param evidenceRoot - Merkle root of artifacts (bytes32)
|
|
902
|
+
* @param feedbackAuth - Feedback authorization (deprecated, default empty)
|
|
903
|
+
* @returns Transaction hash
|
|
904
|
+
*/
|
|
905
|
+
submitWork(studioAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, feedbackAuth?: string): Promise<string>;
|
|
906
|
+
/**
|
|
907
|
+
* Submit work with multi-agent attribution.
|
|
908
|
+
* @deprecated Use Gateway for production.
|
|
909
|
+
*
|
|
910
|
+
* @param studioAddress - Address of the Studio proxy
|
|
911
|
+
* @param dataHash - EIP-712 DataHash of the work (bytes32)
|
|
912
|
+
* @param threadRoot - VLC/Merkle root of XMTP thread (bytes32)
|
|
913
|
+
* @param evidenceRoot - Merkle root of artifacts (bytes32)
|
|
914
|
+
* @param participants - List of participant addresses (in order)
|
|
915
|
+
* @param contributionWeights - Contribution weights in basis points (must sum to 10000)
|
|
916
|
+
* @param evidenceCID - IPFS/Arweave CID of evidence package (optional)
|
|
917
|
+
* @returns Transaction hash
|
|
918
|
+
*/
|
|
919
|
+
submitWorkMultiAgent(studioAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, participants: string[], contributionWeights: number[], evidenceCID?: string): Promise<string>;
|
|
920
|
+
/**
|
|
921
|
+
* Commit a score (commit phase of commit-reveal).
|
|
922
|
+
*
|
|
923
|
+
* NOTE: For production, use Gateway.submitScore() with mode=COMMIT_REVEAL.
|
|
924
|
+
* The Gateway handles workflow management, crash recovery, and proper sequencing.
|
|
925
|
+
*
|
|
926
|
+
* @param studioAddress - Address of the Studio proxy
|
|
927
|
+
* @param dataHash - DataHash of the work being scored (bytes32)
|
|
928
|
+
* @param commitment - keccak256(abi.encodePacked(scoreVector, salt, dataHash))
|
|
929
|
+
* @returns Transaction hash
|
|
930
|
+
*/
|
|
931
|
+
commitScore(studioAddress: string, dataHash: string, commitment: string): Promise<string>;
|
|
932
|
+
/**
|
|
933
|
+
* Reveal a score (reveal phase of commit-reveal).
|
|
934
|
+
*
|
|
935
|
+
* NOTE: For production, use Gateway.submitScore() with mode=COMMIT_REVEAL.
|
|
936
|
+
* The Gateway handles the full commit-reveal lifecycle automatically.
|
|
937
|
+
*
|
|
938
|
+
* @param studioAddress - Address of the Studio proxy
|
|
939
|
+
* @param dataHash - DataHash of the work being scored (bytes32)
|
|
940
|
+
* @param scoreVector - ABI-encoded score array (bytes)
|
|
941
|
+
* @param salt - Random salt used in commitment (bytes32)
|
|
942
|
+
* @returns Transaction hash
|
|
943
|
+
*/
|
|
944
|
+
revealScore(studioAddress: string, dataHash: string, scoreVector: string, salt: string): Promise<string>;
|
|
945
|
+
/**
|
|
946
|
+
* Submit score vector directly (simpler alternative to commit-reveal).
|
|
947
|
+
*
|
|
948
|
+
* NOTE: For production, use Gateway.submitScore() with mode=DIRECT.
|
|
949
|
+
* The Gateway handles workflow management and crash recovery.
|
|
950
|
+
*
|
|
951
|
+
* Use this direct method only for:
|
|
952
|
+
* - Local testing and development
|
|
953
|
+
* - Admin operations requiring low-level control
|
|
954
|
+
* - Studios that don't require commit-reveal protection
|
|
955
|
+
*
|
|
956
|
+
* @param studioAddress - Address of the Studio proxy
|
|
957
|
+
* @param dataHash - DataHash of the work being scored (bytes32)
|
|
958
|
+
* @param scores - Multi-dimensional scores [0-100 each]
|
|
959
|
+
* @returns Transaction hash
|
|
960
|
+
*/
|
|
961
|
+
submitScoreVector(studioAddress: string, dataHash: string, scores: number[]): Promise<string>;
|
|
962
|
+
/**
|
|
963
|
+
* Submit score vector for a SPECIFIC WORKER in multi-agent tasks.
|
|
964
|
+
*
|
|
965
|
+
* NOTE: For production, use Gateway.submitScore() which handles per-worker
|
|
966
|
+
* scoring automatically based on DKG causal analysis.
|
|
967
|
+
*
|
|
968
|
+
* This direct method is for:
|
|
969
|
+
* - Local testing and development
|
|
970
|
+
* - Admin operations requiring low-level control
|
|
971
|
+
*
|
|
972
|
+
* How multi-agent scoring works:
|
|
973
|
+
* - Each verifier evaluates EACH WORKER from DKG causal analysis
|
|
974
|
+
* - Submits separate score vector for each worker
|
|
975
|
+
* - Contract calculates per-worker consensus
|
|
976
|
+
* - Each worker gets THEIR OWN reputation scores
|
|
977
|
+
*
|
|
978
|
+
* @param studioAddress - Address of the Studio proxy
|
|
979
|
+
* @param dataHash - DataHash of the work being scored (bytes32)
|
|
980
|
+
* @param workerAddress - Address of the worker being scored
|
|
981
|
+
* @param scores - Multi-dimensional scores for THIS worker [0-100 each]
|
|
982
|
+
* @returns Transaction hash
|
|
983
|
+
*/
|
|
984
|
+
submitScoreVectorForWorker(studioAddress: string, dataHash: string, workerAddress: string, scores: number[]): Promise<string>;
|
|
985
|
+
/**
|
|
986
|
+
* Close an epoch and trigger reward distribution.
|
|
987
|
+
*
|
|
988
|
+
* NOTE: For production, use Gateway.closeEpoch() which handles
|
|
989
|
+
* workflow management, logging, and crash recovery.
|
|
990
|
+
*
|
|
991
|
+
* @param studioAddress - Address of the Studio proxy
|
|
992
|
+
* @param epoch - Epoch number to close
|
|
993
|
+
* @returns Transaction hash
|
|
994
|
+
*/
|
|
995
|
+
closeEpoch(studioAddress: string, epoch: number): Promise<string>;
|
|
996
|
+
/**
|
|
997
|
+
* Get pending rewards for an account in a Studio.
|
|
998
|
+
*
|
|
999
|
+
* @param studioAddress - Address of the Studio proxy
|
|
1000
|
+
* @param account - Address to check balance for
|
|
1001
|
+
* @returns Pending reward amount in wei
|
|
1002
|
+
*/
|
|
1003
|
+
getPendingRewards(studioAddress: string, account: string): Promise<bigint>;
|
|
1004
|
+
/**
|
|
1005
|
+
* Withdraw pending rewards from a Studio.
|
|
1006
|
+
*
|
|
1007
|
+
* @param studioAddress - Address of the Studio proxy
|
|
1008
|
+
* @returns Transaction hash
|
|
1009
|
+
*/
|
|
1010
|
+
withdrawRewards(studioAddress: string): Promise<string>;
|
|
1011
|
+
/**
|
|
1012
|
+
* Compute score commitment for commit-reveal pattern.
|
|
1013
|
+
*
|
|
1014
|
+
* @param scores - Array of scores (0-100 or 0-10000 depending on contract)
|
|
1015
|
+
* @param salt - Random bytes32 salt
|
|
1016
|
+
* @param dataHash - DataHash of the work being scored
|
|
1017
|
+
* @returns bytes32 commitment hash
|
|
1018
|
+
*/
|
|
1019
|
+
computeScoreCommitment(scores: number[], salt: string, dataHash: string): string;
|
|
1020
|
+
/**
|
|
1021
|
+
* Encode score vector for revealScore.
|
|
1022
|
+
*
|
|
1023
|
+
* @param scores - Array of scores
|
|
1024
|
+
* @returns ABI-encoded bytes
|
|
1025
|
+
*/
|
|
1026
|
+
encodeScoreVector(scores: number[]): string;
|
|
1027
|
+
/**
|
|
1028
|
+
* Generate random salt for commit-reveal.
|
|
1029
|
+
*
|
|
1030
|
+
* @returns bytes32 random salt
|
|
1031
|
+
*/
|
|
1032
|
+
generateSalt(): string;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Main ChaosChain SDK Class - Complete TypeScript implementation
|
|
1037
|
+
*
|
|
1038
|
+
* Features:
|
|
1039
|
+
* - ERC-8004 v1.0 on-chain identity, reputation, and validation
|
|
1040
|
+
* - x402 crypto payments (USDC/ETH)
|
|
1041
|
+
* - Traditional payments (cards, Google Pay, Apple Pay, PayPal)
|
|
1042
|
+
* - Google AP2 intent verification
|
|
1043
|
+
* - Process integrity with cryptographic proofs
|
|
1044
|
+
* - Pluggable storage providers (IPFS, Pinata, Irys, 0G)
|
|
1045
|
+
* - Pluggable compute providers
|
|
1046
|
+
* - A2A-x402 extension for multi-payment support
|
|
1047
|
+
* - HTTP 402 paywall server
|
|
1048
|
+
*/
|
|
1049
|
+
declare class ChaosChainSDK {
|
|
1050
|
+
private static warnedGatewayMissing;
|
|
1051
|
+
private static warnedStudioClientProduction;
|
|
1052
|
+
private walletManager;
|
|
1053
|
+
private chaosAgent;
|
|
1054
|
+
private x402PaymentManager?;
|
|
1055
|
+
private paymentManager?;
|
|
1056
|
+
private storageBackend;
|
|
1057
|
+
private computeProvider?;
|
|
1058
|
+
private provider;
|
|
1059
|
+
googleAP2?: GoogleAP2Integration;
|
|
1060
|
+
a2aX402Extension?: A2AX402Extension;
|
|
1061
|
+
processIntegrity?: ProcessIntegrity;
|
|
1062
|
+
mandateManager?: MandateManager;
|
|
1063
|
+
gateway: GatewayClient | null;
|
|
1064
|
+
studio: StudioClient;
|
|
1065
|
+
readonly agentName: string;
|
|
1066
|
+
readonly agentDomain: string;
|
|
1067
|
+
readonly agentRole: AgentRole | string;
|
|
1068
|
+
readonly network: NetworkConfig | string;
|
|
1069
|
+
readonly networkInfo: ReturnType<typeof getNetworkInfo>;
|
|
1070
|
+
private _agentId?;
|
|
1071
|
+
constructor(config: ChaosChainSDKConfig);
|
|
1072
|
+
/**
|
|
1073
|
+
* Register agent identity on-chain
|
|
1074
|
+
*/
|
|
1075
|
+
registerIdentity(metadata?: AgentMetadata): Promise<AgentRegistration>;
|
|
1076
|
+
/**
|
|
1077
|
+
* Get agent metadata
|
|
1078
|
+
*/
|
|
1079
|
+
getAgentMetadata(agentId: bigint): Promise<AgentMetadata | null>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Update agent metadata
|
|
1082
|
+
*/
|
|
1083
|
+
updateAgentMetadata(agentId: bigint, metadata: AgentMetadata): Promise<string>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Get current agent ID
|
|
1086
|
+
*/
|
|
1087
|
+
getAgentId(): bigint | undefined;
|
|
1088
|
+
/**
|
|
1089
|
+
* Generate feedback authorization (EIP-191 signing)
|
|
1090
|
+
*/
|
|
1091
|
+
generateFeedbackAuthorization(agentId: bigint, clientAddress: string, indexLimit: bigint, expiry: bigint): Promise<string>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Give feedback to an agent
|
|
1094
|
+
*/
|
|
1095
|
+
giveFeedback(params: FeedbackParams): Promise<string>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Submit feedback with payment proof (ERC-8004 reputation enrichment)
|
|
1098
|
+
*/
|
|
1099
|
+
submitFeedbackWithPayment(agentId: bigint, score: number, feedbackData: Record<string, any>, paymentProof: Record<string, any>): Promise<{
|
|
1100
|
+
feedbackTxHash: string;
|
|
1101
|
+
feedbackUri: string;
|
|
1102
|
+
}>;
|
|
1103
|
+
/**
|
|
1104
|
+
* Get agent reputation score (ERC-8004 v1.0)
|
|
1105
|
+
*/
|
|
1106
|
+
getReputationScore(agentId: bigint): Promise<number>;
|
|
1107
|
+
/**
|
|
1108
|
+
* Read all feedback for an agent
|
|
1109
|
+
*/
|
|
1110
|
+
readAllFeedback(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string, includeRevoked?: boolean): Promise<{
|
|
1111
|
+
clients: string[];
|
|
1112
|
+
feedbackIndexes: bigint[];
|
|
1113
|
+
scores: number[];
|
|
1114
|
+
valueDecimals: number[];
|
|
1115
|
+
tag1s: string[];
|
|
1116
|
+
tag2s: string[];
|
|
1117
|
+
revokedStatuses: boolean[];
|
|
1118
|
+
}>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Get feedback summary statistics
|
|
1121
|
+
*/
|
|
1122
|
+
getFeedbackSummary(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string): Promise<{
|
|
1123
|
+
count: bigint;
|
|
1124
|
+
averageScore: number;
|
|
1125
|
+
averageScoreDecimals: number;
|
|
1126
|
+
}>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Get clients who gave feedback
|
|
1129
|
+
*/
|
|
1130
|
+
getClients(agentId: bigint): Promise<string[]>;
|
|
1131
|
+
/**
|
|
1132
|
+
* Request validation from validator (ERC-8004 v1.0)
|
|
1133
|
+
*/
|
|
1134
|
+
requestValidation(validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string): Promise<string>;
|
|
1135
|
+
/**
|
|
1136
|
+
* Respond to validation request (ERC-8004 v1.0)
|
|
1137
|
+
*/
|
|
1138
|
+
respondToValidation(requestHash: string, response: number, responseUri: string, responseHash: string, tag?: string): Promise<string>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Get validation status
|
|
1141
|
+
*/
|
|
1142
|
+
getValidationStatus(requestHash: string): Promise<{
|
|
1143
|
+
validatorAddress: string;
|
|
1144
|
+
agentId: bigint;
|
|
1145
|
+
response: number;
|
|
1146
|
+
responseHash: string;
|
|
1147
|
+
tag: string;
|
|
1148
|
+
lastUpdate: bigint;
|
|
1149
|
+
}>;
|
|
1150
|
+
/**
|
|
1151
|
+
* Get validation summary for an agent
|
|
1152
|
+
*/
|
|
1153
|
+
getValidationSummary(agentId: bigint, validatorAddresses?: string[], tag?: string): Promise<{
|
|
1154
|
+
count: bigint;
|
|
1155
|
+
avgResponse: number;
|
|
1156
|
+
}>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Get validation stats (alias for getValidationSummary)
|
|
1159
|
+
*/
|
|
1160
|
+
getValidationStats(agentId: bigint): Promise<{
|
|
1161
|
+
count: bigint;
|
|
1162
|
+
avgResponse: number;
|
|
1163
|
+
}>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Create x402 payment request
|
|
1166
|
+
*/
|
|
1167
|
+
createX402PaymentRequest(fromAgent: string, toAgent: string, amount: number, currency?: string, serviceDescription?: string): Record<string, any>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Execute x402 crypto payment
|
|
1170
|
+
*/
|
|
1171
|
+
executeX402Payment(paymentRequest: Record<string, any>, recipientAddress: string): Promise<Record<string, any>>;
|
|
1172
|
+
/**
|
|
1173
|
+
* Create x402 payment requirements (for receiving payments)
|
|
1174
|
+
*/
|
|
1175
|
+
createX402PaymentRequirements(amount: number, currency?: string, serviceDescription?: string, evidenceCid?: string): Record<string, any>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Create x402 paywall server
|
|
1178
|
+
*/
|
|
1179
|
+
createX402PaywallServer(port?: number): X402Server;
|
|
1180
|
+
/**
|
|
1181
|
+
* Get x402 payment history
|
|
1182
|
+
*/
|
|
1183
|
+
getX402PaymentHistory(limit?: number): Promise<any[]>;
|
|
1184
|
+
/**
|
|
1185
|
+
* Calculate total cost including protocol fee (2.5%)
|
|
1186
|
+
*/
|
|
1187
|
+
calculateTotalCost(amount: string, currency?: string): {
|
|
1188
|
+
amount: string;
|
|
1189
|
+
fee: string;
|
|
1190
|
+
total: string;
|
|
1191
|
+
currency: string;
|
|
1192
|
+
};
|
|
1193
|
+
/**
|
|
1194
|
+
* Get ETH balance
|
|
1195
|
+
*/
|
|
1196
|
+
getETHBalance(): Promise<string>;
|
|
1197
|
+
/**
|
|
1198
|
+
* Get USDC balance (if USDC contract exists on network)
|
|
1199
|
+
*/
|
|
1200
|
+
getUSDCBalance(): Promise<string>;
|
|
1201
|
+
/**
|
|
1202
|
+
* Execute traditional payment
|
|
1203
|
+
*/
|
|
1204
|
+
executeTraditionalPayment(paymentMethod: PaymentMethod, amount: number, currency: string, paymentData: Record<string, any>): Record<string, any>;
|
|
1205
|
+
/**
|
|
1206
|
+
* Get supported payment methods
|
|
1207
|
+
*/
|
|
1208
|
+
getSupportedPaymentMethods(): PaymentMethod[];
|
|
1209
|
+
/**
|
|
1210
|
+
* Get payment methods status
|
|
1211
|
+
*/
|
|
1212
|
+
getPaymentMethodsStatus(): Record<string, boolean>;
|
|
1213
|
+
/**
|
|
1214
|
+
* Create Google AP2 intent mandate
|
|
1215
|
+
*/
|
|
1216
|
+
createIntentMandate(userDescription: string, merchants?: string[], skus?: string[], requiresRefundability?: boolean, expiryMinutes?: number): GoogleAP2IntegrationResult;
|
|
1217
|
+
/**
|
|
1218
|
+
* Create Google AP2 cart mandate with JWT signing
|
|
1219
|
+
*/
|
|
1220
|
+
createCartMandate(cartId: string, items: Array<{
|
|
1221
|
+
name: string;
|
|
1222
|
+
price: number;
|
|
1223
|
+
}>, totalAmount: number, currency?: string, merchantName?: string, expiryMinutes?: number): Promise<GoogleAP2IntegrationResult>;
|
|
1224
|
+
/**
|
|
1225
|
+
* Verify JWT token
|
|
1226
|
+
*/
|
|
1227
|
+
verifyJwtToken(token: string): Promise<Record<string, any>>;
|
|
1228
|
+
/**
|
|
1229
|
+
* Register function for integrity verification
|
|
1230
|
+
*/
|
|
1231
|
+
registerFunction(func: (...args: any[]) => Promise<any>): void;
|
|
1232
|
+
/**
|
|
1233
|
+
* Execute function with integrity proof
|
|
1234
|
+
*/
|
|
1235
|
+
executeWithIntegrityProof(functionName: string, args: Record<string, any>): Promise<{
|
|
1236
|
+
result: any;
|
|
1237
|
+
proof: Record<string, any>;
|
|
1238
|
+
}>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Verify integrity proof
|
|
1241
|
+
*/
|
|
1242
|
+
verifyIntegrityProof(_proof: Record<string, any>): Promise<boolean>;
|
|
1243
|
+
/**
|
|
1244
|
+
* Upload data to storage
|
|
1245
|
+
*/
|
|
1246
|
+
upload(data: any, _options?: UploadOptions): Promise<UploadResult>;
|
|
1247
|
+
/**
|
|
1248
|
+
* Download data from storage
|
|
1249
|
+
*/
|
|
1250
|
+
download(cid: string): Promise<any>;
|
|
1251
|
+
/**
|
|
1252
|
+
* Store evidence (convenience method)
|
|
1253
|
+
*/
|
|
1254
|
+
storeEvidence(evidenceData: Record<string, any>): Promise<string>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Get wallet address
|
|
1257
|
+
*/
|
|
1258
|
+
getAddress(): string;
|
|
1259
|
+
/**
|
|
1260
|
+
* Get wallet balance
|
|
1261
|
+
*/
|
|
1262
|
+
getBalance(): Promise<bigint>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Get network info
|
|
1265
|
+
*/
|
|
1266
|
+
getNetworkInfo(): NetworkInfo;
|
|
1267
|
+
/**
|
|
1268
|
+
* Get SDK version
|
|
1269
|
+
*/
|
|
1270
|
+
getVersion(): string;
|
|
1271
|
+
/**
|
|
1272
|
+
* Get SDK capabilities summary
|
|
1273
|
+
*/
|
|
1274
|
+
getCapabilities(): Record<string, any>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Check if Gateway is configured.
|
|
1277
|
+
*/
|
|
1278
|
+
isGatewayEnabled(): boolean;
|
|
1279
|
+
/**
|
|
1280
|
+
* Get Gateway client instance.
|
|
1281
|
+
* @throws Error if Gateway is not configured
|
|
1282
|
+
*/
|
|
1283
|
+
getGateway(): GatewayClient;
|
|
1284
|
+
/**
|
|
1285
|
+
* Submit work via Gateway.
|
|
1286
|
+
*
|
|
1287
|
+
* The Gateway handles XMTP, DKG, Arweave archival, and on-chain submission.
|
|
1288
|
+
*/
|
|
1289
|
+
submitWorkViaGateway(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string): Promise<WorkflowStatus>;
|
|
1290
|
+
/**
|
|
1291
|
+
* Submit score via Gateway.
|
|
1292
|
+
*/
|
|
1293
|
+
submitScoreViaGateway(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
|
|
1294
|
+
workerAddress?: string;
|
|
1295
|
+
salt?: string;
|
|
1296
|
+
mode?: ScoreSubmissionMode;
|
|
1297
|
+
}): Promise<WorkflowStatus>;
|
|
1298
|
+
/**
|
|
1299
|
+
* Close epoch via Gateway.
|
|
1300
|
+
* WARNING: This is economically final and cannot be undone.
|
|
1301
|
+
*/
|
|
1302
|
+
closeEpochViaGateway(studioAddress: string, epoch: number, signerAddress: string): Promise<WorkflowStatus>;
|
|
1303
|
+
/**
|
|
1304
|
+
* Wait for workflow completion.
|
|
1305
|
+
*/
|
|
1306
|
+
waitWorkflow(workflowId: string, options?: {
|
|
1307
|
+
maxWait?: number;
|
|
1308
|
+
pollInterval?: number;
|
|
1309
|
+
onProgress?: (status: WorkflowStatus) => void;
|
|
1310
|
+
}): Promise<WorkflowStatus>;
|
|
1311
|
+
buildMandateCore(kind: string, payload: Record<string, unknown>, baseUrl?: string): Record<string, unknown>;
|
|
1312
|
+
createMandate(params: {
|
|
1313
|
+
intent: string;
|
|
1314
|
+
core: Record<string, unknown>;
|
|
1315
|
+
deadline: string;
|
|
1316
|
+
client: string;
|
|
1317
|
+
server?: string;
|
|
1318
|
+
version?: string;
|
|
1319
|
+
mandateId?: string;
|
|
1320
|
+
createdAt?: string;
|
|
1321
|
+
}): any;
|
|
1322
|
+
signMandateAsServer(mandate: any, privateKey?: string): any;
|
|
1323
|
+
signMandateAsClient(mandate: any, privateKey: string): any;
|
|
1324
|
+
verifyMandate(mandate: any): {
|
|
1325
|
+
client_ok: boolean;
|
|
1326
|
+
server_ok: boolean;
|
|
1327
|
+
all_ok: boolean;
|
|
1328
|
+
mandate_hash: string;
|
|
1329
|
+
};
|
|
1330
|
+
/**
|
|
1331
|
+
* Create a new Studio on ChaosChain.
|
|
1332
|
+
* @see StudioClient.createStudio for full documentation
|
|
1333
|
+
*/
|
|
1334
|
+
createStudio(name: string, logicModuleAddress: string): Promise<{
|
|
1335
|
+
proxyAddress: string;
|
|
1336
|
+
studioId: bigint;
|
|
1337
|
+
}>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Register agent with a Studio.
|
|
1340
|
+
* @see StudioClient.registerWithStudio for full documentation
|
|
1341
|
+
*/
|
|
1342
|
+
registerWithStudio(studioAddress: string, agentId: string, role: number, stakeAmount?: bigint): Promise<string>;
|
|
1343
|
+
/**
|
|
1344
|
+
* Get pending rewards for an account.
|
|
1345
|
+
* @see StudioClient.getPendingRewards for full documentation
|
|
1346
|
+
*/
|
|
1347
|
+
getStudioPendingRewards(studioAddress: string, account: string): Promise<bigint>;
|
|
1348
|
+
/**
|
|
1349
|
+
* Withdraw pending rewards from a Studio.
|
|
1350
|
+
* @see StudioClient.withdrawRewards for full documentation
|
|
1351
|
+
*/
|
|
1352
|
+
withdrawStudioRewards(studioAddress: string): Promise<string>;
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* ChaosAgent - ERC-8004 v1.0 Contract Interactions
|
|
1357
|
+
* Handles Identity, Reputation, and Validation Registry interactions
|
|
1358
|
+
*/
|
|
1359
|
+
|
|
1360
|
+
declare class ChaosAgent {
|
|
1361
|
+
private identityContract;
|
|
1362
|
+
private reputationContract;
|
|
1363
|
+
private validationContract;
|
|
1364
|
+
private signer;
|
|
1365
|
+
private _agentId;
|
|
1366
|
+
constructor(addresses: ContractAddresses, signer: ethers.Signer, _provider: ethers.Provider);
|
|
1367
|
+
/**
|
|
1368
|
+
* Register a new agent identity (ERC-8004)
|
|
1369
|
+
*/
|
|
1370
|
+
registerIdentity(metadata?: AgentMetadata): Promise<AgentRegistration>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Get agent metadata
|
|
1373
|
+
*/
|
|
1374
|
+
getAgentMetadata(agentId: bigint): Promise<AgentMetadata | null>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Set agent URI
|
|
1377
|
+
*/
|
|
1378
|
+
setAgentUri(agentId: bigint, uri: string): Promise<string>;
|
|
1379
|
+
/**
|
|
1380
|
+
* Update agent metadata
|
|
1381
|
+
*/
|
|
1382
|
+
updateAgentMetadata(agentId: bigint, metadata: AgentMetadata): Promise<string>;
|
|
1383
|
+
/**
|
|
1384
|
+
* Check if agent exists
|
|
1385
|
+
*/
|
|
1386
|
+
agentExists(agentId: bigint): Promise<boolean>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Get agent owner
|
|
1389
|
+
*/
|
|
1390
|
+
getAgentOwner(agentId: bigint): Promise<string>;
|
|
1391
|
+
/**
|
|
1392
|
+
* Get total number of agents
|
|
1393
|
+
*/
|
|
1394
|
+
getTotalAgents(): Promise<bigint>;
|
|
1395
|
+
/**
|
|
1396
|
+
* Get the agent's on-chain ID (ERC-8004) with optional local caching.
|
|
1397
|
+
*
|
|
1398
|
+
* @param useCache - If true, check local cache first (default: true)
|
|
1399
|
+
* @returns Agent ID if registered, null otherwise
|
|
1400
|
+
*/
|
|
1401
|
+
getAgentId(useCache?: boolean): Promise<bigint | null>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Manually set the agent ID (useful when known from external source).
|
|
1404
|
+
* Sets both in-memory state AND saves to cache.
|
|
1405
|
+
*
|
|
1406
|
+
* @param agentId - The ERC-8004 agent ID to cache
|
|
1407
|
+
*/
|
|
1408
|
+
setCachedAgentId(agentId: bigint): Promise<void>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Transfer agent ownership
|
|
1411
|
+
*/
|
|
1412
|
+
transferAgent(agentId: bigint, to: string): Promise<string>;
|
|
1413
|
+
/**
|
|
1414
|
+
* Generate EIP-191 signed feedback authorization (ERC-8004 v1.0)
|
|
1415
|
+
*
|
|
1416
|
+
* This signature allows a client to submit feedback to an agent's reputation.
|
|
1417
|
+
* The agent owner signs to authorize the client to give feedback up to a certain index.
|
|
1418
|
+
*
|
|
1419
|
+
* @param agentId Target agent ID receiving feedback
|
|
1420
|
+
* @param clientAddress Address of the client giving feedback
|
|
1421
|
+
* @param indexLimit Maximum feedback index this authorization permits
|
|
1422
|
+
* @param expiry Unix timestamp when authorization expires
|
|
1423
|
+
* @returns Signed feedbackAuth bytes for use in giveFeedback()
|
|
1424
|
+
*/
|
|
1425
|
+
generateFeedbackAuthorization(agentId: bigint, clientAddress: string, indexLimit: bigint, expiry: bigint): Promise<string>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Give feedback to an agent (ERC-8004 Jan/Feb 2026)
|
|
1428
|
+
*
|
|
1429
|
+
* @param params Feedback parameters including agentId, rating, feedbackUri, and optional metadata
|
|
1430
|
+
* @returns Transaction hash
|
|
1431
|
+
*/
|
|
1432
|
+
giveFeedback(params: FeedbackParams): Promise<string>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Revoke feedback (ERC-8004 v1.0)
|
|
1435
|
+
* @param agentId Agent ID that received the feedback
|
|
1436
|
+
* @param feedbackIndex Index of the feedback to revoke (uint64)
|
|
1437
|
+
*/
|
|
1438
|
+
revokeFeedback(agentId: bigint, feedbackIndex: bigint): Promise<string>;
|
|
1439
|
+
/**
|
|
1440
|
+
* Append response to feedback (ERC-8004 v1.0)
|
|
1441
|
+
* @param agentId Agent ID that received the feedback
|
|
1442
|
+
* @param clientAddress Address of the client who gave feedback
|
|
1443
|
+
* @param feedbackIndex Index of the feedback
|
|
1444
|
+
* @param responseUri URI containing the response data
|
|
1445
|
+
* @param responseHash Hash of the response content
|
|
1446
|
+
*/
|
|
1447
|
+
appendResponse(agentId: bigint, clientAddress: string, feedbackIndex: bigint, responseUri: string, responseHash: string): Promise<string>;
|
|
1448
|
+
/**
|
|
1449
|
+
* Read specific feedback (ERC-8004 v1.0)
|
|
1450
|
+
* @param agentId Agent ID that received the feedback
|
|
1451
|
+
* @param clientAddress Address of the client who gave feedback
|
|
1452
|
+
* @param index Index of the feedback
|
|
1453
|
+
*/
|
|
1454
|
+
readFeedback(agentId: bigint, clientAddress: string, index: bigint): Promise<{
|
|
1455
|
+
score: number;
|
|
1456
|
+
value: bigint;
|
|
1457
|
+
valueDecimals: number;
|
|
1458
|
+
tag1: string;
|
|
1459
|
+
tag2: string;
|
|
1460
|
+
isRevoked: boolean;
|
|
1461
|
+
}>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Read all feedback for an agent (ERC-8004 v1.0)
|
|
1464
|
+
* @param agentId Agent ID
|
|
1465
|
+
* @param clientAddresses Array of client addresses (empty array for all clients)
|
|
1466
|
+
* @param tag1 First tag filter (ZeroHash for no filter)
|
|
1467
|
+
* @param tag2 Second tag filter (ZeroHash for no filter)
|
|
1468
|
+
* @param includeRevoked Whether to include revoked feedback
|
|
1469
|
+
*/
|
|
1470
|
+
readAllFeedback(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string, includeRevoked?: boolean): Promise<{
|
|
1471
|
+
clients: string[];
|
|
1472
|
+
feedbackIndexes: bigint[];
|
|
1473
|
+
scores: number[];
|
|
1474
|
+
valueDecimals: number[];
|
|
1475
|
+
tag1s: string[];
|
|
1476
|
+
tag2s: string[];
|
|
1477
|
+
revokedStatuses: boolean[];
|
|
1478
|
+
}>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Get summary statistics (ERC-8004 v1.0)
|
|
1481
|
+
* @param agentId Agent ID
|
|
1482
|
+
* @param clientAddresses Array of client addresses (empty array for all clients)
|
|
1483
|
+
* @param tag1 First tag filter (ZeroHash for no filter)
|
|
1484
|
+
* @param tag2 Second tag filter (ZeroHash for no filter)
|
|
1485
|
+
*/
|
|
1486
|
+
getSummary(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string): Promise<{
|
|
1487
|
+
count: bigint;
|
|
1488
|
+
averageScore: number;
|
|
1489
|
+
averageScoreDecimals: number;
|
|
1490
|
+
}>;
|
|
1491
|
+
/**
|
|
1492
|
+
* Get list of clients who gave feedback
|
|
1493
|
+
* @param agentId Agent ID
|
|
1494
|
+
*/
|
|
1495
|
+
getClients(agentId: bigint): Promise<string[]>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Get last feedback index for a client
|
|
1498
|
+
* @param agentId Agent ID
|
|
1499
|
+
* @param clientAddress Client address
|
|
1500
|
+
*/
|
|
1501
|
+
getLastIndex(agentId: bigint, clientAddress: string): Promise<bigint>;
|
|
1502
|
+
/**
|
|
1503
|
+
* Get identity registry address from reputation contract
|
|
1504
|
+
*/
|
|
1505
|
+
getIdentityRegistry(): Promise<string>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Request validation from a validator (ERC-8004 v1.0)
|
|
1508
|
+
* @param validatorAddress Address of the validator
|
|
1509
|
+
* @param agentId Agent ID requesting validation
|
|
1510
|
+
* @param requestUri URI containing validation request data
|
|
1511
|
+
* @param requestHash Hash of the request content (bytes32)
|
|
1512
|
+
*/
|
|
1513
|
+
requestValidation(validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string): Promise<string>;
|
|
1514
|
+
/**
|
|
1515
|
+
* Respond to validation request (ERC-8004 v1.0)
|
|
1516
|
+
* @param requestHash Hash of the original validation request (bytes32)
|
|
1517
|
+
* @param response Response score (0-100, where 100 = approved)
|
|
1518
|
+
* @param responseUri URI containing response data
|
|
1519
|
+
* @param responseHash Hash of the response content (bytes32)
|
|
1520
|
+
* @param tag Optional tag for categorization (bytes32)
|
|
1521
|
+
*/
|
|
1522
|
+
respondToValidation(requestHash: string, response: number, responseUri: string, responseHash: string, tag?: string): Promise<string>;
|
|
1523
|
+
/**
|
|
1524
|
+
* Get validation status (ERC-8004 v1.0)
|
|
1525
|
+
* @param requestHash Hash of the validation request (bytes32)
|
|
1526
|
+
*/
|
|
1527
|
+
getValidationStatus(requestHash: string): Promise<{
|
|
1528
|
+
validatorAddress: string;
|
|
1529
|
+
agentId: bigint;
|
|
1530
|
+
response: number;
|
|
1531
|
+
responseHash: string;
|
|
1532
|
+
tag: string;
|
|
1533
|
+
lastUpdate: bigint;
|
|
1534
|
+
}>;
|
|
1535
|
+
/**
|
|
1536
|
+
* Get validation summary statistics (ERC-8004 v1.0)
|
|
1537
|
+
* @param agentId Agent ID
|
|
1538
|
+
* @param validatorAddresses Array of validator addresses (empty for all)
|
|
1539
|
+
* @param tag Tag filter (ZeroHash for no filter)
|
|
1540
|
+
*/
|
|
1541
|
+
getValidationSummary(agentId: bigint, validatorAddresses?: string[], tag?: string): Promise<{
|
|
1542
|
+
count: bigint;
|
|
1543
|
+
avgResponse: number;
|
|
1544
|
+
}>;
|
|
1545
|
+
/**
|
|
1546
|
+
* Get all validation request hashes for an agent
|
|
1547
|
+
* @param agentId Agent ID
|
|
1548
|
+
*/
|
|
1549
|
+
getAgentValidations(agentId: bigint): Promise<string[]>;
|
|
1550
|
+
/**
|
|
1551
|
+
* Get all validation requests for a validator
|
|
1552
|
+
* @param validatorAddress Validator address
|
|
1553
|
+
*/
|
|
1554
|
+
getValidatorRequests(validatorAddress: string): Promise<string[]>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Get identity registry address from validation contract
|
|
1557
|
+
*/
|
|
1558
|
+
getValidationIdentityRegistry(): Promise<string>;
|
|
1559
|
+
private getCachedFilePath;
|
|
1560
|
+
private loadAgentIdFromCache;
|
|
1561
|
+
private saveAgentIdTocache;
|
|
1562
|
+
/**
|
|
1563
|
+
* Listen for Registered events
|
|
1564
|
+
*/
|
|
1565
|
+
onAgentRegistered(callback: (agentId: bigint, owner: string, uri: string) => void): void;
|
|
1566
|
+
/**
|
|
1567
|
+
* Listen for NewFeedback events (ERC-8004 v1.0)
|
|
1568
|
+
*/
|
|
1569
|
+
onNewFeedback(callback: (agentId: bigint, clientAddress: string, score: number, tag1: string, tag2: string, feedbackUri: string, feedbackHash: string) => void): void;
|
|
1570
|
+
/**
|
|
1571
|
+
* Listen for ResponseAppended events (ERC-8004 v1.0)
|
|
1572
|
+
*/
|
|
1573
|
+
onResponseAppended(callback: (agentId: bigint, clientAddress: string, feedbackIndex: bigint, responder: string, responseUri: string, responseHash: string) => void): void;
|
|
1574
|
+
/**
|
|
1575
|
+
* Listen for ValidationRequest events (ERC-8004 v1.0)
|
|
1576
|
+
*/
|
|
1577
|
+
onValidationRequest(callback: (validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string) => void): void;
|
|
1578
|
+
/**
|
|
1579
|
+
* Listen for ValidationResponse events (ERC-8004 v1.0)
|
|
1580
|
+
*/
|
|
1581
|
+
onValidationResponse(callback: (validatorAddress: string, agentId: bigint, requestHash: string, response: number, responseUri: string, responseHash: string, tag: string) => void): void;
|
|
1582
|
+
/**
|
|
1583
|
+
* Remove all event listeners
|
|
1584
|
+
*/
|
|
1585
|
+
removeAllListeners(): void;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Payment Manager for ChaosChain SDK
|
|
1590
|
+
*
|
|
1591
|
+
* This module manages traditional and crypto payment processing,
|
|
1592
|
+
* supporting multiple payment methods (cards, Google Pay, Apple Pay, PayPal, crypto).
|
|
1593
|
+
*/
|
|
1594
|
+
|
|
1595
|
+
interface TraditionalPaymentResult {
|
|
1596
|
+
payment_id: string;
|
|
1597
|
+
transaction_id: string;
|
|
1598
|
+
status: string;
|
|
1599
|
+
amount: number;
|
|
1600
|
+
currency: string;
|
|
1601
|
+
payment_method: PaymentMethod;
|
|
1602
|
+
timestamp: string;
|
|
1603
|
+
processor_response?: Record<string, any>;
|
|
1604
|
+
}
|
|
1605
|
+
interface PaymentMethodCredentials {
|
|
1606
|
+
stripe_secret_key?: string;
|
|
1607
|
+
google_pay_merchant_id?: string;
|
|
1608
|
+
apple_pay_merchant_id?: string;
|
|
1609
|
+
paypal_client_id?: string;
|
|
1610
|
+
paypal_client_secret?: string;
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Payment Manager - handles all payment types
|
|
1614
|
+
*
|
|
1615
|
+
* Supports:
|
|
1616
|
+
* - Basic card payments (Visa, Mastercard via Stripe)
|
|
1617
|
+
* - Google Pay
|
|
1618
|
+
* - Apple Pay
|
|
1619
|
+
* - PayPal
|
|
1620
|
+
* - Cryptocurrency (via x402 protocol)
|
|
1621
|
+
*/
|
|
1622
|
+
declare class PaymentManager {
|
|
1623
|
+
private agentName;
|
|
1624
|
+
private network;
|
|
1625
|
+
private wallet;
|
|
1626
|
+
private credentials;
|
|
1627
|
+
private stripeAxiosInstance?;
|
|
1628
|
+
private paypalAccessToken?;
|
|
1629
|
+
constructor(agentName: string, network: NetworkConfig, wallet: ethers.Wallet | ethers.HDNodeWallet, credentials?: PaymentMethodCredentials);
|
|
1630
|
+
/**
|
|
1631
|
+
* Initialize PayPal OAuth access token
|
|
1632
|
+
*/
|
|
1633
|
+
private initializePayPal;
|
|
1634
|
+
/**
|
|
1635
|
+
* Execute traditional payment (cards, wallets, etc.)
|
|
1636
|
+
*/
|
|
1637
|
+
executeTraditionalPayment(paymentMethod: PaymentMethod, amount: number, currency: string, paymentData: Record<string, any>): TraditionalPaymentResult;
|
|
1638
|
+
/**
|
|
1639
|
+
* Process Basic Card payment (Visa, Mastercard, Amex, etc.) via Stripe
|
|
1640
|
+
*/
|
|
1641
|
+
private processBasicCard;
|
|
1642
|
+
/**
|
|
1643
|
+
* Process Google Pay payment
|
|
1644
|
+
*/
|
|
1645
|
+
private processGooglePay;
|
|
1646
|
+
/**
|
|
1647
|
+
* Process Apple Pay payment
|
|
1648
|
+
*/
|
|
1649
|
+
private processApplePay;
|
|
1650
|
+
/**
|
|
1651
|
+
* Process PayPal payment
|
|
1652
|
+
*/
|
|
1653
|
+
private processPayPal;
|
|
1654
|
+
/**
|
|
1655
|
+
* Process A2A-x402 crypto payment
|
|
1656
|
+
*/
|
|
1657
|
+
private processA2AX402;
|
|
1658
|
+
/**
|
|
1659
|
+
* Simulate traditional payment (for testing/fallback)
|
|
1660
|
+
*/
|
|
1661
|
+
private simulateTraditionalPayment;
|
|
1662
|
+
/**
|
|
1663
|
+
* Get payment method configuration status
|
|
1664
|
+
*/
|
|
1665
|
+
getPaymentMethodsStatus(): Record<string, boolean>;
|
|
1666
|
+
/**
|
|
1667
|
+
* Get supported payment methods
|
|
1668
|
+
*/
|
|
1669
|
+
getSupportedPaymentMethods(): PaymentMethod[];
|
|
1670
|
+
/**
|
|
1671
|
+
* Validate payment method credentials
|
|
1672
|
+
*/
|
|
1673
|
+
validateCredentials(): Promise<Record<string, boolean>>;
|
|
1674
|
+
/**
|
|
1675
|
+
* Create x402 payment request (for crypto payments)
|
|
1676
|
+
*/
|
|
1677
|
+
createX402PaymentRequest(fromAgent: string, toAgent: string, amount: number, currency: string, serviceDescription: string): Record<string, any>;
|
|
1678
|
+
/**
|
|
1679
|
+
* Execute x402 crypto payment (delegated to X402PaymentManager)
|
|
1680
|
+
*/
|
|
1681
|
+
executeX402Payment(paymentRequest: Record<string, any>): Record<string, any>;
|
|
1682
|
+
/**
|
|
1683
|
+
* Get payment statistics
|
|
1684
|
+
*/
|
|
1685
|
+
getPaymentStats(): Record<string, any>;
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Storage Backends for ChaosChain SDK
|
|
1690
|
+
*
|
|
1691
|
+
* This module provides a unified interface for multiple storage providers,
|
|
1692
|
+
* allowing seamless switching between IPFS, Pinata, Irys, and 0G Storage.
|
|
1693
|
+
*/
|
|
1694
|
+
interface StorageResult {
|
|
1695
|
+
cid: string;
|
|
1696
|
+
url?: string;
|
|
1697
|
+
size?: number;
|
|
1698
|
+
provider: string;
|
|
1699
|
+
}
|
|
1700
|
+
interface StorageBackend {
|
|
1701
|
+
put(data: Buffer | string, mime?: string): Promise<StorageResult>;
|
|
1702
|
+
get(cid: string): Promise<Buffer>;
|
|
1703
|
+
pin?(cid: string): Promise<void>;
|
|
1704
|
+
unpin?(cid: string): Promise<void>;
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Local IPFS Storage Backend
|
|
1708
|
+
*
|
|
1709
|
+
* Requires: ipfs daemon running locally
|
|
1710
|
+
* Cost: Free
|
|
1711
|
+
* Setup: brew install ipfs && ipfs daemon
|
|
1712
|
+
*/
|
|
1713
|
+
declare class LocalIPFSStorage implements StorageBackend {
|
|
1714
|
+
private apiUrl;
|
|
1715
|
+
constructor(apiUrl?: string);
|
|
1716
|
+
put(data: Buffer | string, mime?: string): Promise<StorageResult>;
|
|
1717
|
+
get(cid: string): Promise<Buffer>;
|
|
1718
|
+
pin(cid: string): Promise<void>;
|
|
1719
|
+
unpin(cid: string): Promise<void>;
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Pinata Cloud IPFS Storage Backend
|
|
1723
|
+
*
|
|
1724
|
+
* Requires: Pinata API key
|
|
1725
|
+
* Cost: Free tier + paid plans
|
|
1726
|
+
* Setup: Get JWT from https://pinata.cloud
|
|
1727
|
+
*/
|
|
1728
|
+
declare class PinataStorage implements StorageBackend {
|
|
1729
|
+
private jwtToken;
|
|
1730
|
+
private gatewayUrl;
|
|
1731
|
+
constructor(jwtToken: string, gatewayUrl?: string);
|
|
1732
|
+
put(data: Buffer | string, mime?: string): Promise<StorageResult>;
|
|
1733
|
+
get(cid: string): Promise<Buffer>;
|
|
1734
|
+
pin(cid: string): Promise<void>;
|
|
1735
|
+
unpin(cid: string): Promise<void>;
|
|
1736
|
+
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Irys (Arweave) Storage Backend
|
|
1739
|
+
*
|
|
1740
|
+
* Requires: Arweave wallet key
|
|
1741
|
+
* Cost: Pay per upload (permanent storage)
|
|
1742
|
+
* Setup: Fund wallet with AR tokens
|
|
1743
|
+
*/
|
|
1744
|
+
declare class IrysStorage implements StorageBackend {
|
|
1745
|
+
private walletKey;
|
|
1746
|
+
constructor(walletKey: string);
|
|
1747
|
+
/** Get wallet key (for future SDK integration) */
|
|
1748
|
+
getWalletKey(): string;
|
|
1749
|
+
put(_data: Buffer | string, _mime?: string): Promise<StorageResult>;
|
|
1750
|
+
get(cid: string): Promise<Buffer>;
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* 0G Storage Backend
|
|
1754
|
+
*
|
|
1755
|
+
* Requires: 0G CLI running as sidecar
|
|
1756
|
+
* Cost: Gas fees on 0G Network
|
|
1757
|
+
* Setup: Install 0G CLI and start sidecar
|
|
1758
|
+
*/
|
|
1759
|
+
declare class ZeroGStorage implements StorageBackend {
|
|
1760
|
+
private grpcUrl;
|
|
1761
|
+
private privateKey;
|
|
1762
|
+
constructor(privateKey: string, grpcUrl?: string);
|
|
1763
|
+
/** Get gRPC URL (for connection management) */
|
|
1764
|
+
getGrpcUrl(): string;
|
|
1765
|
+
/** Get private key (for signing) */
|
|
1766
|
+
getPrivateKey(): string;
|
|
1767
|
+
put(_data: Buffer | string, _mime?: string): Promise<StorageResult>;
|
|
1768
|
+
get(_cid: string): Promise<Buffer>;
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Auto-detecting Storage Manager
|
|
1772
|
+
*
|
|
1773
|
+
* Automatically selects the best available storage backend:
|
|
1774
|
+
* 1. Try local IPFS first (fastest, free)
|
|
1775
|
+
* 2. Fall back to Pinata if configured
|
|
1776
|
+
* 3. Fall back to Irys if configured
|
|
1777
|
+
* 4. Fall back to 0G Storage if configured
|
|
1778
|
+
*/
|
|
1779
|
+
declare class AutoStorageManager implements StorageBackend {
|
|
1780
|
+
private backends;
|
|
1781
|
+
private preferredBackend;
|
|
1782
|
+
constructor();
|
|
1783
|
+
private detectAvailableBackends;
|
|
1784
|
+
put(data: Buffer | string, mime?: string): Promise<StorageResult>;
|
|
1785
|
+
get(cid: string): Promise<Buffer>;
|
|
1786
|
+
getAvailableBackends(): string[];
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* Exception classes for the ChaosChain SDK.
|
|
1791
|
+
*
|
|
1792
|
+
* This module defines all custom exceptions used throughout the SDK
|
|
1793
|
+
* to provide clear error handling and debugging information.
|
|
1794
|
+
*/
|
|
1795
|
+
declare class ChaosChainSDKError extends Error {
|
|
1796
|
+
details: Record<string, any>;
|
|
1797
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1798
|
+
toString(): string;
|
|
1799
|
+
}
|
|
1800
|
+
declare class AgentRegistrationError extends ChaosChainSDKError {
|
|
1801
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1802
|
+
}
|
|
1803
|
+
declare class PaymentError extends ChaosChainSDKError {
|
|
1804
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1805
|
+
}
|
|
1806
|
+
declare class StorageError extends ChaosChainSDKError {
|
|
1807
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1808
|
+
}
|
|
1809
|
+
declare class IntegrityVerificationError extends ChaosChainSDKError {
|
|
1810
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1811
|
+
}
|
|
1812
|
+
declare class ContractError extends ChaosChainSDKError {
|
|
1813
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1814
|
+
}
|
|
1815
|
+
declare class ValidationError extends ChaosChainSDKError {
|
|
1816
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1817
|
+
}
|
|
1818
|
+
declare class ConfigurationError extends ChaosChainSDKError {
|
|
1819
|
+
constructor(message: string, details?: Record<string, any>);
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Options passed when constructing a GatewayError (statusCode, response, category, retryable).
|
|
1823
|
+
*/
|
|
1824
|
+
interface GatewayErrorDetails {
|
|
1825
|
+
statusCode?: number;
|
|
1826
|
+
response?: Record<string, any>;
|
|
1827
|
+
category?: 'transient' | 'permanent' | 'auth' | 'unknown';
|
|
1828
|
+
retryable?: boolean;
|
|
1829
|
+
}
|
|
1830
|
+
/**
|
|
1831
|
+
* Base error from Gateway API.
|
|
1832
|
+
*/
|
|
1833
|
+
declare class GatewayError extends ChaosChainSDKError {
|
|
1834
|
+
readonly statusCode?: number;
|
|
1835
|
+
readonly response?: Record<string, any>;
|
|
1836
|
+
readonly category?: 'transient' | 'permanent' | 'auth' | 'unknown';
|
|
1837
|
+
readonly retryable?: boolean;
|
|
1838
|
+
constructor(message: string, details?: GatewayErrorDetails);
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Failed to connect to Gateway.
|
|
1842
|
+
*/
|
|
1843
|
+
declare class GatewayConnectionError extends GatewayError {
|
|
1844
|
+
constructor(message: string);
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Gateway request or polling timed out.
|
|
1848
|
+
*/
|
|
1849
|
+
declare class GatewayTimeoutError extends GatewayError {
|
|
1850
|
+
readonly workflowId: string;
|
|
1851
|
+
readonly lastStatus?: WorkflowStatus;
|
|
1852
|
+
constructor(workflowId: string, message: string, lastStatus?: WorkflowStatus);
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Workflow reached FAILED state.
|
|
1856
|
+
*/
|
|
1857
|
+
declare class WorkflowFailedError extends GatewayError {
|
|
1858
|
+
readonly workflowId: string;
|
|
1859
|
+
readonly workflowError: WorkflowError;
|
|
1860
|
+
constructor(workflowId: string, error: WorkflowError);
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/**
|
|
1864
|
+
* ERC-8004 v1.0 Contract ABIs and Addresses
|
|
1865
|
+
*
|
|
1866
|
+
* Complete ABIs extracted from Python SDK (chaos_agent.py lines 155-637)
|
|
1867
|
+
*
|
|
1868
|
+
* This module contains the complete ABIs for all ERC-8004 v1.0 contracts.
|
|
1869
|
+
* These are the official ABIs deployed on testnets.
|
|
1870
|
+
*/
|
|
1871
|
+
/**
|
|
1872
|
+
* Get embedded Identity Registry ABI for ERC-8004 v1.0.
|
|
1873
|
+
*
|
|
1874
|
+
* v1.0 uses ERC-721 with URIStorage extension. Key changes:
|
|
1875
|
+
* - register() functions replace newAgent()
|
|
1876
|
+
* - Agents are ERC-721 NFTs with tokenURI
|
|
1877
|
+
* - ownerOf() to get agent owner
|
|
1878
|
+
* - tokenURI() to get registration file
|
|
1879
|
+
*/
|
|
1880
|
+
declare const IDENTITY_REGISTRY_ABI: ({
|
|
1881
|
+
inputs: ({
|
|
1882
|
+
name: string;
|
|
1883
|
+
type: string;
|
|
1884
|
+
components?: undefined;
|
|
1885
|
+
} | {
|
|
1886
|
+
name: string;
|
|
1887
|
+
type: string;
|
|
1888
|
+
components: {
|
|
1889
|
+
name: string;
|
|
1890
|
+
type: string;
|
|
1891
|
+
}[];
|
|
1892
|
+
})[];
|
|
1893
|
+
name: string;
|
|
1894
|
+
outputs: {
|
|
1895
|
+
name: string;
|
|
1896
|
+
type: string;
|
|
1897
|
+
}[];
|
|
1898
|
+
stateMutability: string;
|
|
1899
|
+
type: string;
|
|
1900
|
+
anonymous?: undefined;
|
|
1901
|
+
} | {
|
|
1902
|
+
anonymous: boolean;
|
|
1903
|
+
inputs: {
|
|
1904
|
+
indexed: boolean;
|
|
1905
|
+
name: string;
|
|
1906
|
+
type: string;
|
|
1907
|
+
}[];
|
|
1908
|
+
name: string;
|
|
1909
|
+
type: string;
|
|
1910
|
+
outputs?: undefined;
|
|
1911
|
+
stateMutability?: undefined;
|
|
1912
|
+
})[];
|
|
1913
|
+
/**
|
|
1914
|
+
* Get Reputation Registry ABI (ERC-8004 Feb 2026)
|
|
1915
|
+
*
|
|
1916
|
+
* Feb 2026 KEY CHANGES from Oct 2025:
|
|
1917
|
+
* - REMOVED feedbackAuth parameter - feedback is now permissionless
|
|
1918
|
+
* - ADDED endpoint parameter for endpoint being reviewed
|
|
1919
|
+
* - CHANGED tag1, tag2 from bytes32 to string
|
|
1920
|
+
* - ADDED feedbackIndex to NewFeedback event
|
|
1921
|
+
* - readFeedback returns string tags and feedbackIndex parameter renamed
|
|
1922
|
+
*
|
|
1923
|
+
* Feb 2026 ABI UPDATE:
|
|
1924
|
+
* - CHANGED score (uint8) to value (int128) + valueDecimals (uint8)
|
|
1925
|
+
* - getSummary returns summaryValue (int128) + summaryValueDecimals (uint8)
|
|
1926
|
+
* - readFeedback returns value (int128) + valueDecimals (uint8)
|
|
1927
|
+
*/
|
|
1928
|
+
declare const REPUTATION_REGISTRY_ABI: ({
|
|
1929
|
+
inputs: {
|
|
1930
|
+
name: string;
|
|
1931
|
+
type: string;
|
|
1932
|
+
}[];
|
|
1933
|
+
name: string;
|
|
1934
|
+
outputs: {
|
|
1935
|
+
name: string;
|
|
1936
|
+
type: string;
|
|
1937
|
+
}[];
|
|
1938
|
+
stateMutability: string;
|
|
1939
|
+
type: string;
|
|
1940
|
+
anonymous?: undefined;
|
|
1941
|
+
} | {
|
|
1942
|
+
anonymous: boolean;
|
|
1943
|
+
inputs: {
|
|
1944
|
+
indexed: boolean;
|
|
1945
|
+
name: string;
|
|
1946
|
+
type: string;
|
|
1947
|
+
}[];
|
|
1948
|
+
name: string;
|
|
1949
|
+
type: string;
|
|
1950
|
+
outputs?: undefined;
|
|
1951
|
+
stateMutability?: undefined;
|
|
1952
|
+
})[];
|
|
1953
|
+
/**
|
|
1954
|
+
* Get Validation Registry ABI (ERC-8004 v1.0)
|
|
1955
|
+
*
|
|
1956
|
+
* v1.0 uses URI-based validation with off-chain evidence storage.
|
|
1957
|
+
* Key changes:
|
|
1958
|
+
* - validationRequest() uses validatorAddress instead of validatorAgentId
|
|
1959
|
+
* - requestUri and requestHash for off-chain evidence
|
|
1960
|
+
* - validationResponse() uses requestHash with response (0-100)
|
|
1961
|
+
* - Support for multiple responses per request (progressive validation)
|
|
1962
|
+
*/
|
|
1963
|
+
declare const VALIDATION_REGISTRY_ABI: readonly [{
|
|
1964
|
+
readonly inputs: readonly [{
|
|
1965
|
+
readonly name: "validatorAddress";
|
|
1966
|
+
readonly type: "address";
|
|
1967
|
+
}, {
|
|
1968
|
+
readonly name: "agentId";
|
|
1969
|
+
readonly type: "uint256";
|
|
1970
|
+
}, {
|
|
1971
|
+
readonly name: "requestUri";
|
|
1972
|
+
readonly type: "string";
|
|
1973
|
+
}, {
|
|
1974
|
+
readonly name: "requestHash";
|
|
1975
|
+
readonly type: "bytes32";
|
|
1976
|
+
}];
|
|
1977
|
+
readonly name: "validationRequest";
|
|
1978
|
+
readonly outputs: readonly [];
|
|
1979
|
+
readonly stateMutability: "nonpayable";
|
|
1980
|
+
readonly type: "function";
|
|
1981
|
+
}, {
|
|
1982
|
+
readonly inputs: readonly [{
|
|
1983
|
+
readonly name: "requestHash";
|
|
1984
|
+
readonly type: "bytes32";
|
|
1985
|
+
}, {
|
|
1986
|
+
readonly name: "response";
|
|
1987
|
+
readonly type: "uint8";
|
|
1988
|
+
}, {
|
|
1989
|
+
readonly name: "responseUri";
|
|
1990
|
+
readonly type: "string";
|
|
1991
|
+
}, {
|
|
1992
|
+
readonly name: "responseHash";
|
|
1993
|
+
readonly type: "bytes32";
|
|
1994
|
+
}, {
|
|
1995
|
+
readonly name: "tag";
|
|
1996
|
+
readonly type: "bytes32";
|
|
1997
|
+
}];
|
|
1998
|
+
readonly name: "validationResponse";
|
|
1999
|
+
readonly outputs: readonly [];
|
|
2000
|
+
readonly stateMutability: "nonpayable";
|
|
2001
|
+
readonly type: "function";
|
|
2002
|
+
}, {
|
|
2003
|
+
readonly inputs: readonly [{
|
|
2004
|
+
readonly name: "requestHash";
|
|
2005
|
+
readonly type: "bytes32";
|
|
2006
|
+
}];
|
|
2007
|
+
readonly name: "getValidationStatus";
|
|
2008
|
+
readonly outputs: readonly [{
|
|
2009
|
+
readonly name: "validatorAddress";
|
|
2010
|
+
readonly type: "address";
|
|
2011
|
+
}, {
|
|
2012
|
+
readonly name: "agentId";
|
|
2013
|
+
readonly type: "uint256";
|
|
2014
|
+
}, {
|
|
2015
|
+
readonly name: "response";
|
|
2016
|
+
readonly type: "uint8";
|
|
2017
|
+
}, {
|
|
2018
|
+
readonly name: "responseHash";
|
|
2019
|
+
readonly type: "bytes32";
|
|
2020
|
+
}, {
|
|
2021
|
+
readonly name: "tag";
|
|
2022
|
+
readonly type: "bytes32";
|
|
2023
|
+
}, {
|
|
2024
|
+
readonly name: "lastUpdate";
|
|
2025
|
+
readonly type: "uint256";
|
|
2026
|
+
}];
|
|
2027
|
+
readonly stateMutability: "view";
|
|
2028
|
+
readonly type: "function";
|
|
2029
|
+
}, {
|
|
2030
|
+
readonly inputs: readonly [{
|
|
2031
|
+
readonly name: "agentId";
|
|
2032
|
+
readonly type: "uint256";
|
|
2033
|
+
}, {
|
|
2034
|
+
readonly name: "validatorAddresses";
|
|
2035
|
+
readonly type: "address[]";
|
|
2036
|
+
}, {
|
|
2037
|
+
readonly name: "tag";
|
|
2038
|
+
readonly type: "bytes32";
|
|
2039
|
+
}];
|
|
2040
|
+
readonly name: "getSummary";
|
|
2041
|
+
readonly outputs: readonly [{
|
|
2042
|
+
readonly name: "count";
|
|
2043
|
+
readonly type: "uint64";
|
|
2044
|
+
}, {
|
|
2045
|
+
readonly name: "avgResponse";
|
|
2046
|
+
readonly type: "uint8";
|
|
2047
|
+
}];
|
|
2048
|
+
readonly stateMutability: "view";
|
|
2049
|
+
readonly type: "function";
|
|
2050
|
+
}, {
|
|
2051
|
+
readonly inputs: readonly [{
|
|
2052
|
+
readonly name: "agentId";
|
|
2053
|
+
readonly type: "uint256";
|
|
2054
|
+
}];
|
|
2055
|
+
readonly name: "getAgentValidations";
|
|
2056
|
+
readonly outputs: readonly [{
|
|
2057
|
+
readonly name: "requestHashes";
|
|
2058
|
+
readonly type: "bytes32[]";
|
|
2059
|
+
}];
|
|
2060
|
+
readonly stateMutability: "view";
|
|
2061
|
+
readonly type: "function";
|
|
2062
|
+
}, {
|
|
2063
|
+
readonly inputs: readonly [{
|
|
2064
|
+
readonly name: "validatorAddress";
|
|
2065
|
+
readonly type: "address";
|
|
2066
|
+
}];
|
|
2067
|
+
readonly name: "getValidatorRequests";
|
|
2068
|
+
readonly outputs: readonly [{
|
|
2069
|
+
readonly name: "requestHashes";
|
|
2070
|
+
readonly type: "bytes32[]";
|
|
2071
|
+
}];
|
|
2072
|
+
readonly stateMutability: "view";
|
|
2073
|
+
readonly type: "function";
|
|
2074
|
+
}, {
|
|
2075
|
+
readonly inputs: readonly [];
|
|
2076
|
+
readonly name: "getIdentityRegistry";
|
|
2077
|
+
readonly outputs: readonly [{
|
|
2078
|
+
readonly name: "registry";
|
|
2079
|
+
readonly type: "address";
|
|
2080
|
+
}];
|
|
2081
|
+
readonly stateMutability: "view";
|
|
2082
|
+
readonly type: "function";
|
|
2083
|
+
}, {
|
|
2084
|
+
readonly anonymous: false;
|
|
2085
|
+
readonly inputs: readonly [{
|
|
2086
|
+
readonly indexed: true;
|
|
2087
|
+
readonly name: "validatorAddress";
|
|
2088
|
+
readonly type: "address";
|
|
2089
|
+
}, {
|
|
2090
|
+
readonly indexed: true;
|
|
2091
|
+
readonly name: "agentId";
|
|
2092
|
+
readonly type: "uint256";
|
|
2093
|
+
}, {
|
|
2094
|
+
readonly indexed: false;
|
|
2095
|
+
readonly name: "requestUri";
|
|
2096
|
+
readonly type: "string";
|
|
2097
|
+
}, {
|
|
2098
|
+
readonly indexed: true;
|
|
2099
|
+
readonly name: "requestHash";
|
|
2100
|
+
readonly type: "bytes32";
|
|
2101
|
+
}];
|
|
2102
|
+
readonly name: "ValidationRequest";
|
|
2103
|
+
readonly type: "event";
|
|
2104
|
+
}, {
|
|
2105
|
+
readonly anonymous: false;
|
|
2106
|
+
readonly inputs: readonly [{
|
|
2107
|
+
readonly indexed: true;
|
|
2108
|
+
readonly name: "validatorAddress";
|
|
2109
|
+
readonly type: "address";
|
|
2110
|
+
}, {
|
|
2111
|
+
readonly indexed: true;
|
|
2112
|
+
readonly name: "agentId";
|
|
2113
|
+
readonly type: "uint256";
|
|
2114
|
+
}, {
|
|
2115
|
+
readonly indexed: true;
|
|
2116
|
+
readonly name: "requestHash";
|
|
2117
|
+
readonly type: "bytes32";
|
|
2118
|
+
}, {
|
|
2119
|
+
readonly indexed: false;
|
|
2120
|
+
readonly name: "response";
|
|
2121
|
+
readonly type: "uint8";
|
|
2122
|
+
}, {
|
|
2123
|
+
readonly indexed: false;
|
|
2124
|
+
readonly name: "responseUri";
|
|
2125
|
+
readonly type: "string";
|
|
2126
|
+
}, {
|
|
2127
|
+
readonly indexed: false;
|
|
2128
|
+
readonly name: "responseHash";
|
|
2129
|
+
readonly type: "bytes32";
|
|
2130
|
+
}, {
|
|
2131
|
+
readonly indexed: false;
|
|
2132
|
+
readonly name: "tag";
|
|
2133
|
+
readonly type: "bytes32";
|
|
2134
|
+
}];
|
|
2135
|
+
readonly name: "ValidationResponse";
|
|
2136
|
+
readonly type: "event";
|
|
2137
|
+
}];
|
|
2138
|
+
/**
|
|
2139
|
+
* ChaosCore ABI - Factory for creating Studios
|
|
2140
|
+
*
|
|
2141
|
+
* Methods:
|
|
2142
|
+
* - createStudio(name, logicModule) -> (proxy, studioId)
|
|
2143
|
+
*/
|
|
2144
|
+
declare const CHAOS_CORE_ABI: readonly [{
|
|
2145
|
+
readonly inputs: readonly [{
|
|
2146
|
+
readonly name: "name";
|
|
2147
|
+
readonly type: "string";
|
|
2148
|
+
}, {
|
|
2149
|
+
readonly name: "logicModule";
|
|
2150
|
+
readonly type: "address";
|
|
2151
|
+
}];
|
|
2152
|
+
readonly name: "createStudio";
|
|
2153
|
+
readonly outputs: readonly [{
|
|
2154
|
+
readonly name: "proxy";
|
|
2155
|
+
readonly type: "address";
|
|
2156
|
+
}, {
|
|
2157
|
+
readonly name: "studioId";
|
|
2158
|
+
readonly type: "uint256";
|
|
2159
|
+
}];
|
|
2160
|
+
readonly stateMutability: "nonpayable";
|
|
2161
|
+
readonly type: "function";
|
|
2162
|
+
}, {
|
|
2163
|
+
readonly anonymous: false;
|
|
2164
|
+
readonly inputs: readonly [{
|
|
2165
|
+
readonly indexed: true;
|
|
2166
|
+
readonly name: "studioId";
|
|
2167
|
+
readonly type: "uint256";
|
|
2168
|
+
}, {
|
|
2169
|
+
readonly indexed: false;
|
|
2170
|
+
readonly name: "proxy";
|
|
2171
|
+
readonly type: "address";
|
|
2172
|
+
}, {
|
|
2173
|
+
readonly indexed: false;
|
|
2174
|
+
readonly name: "logicModule";
|
|
2175
|
+
readonly type: "address";
|
|
2176
|
+
}, {
|
|
2177
|
+
readonly indexed: true;
|
|
2178
|
+
readonly name: "creator";
|
|
2179
|
+
readonly type: "address";
|
|
2180
|
+
}];
|
|
2181
|
+
readonly name: "StudioCreated";
|
|
2182
|
+
readonly type: "event";
|
|
2183
|
+
}];
|
|
2184
|
+
/**
|
|
2185
|
+
* StudioProxy ABI - Main Studio contract for work submission and scoring
|
|
2186
|
+
*
|
|
2187
|
+
* Methods:
|
|
2188
|
+
* - registerAgent(agentId, role) [payable] - Register agent with stake
|
|
2189
|
+
* - submitWork(dataHash, threadRoot, evidenceRoot, feedbackAuth) - Submit single-agent work
|
|
2190
|
+
* - submitWorkMultiAgent(dataHash, threadRoot, evidenceRoot, participants, contributionWeights, evidenceCID) - Multi-agent work
|
|
2191
|
+
* - commitScore(dataHash, commitment) - Commit phase of commit-reveal
|
|
2192
|
+
* - revealScore(dataHash, scoreVector, salt) - Reveal phase
|
|
2193
|
+
* - getWithdrawableBalance(account) -> balance - Query pending rewards
|
|
2194
|
+
* - withdrawRewards() - Withdraw pending rewards
|
|
2195
|
+
*/
|
|
2196
|
+
declare const STUDIO_PROXY_ABI: readonly [{
|
|
2197
|
+
readonly inputs: readonly [{
|
|
2198
|
+
readonly name: "agentId";
|
|
2199
|
+
readonly type: "uint256";
|
|
2200
|
+
}, {
|
|
2201
|
+
readonly name: "role";
|
|
2202
|
+
readonly type: "uint8";
|
|
2203
|
+
}];
|
|
2204
|
+
readonly name: "registerAgent";
|
|
2205
|
+
readonly outputs: readonly [];
|
|
2206
|
+
readonly stateMutability: "payable";
|
|
2207
|
+
readonly type: "function";
|
|
2208
|
+
}, {
|
|
2209
|
+
readonly inputs: readonly [{
|
|
2210
|
+
readonly name: "dataHash";
|
|
2211
|
+
readonly type: "bytes32";
|
|
2212
|
+
}, {
|
|
2213
|
+
readonly name: "threadRoot";
|
|
2214
|
+
readonly type: "bytes32";
|
|
2215
|
+
}, {
|
|
2216
|
+
readonly name: "evidenceRoot";
|
|
2217
|
+
readonly type: "bytes32";
|
|
2218
|
+
}, {
|
|
2219
|
+
readonly name: "feedbackAuth";
|
|
2220
|
+
readonly type: "bytes";
|
|
2221
|
+
}];
|
|
2222
|
+
readonly name: "submitWork";
|
|
2223
|
+
readonly outputs: readonly [];
|
|
2224
|
+
readonly stateMutability: "nonpayable";
|
|
2225
|
+
readonly type: "function";
|
|
2226
|
+
}, {
|
|
2227
|
+
readonly inputs: readonly [{
|
|
2228
|
+
readonly name: "dataHash";
|
|
2229
|
+
readonly type: "bytes32";
|
|
2230
|
+
}, {
|
|
2231
|
+
readonly name: "threadRoot";
|
|
2232
|
+
readonly type: "bytes32";
|
|
2233
|
+
}, {
|
|
2234
|
+
readonly name: "evidenceRoot";
|
|
2235
|
+
readonly type: "bytes32";
|
|
2236
|
+
}, {
|
|
2237
|
+
readonly name: "participants";
|
|
2238
|
+
readonly type: "address[]";
|
|
2239
|
+
}, {
|
|
2240
|
+
readonly name: "contributionWeights";
|
|
2241
|
+
readonly type: "uint16[]";
|
|
2242
|
+
}, {
|
|
2243
|
+
readonly name: "evidenceCID";
|
|
2244
|
+
readonly type: "string";
|
|
2245
|
+
}];
|
|
2246
|
+
readonly name: "submitWorkMultiAgent";
|
|
2247
|
+
readonly outputs: readonly [];
|
|
2248
|
+
readonly stateMutability: "nonpayable";
|
|
2249
|
+
readonly type: "function";
|
|
2250
|
+
}, {
|
|
2251
|
+
readonly inputs: readonly [{
|
|
2252
|
+
readonly name: "dataHash";
|
|
2253
|
+
readonly type: "bytes32";
|
|
2254
|
+
}, {
|
|
2255
|
+
readonly name: "commitment";
|
|
2256
|
+
readonly type: "bytes32";
|
|
2257
|
+
}];
|
|
2258
|
+
readonly name: "commitScore";
|
|
2259
|
+
readonly outputs: readonly [];
|
|
2260
|
+
readonly stateMutability: "nonpayable";
|
|
2261
|
+
readonly type: "function";
|
|
2262
|
+
}, {
|
|
2263
|
+
readonly inputs: readonly [{
|
|
2264
|
+
readonly name: "dataHash";
|
|
2265
|
+
readonly type: "bytes32";
|
|
2266
|
+
}, {
|
|
2267
|
+
readonly name: "scoreVector";
|
|
2268
|
+
readonly type: "bytes";
|
|
2269
|
+
}, {
|
|
2270
|
+
readonly name: "salt";
|
|
2271
|
+
readonly type: "bytes32";
|
|
2272
|
+
}];
|
|
2273
|
+
readonly name: "revealScore";
|
|
2274
|
+
readonly outputs: readonly [];
|
|
2275
|
+
readonly stateMutability: "nonpayable";
|
|
2276
|
+
readonly type: "function";
|
|
2277
|
+
}, {
|
|
2278
|
+
readonly inputs: readonly [{
|
|
2279
|
+
readonly name: "dataHash";
|
|
2280
|
+
readonly type: "bytes32";
|
|
2281
|
+
}, {
|
|
2282
|
+
readonly name: "scoreVector";
|
|
2283
|
+
readonly type: "bytes";
|
|
2284
|
+
}];
|
|
2285
|
+
readonly name: "submitScoreVector";
|
|
2286
|
+
readonly outputs: readonly [];
|
|
2287
|
+
readonly stateMutability: "nonpayable";
|
|
2288
|
+
readonly type: "function";
|
|
2289
|
+
}, {
|
|
2290
|
+
readonly inputs: readonly [{
|
|
2291
|
+
readonly name: "dataHash";
|
|
2292
|
+
readonly type: "bytes32";
|
|
2293
|
+
}, {
|
|
2294
|
+
readonly name: "workerAddress";
|
|
2295
|
+
readonly type: "address";
|
|
2296
|
+
}, {
|
|
2297
|
+
readonly name: "scoreVector";
|
|
2298
|
+
readonly type: "bytes";
|
|
2299
|
+
}];
|
|
2300
|
+
readonly name: "submitScoreVectorForWorker";
|
|
2301
|
+
readonly outputs: readonly [];
|
|
2302
|
+
readonly stateMutability: "nonpayable";
|
|
2303
|
+
readonly type: "function";
|
|
2304
|
+
}, {
|
|
2305
|
+
readonly inputs: readonly [{
|
|
2306
|
+
readonly name: "account";
|
|
2307
|
+
readonly type: "address";
|
|
2308
|
+
}];
|
|
2309
|
+
readonly name: "getWithdrawableBalance";
|
|
2310
|
+
readonly outputs: readonly [{
|
|
2311
|
+
readonly name: "balance";
|
|
2312
|
+
readonly type: "uint256";
|
|
2313
|
+
}];
|
|
2314
|
+
readonly stateMutability: "view";
|
|
2315
|
+
readonly type: "function";
|
|
2316
|
+
}, {
|
|
2317
|
+
readonly inputs: readonly [];
|
|
2318
|
+
readonly name: "withdrawRewards";
|
|
2319
|
+
readonly outputs: readonly [];
|
|
2320
|
+
readonly stateMutability: "nonpayable";
|
|
2321
|
+
readonly type: "function";
|
|
2322
|
+
}, {
|
|
2323
|
+
readonly inputs: readonly [{
|
|
2324
|
+
readonly name: "dataHash";
|
|
2325
|
+
readonly type: "bytes32";
|
|
2326
|
+
}, {
|
|
2327
|
+
readonly name: "feedbackAuth";
|
|
2328
|
+
readonly type: "bytes";
|
|
2329
|
+
}];
|
|
2330
|
+
readonly name: "registerFeedbackAuth";
|
|
2331
|
+
readonly outputs: readonly [];
|
|
2332
|
+
readonly stateMutability: "nonpayable";
|
|
2333
|
+
readonly type: "function";
|
|
2334
|
+
}, {
|
|
2335
|
+
readonly anonymous: false;
|
|
2336
|
+
readonly inputs: readonly [{
|
|
2337
|
+
readonly indexed: true;
|
|
2338
|
+
readonly name: "agentId";
|
|
2339
|
+
readonly type: "uint256";
|
|
2340
|
+
}, {
|
|
2341
|
+
readonly indexed: true;
|
|
2342
|
+
readonly name: "agentAddress";
|
|
2343
|
+
readonly type: "address";
|
|
2344
|
+
}, {
|
|
2345
|
+
readonly indexed: false;
|
|
2346
|
+
readonly name: "role";
|
|
2347
|
+
readonly type: "uint8";
|
|
2348
|
+
}, {
|
|
2349
|
+
readonly indexed: false;
|
|
2350
|
+
readonly name: "stake";
|
|
2351
|
+
readonly type: "uint256";
|
|
2352
|
+
}];
|
|
2353
|
+
readonly name: "AgentRegistered";
|
|
2354
|
+
readonly type: "event";
|
|
2355
|
+
}, {
|
|
2356
|
+
readonly anonymous: false;
|
|
2357
|
+
readonly inputs: readonly [{
|
|
2358
|
+
readonly indexed: true;
|
|
2359
|
+
readonly name: "dataHash";
|
|
2360
|
+
readonly type: "bytes32";
|
|
2361
|
+
}, {
|
|
2362
|
+
readonly indexed: true;
|
|
2363
|
+
readonly name: "submitter";
|
|
2364
|
+
readonly type: "address";
|
|
2365
|
+
}, {
|
|
2366
|
+
readonly indexed: false;
|
|
2367
|
+
readonly name: "threadRoot";
|
|
2368
|
+
readonly type: "bytes32";
|
|
2369
|
+
}, {
|
|
2370
|
+
readonly indexed: false;
|
|
2371
|
+
readonly name: "evidenceRoot";
|
|
2372
|
+
readonly type: "bytes32";
|
|
2373
|
+
}];
|
|
2374
|
+
readonly name: "WorkSubmitted";
|
|
2375
|
+
readonly type: "event";
|
|
2376
|
+
}, {
|
|
2377
|
+
readonly anonymous: false;
|
|
2378
|
+
readonly inputs: readonly [{
|
|
2379
|
+
readonly indexed: true;
|
|
2380
|
+
readonly name: "dataHash";
|
|
2381
|
+
readonly type: "bytes32";
|
|
2382
|
+
}, {
|
|
2383
|
+
readonly indexed: true;
|
|
2384
|
+
readonly name: "validator";
|
|
2385
|
+
readonly type: "address";
|
|
2386
|
+
}, {
|
|
2387
|
+
readonly indexed: false;
|
|
2388
|
+
readonly name: "commitment";
|
|
2389
|
+
readonly type: "bytes32";
|
|
2390
|
+
}];
|
|
2391
|
+
readonly name: "ScoreCommitted";
|
|
2392
|
+
readonly type: "event";
|
|
2393
|
+
}, {
|
|
2394
|
+
readonly anonymous: false;
|
|
2395
|
+
readonly inputs: readonly [{
|
|
2396
|
+
readonly indexed: true;
|
|
2397
|
+
readonly name: "dataHash";
|
|
2398
|
+
readonly type: "bytes32";
|
|
2399
|
+
}, {
|
|
2400
|
+
readonly indexed: true;
|
|
2401
|
+
readonly name: "validator";
|
|
2402
|
+
readonly type: "address";
|
|
2403
|
+
}, {
|
|
2404
|
+
readonly indexed: false;
|
|
2405
|
+
readonly name: "scoreVector";
|
|
2406
|
+
readonly type: "bytes";
|
|
2407
|
+
}];
|
|
2408
|
+
readonly name: "ScoreRevealed";
|
|
2409
|
+
readonly type: "event";
|
|
2410
|
+
}];
|
|
2411
|
+
/**
|
|
2412
|
+
* RewardsDistributor ABI - Manages epoch closure and reward distribution
|
|
2413
|
+
*
|
|
2414
|
+
* Methods:
|
|
2415
|
+
* - closeEpoch(studio, epoch) - Close an epoch and trigger reward distribution
|
|
2416
|
+
*/
|
|
2417
|
+
declare const REWARDS_DISTRIBUTOR_ABI: readonly [{
|
|
2418
|
+
readonly inputs: readonly [{
|
|
2419
|
+
readonly name: "studio";
|
|
2420
|
+
readonly type: "address";
|
|
2421
|
+
}, {
|
|
2422
|
+
readonly name: "epoch";
|
|
2423
|
+
readonly type: "uint64";
|
|
2424
|
+
}];
|
|
2425
|
+
readonly name: "closeEpoch";
|
|
2426
|
+
readonly outputs: readonly [];
|
|
2427
|
+
readonly stateMutability: "nonpayable";
|
|
2428
|
+
readonly type: "function";
|
|
2429
|
+
}, {
|
|
2430
|
+
readonly anonymous: false;
|
|
2431
|
+
readonly inputs: readonly [{
|
|
2432
|
+
readonly indexed: true;
|
|
2433
|
+
readonly name: "studio";
|
|
2434
|
+
readonly type: "address";
|
|
2435
|
+
}, {
|
|
2436
|
+
readonly indexed: true;
|
|
2437
|
+
readonly name: "epoch";
|
|
2438
|
+
readonly type: "uint64";
|
|
2439
|
+
}, {
|
|
2440
|
+
readonly indexed: false;
|
|
2441
|
+
readonly name: "totalRewards";
|
|
2442
|
+
readonly type: "uint256";
|
|
2443
|
+
}];
|
|
2444
|
+
readonly name: "EpochClosed";
|
|
2445
|
+
readonly type: "event";
|
|
2446
|
+
}, {
|
|
2447
|
+
readonly anonymous: false;
|
|
2448
|
+
readonly inputs: readonly [{
|
|
2449
|
+
readonly indexed: true;
|
|
2450
|
+
readonly name: "studio";
|
|
2451
|
+
readonly type: "address";
|
|
2452
|
+
}, {
|
|
2453
|
+
readonly indexed: true;
|
|
2454
|
+
readonly name: "recipient";
|
|
2455
|
+
readonly type: "address";
|
|
2456
|
+
}, {
|
|
2457
|
+
readonly indexed: false;
|
|
2458
|
+
readonly name: "amount";
|
|
2459
|
+
readonly type: "uint256";
|
|
2460
|
+
}];
|
|
2461
|
+
readonly name: "RewardsDistributed";
|
|
2462
|
+
readonly type: "event";
|
|
2463
|
+
}];
|
|
2464
|
+
/**
|
|
2465
|
+
* StudioFactory ABI - Factory for creating Studios (alternative to ChaosCore)
|
|
2466
|
+
*/
|
|
2467
|
+
declare const STUDIO_FACTORY_ABI: readonly [{
|
|
2468
|
+
readonly inputs: readonly [{
|
|
2469
|
+
readonly name: "name";
|
|
2470
|
+
readonly type: "string";
|
|
2471
|
+
}, {
|
|
2472
|
+
readonly name: "logicModule";
|
|
2473
|
+
readonly type: "address";
|
|
2474
|
+
}];
|
|
2475
|
+
readonly name: "createStudio";
|
|
2476
|
+
readonly outputs: readonly [{
|
|
2477
|
+
readonly name: "proxy";
|
|
2478
|
+
readonly type: "address";
|
|
2479
|
+
}];
|
|
2480
|
+
readonly stateMutability: "nonpayable";
|
|
2481
|
+
readonly type: "function";
|
|
2482
|
+
}];
|
|
2483
|
+
|
|
2484
|
+
interface Task {
|
|
2485
|
+
taskId: string;
|
|
2486
|
+
studioAddress: string;
|
|
2487
|
+
requirements: Record<string, any>;
|
|
2488
|
+
status: string;
|
|
2489
|
+
createdAt: Date;
|
|
2490
|
+
assignedTo?: string;
|
|
2491
|
+
assignedAt?: Date;
|
|
2492
|
+
}
|
|
2493
|
+
interface WorkerBid {
|
|
2494
|
+
bidId: string;
|
|
2495
|
+
taskId: string;
|
|
2496
|
+
workerAddress: string;
|
|
2497
|
+
workerAgentId: number;
|
|
2498
|
+
proposedPrice: number;
|
|
2499
|
+
estimatedTimeHours: number;
|
|
2500
|
+
capabilities: string[];
|
|
2501
|
+
reputationScore: number;
|
|
2502
|
+
message: string;
|
|
2503
|
+
submittedAt: Date;
|
|
2504
|
+
}
|
|
2505
|
+
interface StudioManagerConfig {
|
|
2506
|
+
sdk: ChaosChainSDK;
|
|
2507
|
+
messenger?: {
|
|
2508
|
+
sendMessage: (params: {
|
|
2509
|
+
toAgent: string;
|
|
2510
|
+
messageType: string;
|
|
2511
|
+
content: Record<string, any>;
|
|
2512
|
+
}) => Promise<string>;
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
declare class StudioManager {
|
|
2516
|
+
private sdk;
|
|
2517
|
+
private messenger?;
|
|
2518
|
+
private activeTasks;
|
|
2519
|
+
private workerBids;
|
|
2520
|
+
constructor(config: StudioManagerConfig);
|
|
2521
|
+
getRegisteredWorkers(_studioAddress: string): string[];
|
|
2522
|
+
broadcastTask(studioAddress: string, taskRequirements: Record<string, any>, registeredWorkers: string[]): Promise<string>;
|
|
2523
|
+
collectBids(taskId: string, timeoutSeconds?: number): Promise<WorkerBid[]>;
|
|
2524
|
+
submitBid(taskId: string, workerAddress: string, workerAgentId: number, proposedPrice: number, estimatedTimeHours: number, capabilities: string[], message?: string): string;
|
|
2525
|
+
getWorkerReputations(workerAddresses: string[]): Record<string, number>;
|
|
2526
|
+
selectWorker(bids: WorkerBid[], reputationScores: Record<string, number>, weights?: Record<string, number>): string;
|
|
2527
|
+
assignTask(taskId: string, workerAddress: string, budget: number): Promise<string>;
|
|
2528
|
+
private displayBids;
|
|
2529
|
+
}
|
|
2530
|
+
|
|
2531
|
+
/**
|
|
2532
|
+
* ChaosChain SDK - TypeScript Entry Point
|
|
2533
|
+
*
|
|
2534
|
+
* Complete TypeScript implementation with feature parity to Python SDK
|
|
2535
|
+
*
|
|
2536
|
+
* @packageDocumentation
|
|
2537
|
+
*/
|
|
2538
|
+
|
|
2539
|
+
declare const SDK_VERSION = "0.2.3";
|
|
2540
|
+
declare const ERC8004_VERSION = "1.0";
|
|
2541
|
+
declare const X402_VERSION = "1.0";
|
|
2542
|
+
|
|
2543
|
+
/**
|
|
2544
|
+
* Initialize ChaosChain SDK with minimal configuration
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```typescript
|
|
2548
|
+
* import { initChaosChainSDK, ChaosChainSDK } from '@chaoschain/sdk';
|
|
2549
|
+
*
|
|
2550
|
+
* const sdk = initChaosChainSDK({
|
|
2551
|
+
* agentName: 'MyAgent',
|
|
2552
|
+
* agentDomain: 'myagent.example.com',
|
|
2553
|
+
* agentRole: 'server',
|
|
2554
|
+
* network: 'base-sepolia',
|
|
2555
|
+
* privateKey: process.env.PRIVATE_KEY
|
|
2556
|
+
* });
|
|
2557
|
+
*
|
|
2558
|
+
* const { agentId } = await sdk.registerIdentity();
|
|
2559
|
+
* console.log(`Agent registered with ID: ${agentId}`);
|
|
2560
|
+
* ```
|
|
2561
|
+
*/
|
|
2562
|
+
declare function initChaosChainSDK(config: {
|
|
2563
|
+
agentName: string;
|
|
2564
|
+
agentDomain: string;
|
|
2565
|
+
agentRole: string;
|
|
2566
|
+
network: string;
|
|
2567
|
+
privateKey?: string;
|
|
2568
|
+
mnemonic?: string;
|
|
2569
|
+
rpcUrl?: string;
|
|
2570
|
+
enablePayments?: boolean;
|
|
2571
|
+
enableAP2?: boolean;
|
|
2572
|
+
enableProcessIntegrity?: boolean;
|
|
2573
|
+
enableStorage?: boolean;
|
|
2574
|
+
}): ChaosChainSDK;
|
|
2575
|
+
|
|
2576
|
+
export { A2AX402Extension, AgentMetadata, AgentRegistration, AgentRegistrationError, AgentRole, AutoStorageManager, CHAOS_CORE_ABI, ChaosAgent, ChaosChainSDK, ChaosChainSDKConfig, ChaosChainSDKError, ConfigurationError, ContractAddresses, ContractError, ERC8004_VERSION, FeedbackParams, GatewayClient, GatewayClientConfig, GatewayConnectionError, GatewayError, GatewayTimeoutError, GoogleAP2Integration, IDENTITY_REGISTRY_ABI, PinataStorage as IPFSPinataStorage, IntegrityProof, IntegrityVerificationError, IrysStorage, IrysStorage as IrysStorageProvider, LocalIPFSStorage, MandateManager, NetworkConfig, PaymentError, type PaymentHeader, PaymentManager, PaymentMethod, PendingWorkResponse, PinataStorage, REPUTATION_REGISTRY_ABI, REWARDS_DISTRIBUTOR_ABI, ValidationError as SDKValidationError, SDK_VERSION, STUDIO_FACTORY_ABI, STUDIO_PROXY_ABI, type SettleRequest, type SettleResponse, type StorageBackend, StorageError, type StorageResult, StudioClient, type StudioClientConfig, StudioManager, type StudioManagerConfig, type Task, type TransferAuthorizationParams, UploadOptions, UploadResult, VALIDATION_REGISTRY_ABI, WalletConfig, WalletManager, WorkEvidenceResponse, type WorkerBid, WorkflowError, WorkflowFailedError, WorkflowStatus, type X402FacilitatorConfig, X402PaymentManager, type X402PaymentProof, type X402PaymentRequest$1 as X402PaymentRequest, type X402PaymentRequirements, X402Server, X402_VERSION, ZeroGStorage, ChaosChainSDK as default, getContractAddresses, getNetworkInfo, initChaosChainSDK };
|