@openserv-labs/client 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,558 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Erc8004API = void 0;
4
+ const viem_1 = require("viem");
5
+ const accounts_1 = require("viem/accounts");
6
+ const pinata_1 = require("pinata");
7
+ const erc8004_abi_js_1 = require("./erc8004-abi.js");
8
+ const erc8004_contracts_js_1 = require("./erc8004-contracts.js");
9
+ /**
10
+ * API for ERC-8004 agent identity operations on the OpenServ platform.
11
+ *
12
+ * ERC-8004 is an on-chain agent identity standard. This API enables:
13
+ * - Deploying workspace agents to the blockchain as ERC-8004 tokens
14
+ * - Managing web3 wallets associated with workspaces
15
+ * - Presigning IPFS URLs for uploading agent registration files
16
+ * - Querying callable triggers for on-chain service registration
17
+ * - Signing feedback auth for reputation interactions
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const client = new PlatformClient({ apiKey: 'your-key' });
22
+ *
23
+ * // Generate a web3 wallet for the workspace
24
+ * const wallet = await client.erc8004.generateWallet({ workflowId: 123 });
25
+ *
26
+ * // Get a presigned IPFS URL for uploading the agent card
27
+ * const { url } = await client.erc8004.presignIpfsUrl({ workflowId: 123 });
28
+ *
29
+ * // Deploy to ERC-8004
30
+ * await client.erc8004.deploy({
31
+ * workflowId: 123,
32
+ * erc8004AgentId: '8453:42',
33
+ * stringifiedAgentCard: JSON.stringify(registrationFile),
34
+ * walletAddress: '0x...',
35
+ * network: 'base',
36
+ * chainId: 8453,
37
+ * });
38
+ * ```
39
+ */
40
+ class Erc8004API {
41
+ client;
42
+ constructor(client) {
43
+ this.client = client;
44
+ }
45
+ // ===========================================================================
46
+ // ERC-8004 Deployment
47
+ // ===========================================================================
48
+ /**
49
+ * Deploy a workspace agent to the ERC-8004 identity registry.
50
+ *
51
+ * This records the deployment details in the platform database. The actual
52
+ * on-chain registration should be performed separately using the agent0 SDK.
53
+ * Call this method both before and after blockchain registration to keep
54
+ * the platform in sync.
55
+ *
56
+ * If the deploy fails (e.g. insufficient ETH for gas), the error is
57
+ * enriched with the workspace wallet address and instructions for funding
58
+ * it so you can retry.
59
+ *
60
+ * @param params - Deployment parameters
61
+ * @param params.workflowId - The workflow (workspace) ID to deploy
62
+ * @param params.erc8004AgentId - Agent ID in format "chainId:tokenId"
63
+ * @param params.stringifiedAgentCard - JSON-stringified registration file
64
+ * @param params.latestDeploymentTransactionHash - Transaction hash from on-chain registration
65
+ * @param params.latestDeploymentTimestamp - Timestamp of the deployment
66
+ * @param params.walletAddress - Wallet address that performed the deployment
67
+ * @param params.network - Network name (e.g., "base")
68
+ * @param params.chainId - Chain ID (e.g., 8453 for Base mainnet)
69
+ * @param params.rpcUrl - RPC URL for the chain
70
+ * @param params.swap - If true, swap USDC in the wallet to ETH for gas before deploying (not yet implemented)
71
+ * @returns The updated workflow data
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Before blockchain registration (save initial state)
76
+ * await client.erc8004.deploy({
77
+ * workflowId: 123,
78
+ * erc8004AgentId: '',
79
+ * stringifiedAgentCard: JSON.stringify(registrationFile),
80
+ * walletAddress: '0x...',
81
+ * network: 'base',
82
+ * chainId: 8453,
83
+ * rpcUrl: 'https://mainnet.base.org',
84
+ * });
85
+ *
86
+ * // ... perform on-chain registration ...
87
+ *
88
+ * // After blockchain registration (save final state with tx hash)
89
+ * await client.erc8004.deploy({
90
+ * workflowId: 123,
91
+ * erc8004AgentId: '8453:42',
92
+ * stringifiedAgentCard: JSON.stringify(updatedRegistrationFile),
93
+ * latestDeploymentTransactionHash: '0xabc...',
94
+ * latestDeploymentTimestamp: new Date(),
95
+ * walletAddress: '0x...',
96
+ * network: 'base',
97
+ * chainId: 8453,
98
+ * rpcUrl: 'https://mainnet.base.org',
99
+ * });
100
+ * ```
101
+ */
102
+ async deploy(params) {
103
+ const { workflowId, swap, ...body } = params;
104
+ if (swap) {
105
+ throw new Error("USDC-to-ETH swap for gas is not yet implemented. " +
106
+ "This feature is coming soon. In the meantime, fund the workspace " +
107
+ "wallet with ETH directly and retry without the swap option.");
108
+ }
109
+ try {
110
+ return await this.client.put(`/workspaces/${workflowId}/erc-8004/deploy`, body);
111
+ }
112
+ catch (error) {
113
+ // Enrich the error with wallet info so the user knows where to send ETH
114
+ throw await this.enrichDeployError(error, workflowId);
115
+ }
116
+ }
117
+ /**
118
+ * Enrich a deploy error with the workspace wallet address and funding
119
+ * instructions. Called automatically when deploy() fails.
120
+ */
121
+ async enrichDeployError(originalError, workflowId) {
122
+ const originalMessage = originalError instanceof Error
123
+ ? originalError.message
124
+ : String(originalError);
125
+ let walletAddress = null;
126
+ try {
127
+ const wallet = await this.getWallet({ workflowId });
128
+ walletAddress = wallet.address;
129
+ }
130
+ catch {
131
+ // Wallet may not exist yet
132
+ }
133
+ const fundingHint = walletAddress
134
+ ? `\n\nWorkspace wallet address: ${walletAddress}\n` +
135
+ `Send ETH to this address to cover gas fees, then retry.` +
136
+ `\n\nNote: automatic USDC-to-ETH swap is coming soon. ` +
137
+ `Once available, pass swap: true to convert USDC in the wallet to ETH for gas.`
138
+ : `\n\nNo wallet found for this workspace. ` +
139
+ `Generate one first with client.erc8004.generateWallet({ workflowId: ${workflowId} }), ` +
140
+ `then fund it with ETH and retry.`;
141
+ return new Error(originalMessage + fundingHint);
142
+ }
143
+ // ===========================================================================
144
+ // Full On-Chain Registration
145
+ // ===========================================================================
146
+ /**
147
+ * Register (or re-deploy) a workspace agent on-chain as an ERC-8004 identity.
148
+ *
149
+ * This is a high-level method that orchestrates the entire deployment:
150
+ * 1. Reads workspace wallet and callable triggers
151
+ * 2. Builds the ERC-8004 agent card JSON
152
+ * 3. Uploads the agent card to IPFS via a presigned Pinata URL
153
+ * 4. Registers on-chain (first deploy) or updates the URI (re-deploy)
154
+ * 5. Saves the deployment state to the platform
155
+ *
156
+ * @param params.workflowId - The workflow (workspace) ID
157
+ * @param params.privateKey - Funded private key for on-chain transactions (must have ETH for gas)
158
+ * @param params.chainId - Chain ID (default: 8453 for Base mainnet)
159
+ * @param params.rpcUrl - RPC URL (default: "https://mainnet.base.org")
160
+ * @param params.name - Agent name override (falls back to "ERC-8004 Agent")
161
+ * @param params.description - Agent description override
162
+ * @returns Deployment result with agentId, IPFS CID, transaction hash, and URLs
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * const result = await client.erc8004.registerOnChain({
167
+ * workflowId: 123,
168
+ * privateKey: '0x...',
169
+ * name: 'My AI Agent',
170
+ * description: 'An agent that does amazing things',
171
+ * });
172
+ * console.log(result.agentId); // "8453:42"
173
+ * console.log(result.txHash); // "0xabc..."
174
+ * console.log(result.ipfsCid); // "bafkrei..."
175
+ * console.log(result.blockExplorerUrl); // "https://basescan.org/tx/0xabc..."
176
+ * console.log(result.scanUrl); // "https://www.8004scan.io/agents/base/42"
177
+ * ```
178
+ */
179
+ async registerOnChain(params) {
180
+ const { workflowId, privateKey, chainId = 8453, rpcUrl = "https://mainnet.base.org", name = "ERC-8004 Agent", description = "Agent registered via OpenServ Platform", } = params;
181
+ // 1. Get wallet and callable triggers
182
+ const wallet = await this.getWallet({ workflowId });
183
+ const callableTriggers = await this.getCallableTriggers({ workflowId });
184
+ // 2. Build ERC-8004 agent card
185
+ const services = callableTriggers.map((t) => ({
186
+ name: "WEB",
187
+ endpoint: t.webEndpoint,
188
+ triggerName: t.name,
189
+ description: t.description ?? undefined,
190
+ ...(t.httpEndpoint
191
+ ? { httpEndpoint: t.httpEndpoint, inputSchema: t.inputSchema }
192
+ : {}),
193
+ }));
194
+ if (wallet.address) {
195
+ services.push({
196
+ name: "agentWallet",
197
+ endpoint: `eip155:${chainId}:${wallet.address}`,
198
+ triggerName: undefined,
199
+ description: undefined,
200
+ });
201
+ }
202
+ const agentCard = {
203
+ type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
204
+ name,
205
+ description,
206
+ services,
207
+ active: true,
208
+ x402support: true,
209
+ };
210
+ const agentCardJson = JSON.stringify(agentCard);
211
+ // 3. Detect first deploy vs re-deploy
212
+ const existingAgentId = wallet.erc8004AgentId;
213
+ const isRedeploy = !!existingAgentId;
214
+ // 4. Save initial state
215
+ await this.deploy({
216
+ workflowId,
217
+ erc8004AgentId: existingAgentId ?? "",
218
+ stringifiedAgentCard: agentCardJson,
219
+ ...(wallet.address ? { walletAddress: wallet.address } : {}),
220
+ network: "base",
221
+ chainId,
222
+ rpcUrl,
223
+ });
224
+ // 5. Upload to IPFS
225
+ const { url: presignedUrl } = await this.presignIpfsUrl({ workflowId });
226
+ const ipfsCid = await this.uploadToIpfs(agentCardJson, presignedUrl);
227
+ // 6. On-chain registration
228
+ const contracts = (0, erc8004_contracts_js_1.getErc8004Contracts)(chainId);
229
+ const chainConfig = (0, erc8004_contracts_js_1.getErc8004Chain)(chainId);
230
+ const registryAddress = contracts.IDENTITY_REGISTRY;
231
+ // Build a viem Chain from the ERC-8004 chain config
232
+ const viemChain = chainConfig
233
+ ? (0, viem_1.defineChain)({
234
+ id: chainConfig.chainId,
235
+ name: chainConfig.name,
236
+ nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
237
+ rpcUrls: {
238
+ default: { http: [rpcUrl] },
239
+ },
240
+ blockExplorers: {
241
+ default: {
242
+ name: chainConfig.name,
243
+ url: chainConfig.blockExplorerUrl,
244
+ },
245
+ },
246
+ testnet: chainConfig.testnet,
247
+ })
248
+ : (0, viem_1.defineChain)({
249
+ id: chainId,
250
+ name: `Chain ${chainId}`,
251
+ nativeCurrency: { name: "ETH", symbol: "ETH", decimals: 18 },
252
+ rpcUrls: {
253
+ default: { http: [rpcUrl] },
254
+ },
255
+ });
256
+ const normalizedKey = (privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`);
257
+ const account = (0, accounts_1.privateKeyToAccount)(normalizedKey);
258
+ const publicClient = (0, viem_1.createPublicClient)({
259
+ chain: viemChain,
260
+ transport: (0, viem_1.http)(rpcUrl),
261
+ });
262
+ const walletClient = (0, viem_1.createWalletClient)({
263
+ account,
264
+ chain: viemChain,
265
+ transport: (0, viem_1.http)(rpcUrl),
266
+ });
267
+ let agentId;
268
+ let txHash;
269
+ if (isRedeploy) {
270
+ // Re-deploy: just update the URI
271
+ const tokenId = existingAgentId.split(":")[1];
272
+ if (!tokenId) {
273
+ throw new Error(`Invalid existing agentId format: ${existingAgentId}`);
274
+ }
275
+ const hash = await walletClient.writeContract({
276
+ address: registryAddress,
277
+ abi: erc8004_abi_js_1.IDENTITY_REGISTRY_ABI,
278
+ functionName: "setAgentURI",
279
+ args: [BigInt(tokenId), `ipfs://${ipfsCid}`],
280
+ });
281
+ await publicClient.waitForTransactionReceipt({ hash });
282
+ txHash = hash;
283
+ agentId = existingAgentId;
284
+ }
285
+ else {
286
+ // First deploy: register then set URI
287
+ const registerHash = await walletClient.writeContract({
288
+ address: registryAddress,
289
+ abi: erc8004_abi_js_1.IDENTITY_REGISTRY_ABI,
290
+ functionName: "register",
291
+ args: [],
292
+ });
293
+ const registerReceipt = await publicClient.waitForTransactionReceipt({
294
+ hash: registerHash,
295
+ });
296
+ // Extract agentId from Registered or Transfer event
297
+ const tokenId = this.extractAgentIdFromReceipt(registerReceipt.logs, registryAddress);
298
+ agentId = `${chainId}:${tokenId}`;
299
+ // Set the IPFS URI
300
+ const uriHash = await walletClient.writeContract({
301
+ address: registryAddress,
302
+ abi: erc8004_abi_js_1.IDENTITY_REGISTRY_ABI,
303
+ functionName: "setAgentURI",
304
+ args: [BigInt(tokenId), `ipfs://${ipfsCid}`],
305
+ });
306
+ await publicClient.waitForTransactionReceipt({ hash: uriHash });
307
+ txHash = uriHash;
308
+ }
309
+ // 7. Save final state
310
+ await this.deploy({
311
+ workflowId,
312
+ erc8004AgentId: agentId,
313
+ stringifiedAgentCard: agentCardJson,
314
+ latestDeploymentTransactionHash: txHash,
315
+ latestDeploymentTimestamp: new Date(),
316
+ ...(wallet.address ? { walletAddress: wallet.address } : {}),
317
+ network: "base",
318
+ chainId,
319
+ rpcUrl,
320
+ });
321
+ const blockExplorerUrl = chainConfig
322
+ ? `${chainConfig.blockExplorerUrl}/tx/${txHash}`
323
+ : `https://basescan.org/tx/${txHash}`;
324
+ const network = chainConfig?.network ?? "base";
325
+ const tokenId = agentId.split(":")[1];
326
+ const scanUrl = `https://www.8004scan.io/agents/${network}/${tokenId}`;
327
+ return {
328
+ agentId,
329
+ ipfsCid,
330
+ txHash,
331
+ agentCardUrl: `https://gateway.pinata.cloud/ipfs/${ipfsCid}`,
332
+ blockExplorerUrl,
333
+ scanUrl,
334
+ };
335
+ }
336
+ /**
337
+ * Upload a JSON string to IPFS using a presigned Pinata URL.
338
+ */
339
+ async uploadToIpfs(jsonContent, presignedUrl) {
340
+ const pinata = new pinata_1.PinataSDK({
341
+ pinataJwt: "",
342
+ pinataGateway: "gateway.pinata.cloud",
343
+ });
344
+ const file = new File([jsonContent], "registration.json", {
345
+ type: "application/json",
346
+ });
347
+ const response = await pinata.upload.public.file(file).url(presignedUrl);
348
+ const cid = response.cid;
349
+ if (!cid) {
350
+ throw new Error(`No CID returned from Pinata. Response: ${JSON.stringify(response)}`);
351
+ }
352
+ return cid;
353
+ }
354
+ /**
355
+ * Extract the agent token ID from a registration transaction receipt.
356
+ * Looks for the Registered event first, then falls back to Transfer event.
357
+ */
358
+ extractAgentIdFromReceipt(logs, registryAddress) {
359
+ // Try Registered event first
360
+ for (const log of logs) {
361
+ if (log.address.toLowerCase() !== registryAddress.toLowerCase())
362
+ continue;
363
+ try {
364
+ const decoded = (0, viem_1.decodeEventLog)({
365
+ abi: erc8004_abi_js_1.IDENTITY_REGISTRY_ABI,
366
+ data: log.data,
367
+ topics: log.topics,
368
+ });
369
+ if (decoded.eventName === "Registered") {
370
+ const args = decoded.args;
371
+ return args.agentId.toString();
372
+ }
373
+ }
374
+ catch {
375
+ // Not this event, try next
376
+ }
377
+ }
378
+ // Fallback to Transfer event (ERC-721 mint: from=0x0)
379
+ for (const log of logs) {
380
+ if (log.address.toLowerCase() !== registryAddress.toLowerCase())
381
+ continue;
382
+ try {
383
+ const decoded = (0, viem_1.decodeEventLog)({
384
+ abi: erc8004_abi_js_1.IDENTITY_REGISTRY_ABI,
385
+ data: log.data,
386
+ topics: log.topics,
387
+ });
388
+ if (decoded.eventName === "Transfer") {
389
+ const args = decoded.args;
390
+ return args.tokenId.toString();
391
+ }
392
+ }
393
+ catch {
394
+ // Not this event, try next
395
+ }
396
+ }
397
+ throw new Error("Could not extract agent ID from transaction receipt. " +
398
+ "No Registered or Transfer event found.");
399
+ }
400
+ /**
401
+ * Get a presigned IPFS URL for uploading an agent registration file.
402
+ *
403
+ * The returned URL is a signed Pinata upload URL that expires in 60 seconds.
404
+ * Use it to upload the agent's registration file (agent card) to IPFS before
405
+ * on-chain registration.
406
+ *
407
+ * @param params - Parameters
408
+ * @param params.workflowId - The workflow (workspace) ID
409
+ * @returns Object containing the presigned IPFS upload URL
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * const { url } = await client.erc8004.presignIpfsUrl({ workflowId: 123 });
414
+ * // Use the URL to upload agent card to IPFS within 60 seconds
415
+ * ```
416
+ */
417
+ async presignIpfsUrl(params) {
418
+ return this.client.put(`/workspaces/${params.workflowId}/erc-8004/presign-ipfs-url`);
419
+ }
420
+ // ===========================================================================
421
+ // Web3 Wallet Management
422
+ // ===========================================================================
423
+ /**
424
+ * Get the web3 wallet associated with a workspace.
425
+ *
426
+ * @param params - Parameters
427
+ * @param params.workflowId - The workflow (workspace) ID
428
+ * @returns The web3 wallet details
429
+ *
430
+ * @example
431
+ * ```typescript
432
+ * const wallet = await client.erc8004.getWallet({ workflowId: 123 });
433
+ * console.log(wallet.address, wallet.deployed, wallet.erc8004AgentId);
434
+ * ```
435
+ */
436
+ async getWallet(params) {
437
+ return this.client.get(`/workspaces/${params.workflowId}/web3`);
438
+ }
439
+ /**
440
+ * Generate a new web3 wallet for a workspace.
441
+ *
442
+ * Creates a fresh wallet with a server-generated private key. The wallet
443
+ * is stored securely on the platform and used for ERC-8004 operations.
444
+ * A workspace can only have one web3 wallet.
445
+ *
446
+ * @param params - Parameters
447
+ * @param params.workflowId - The workflow (workspace) ID
448
+ * @returns The generated web3 wallet
449
+ * @throws Error if the workspace already has a web3 wallet
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * const wallet = await client.erc8004.generateWallet({ workflowId: 123 });
454
+ * console.log('Wallet address:', wallet.address);
455
+ * ```
456
+ */
457
+ async generateWallet(params) {
458
+ return this.client.post(`/workspaces/${params.workflowId}/web3/generate`);
459
+ }
460
+ /**
461
+ * Import an existing web3 wallet into a workspace.
462
+ *
463
+ * Use this to associate a pre-existing wallet (e.g., one that already has
464
+ * an ERC-8004 registration) with a workspace.
465
+ * A workspace can only have one web3 wallet.
466
+ *
467
+ * @param params - Import parameters
468
+ * @param params.workflowId - The workflow (workspace) ID
469
+ * @param params.address - Wallet address
470
+ * @param params.network - Network name (e.g., "base")
471
+ * @param params.chainId - Chain ID (e.g., 8453)
472
+ * @param params.privateKey - Wallet private key
473
+ * @returns The imported web3 wallet
474
+ * @throws Error if the workspace already has a web3 wallet
475
+ *
476
+ * @example
477
+ * ```typescript
478
+ * const wallet = await client.erc8004.importWallet({
479
+ * workflowId: 123,
480
+ * address: '0x...',
481
+ * network: 'base',
482
+ * chainId: 8453,
483
+ * privateKey: '0x...',
484
+ * });
485
+ * ```
486
+ */
487
+ async importWallet(params) {
488
+ const { workflowId, ...body } = params;
489
+ return this.client.post(`/workspaces/${workflowId}/web3/import`, body);
490
+ }
491
+ /**
492
+ * Delete the web3 wallet associated with a workspace.
493
+ *
494
+ * This removes the wallet record from the platform. Note that the on-chain
495
+ * ERC-8004 registration is not affected -- this only removes the platform's
496
+ * association.
497
+ *
498
+ * @param params - Parameters
499
+ * @param params.workflowId - The workflow (workspace) ID
500
+ *
501
+ * @example
502
+ * ```typescript
503
+ * await client.erc8004.deleteWallet({ workflowId: 123 });
504
+ * ```
505
+ */
506
+ async deleteWallet(params) {
507
+ await this.client.delete(`/workspaces/${params.workflowId}/web3`);
508
+ }
509
+ /**
510
+ * Sign a feedback auth message for a buyer address.
511
+ *
512
+ * This is used for the ERC-8004 reputation system. The workspace's web3 wallet
513
+ * signs an auth message that allows a buyer to submit feedback/reputation
514
+ * for the agent on-chain.
515
+ *
516
+ * @param params - Parameters
517
+ * @param params.workflowId - The workflow (workspace) ID
518
+ * @param params.buyerAddress - The buyer's wallet address to authorize
519
+ * @returns Object containing the signed feedback auth
520
+ *
521
+ * @example
522
+ * ```typescript
523
+ * const { signature } = await client.erc8004.signFeedbackAuth({
524
+ * workflowId: 123,
525
+ * buyerAddress: '0xBuyer...',
526
+ * });
527
+ * ```
528
+ */
529
+ async signFeedbackAuth(params) {
530
+ return this.client.post(`/workspaces/${params.workflowId}/web3/sign-feedback-auth`, { buyerAddress: params.buyerAddress });
531
+ }
532
+ // ===========================================================================
533
+ // Callable Triggers
534
+ // ===========================================================================
535
+ /**
536
+ * Get callable triggers for a workspace.
537
+ *
538
+ * Returns the list of triggers that can be called externally, along with
539
+ * their input schemas and endpoint URLs. This is used during ERC-8004
540
+ * deployment to register the agent's available services on-chain.
541
+ *
542
+ * @param params - Parameters
543
+ * @param params.workflowId - The workflow (workspace) ID
544
+ * @returns Array of callable triggers with their schemas and endpoints
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * const triggers = await client.erc8004.getCallableTriggers({ workflowId: 123 });
549
+ * for (const trigger of triggers) {
550
+ * console.log(trigger.name, trigger.webEndpoint);
551
+ * }
552
+ * ```
553
+ */
554
+ async getCallableTriggers(params) {
555
+ return this.client.get(`/workspaces/${params.workflowId}/callable-triggers`);
556
+ }
557
+ }
558
+ exports.Erc8004API = Erc8004API;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * ERC-8004 contract addresses and chain configuration.
3
+ *
4
+ * Contract addresses sourced from the official erc-8004-contracts repository:
5
+ * https://github.com/erc-8004/erc-8004-contracts
6
+ *
7
+ * All mainnets share the same contract addresses.
8
+ * All testnets share the same contract addresses.
9
+ */
10
+ /** Contract addresses shared across all ERC-8004 mainnets */
11
+ export declare const ERC8004_MAINNET_CONTRACTS: {
12
+ readonly IDENTITY_REGISTRY: "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432";
13
+ readonly REPUTATION_REGISTRY: "0x8004BAa17C55a88189AE136b182e5fdA19dE9b63";
14
+ };
15
+ /** Contract addresses shared across all ERC-8004 testnets */
16
+ export declare const ERC8004_TESTNET_CONTRACTS: {
17
+ readonly IDENTITY_REGISTRY: "0x8004A818BFB912233c491871b3d84c89A494BD9e";
18
+ readonly REPUTATION_REGISTRY: "0x8004B663056A597Dffe9eCcC1965A193B7388713";
19
+ };
20
+ /** Configuration for an ERC-8004 supported chain */
21
+ export interface Erc8004ChainConfig {
22
+ /** Numeric chain ID */
23
+ chainId: number;
24
+ /** Human-readable network name */
25
+ network: string;
26
+ /** Display name */
27
+ name: string;
28
+ /** Whether this is a testnet */
29
+ testnet: boolean;
30
+ /** Default public RPC URL */
31
+ rpcUrl: string;
32
+ /** Block explorer base URL */
33
+ blockExplorerUrl: string;
34
+ /** ERC-8004 contract addresses */
35
+ contracts: {
36
+ IDENTITY_REGISTRY: string;
37
+ REPUTATION_REGISTRY: string;
38
+ };
39
+ }
40
+ /**
41
+ * All chains where ERC-8004 contracts are deployed.
42
+ *
43
+ * Source: https://github.com/erc-8004/erc-8004-contracts
44
+ */
45
+ export declare const ERC8004_CHAINS: Record<number, Erc8004ChainConfig>;
46
+ /**
47
+ * Get the ERC-8004 chain configuration for a given chain ID.
48
+ *
49
+ * @param chainId - The numeric chain ID
50
+ * @returns The chain configuration, or undefined if the chain is not supported
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const baseConfig = getErc8004Chain(8453);
55
+ * console.log(baseConfig?.contracts.IDENTITY_REGISTRY);
56
+ * // "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"
57
+ * ```
58
+ */
59
+ export declare function getErc8004Chain(chainId: number): Erc8004ChainConfig | undefined;
60
+ /**
61
+ * Get the ERC-8004 contract addresses for a given chain ID.
62
+ *
63
+ * @param chainId - The numeric chain ID
64
+ * @returns The contract addresses
65
+ * @throws Error if the chain ID is not supported
66
+ *
67
+ * @example
68
+ * ```typescript
69
+ * const contracts = getErc8004Contracts(8453);
70
+ * console.log(contracts.IDENTITY_REGISTRY);
71
+ * // "0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"
72
+ * ```
73
+ */
74
+ export declare function getErc8004Contracts(chainId: number): {
75
+ IDENTITY_REGISTRY: string;
76
+ REPUTATION_REGISTRY: string;
77
+ };
78
+ /**
79
+ * List all supported ERC-8004 chain IDs.
80
+ *
81
+ * @param filter - Optional filter: "mainnet", "testnet", or undefined for all
82
+ * @returns Array of supported chain IDs
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const allChains = listErc8004ChainIds();
87
+ * const mainnets = listErc8004ChainIds("mainnet");
88
+ * const testnets = listErc8004ChainIds("testnet");
89
+ * ```
90
+ */
91
+ export declare function listErc8004ChainIds(filter?: "mainnet" | "testnet"): number[];
92
+ //# sourceMappingURL=erc8004-contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"erc8004-contracts.d.ts","sourceRoot":"","sources":["../src/erc8004-contracts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAEX,6DAA6D;AAC7D,eAAO,MAAM,yBAAyB;;;CAG5B,CAAC;AAMX,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,kCAAkC;IAClC,SAAS,EAAE;QACT,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAwJpD,CAAC;AAMX;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,GACd,kBAAkB,GAAG,SAAS,CAEhC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG;IACpD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CASA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,EAAE,CAQ5E"}