@chaoschain/sdk 0.2.2 → 0.2.4

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.
@@ -0,0 +1,2575 @@
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-DZze-Z8B.cjs';
2
+ export { O as AgencySignals, o as ComputeProvider, D as DKGNodeData, R as DemoAssessment, Z as EngineeringStudioPolicy, K as EvidencePackage, k as FeedbackRecord, u as PendingWorkItem, Y as ScoreRange, $ as SignalExtractionContext, n as StorageProvider, T as TEEAttestation, p as TransactionResult, l as ValidationRequest, V as ValidationRequestParams, q as ValidationStatus, Q as VerifierAssessment, L as WorkEvidenceVerificationResult, _ as WorkMandate, M as WorkVerificationResult, t as WorkflowProgress, s as WorkflowState, r as WorkflowType, m as X402Payment, X as X402PaymentParams, v as XMTPMessageData, E as composeScoreVector, H as composeScoreVectorWithDefaults, w as computeDepth, x as derivePoAScores, B as extractAgencySignals, J as rangeFit, y as validateEvidenceGraph, z as verifyWorkEvidence } from './types-DZze-Z8B.cjs';
3
+ import { ethers } from 'ethers';
4
+ export { I as IPFSLocalStorage } from './IPFSLocal-azjjaiGR.cjs';
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 warnedStudioClientProduction;
1051
+ private walletManager;
1052
+ private chaosAgent;
1053
+ private x402PaymentManager?;
1054
+ private paymentManager?;
1055
+ private storageBackend;
1056
+ private computeProvider?;
1057
+ private provider;
1058
+ googleAP2?: GoogleAP2Integration;
1059
+ a2aX402Extension?: A2AX402Extension;
1060
+ processIntegrity?: ProcessIntegrity;
1061
+ mandateManager?: MandateManager;
1062
+ gateway: GatewayClient | null;
1063
+ studio: StudioClient;
1064
+ readonly agentName: string;
1065
+ readonly agentDomain: string;
1066
+ readonly agentRole: AgentRole | string;
1067
+ readonly network: NetworkConfig | string;
1068
+ readonly networkInfo: ReturnType<typeof getNetworkInfo>;
1069
+ private _agentId?;
1070
+ constructor(config: ChaosChainSDKConfig);
1071
+ /**
1072
+ * Register agent identity on-chain
1073
+ */
1074
+ registerIdentity(metadata?: AgentMetadata): Promise<AgentRegistration>;
1075
+ /**
1076
+ * Get agent metadata
1077
+ */
1078
+ getAgentMetadata(agentId: bigint): Promise<AgentMetadata | null>;
1079
+ /**
1080
+ * Update agent metadata
1081
+ */
1082
+ updateAgentMetadata(agentId: bigint, metadata: AgentMetadata): Promise<string>;
1083
+ /**
1084
+ * Get current agent ID
1085
+ */
1086
+ getAgentId(): bigint | undefined;
1087
+ /**
1088
+ * Generate feedback authorization (EIP-191 signing)
1089
+ */
1090
+ generateFeedbackAuthorization(agentId: bigint, clientAddress: string, indexLimit: bigint, expiry: bigint): Promise<string>;
1091
+ /**
1092
+ * Give feedback to an agent
1093
+ */
1094
+ giveFeedback(params: FeedbackParams): Promise<string>;
1095
+ /**
1096
+ * Submit feedback with payment proof (ERC-8004 reputation enrichment)
1097
+ */
1098
+ submitFeedbackWithPayment(agentId: bigint, score: number, feedbackData: Record<string, any>, paymentProof: Record<string, any>): Promise<{
1099
+ feedbackTxHash: string;
1100
+ feedbackUri: string;
1101
+ }>;
1102
+ /**
1103
+ * Get agent reputation score (ERC-8004 v1.0)
1104
+ */
1105
+ getReputationScore(agentId: bigint): Promise<number>;
1106
+ /**
1107
+ * Read all feedback for an agent
1108
+ */
1109
+ readAllFeedback(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string, includeRevoked?: boolean): Promise<{
1110
+ clients: string[];
1111
+ feedbackIndexes: bigint[];
1112
+ scores: number[];
1113
+ valueDecimals: number[];
1114
+ tag1s: string[];
1115
+ tag2s: string[];
1116
+ revokedStatuses: boolean[];
1117
+ }>;
1118
+ /**
1119
+ * Get feedback summary statistics
1120
+ */
1121
+ getFeedbackSummary(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string): Promise<{
1122
+ count: bigint;
1123
+ averageScore: number;
1124
+ averageScoreDecimals: number;
1125
+ }>;
1126
+ /**
1127
+ * Get clients who gave feedback
1128
+ */
1129
+ getClients(agentId: bigint): Promise<string[]>;
1130
+ /**
1131
+ * Request validation from validator (ERC-8004 v1.0)
1132
+ */
1133
+ requestValidation(validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string): Promise<string>;
1134
+ /**
1135
+ * Respond to validation request (ERC-8004 v1.0)
1136
+ */
1137
+ respondToValidation(requestHash: string, response: number, responseUri: string, responseHash: string, tag?: string): Promise<string>;
1138
+ /**
1139
+ * Get validation status
1140
+ */
1141
+ getValidationStatus(requestHash: string): Promise<{
1142
+ validatorAddress: string;
1143
+ agentId: bigint;
1144
+ response: number;
1145
+ responseHash: string;
1146
+ tag: string;
1147
+ lastUpdate: bigint;
1148
+ }>;
1149
+ /**
1150
+ * Get validation summary for an agent
1151
+ */
1152
+ getValidationSummary(agentId: bigint, validatorAddresses?: string[], tag?: string): Promise<{
1153
+ count: bigint;
1154
+ avgResponse: number;
1155
+ }>;
1156
+ /**
1157
+ * Get validation stats (alias for getValidationSummary)
1158
+ */
1159
+ getValidationStats(agentId: bigint): Promise<{
1160
+ count: bigint;
1161
+ avgResponse: number;
1162
+ }>;
1163
+ /**
1164
+ * Create x402 payment request
1165
+ */
1166
+ createX402PaymentRequest(fromAgent: string, toAgent: string, amount: number, currency?: string, serviceDescription?: string): Record<string, any>;
1167
+ /**
1168
+ * Execute x402 crypto payment
1169
+ */
1170
+ executeX402Payment(paymentRequest: Record<string, any>, recipientAddress: string): Promise<Record<string, any>>;
1171
+ /**
1172
+ * Create x402 payment requirements (for receiving payments)
1173
+ */
1174
+ createX402PaymentRequirements(amount: number, currency?: string, serviceDescription?: string, evidenceCid?: string): Record<string, any>;
1175
+ /**
1176
+ * Create x402 paywall server
1177
+ */
1178
+ createX402PaywallServer(port?: number): X402Server;
1179
+ /**
1180
+ * Get x402 payment history
1181
+ */
1182
+ getX402PaymentHistory(limit?: number): Promise<any[]>;
1183
+ /**
1184
+ * Calculate total cost including protocol fee (2.5%)
1185
+ */
1186
+ calculateTotalCost(amount: string, currency?: string): {
1187
+ amount: string;
1188
+ fee: string;
1189
+ total: string;
1190
+ currency: string;
1191
+ };
1192
+ /**
1193
+ * Get ETH balance
1194
+ */
1195
+ getETHBalance(): Promise<string>;
1196
+ /**
1197
+ * Get USDC balance (if USDC contract exists on network)
1198
+ */
1199
+ getUSDCBalance(): Promise<string>;
1200
+ /**
1201
+ * Execute traditional payment
1202
+ */
1203
+ executeTraditionalPayment(paymentMethod: PaymentMethod, amount: number, currency: string, paymentData: Record<string, any>): Record<string, any>;
1204
+ /**
1205
+ * Get supported payment methods
1206
+ */
1207
+ getSupportedPaymentMethods(): PaymentMethod[];
1208
+ /**
1209
+ * Get payment methods status
1210
+ */
1211
+ getPaymentMethodsStatus(): Record<string, boolean>;
1212
+ /**
1213
+ * Create Google AP2 intent mandate
1214
+ */
1215
+ createIntentMandate(userDescription: string, merchants?: string[], skus?: string[], requiresRefundability?: boolean, expiryMinutes?: number): GoogleAP2IntegrationResult;
1216
+ /**
1217
+ * Create Google AP2 cart mandate with JWT signing
1218
+ */
1219
+ createCartMandate(cartId: string, items: Array<{
1220
+ name: string;
1221
+ price: number;
1222
+ }>, totalAmount: number, currency?: string, merchantName?: string, expiryMinutes?: number): Promise<GoogleAP2IntegrationResult>;
1223
+ /**
1224
+ * Verify JWT token
1225
+ */
1226
+ verifyJwtToken(token: string): Promise<Record<string, any>>;
1227
+ /**
1228
+ * Register function for integrity verification
1229
+ */
1230
+ registerFunction(func: (...args: any[]) => Promise<any>): void;
1231
+ /**
1232
+ * Execute function with integrity proof
1233
+ */
1234
+ executeWithIntegrityProof(functionName: string, args: Record<string, any>): Promise<{
1235
+ result: any;
1236
+ proof: Record<string, any>;
1237
+ }>;
1238
+ /**
1239
+ * Verify integrity proof
1240
+ */
1241
+ verifyIntegrityProof(_proof: Record<string, any>): Promise<boolean>;
1242
+ /**
1243
+ * Upload data to storage
1244
+ */
1245
+ upload(data: any, _options?: UploadOptions): Promise<UploadResult>;
1246
+ /**
1247
+ * Download data from storage
1248
+ */
1249
+ download(cid: string): Promise<any>;
1250
+ /**
1251
+ * Store evidence (convenience method)
1252
+ */
1253
+ storeEvidence(evidenceData: Record<string, any>): Promise<string>;
1254
+ /**
1255
+ * Get wallet address
1256
+ */
1257
+ getAddress(): string;
1258
+ /**
1259
+ * Get wallet balance
1260
+ */
1261
+ getBalance(): Promise<bigint>;
1262
+ /**
1263
+ * Get network info
1264
+ */
1265
+ getNetworkInfo(): NetworkInfo;
1266
+ /**
1267
+ * Get SDK version
1268
+ */
1269
+ getVersion(): string;
1270
+ /**
1271
+ * Get SDK capabilities summary
1272
+ */
1273
+ getCapabilities(): Record<string, any>;
1274
+ /**
1275
+ * Check if Gateway is configured.
1276
+ */
1277
+ isGatewayEnabled(): boolean;
1278
+ /**
1279
+ * Get Gateway client instance.
1280
+ * @throws Error if Gateway is not configured
1281
+ */
1282
+ getGateway(): GatewayClient;
1283
+ /**
1284
+ * Submit work via Gateway.
1285
+ *
1286
+ * The Gateway handles XMTP, DKG, Arweave archival, and on-chain submission.
1287
+ */
1288
+ submitWorkViaGateway(studioAddress: string, epoch: number, agentAddress: string, dataHash: string, threadRoot: string, evidenceRoot: string, evidenceContent: Buffer | string, signerAddress: string): Promise<WorkflowStatus>;
1289
+ /**
1290
+ * Submit score via Gateway.
1291
+ */
1292
+ submitScoreViaGateway(studioAddress: string, epoch: number, validatorAddress: string, dataHash: string, scores: number[], signerAddress: string, options?: {
1293
+ workerAddress?: string;
1294
+ salt?: string;
1295
+ mode?: ScoreSubmissionMode;
1296
+ }): Promise<WorkflowStatus>;
1297
+ /**
1298
+ * Close epoch via Gateway.
1299
+ * WARNING: This is economically final and cannot be undone.
1300
+ */
1301
+ closeEpochViaGateway(studioAddress: string, epoch: number, signerAddress: string): Promise<WorkflowStatus>;
1302
+ /**
1303
+ * Wait for workflow completion.
1304
+ */
1305
+ waitWorkflow(workflowId: string, options?: {
1306
+ maxWait?: number;
1307
+ pollInterval?: number;
1308
+ onProgress?: (status: WorkflowStatus) => void;
1309
+ }): Promise<WorkflowStatus>;
1310
+ buildMandateCore(kind: string, payload: Record<string, unknown>, baseUrl?: string): Record<string, unknown>;
1311
+ createMandate(params: {
1312
+ intent: string;
1313
+ core: Record<string, unknown>;
1314
+ deadline: string;
1315
+ client: string;
1316
+ server?: string;
1317
+ version?: string;
1318
+ mandateId?: string;
1319
+ createdAt?: string;
1320
+ }): any;
1321
+ signMandateAsServer(mandate: any, privateKey?: string): any;
1322
+ signMandateAsClient(mandate: any, privateKey: string): any;
1323
+ verifyMandate(mandate: any): {
1324
+ client_ok: boolean;
1325
+ server_ok: boolean;
1326
+ all_ok: boolean;
1327
+ mandate_hash: string;
1328
+ };
1329
+ /**
1330
+ * Create a new Studio on ChaosChain.
1331
+ * @see StudioClient.createStudio for full documentation
1332
+ */
1333
+ createStudio(name: string, logicModuleAddress: string): Promise<{
1334
+ proxyAddress: string;
1335
+ studioId: bigint;
1336
+ }>;
1337
+ /**
1338
+ * Register agent with a Studio.
1339
+ * @see StudioClient.registerWithStudio for full documentation
1340
+ */
1341
+ registerWithStudio(studioAddress: string, agentId: string, role: number, stakeAmount?: bigint): Promise<string>;
1342
+ /**
1343
+ * Get pending rewards for an account.
1344
+ * @see StudioClient.getPendingRewards for full documentation
1345
+ */
1346
+ getStudioPendingRewards(studioAddress: string, account: string): Promise<bigint>;
1347
+ /**
1348
+ * Withdraw pending rewards from a Studio.
1349
+ * @see StudioClient.withdrawRewards for full documentation
1350
+ */
1351
+ withdrawStudioRewards(studioAddress: string): Promise<string>;
1352
+ }
1353
+
1354
+ /**
1355
+ * ChaosAgent - ERC-8004 v1.0 Contract Interactions
1356
+ * Handles Identity, Reputation, and Validation Registry interactions
1357
+ */
1358
+
1359
+ declare class ChaosAgent {
1360
+ private identityContract;
1361
+ private reputationContract;
1362
+ private validationContract;
1363
+ private signer;
1364
+ private _agentId;
1365
+ constructor(addresses: ContractAddresses, signer: ethers.Signer, _provider: ethers.Provider);
1366
+ /**
1367
+ * Register a new agent identity (ERC-8004)
1368
+ */
1369
+ registerIdentity(metadata?: AgentMetadata): Promise<AgentRegistration>;
1370
+ /**
1371
+ * Get agent metadata
1372
+ */
1373
+ getAgentMetadata(agentId: bigint): Promise<AgentMetadata | null>;
1374
+ /**
1375
+ * Set agent URI
1376
+ */
1377
+ setAgentUri(agentId: bigint, uri: string): Promise<string>;
1378
+ /**
1379
+ * Update agent metadata
1380
+ */
1381
+ updateAgentMetadata(agentId: bigint, metadata: AgentMetadata): Promise<string>;
1382
+ /**
1383
+ * Check if agent exists
1384
+ */
1385
+ agentExists(agentId: bigint): Promise<boolean>;
1386
+ /**
1387
+ * Get agent owner
1388
+ */
1389
+ getAgentOwner(agentId: bigint): Promise<string>;
1390
+ /**
1391
+ * Get total number of agents
1392
+ */
1393
+ getTotalAgents(): Promise<bigint>;
1394
+ /**
1395
+ * Get the agent's on-chain ID (ERC-8004) with optional local caching.
1396
+ *
1397
+ * @param useCache - If true, check local cache first (default: true)
1398
+ * @returns Agent ID if registered, null otherwise
1399
+ */
1400
+ getAgentId(useCache?: boolean): Promise<bigint | null>;
1401
+ /**
1402
+ * Manually set the agent ID (useful when known from external source).
1403
+ * Sets both in-memory state AND saves to cache.
1404
+ *
1405
+ * @param agentId - The ERC-8004 agent ID to cache
1406
+ */
1407
+ setCachedAgentId(agentId: bigint): Promise<void>;
1408
+ /**
1409
+ * Transfer agent ownership
1410
+ */
1411
+ transferAgent(agentId: bigint, to: string): Promise<string>;
1412
+ /**
1413
+ * Generate EIP-191 signed feedback authorization (ERC-8004 v1.0)
1414
+ *
1415
+ * This signature allows a client to submit feedback to an agent's reputation.
1416
+ * The agent owner signs to authorize the client to give feedback up to a certain index.
1417
+ *
1418
+ * @param agentId Target agent ID receiving feedback
1419
+ * @param clientAddress Address of the client giving feedback
1420
+ * @param indexLimit Maximum feedback index this authorization permits
1421
+ * @param expiry Unix timestamp when authorization expires
1422
+ * @returns Signed feedbackAuth bytes for use in giveFeedback()
1423
+ */
1424
+ generateFeedbackAuthorization(agentId: bigint, clientAddress: string, indexLimit: bigint, expiry: bigint): Promise<string>;
1425
+ /**
1426
+ * Give feedback to an agent (ERC-8004 Jan/Feb 2026)
1427
+ *
1428
+ * @param params Feedback parameters including agentId, rating, feedbackUri, and optional metadata
1429
+ * @returns Transaction hash
1430
+ */
1431
+ giveFeedback(params: FeedbackParams): Promise<string>;
1432
+ /**
1433
+ * Revoke feedback (ERC-8004 v1.0)
1434
+ * @param agentId Agent ID that received the feedback
1435
+ * @param feedbackIndex Index of the feedback to revoke (uint64)
1436
+ */
1437
+ revokeFeedback(agentId: bigint, feedbackIndex: bigint): Promise<string>;
1438
+ /**
1439
+ * Append response to feedback (ERC-8004 v1.0)
1440
+ * @param agentId Agent ID that received the feedback
1441
+ * @param clientAddress Address of the client who gave feedback
1442
+ * @param feedbackIndex Index of the feedback
1443
+ * @param responseUri URI containing the response data
1444
+ * @param responseHash Hash of the response content
1445
+ */
1446
+ appendResponse(agentId: bigint, clientAddress: string, feedbackIndex: bigint, responseUri: string, responseHash: string): Promise<string>;
1447
+ /**
1448
+ * Read specific feedback (ERC-8004 v1.0)
1449
+ * @param agentId Agent ID that received the feedback
1450
+ * @param clientAddress Address of the client who gave feedback
1451
+ * @param index Index of the feedback
1452
+ */
1453
+ readFeedback(agentId: bigint, clientAddress: string, index: bigint): Promise<{
1454
+ score: number;
1455
+ value: bigint;
1456
+ valueDecimals: number;
1457
+ tag1: string;
1458
+ tag2: string;
1459
+ isRevoked: boolean;
1460
+ }>;
1461
+ /**
1462
+ * Read all feedback for an agent (ERC-8004 v1.0)
1463
+ * @param agentId Agent ID
1464
+ * @param clientAddresses Array of client addresses (empty array for all clients)
1465
+ * @param tag1 First tag filter (ZeroHash for no filter)
1466
+ * @param tag2 Second tag filter (ZeroHash for no filter)
1467
+ * @param includeRevoked Whether to include revoked feedback
1468
+ */
1469
+ readAllFeedback(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string, includeRevoked?: boolean): Promise<{
1470
+ clients: string[];
1471
+ feedbackIndexes: bigint[];
1472
+ scores: number[];
1473
+ valueDecimals: number[];
1474
+ tag1s: string[];
1475
+ tag2s: string[];
1476
+ revokedStatuses: boolean[];
1477
+ }>;
1478
+ /**
1479
+ * Get summary statistics (ERC-8004 v1.0)
1480
+ * @param agentId Agent ID
1481
+ * @param clientAddresses Array of client addresses (empty array for all clients)
1482
+ * @param tag1 First tag filter (ZeroHash for no filter)
1483
+ * @param tag2 Second tag filter (ZeroHash for no filter)
1484
+ */
1485
+ getSummary(agentId: bigint, clientAddresses?: string[], tag1?: string, tag2?: string): Promise<{
1486
+ count: bigint;
1487
+ averageScore: number;
1488
+ averageScoreDecimals: number;
1489
+ }>;
1490
+ /**
1491
+ * Get list of clients who gave feedback
1492
+ * @param agentId Agent ID
1493
+ */
1494
+ getClients(agentId: bigint): Promise<string[]>;
1495
+ /**
1496
+ * Get last feedback index for a client
1497
+ * @param agentId Agent ID
1498
+ * @param clientAddress Client address
1499
+ */
1500
+ getLastIndex(agentId: bigint, clientAddress: string): Promise<bigint>;
1501
+ /**
1502
+ * Get identity registry address from reputation contract
1503
+ */
1504
+ getIdentityRegistry(): Promise<string>;
1505
+ /**
1506
+ * Request validation from a validator (ERC-8004 v1.0)
1507
+ * @param validatorAddress Address of the validator
1508
+ * @param agentId Agent ID requesting validation
1509
+ * @param requestUri URI containing validation request data
1510
+ * @param requestHash Hash of the request content (bytes32)
1511
+ */
1512
+ requestValidation(validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string): Promise<string>;
1513
+ /**
1514
+ * Respond to validation request (ERC-8004 v1.0)
1515
+ * @param requestHash Hash of the original validation request (bytes32)
1516
+ * @param response Response score (0-100, where 100 = approved)
1517
+ * @param responseUri URI containing response data
1518
+ * @param responseHash Hash of the response content (bytes32)
1519
+ * @param tag Optional tag for categorization (bytes32)
1520
+ */
1521
+ respondToValidation(requestHash: string, response: number, responseUri: string, responseHash: string, tag?: string): Promise<string>;
1522
+ /**
1523
+ * Get validation status (ERC-8004 v1.0)
1524
+ * @param requestHash Hash of the validation request (bytes32)
1525
+ */
1526
+ getValidationStatus(requestHash: string): Promise<{
1527
+ validatorAddress: string;
1528
+ agentId: bigint;
1529
+ response: number;
1530
+ responseHash: string;
1531
+ tag: string;
1532
+ lastUpdate: bigint;
1533
+ }>;
1534
+ /**
1535
+ * Get validation summary statistics (ERC-8004 v1.0)
1536
+ * @param agentId Agent ID
1537
+ * @param validatorAddresses Array of validator addresses (empty for all)
1538
+ * @param tag Tag filter (ZeroHash for no filter)
1539
+ */
1540
+ getValidationSummary(agentId: bigint, validatorAddresses?: string[], tag?: string): Promise<{
1541
+ count: bigint;
1542
+ avgResponse: number;
1543
+ }>;
1544
+ /**
1545
+ * Get all validation request hashes for an agent
1546
+ * @param agentId Agent ID
1547
+ */
1548
+ getAgentValidations(agentId: bigint): Promise<string[]>;
1549
+ /**
1550
+ * Get all validation requests for a validator
1551
+ * @param validatorAddress Validator address
1552
+ */
1553
+ getValidatorRequests(validatorAddress: string): Promise<string[]>;
1554
+ /**
1555
+ * Get identity registry address from validation contract
1556
+ */
1557
+ getValidationIdentityRegistry(): Promise<string>;
1558
+ private getCachedFilePath;
1559
+ private loadAgentIdFromCache;
1560
+ private saveAgentIdTocache;
1561
+ /**
1562
+ * Listen for Registered events
1563
+ */
1564
+ onAgentRegistered(callback: (agentId: bigint, owner: string, uri: string) => void): void;
1565
+ /**
1566
+ * Listen for NewFeedback events (ERC-8004 v1.0)
1567
+ */
1568
+ onNewFeedback(callback: (agentId: bigint, clientAddress: string, score: number, tag1: string, tag2: string, feedbackUri: string, feedbackHash: string) => void): void;
1569
+ /**
1570
+ * Listen for ResponseAppended events (ERC-8004 v1.0)
1571
+ */
1572
+ onResponseAppended(callback: (agentId: bigint, clientAddress: string, feedbackIndex: bigint, responder: string, responseUri: string, responseHash: string) => void): void;
1573
+ /**
1574
+ * Listen for ValidationRequest events (ERC-8004 v1.0)
1575
+ */
1576
+ onValidationRequest(callback: (validatorAddress: string, agentId: bigint, requestUri: string, requestHash: string) => void): void;
1577
+ /**
1578
+ * Listen for ValidationResponse events (ERC-8004 v1.0)
1579
+ */
1580
+ onValidationResponse(callback: (validatorAddress: string, agentId: bigint, requestHash: string, response: number, responseUri: string, responseHash: string, tag: string) => void): void;
1581
+ /**
1582
+ * Remove all event listeners
1583
+ */
1584
+ removeAllListeners(): void;
1585
+ }
1586
+
1587
+ /**
1588
+ * Payment Manager for ChaosChain SDK
1589
+ *
1590
+ * This module manages traditional and crypto payment processing,
1591
+ * supporting multiple payment methods (cards, Google Pay, Apple Pay, PayPal, crypto).
1592
+ */
1593
+
1594
+ interface TraditionalPaymentResult {
1595
+ payment_id: string;
1596
+ transaction_id: string;
1597
+ status: string;
1598
+ amount: number;
1599
+ currency: string;
1600
+ payment_method: PaymentMethod;
1601
+ timestamp: string;
1602
+ processor_response?: Record<string, any>;
1603
+ }
1604
+ interface PaymentMethodCredentials {
1605
+ stripe_secret_key?: string;
1606
+ google_pay_merchant_id?: string;
1607
+ apple_pay_merchant_id?: string;
1608
+ paypal_client_id?: string;
1609
+ paypal_client_secret?: string;
1610
+ }
1611
+ /**
1612
+ * Payment Manager - handles all payment types
1613
+ *
1614
+ * Supports:
1615
+ * - Basic card payments (Visa, Mastercard via Stripe)
1616
+ * - Google Pay
1617
+ * - Apple Pay
1618
+ * - PayPal
1619
+ * - Cryptocurrency (via x402 protocol)
1620
+ */
1621
+ declare class PaymentManager {
1622
+ private agentName;
1623
+ private network;
1624
+ private wallet;
1625
+ private credentials;
1626
+ private stripeAxiosInstance?;
1627
+ private paypalAccessToken?;
1628
+ constructor(agentName: string, network: NetworkConfig, wallet: ethers.Wallet | ethers.HDNodeWallet, credentials?: PaymentMethodCredentials);
1629
+ /**
1630
+ * Initialize PayPal OAuth access token
1631
+ */
1632
+ private initializePayPal;
1633
+ /**
1634
+ * Execute traditional payment (cards, wallets, etc.)
1635
+ */
1636
+ executeTraditionalPayment(paymentMethod: PaymentMethod, amount: number, currency: string, paymentData: Record<string, any>): TraditionalPaymentResult;
1637
+ /**
1638
+ * Process Basic Card payment (Visa, Mastercard, Amex, etc.) via Stripe
1639
+ */
1640
+ private processBasicCard;
1641
+ /**
1642
+ * Process Google Pay payment
1643
+ */
1644
+ private processGooglePay;
1645
+ /**
1646
+ * Process Apple Pay payment
1647
+ */
1648
+ private processApplePay;
1649
+ /**
1650
+ * Process PayPal payment
1651
+ */
1652
+ private processPayPal;
1653
+ /**
1654
+ * Process A2A-x402 crypto payment
1655
+ */
1656
+ private processA2AX402;
1657
+ /**
1658
+ * Simulate traditional payment (for testing/fallback)
1659
+ */
1660
+ private simulateTraditionalPayment;
1661
+ /**
1662
+ * Get payment method configuration status
1663
+ */
1664
+ getPaymentMethodsStatus(): Record<string, boolean>;
1665
+ /**
1666
+ * Get supported payment methods
1667
+ */
1668
+ getSupportedPaymentMethods(): PaymentMethod[];
1669
+ /**
1670
+ * Validate payment method credentials
1671
+ */
1672
+ validateCredentials(): Promise<Record<string, boolean>>;
1673
+ /**
1674
+ * Create x402 payment request (for crypto payments)
1675
+ */
1676
+ createX402PaymentRequest(fromAgent: string, toAgent: string, amount: number, currency: string, serviceDescription: string): Record<string, any>;
1677
+ /**
1678
+ * Execute x402 crypto payment (delegated to X402PaymentManager)
1679
+ */
1680
+ executeX402Payment(paymentRequest: Record<string, any>): Record<string, any>;
1681
+ /**
1682
+ * Get payment statistics
1683
+ */
1684
+ getPaymentStats(): Record<string, any>;
1685
+ }
1686
+
1687
+ /**
1688
+ * Storage Backends for ChaosChain SDK
1689
+ *
1690
+ * This module provides a unified interface for multiple storage providers,
1691
+ * allowing seamless switching between IPFS, Pinata, Irys, and 0G Storage.
1692
+ */
1693
+ interface StorageResult {
1694
+ cid: string;
1695
+ url?: string;
1696
+ size?: number;
1697
+ provider: string;
1698
+ }
1699
+ interface StorageBackend {
1700
+ put(data: Buffer | string, mime?: string): Promise<StorageResult>;
1701
+ get(cid: string): Promise<Buffer>;
1702
+ pin?(cid: string): Promise<void>;
1703
+ unpin?(cid: string): Promise<void>;
1704
+ }
1705
+ /**
1706
+ * Local IPFS Storage Backend
1707
+ *
1708
+ * Requires: ipfs daemon running locally
1709
+ * Cost: Free
1710
+ * Setup: brew install ipfs && ipfs daemon
1711
+ */
1712
+ declare class LocalIPFSStorage implements StorageBackend {
1713
+ private apiUrl;
1714
+ constructor(apiUrl?: string);
1715
+ put(data: Buffer | string, mime?: string): Promise<StorageResult>;
1716
+ get(cid: string): Promise<Buffer>;
1717
+ pin(cid: string): Promise<void>;
1718
+ unpin(cid: string): Promise<void>;
1719
+ }
1720
+ /**
1721
+ * Pinata Cloud IPFS Storage Backend
1722
+ *
1723
+ * Requires: Pinata API key
1724
+ * Cost: Free tier + paid plans
1725
+ * Setup: Get JWT from https://pinata.cloud
1726
+ */
1727
+ declare class PinataStorage implements StorageBackend {
1728
+ private jwtToken;
1729
+ private gatewayUrl;
1730
+ constructor(jwtToken: string, gatewayUrl?: string);
1731
+ put(data: Buffer | string, mime?: string): Promise<StorageResult>;
1732
+ get(cid: string): Promise<Buffer>;
1733
+ pin(cid: string): Promise<void>;
1734
+ unpin(cid: string): Promise<void>;
1735
+ }
1736
+ /**
1737
+ * Irys (Arweave) Storage Backend
1738
+ *
1739
+ * Requires: Arweave wallet key
1740
+ * Cost: Pay per upload (permanent storage)
1741
+ * Setup: Fund wallet with AR tokens
1742
+ */
1743
+ declare class IrysStorage implements StorageBackend {
1744
+ private walletKey;
1745
+ constructor(walletKey: string);
1746
+ /** Get wallet key (for future SDK integration) */
1747
+ getWalletKey(): string;
1748
+ put(_data: Buffer | string, _mime?: string): Promise<StorageResult>;
1749
+ get(cid: string): Promise<Buffer>;
1750
+ }
1751
+ /**
1752
+ * 0G Storage Backend
1753
+ *
1754
+ * Requires: 0G CLI running as sidecar
1755
+ * Cost: Gas fees on 0G Network
1756
+ * Setup: Install 0G CLI and start sidecar
1757
+ */
1758
+ declare class ZeroGStorage implements StorageBackend {
1759
+ private grpcUrl;
1760
+ private privateKey;
1761
+ constructor(privateKey: string, grpcUrl?: string);
1762
+ /** Get gRPC URL (for connection management) */
1763
+ getGrpcUrl(): string;
1764
+ /** Get private key (for signing) */
1765
+ getPrivateKey(): string;
1766
+ put(_data: Buffer | string, _mime?: string): Promise<StorageResult>;
1767
+ get(_cid: string): Promise<Buffer>;
1768
+ }
1769
+ /**
1770
+ * Auto-detecting Storage Manager
1771
+ *
1772
+ * Automatically selects the best available storage backend:
1773
+ * 1. Try local IPFS first (fastest, free)
1774
+ * 2. Fall back to Pinata if configured
1775
+ * 3. Fall back to Irys if configured
1776
+ * 4. Fall back to 0G Storage if configured
1777
+ */
1778
+ declare class AutoStorageManager implements StorageBackend {
1779
+ private backends;
1780
+ private preferredBackend;
1781
+ constructor();
1782
+ private detectAvailableBackends;
1783
+ put(data: Buffer | string, mime?: string): Promise<StorageResult>;
1784
+ get(cid: string): Promise<Buffer>;
1785
+ getAvailableBackends(): string[];
1786
+ }
1787
+
1788
+ /**
1789
+ * Exception classes for the ChaosChain SDK.
1790
+ *
1791
+ * This module defines all custom exceptions used throughout the SDK
1792
+ * to provide clear error handling and debugging information.
1793
+ */
1794
+ declare class ChaosChainSDKError extends Error {
1795
+ details: Record<string, any>;
1796
+ constructor(message: string, details?: Record<string, any>);
1797
+ toString(): string;
1798
+ }
1799
+ declare class AgentRegistrationError extends ChaosChainSDKError {
1800
+ constructor(message: string, details?: Record<string, any>);
1801
+ }
1802
+ declare class PaymentError extends ChaosChainSDKError {
1803
+ constructor(message: string, details?: Record<string, any>);
1804
+ }
1805
+ declare class StorageError extends ChaosChainSDKError {
1806
+ constructor(message: string, details?: Record<string, any>);
1807
+ }
1808
+ declare class IntegrityVerificationError extends ChaosChainSDKError {
1809
+ constructor(message: string, details?: Record<string, any>);
1810
+ }
1811
+ declare class ContractError extends ChaosChainSDKError {
1812
+ constructor(message: string, details?: Record<string, any>);
1813
+ }
1814
+ declare class ValidationError extends ChaosChainSDKError {
1815
+ constructor(message: string, details?: Record<string, any>);
1816
+ }
1817
+ declare class ConfigurationError extends ChaosChainSDKError {
1818
+ constructor(message: string, details?: Record<string, any>);
1819
+ }
1820
+ /**
1821
+ * Options passed when constructing a GatewayError (statusCode, response, category, retryable).
1822
+ */
1823
+ interface GatewayErrorDetails {
1824
+ statusCode?: number;
1825
+ response?: Record<string, any>;
1826
+ category?: 'transient' | 'permanent' | 'auth' | 'unknown';
1827
+ retryable?: boolean;
1828
+ }
1829
+ /**
1830
+ * Base error from Gateway API.
1831
+ */
1832
+ declare class GatewayError extends ChaosChainSDKError {
1833
+ readonly statusCode?: number;
1834
+ readonly response?: Record<string, any>;
1835
+ readonly category?: 'transient' | 'permanent' | 'auth' | 'unknown';
1836
+ readonly retryable?: boolean;
1837
+ constructor(message: string, details?: GatewayErrorDetails);
1838
+ }
1839
+ /**
1840
+ * Failed to connect to Gateway.
1841
+ */
1842
+ declare class GatewayConnectionError extends GatewayError {
1843
+ constructor(message: string);
1844
+ }
1845
+ /**
1846
+ * Gateway request or polling timed out.
1847
+ */
1848
+ declare class GatewayTimeoutError extends GatewayError {
1849
+ readonly workflowId: string;
1850
+ readonly lastStatus?: WorkflowStatus;
1851
+ constructor(workflowId: string, message: string, lastStatus?: WorkflowStatus);
1852
+ }
1853
+ /**
1854
+ * Workflow reached FAILED state.
1855
+ */
1856
+ declare class WorkflowFailedError extends GatewayError {
1857
+ readonly workflowId: string;
1858
+ readonly workflowError: WorkflowError;
1859
+ constructor(workflowId: string, error: WorkflowError);
1860
+ }
1861
+
1862
+ /**
1863
+ * ERC-8004 v1.0 Contract ABIs and Addresses
1864
+ *
1865
+ * Complete ABIs extracted from Python SDK (chaos_agent.py lines 155-637)
1866
+ *
1867
+ * This module contains the complete ABIs for all ERC-8004 v1.0 contracts.
1868
+ * These are the official ABIs deployed on testnets.
1869
+ */
1870
+ /**
1871
+ * Get embedded Identity Registry ABI for ERC-8004 v1.0.
1872
+ *
1873
+ * v1.0 uses ERC-721 with URIStorage extension. Key changes:
1874
+ * - register() functions replace newAgent()
1875
+ * - Agents are ERC-721 NFTs with tokenURI
1876
+ * - ownerOf() to get agent owner
1877
+ * - tokenURI() to get registration file
1878
+ */
1879
+ declare const IDENTITY_REGISTRY_ABI: ({
1880
+ inputs: ({
1881
+ name: string;
1882
+ type: string;
1883
+ components?: undefined;
1884
+ } | {
1885
+ name: string;
1886
+ type: string;
1887
+ components: {
1888
+ name: string;
1889
+ type: string;
1890
+ }[];
1891
+ })[];
1892
+ name: string;
1893
+ outputs: {
1894
+ name: string;
1895
+ type: string;
1896
+ }[];
1897
+ stateMutability: string;
1898
+ type: string;
1899
+ anonymous?: undefined;
1900
+ } | {
1901
+ anonymous: boolean;
1902
+ inputs: {
1903
+ indexed: boolean;
1904
+ name: string;
1905
+ type: string;
1906
+ }[];
1907
+ name: string;
1908
+ type: string;
1909
+ outputs?: undefined;
1910
+ stateMutability?: undefined;
1911
+ })[];
1912
+ /**
1913
+ * Get Reputation Registry ABI (ERC-8004 Feb 2026)
1914
+ *
1915
+ * Feb 2026 KEY CHANGES from Oct 2025:
1916
+ * - REMOVED feedbackAuth parameter - feedback is now permissionless
1917
+ * - ADDED endpoint parameter for endpoint being reviewed
1918
+ * - CHANGED tag1, tag2 from bytes32 to string
1919
+ * - ADDED feedbackIndex to NewFeedback event
1920
+ * - readFeedback returns string tags and feedbackIndex parameter renamed
1921
+ *
1922
+ * Feb 2026 ABI UPDATE:
1923
+ * - CHANGED score (uint8) to value (int128) + valueDecimals (uint8)
1924
+ * - getSummary returns summaryValue (int128) + summaryValueDecimals (uint8)
1925
+ * - readFeedback returns value (int128) + valueDecimals (uint8)
1926
+ */
1927
+ declare const REPUTATION_REGISTRY_ABI: ({
1928
+ inputs: {
1929
+ name: string;
1930
+ type: string;
1931
+ }[];
1932
+ name: string;
1933
+ outputs: {
1934
+ name: string;
1935
+ type: string;
1936
+ }[];
1937
+ stateMutability: string;
1938
+ type: string;
1939
+ anonymous?: undefined;
1940
+ } | {
1941
+ anonymous: boolean;
1942
+ inputs: {
1943
+ indexed: boolean;
1944
+ name: string;
1945
+ type: string;
1946
+ }[];
1947
+ name: string;
1948
+ type: string;
1949
+ outputs?: undefined;
1950
+ stateMutability?: undefined;
1951
+ })[];
1952
+ /**
1953
+ * Get Validation Registry ABI (ERC-8004 v1.0)
1954
+ *
1955
+ * v1.0 uses URI-based validation with off-chain evidence storage.
1956
+ * Key changes:
1957
+ * - validationRequest() uses validatorAddress instead of validatorAgentId
1958
+ * - requestUri and requestHash for off-chain evidence
1959
+ * - validationResponse() uses requestHash with response (0-100)
1960
+ * - Support for multiple responses per request (progressive validation)
1961
+ */
1962
+ declare const VALIDATION_REGISTRY_ABI: readonly [{
1963
+ readonly inputs: readonly [{
1964
+ readonly name: "validatorAddress";
1965
+ readonly type: "address";
1966
+ }, {
1967
+ readonly name: "agentId";
1968
+ readonly type: "uint256";
1969
+ }, {
1970
+ readonly name: "requestUri";
1971
+ readonly type: "string";
1972
+ }, {
1973
+ readonly name: "requestHash";
1974
+ readonly type: "bytes32";
1975
+ }];
1976
+ readonly name: "validationRequest";
1977
+ readonly outputs: readonly [];
1978
+ readonly stateMutability: "nonpayable";
1979
+ readonly type: "function";
1980
+ }, {
1981
+ readonly inputs: readonly [{
1982
+ readonly name: "requestHash";
1983
+ readonly type: "bytes32";
1984
+ }, {
1985
+ readonly name: "response";
1986
+ readonly type: "uint8";
1987
+ }, {
1988
+ readonly name: "responseUri";
1989
+ readonly type: "string";
1990
+ }, {
1991
+ readonly name: "responseHash";
1992
+ readonly type: "bytes32";
1993
+ }, {
1994
+ readonly name: "tag";
1995
+ readonly type: "bytes32";
1996
+ }];
1997
+ readonly name: "validationResponse";
1998
+ readonly outputs: readonly [];
1999
+ readonly stateMutability: "nonpayable";
2000
+ readonly type: "function";
2001
+ }, {
2002
+ readonly inputs: readonly [{
2003
+ readonly name: "requestHash";
2004
+ readonly type: "bytes32";
2005
+ }];
2006
+ readonly name: "getValidationStatus";
2007
+ readonly outputs: readonly [{
2008
+ readonly name: "validatorAddress";
2009
+ readonly type: "address";
2010
+ }, {
2011
+ readonly name: "agentId";
2012
+ readonly type: "uint256";
2013
+ }, {
2014
+ readonly name: "response";
2015
+ readonly type: "uint8";
2016
+ }, {
2017
+ readonly name: "responseHash";
2018
+ readonly type: "bytes32";
2019
+ }, {
2020
+ readonly name: "tag";
2021
+ readonly type: "bytes32";
2022
+ }, {
2023
+ readonly name: "lastUpdate";
2024
+ readonly type: "uint256";
2025
+ }];
2026
+ readonly stateMutability: "view";
2027
+ readonly type: "function";
2028
+ }, {
2029
+ readonly inputs: readonly [{
2030
+ readonly name: "agentId";
2031
+ readonly type: "uint256";
2032
+ }, {
2033
+ readonly name: "validatorAddresses";
2034
+ readonly type: "address[]";
2035
+ }, {
2036
+ readonly name: "tag";
2037
+ readonly type: "bytes32";
2038
+ }];
2039
+ readonly name: "getSummary";
2040
+ readonly outputs: readonly [{
2041
+ readonly name: "count";
2042
+ readonly type: "uint64";
2043
+ }, {
2044
+ readonly name: "avgResponse";
2045
+ readonly type: "uint8";
2046
+ }];
2047
+ readonly stateMutability: "view";
2048
+ readonly type: "function";
2049
+ }, {
2050
+ readonly inputs: readonly [{
2051
+ readonly name: "agentId";
2052
+ readonly type: "uint256";
2053
+ }];
2054
+ readonly name: "getAgentValidations";
2055
+ readonly outputs: readonly [{
2056
+ readonly name: "requestHashes";
2057
+ readonly type: "bytes32[]";
2058
+ }];
2059
+ readonly stateMutability: "view";
2060
+ readonly type: "function";
2061
+ }, {
2062
+ readonly inputs: readonly [{
2063
+ readonly name: "validatorAddress";
2064
+ readonly type: "address";
2065
+ }];
2066
+ readonly name: "getValidatorRequests";
2067
+ readonly outputs: readonly [{
2068
+ readonly name: "requestHashes";
2069
+ readonly type: "bytes32[]";
2070
+ }];
2071
+ readonly stateMutability: "view";
2072
+ readonly type: "function";
2073
+ }, {
2074
+ readonly inputs: readonly [];
2075
+ readonly name: "getIdentityRegistry";
2076
+ readonly outputs: readonly [{
2077
+ readonly name: "registry";
2078
+ readonly type: "address";
2079
+ }];
2080
+ readonly stateMutability: "view";
2081
+ readonly type: "function";
2082
+ }, {
2083
+ readonly anonymous: false;
2084
+ readonly inputs: readonly [{
2085
+ readonly indexed: true;
2086
+ readonly name: "validatorAddress";
2087
+ readonly type: "address";
2088
+ }, {
2089
+ readonly indexed: true;
2090
+ readonly name: "agentId";
2091
+ readonly type: "uint256";
2092
+ }, {
2093
+ readonly indexed: false;
2094
+ readonly name: "requestUri";
2095
+ readonly type: "string";
2096
+ }, {
2097
+ readonly indexed: true;
2098
+ readonly name: "requestHash";
2099
+ readonly type: "bytes32";
2100
+ }];
2101
+ readonly name: "ValidationRequest";
2102
+ readonly type: "event";
2103
+ }, {
2104
+ readonly anonymous: false;
2105
+ readonly inputs: readonly [{
2106
+ readonly indexed: true;
2107
+ readonly name: "validatorAddress";
2108
+ readonly type: "address";
2109
+ }, {
2110
+ readonly indexed: true;
2111
+ readonly name: "agentId";
2112
+ readonly type: "uint256";
2113
+ }, {
2114
+ readonly indexed: true;
2115
+ readonly name: "requestHash";
2116
+ readonly type: "bytes32";
2117
+ }, {
2118
+ readonly indexed: false;
2119
+ readonly name: "response";
2120
+ readonly type: "uint8";
2121
+ }, {
2122
+ readonly indexed: false;
2123
+ readonly name: "responseUri";
2124
+ readonly type: "string";
2125
+ }, {
2126
+ readonly indexed: false;
2127
+ readonly name: "responseHash";
2128
+ readonly type: "bytes32";
2129
+ }, {
2130
+ readonly indexed: false;
2131
+ readonly name: "tag";
2132
+ readonly type: "bytes32";
2133
+ }];
2134
+ readonly name: "ValidationResponse";
2135
+ readonly type: "event";
2136
+ }];
2137
+ /**
2138
+ * ChaosCore ABI - Factory for creating Studios
2139
+ *
2140
+ * Methods:
2141
+ * - createStudio(name, logicModule) -> (proxy, studioId)
2142
+ */
2143
+ declare const CHAOS_CORE_ABI: readonly [{
2144
+ readonly inputs: readonly [{
2145
+ readonly name: "name";
2146
+ readonly type: "string";
2147
+ }, {
2148
+ readonly name: "logicModule";
2149
+ readonly type: "address";
2150
+ }];
2151
+ readonly name: "createStudio";
2152
+ readonly outputs: readonly [{
2153
+ readonly name: "proxy";
2154
+ readonly type: "address";
2155
+ }, {
2156
+ readonly name: "studioId";
2157
+ readonly type: "uint256";
2158
+ }];
2159
+ readonly stateMutability: "nonpayable";
2160
+ readonly type: "function";
2161
+ }, {
2162
+ readonly anonymous: false;
2163
+ readonly inputs: readonly [{
2164
+ readonly indexed: true;
2165
+ readonly name: "studioId";
2166
+ readonly type: "uint256";
2167
+ }, {
2168
+ readonly indexed: false;
2169
+ readonly name: "proxy";
2170
+ readonly type: "address";
2171
+ }, {
2172
+ readonly indexed: false;
2173
+ readonly name: "logicModule";
2174
+ readonly type: "address";
2175
+ }, {
2176
+ readonly indexed: true;
2177
+ readonly name: "creator";
2178
+ readonly type: "address";
2179
+ }];
2180
+ readonly name: "StudioCreated";
2181
+ readonly type: "event";
2182
+ }];
2183
+ /**
2184
+ * StudioProxy ABI - Main Studio contract for work submission and scoring
2185
+ *
2186
+ * Methods:
2187
+ * - registerAgent(agentId, role) [payable] - Register agent with stake
2188
+ * - submitWork(dataHash, threadRoot, evidenceRoot, feedbackAuth) - Submit single-agent work
2189
+ * - submitWorkMultiAgent(dataHash, threadRoot, evidenceRoot, participants, contributionWeights, evidenceCID) - Multi-agent work
2190
+ * - commitScore(dataHash, commitment) - Commit phase of commit-reveal
2191
+ * - revealScore(dataHash, scoreVector, salt) - Reveal phase
2192
+ * - getWithdrawableBalance(account) -> balance - Query pending rewards
2193
+ * - withdrawRewards() - Withdraw pending rewards
2194
+ */
2195
+ declare const STUDIO_PROXY_ABI: readonly [{
2196
+ readonly inputs: readonly [{
2197
+ readonly name: "agentId";
2198
+ readonly type: "uint256";
2199
+ }, {
2200
+ readonly name: "role";
2201
+ readonly type: "uint8";
2202
+ }];
2203
+ readonly name: "registerAgent";
2204
+ readonly outputs: readonly [];
2205
+ readonly stateMutability: "payable";
2206
+ readonly type: "function";
2207
+ }, {
2208
+ readonly inputs: readonly [{
2209
+ readonly name: "dataHash";
2210
+ readonly type: "bytes32";
2211
+ }, {
2212
+ readonly name: "threadRoot";
2213
+ readonly type: "bytes32";
2214
+ }, {
2215
+ readonly name: "evidenceRoot";
2216
+ readonly type: "bytes32";
2217
+ }, {
2218
+ readonly name: "feedbackAuth";
2219
+ readonly type: "bytes";
2220
+ }];
2221
+ readonly name: "submitWork";
2222
+ readonly outputs: readonly [];
2223
+ readonly stateMutability: "nonpayable";
2224
+ readonly type: "function";
2225
+ }, {
2226
+ readonly inputs: readonly [{
2227
+ readonly name: "dataHash";
2228
+ readonly type: "bytes32";
2229
+ }, {
2230
+ readonly name: "threadRoot";
2231
+ readonly type: "bytes32";
2232
+ }, {
2233
+ readonly name: "evidenceRoot";
2234
+ readonly type: "bytes32";
2235
+ }, {
2236
+ readonly name: "participants";
2237
+ readonly type: "address[]";
2238
+ }, {
2239
+ readonly name: "contributionWeights";
2240
+ readonly type: "uint16[]";
2241
+ }, {
2242
+ readonly name: "evidenceCID";
2243
+ readonly type: "string";
2244
+ }];
2245
+ readonly name: "submitWorkMultiAgent";
2246
+ readonly outputs: readonly [];
2247
+ readonly stateMutability: "nonpayable";
2248
+ readonly type: "function";
2249
+ }, {
2250
+ readonly inputs: readonly [{
2251
+ readonly name: "dataHash";
2252
+ readonly type: "bytes32";
2253
+ }, {
2254
+ readonly name: "commitment";
2255
+ readonly type: "bytes32";
2256
+ }];
2257
+ readonly name: "commitScore";
2258
+ readonly outputs: readonly [];
2259
+ readonly stateMutability: "nonpayable";
2260
+ readonly type: "function";
2261
+ }, {
2262
+ readonly inputs: readonly [{
2263
+ readonly name: "dataHash";
2264
+ readonly type: "bytes32";
2265
+ }, {
2266
+ readonly name: "scoreVector";
2267
+ readonly type: "bytes";
2268
+ }, {
2269
+ readonly name: "salt";
2270
+ readonly type: "bytes32";
2271
+ }];
2272
+ readonly name: "revealScore";
2273
+ readonly outputs: readonly [];
2274
+ readonly stateMutability: "nonpayable";
2275
+ readonly type: "function";
2276
+ }, {
2277
+ readonly inputs: readonly [{
2278
+ readonly name: "dataHash";
2279
+ readonly type: "bytes32";
2280
+ }, {
2281
+ readonly name: "scoreVector";
2282
+ readonly type: "bytes";
2283
+ }];
2284
+ readonly name: "submitScoreVector";
2285
+ readonly outputs: readonly [];
2286
+ readonly stateMutability: "nonpayable";
2287
+ readonly type: "function";
2288
+ }, {
2289
+ readonly inputs: readonly [{
2290
+ readonly name: "dataHash";
2291
+ readonly type: "bytes32";
2292
+ }, {
2293
+ readonly name: "workerAddress";
2294
+ readonly type: "address";
2295
+ }, {
2296
+ readonly name: "scoreVector";
2297
+ readonly type: "bytes";
2298
+ }];
2299
+ readonly name: "submitScoreVectorForWorker";
2300
+ readonly outputs: readonly [];
2301
+ readonly stateMutability: "nonpayable";
2302
+ readonly type: "function";
2303
+ }, {
2304
+ readonly inputs: readonly [{
2305
+ readonly name: "account";
2306
+ readonly type: "address";
2307
+ }];
2308
+ readonly name: "getWithdrawableBalance";
2309
+ readonly outputs: readonly [{
2310
+ readonly name: "balance";
2311
+ readonly type: "uint256";
2312
+ }];
2313
+ readonly stateMutability: "view";
2314
+ readonly type: "function";
2315
+ }, {
2316
+ readonly inputs: readonly [];
2317
+ readonly name: "withdrawRewards";
2318
+ readonly outputs: readonly [];
2319
+ readonly stateMutability: "nonpayable";
2320
+ readonly type: "function";
2321
+ }, {
2322
+ readonly inputs: readonly [{
2323
+ readonly name: "dataHash";
2324
+ readonly type: "bytes32";
2325
+ }, {
2326
+ readonly name: "feedbackAuth";
2327
+ readonly type: "bytes";
2328
+ }];
2329
+ readonly name: "registerFeedbackAuth";
2330
+ readonly outputs: readonly [];
2331
+ readonly stateMutability: "nonpayable";
2332
+ readonly type: "function";
2333
+ }, {
2334
+ readonly anonymous: false;
2335
+ readonly inputs: readonly [{
2336
+ readonly indexed: true;
2337
+ readonly name: "agentId";
2338
+ readonly type: "uint256";
2339
+ }, {
2340
+ readonly indexed: true;
2341
+ readonly name: "agentAddress";
2342
+ readonly type: "address";
2343
+ }, {
2344
+ readonly indexed: false;
2345
+ readonly name: "role";
2346
+ readonly type: "uint8";
2347
+ }, {
2348
+ readonly indexed: false;
2349
+ readonly name: "stake";
2350
+ readonly type: "uint256";
2351
+ }];
2352
+ readonly name: "AgentRegistered";
2353
+ readonly type: "event";
2354
+ }, {
2355
+ readonly anonymous: false;
2356
+ readonly inputs: readonly [{
2357
+ readonly indexed: true;
2358
+ readonly name: "dataHash";
2359
+ readonly type: "bytes32";
2360
+ }, {
2361
+ readonly indexed: true;
2362
+ readonly name: "submitter";
2363
+ readonly type: "address";
2364
+ }, {
2365
+ readonly indexed: false;
2366
+ readonly name: "threadRoot";
2367
+ readonly type: "bytes32";
2368
+ }, {
2369
+ readonly indexed: false;
2370
+ readonly name: "evidenceRoot";
2371
+ readonly type: "bytes32";
2372
+ }];
2373
+ readonly name: "WorkSubmitted";
2374
+ readonly type: "event";
2375
+ }, {
2376
+ readonly anonymous: false;
2377
+ readonly inputs: readonly [{
2378
+ readonly indexed: true;
2379
+ readonly name: "dataHash";
2380
+ readonly type: "bytes32";
2381
+ }, {
2382
+ readonly indexed: true;
2383
+ readonly name: "validator";
2384
+ readonly type: "address";
2385
+ }, {
2386
+ readonly indexed: false;
2387
+ readonly name: "commitment";
2388
+ readonly type: "bytes32";
2389
+ }];
2390
+ readonly name: "ScoreCommitted";
2391
+ readonly type: "event";
2392
+ }, {
2393
+ readonly anonymous: false;
2394
+ readonly inputs: readonly [{
2395
+ readonly indexed: true;
2396
+ readonly name: "dataHash";
2397
+ readonly type: "bytes32";
2398
+ }, {
2399
+ readonly indexed: true;
2400
+ readonly name: "validator";
2401
+ readonly type: "address";
2402
+ }, {
2403
+ readonly indexed: false;
2404
+ readonly name: "scoreVector";
2405
+ readonly type: "bytes";
2406
+ }];
2407
+ readonly name: "ScoreRevealed";
2408
+ readonly type: "event";
2409
+ }];
2410
+ /**
2411
+ * RewardsDistributor ABI - Manages epoch closure and reward distribution
2412
+ *
2413
+ * Methods:
2414
+ * - closeEpoch(studio, epoch) - Close an epoch and trigger reward distribution
2415
+ */
2416
+ declare const REWARDS_DISTRIBUTOR_ABI: readonly [{
2417
+ readonly inputs: readonly [{
2418
+ readonly name: "studio";
2419
+ readonly type: "address";
2420
+ }, {
2421
+ readonly name: "epoch";
2422
+ readonly type: "uint64";
2423
+ }];
2424
+ readonly name: "closeEpoch";
2425
+ readonly outputs: readonly [];
2426
+ readonly stateMutability: "nonpayable";
2427
+ readonly type: "function";
2428
+ }, {
2429
+ readonly anonymous: false;
2430
+ readonly inputs: readonly [{
2431
+ readonly indexed: true;
2432
+ readonly name: "studio";
2433
+ readonly type: "address";
2434
+ }, {
2435
+ readonly indexed: true;
2436
+ readonly name: "epoch";
2437
+ readonly type: "uint64";
2438
+ }, {
2439
+ readonly indexed: false;
2440
+ readonly name: "totalRewards";
2441
+ readonly type: "uint256";
2442
+ }];
2443
+ readonly name: "EpochClosed";
2444
+ readonly type: "event";
2445
+ }, {
2446
+ readonly anonymous: false;
2447
+ readonly inputs: readonly [{
2448
+ readonly indexed: true;
2449
+ readonly name: "studio";
2450
+ readonly type: "address";
2451
+ }, {
2452
+ readonly indexed: true;
2453
+ readonly name: "recipient";
2454
+ readonly type: "address";
2455
+ }, {
2456
+ readonly indexed: false;
2457
+ readonly name: "amount";
2458
+ readonly type: "uint256";
2459
+ }];
2460
+ readonly name: "RewardsDistributed";
2461
+ readonly type: "event";
2462
+ }];
2463
+ /**
2464
+ * StudioFactory ABI - Factory for creating Studios (alternative to ChaosCore)
2465
+ */
2466
+ declare const STUDIO_FACTORY_ABI: readonly [{
2467
+ readonly inputs: readonly [{
2468
+ readonly name: "name";
2469
+ readonly type: "string";
2470
+ }, {
2471
+ readonly name: "logicModule";
2472
+ readonly type: "address";
2473
+ }];
2474
+ readonly name: "createStudio";
2475
+ readonly outputs: readonly [{
2476
+ readonly name: "proxy";
2477
+ readonly type: "address";
2478
+ }];
2479
+ readonly stateMutability: "nonpayable";
2480
+ readonly type: "function";
2481
+ }];
2482
+
2483
+ interface Task {
2484
+ taskId: string;
2485
+ studioAddress: string;
2486
+ requirements: Record<string, any>;
2487
+ status: string;
2488
+ createdAt: Date;
2489
+ assignedTo?: string;
2490
+ assignedAt?: Date;
2491
+ }
2492
+ interface WorkerBid {
2493
+ bidId: string;
2494
+ taskId: string;
2495
+ workerAddress: string;
2496
+ workerAgentId: number;
2497
+ proposedPrice: number;
2498
+ estimatedTimeHours: number;
2499
+ capabilities: string[];
2500
+ reputationScore: number;
2501
+ message: string;
2502
+ submittedAt: Date;
2503
+ }
2504
+ interface StudioManagerConfig {
2505
+ sdk: ChaosChainSDK;
2506
+ messenger?: {
2507
+ sendMessage: (params: {
2508
+ toAgent: string;
2509
+ messageType: string;
2510
+ content: Record<string, any>;
2511
+ }) => Promise<string>;
2512
+ };
2513
+ }
2514
+ declare class StudioManager {
2515
+ private sdk;
2516
+ private messenger?;
2517
+ private activeTasks;
2518
+ private workerBids;
2519
+ constructor(config: StudioManagerConfig);
2520
+ getRegisteredWorkers(_studioAddress: string): string[];
2521
+ broadcastTask(studioAddress: string, taskRequirements: Record<string, any>, registeredWorkers: string[]): Promise<string>;
2522
+ collectBids(taskId: string, timeoutSeconds?: number): Promise<WorkerBid[]>;
2523
+ submitBid(taskId: string, workerAddress: string, workerAgentId: number, proposedPrice: number, estimatedTimeHours: number, capabilities: string[], message?: string): string;
2524
+ getWorkerReputations(workerAddresses: string[]): Record<string, number>;
2525
+ selectWorker(bids: WorkerBid[], reputationScores: Record<string, number>, weights?: Record<string, number>): string;
2526
+ assignTask(taskId: string, workerAddress: string, budget: number): Promise<string>;
2527
+ private displayBids;
2528
+ }
2529
+
2530
+ /**
2531
+ * ChaosChain SDK - TypeScript Entry Point
2532
+ *
2533
+ * Complete TypeScript implementation with feature parity to Python SDK
2534
+ *
2535
+ * @packageDocumentation
2536
+ */
2537
+
2538
+ declare const SDK_VERSION = "0.2.4";
2539
+ declare const ERC8004_VERSION = "1.0";
2540
+ declare const X402_VERSION = "1.0";
2541
+
2542
+ /**
2543
+ * Initialize ChaosChain SDK with minimal configuration
2544
+ *
2545
+ * @example
2546
+ * ```typescript
2547
+ * import { initChaosChainSDK, ChaosChainSDK } from '@chaoschain/sdk';
2548
+ *
2549
+ * const sdk = initChaosChainSDK({
2550
+ * agentName: 'MyAgent',
2551
+ * agentDomain: 'myagent.example.com',
2552
+ * agentRole: 'server',
2553
+ * network: 'base-sepolia',
2554
+ * privateKey: process.env.PRIVATE_KEY
2555
+ * });
2556
+ *
2557
+ * const { agentId } = await sdk.registerIdentity();
2558
+ * console.log(`Agent registered with ID: ${agentId}`);
2559
+ * ```
2560
+ */
2561
+ declare function initChaosChainSDK(config: {
2562
+ agentName: string;
2563
+ agentDomain: string;
2564
+ agentRole: string;
2565
+ network: string;
2566
+ privateKey?: string;
2567
+ mnemonic?: string;
2568
+ rpcUrl?: string;
2569
+ enablePayments?: boolean;
2570
+ enableAP2?: boolean;
2571
+ enableProcessIntegrity?: boolean;
2572
+ enableStorage?: boolean;
2573
+ }): ChaosChainSDK;
2574
+
2575
+ 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 };