@fangorn-network/sdk 2026.10.19-dev → 2026.10.21-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Fangorn SDK
2
2
 
3
- The Fangorn SDK is a lightweight "git for data" protocol: publishers version *repos* of records in IPFS and move each repo's head on-chain, and *apps* sponsor storage for the publishers they accept.
3
+ The Fangorn SDK is a decentralized "git for data" protocol. It follows an app <> publisher paradigm. An "app" is synonymous with gauranteed data availability and a 'view' of its underlying data. For publishers, it lets you cryptographically commit to to a version controlled "repo", which is data stored as a Merkle search tree in IPFS. Published data exists independently of an app, and apps emerge on top of data that they sponsor (pin).
4
4
 
5
5
  A **repo** belongs to its publisher, keyed **`publisher : repo`**. Its state is a map of **records** (`{ id, type, payload }`, content-addressed), and its head is the digest of the latest commit block. Any wallet can update its own repos; updating a head is a compare-and-swap on the parent (i.e. a git ref update), and an update names no app.
6
6
 
@@ -56,8 +56,7 @@ You can also configure via environment variables (these take precedence over the
56
56
  ETH_PRIVATE_KEY=0x...
57
57
  PINATA_JWT=...
58
58
  PINATA_GATEWAY=https://your-gateway.mypinata.cloud
59
- CHAIN_NAME=arbitrumSepolia
60
- ACCESS_WORKER_URL=https://access-worker.your-subdomain.workers.dev # optional (sealed fields)
59
+ CHAIN_NAME=arbitrumSepolia # or baseSepolia
61
60
  SIGNED_URL_WORKER_URL=https://pinata-url-provider.your-subdomain.workers.dev # optional
62
61
  ```
63
62
 
@@ -112,6 +111,7 @@ fangorn app suspend <address> # suspend a member from THIS app only
112
111
  fangorn app reinstate <address>
113
112
  fangorn app renew # pay for the next period
114
113
  fangorn app cancel # end the subscription now, no refund
114
+ fangorn app agent --access-worker <url> # register the worker's agent card with ERC-8004 (or pass a card URL)
115
115
  fangorn app withdraw-fees [to] # join fees still owed from before joining was removed
116
116
  ```
117
117
 
@@ -598,7 +598,23 @@ gadget_ behind the same handle shape, so committed data doesn't change form.
598
598
  | AppRegistry | `0x55e6209ea1833ceD900989a3b3b22466934E04A5` | Apps: owner, accepted publishers, bans, storage subscription (ERC-5643, USDC); what each app excludes |
599
599
  | MembershipRegistry | `0xDF17030Cd65435C86eb043F31DDACa99E819E347` | Time-limited, unlinkable access to an app's paid records (USDC + Semaphore) |
600
600
 
601
- `FangornConfig` in `src/config.ts` is the authoritative list and what the SDK
601
+ ### Base Sepolia
602
+
603
+ | Contract | Address |
604
+ | -------------------- | -------------------------------------------- |
605
+ | DataRegistry | `0xE9183f768865dd2Cde5f1B71F8446F0Cd798ebe0` |
606
+ | AppRegistry | `0x0D3e98399df41b558048Cdd7D71723c37A3A9D6F` |
607
+ | MembershipRegistry | `0x0e96C012b5c53622EcDAA82F342E31C2623A04f5` |
608
+
609
+ Use it from the SDK with `Fangorn.create({ config: BaseSepoliaConfig, ... })`, or
610
+ from the CLI with `CHAIN_NAME=baseSepolia` (or pick it in `fangorn init`).
611
+
612
+ Its default RPC is `base-sepolia-rpc.publicnode.com`, not `sepolia.base.org`: the
613
+ official endpoint caps `eth_getLogs` at 200 blocks, too narrow to scan the registry's
614
+ history. Each config's `logWindow` is the most blocks one log query spans on its RPC
615
+ (Base 10,000, Arbitrum 100,000); `FANGORN_LOG_WINDOW` overrides it for a private RPC.
616
+
617
+ `FangornConfig` (Arbitrum Sepolia) and `BaseSepoliaConfig` in `src/config.ts` are the authoritative list and what the SDK
602
618
  uses by default — prefer it over any address copied out of a document,
603
619
  including this table. The sources are `fangorn-network/contracts`
604
620
  (`solidity/script/Deployments.sol`); regenerate the ABIs with `pnpm abis`.
package/lib/cli/cli.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { FangornConfig, nonBlank, toAppId } from "../config.js";
2
+ import getNetwork, { nonBlank, toAppId } from "../config.js";
3
3
  import { PublisherStatus } from "../contracts/types.js";
4
4
  import "../contracts/index.js";
5
5
  import { Fangorn } from "../fangorn.js";
6
- import { handleCancel } from "./index.js";
7
- import { createPublicClient, formatEther, formatUnits, http } from "viem";
6
+ import { handleCancel, selectChain } from "./index.js";
7
+ import { agentCardUrl, mcpTools, mintAgent, parseAgentId, registrationFile, setAgentFile } from "./erc8004.js";
8
+ import { createPublicClient, createWalletClient, formatEther, formatUnits, http } from "viem";
8
9
  import { privateKeyToAccount } from "viem/accounts";
9
10
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
10
11
  import { dirname, join } from "path";
@@ -32,18 +33,18 @@ function loadConfig() {
32
33
  const privateKey = process.env.ETH_PRIVATE_KEY;
33
34
  const pinataJwt = process.env.PINATA_JWT;
34
35
  const pinataGateway = process.env.PINATA_GATEWAY;
35
- const accessWorkerUrl = process.env.ACCESS_WORKER_URL;
36
36
  const signedUrlWorkerUrl = process.env.SIGNED_URL_WORKER_URL;
37
37
  const envAppId = nonBlank(process.env.FANGORN_APP_ID);
38
+ const envChain = nonBlank(process.env.CHAIN_NAME);
38
39
  if (existsSync(CONFIG_PATH)) {
39
40
  const stored = readStoredConfig();
41
+ const storedChain = stored.chainName === "Arbitrum Sepolia" ? "arbitrumSepolia" : stored.chainName;
40
42
  _config = {
41
43
  privateKey: stored.privateKey,
42
- cfg: FangornConfig,
44
+ cfg: getNetwork(envChain ?? storedChain),
43
45
  appId: envAppId ?? nonBlank(stored.appId),
44
46
  pinataJwt: stored.pinataJwt,
45
47
  pinataGateway: stored.pinataGateway,
46
- accessWorkerUrl: stored.accessWorkerUrl ?? "",
47
48
  signedUrlWorkerUrl: stored.signedUrlWorkerUrl ?? ""
48
49
  };
49
50
  return _config;
@@ -52,11 +53,10 @@ function loadConfig() {
52
53
  if (!privateKey) throw new Error("Incomplete environment configuration. Missing: ETH_PRIVATE_KEY\nSet it or run `fangorn init` to use a config file.");
53
54
  _config = {
54
55
  privateKey,
55
- cfg: FangornConfig,
56
+ cfg: getNetwork(envChain ?? "arbitrumSepolia"),
56
57
  appId: envAppId,
57
58
  pinataJwt: pinataJwt ?? "",
58
59
  pinataGateway: pinataGateway ?? "",
59
- accessWorkerUrl: accessWorkerUrl ?? "",
60
60
  signedUrlWorkerUrl: signedUrlWorkerUrl ?? ""
61
61
  };
62
62
  return _config;
@@ -153,6 +153,7 @@ program.name("fangorn").description("Fangorn Network CLI").version("0.4.0");
153
153
  program.option("--app <name-or-id>", "App (global namespace) for this command — overrides the stored app (see `set-app`)");
154
154
  program.command("init").description("Configure your Fangorn credentials").action(async () => {
155
155
  intro("Fangorn Setup");
156
+ const chainName = await selectChain();
156
157
  const privateKey = await text({
157
158
  message: "Wallet private key (stored locally, never transmitted):",
158
159
  placeholder: "0x...",
@@ -169,11 +170,6 @@ program.command("init").description("Configure your Fangorn credentials").action
169
170
  placeholder: "https://your-gateway.mypinata.cloud"
170
171
  });
171
172
  handleCancel(pinataGateway);
172
- const accessWorkerUrl = await text({
173
- message: "Access-gating worker URL (optional):",
174
- placeholder: "https://access-worker.your-subdomain.workers.dev"
175
- });
176
- handleCancel(accessWorkerUrl);
177
173
  const signedUrlWorkerUrl = await text({
178
174
  message: "Presigned-URL worker URL (optional; blank uses the hosted default):",
179
175
  placeholder: "https://pinata-url-provider.your-subdomain.workers.dev"
@@ -181,10 +177,9 @@ program.command("init").description("Configure your Fangorn credentials").action
181
177
  handleCancel(signedUrlWorkerUrl);
182
178
  writeStoredConfig({
183
179
  privateKey,
184
- chainName: "Arbitrum Sepolia",
180
+ chainName,
185
181
  pinataJwt,
186
182
  pinataGateway,
187
- accessWorkerUrl,
188
183
  signedUrlWorkerUrl,
189
184
  appId: existsSync(CONFIG_PATH) ? readStoredConfig().appId : void 0
190
185
  });
@@ -292,16 +287,18 @@ appCmd.command("claim").description("Claim the configured app on-chain (first co
292
287
  process.exit(1);
293
288
  }
294
289
  });
295
- const ERC8004_ARBITRUM_SEPOLIA = {
296
- IDENTITY: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
297
- REPUTATION: "0x8004B663056A597Dffe9eCcC1965A193B7388713"
298
- };
299
- const ERC8004_SUBGRAPH = "https://api.studio.thegraph.com/query/1742225/erc-8004-arbitrum-sepolia/version/latest";
300
- appCmd.command("agent").description("Register this app's gateway as an ERC-8004 agent and point the app at its card (owner only)").argument("[cardUrl]", "The agent card URL; defaults to the configured access worker's /.well-known/agent-card.json").option("--mcp <url>", "An MCP endpoint to index alongside the card").option("--skip-register", "Only set agent_uri on-chain — for a gateway already registered with ERC-8004").action(async (cardUrl, opts) => {
290
+ async function retryNonce(f, tries = 4) {
291
+ for (let i = 0;; i++) try {
292
+ return await f();
293
+ } catch (e) {
294
+ if (i >= tries - 1 || !/underpriced|nonce too low|nonce has already been used|already known/i.test(e.message)) throw e;
295
+ await new Promise((ok) => setTimeout(ok, 3e3 * (i + 1)));
296
+ }
297
+ }
298
+ appCmd.command("agent").description("Register this app's gateway as an ERC-8004 agent and point the app at its card (owner only)").argument("[cardUrl]", "The agent card URL; or pass --access-worker to use its /.well-known/agent-card.json").option("--access-worker <url>", "The access worker serving the agent card").option("--mcp <url>", "An MCP endpoint to index alongside the card").option("--skip-register", "Only set agent_uri on-chain — for a gateway already registered with ERC-8004").option("--update <agentId>", "Update an agent already registered (e.g. 84532:10323) from the card as it is now: a new registration file, pointed to by setAgentURI; mints nothing").action(async (cardUrl, opts) => {
301
299
  try {
302
300
  const cfg = loadConfig();
303
- const url = cardUrl ?? (cfg.accessWorkerUrl ? `${cfg.accessWorkerUrl.replace(/\/$/, "")}/.well-known/agent-card.json` : void 0);
304
- if (!url) throw new Error("No card URL. Pass one, or set an access worker URL with `fangorn init`.");
301
+ const url = agentCardUrl(cardUrl, opts.accessWorker);
305
302
  const s = spinner();
306
303
  s.start(`Reading ${url}`);
307
304
  const res = await fetch(url);
@@ -315,32 +312,66 @@ appCmd.command("agent").description("Register this app's gateway as an ERC-8004
315
312
  let agentId;
316
313
  if (!opts.skipRegister) {
317
314
  if (!cfg.pinataJwt) throw new Error("ERC-8004 registration pins the registration file to IPFS — set PINATA_JWT, or pass --skip-register.");
318
- const { SDK } = await import("agent0-sdk");
319
- const agent = new SDK({
320
- chainId: cfg.cfg.caip2,
321
- rpcUrl: cfg.cfg.rpcUrl,
322
- subgraphUrl: ERC8004_SUBGRAPH,
323
- registryOverrides: { [cfg.cfg.caip2]: ERC8004_ARBITRUM_SEPOLIA },
324
- subgraphOverrides: { [cfg.cfg.caip2]: ERC8004_SUBGRAPH },
325
- ipfs: "pinata",
326
- pinataJwt: cfg.pinataJwt,
327
- privateKey: cfg.privateKey
328
- }).createAgent(card.name, card.description);
315
+ const c = {
316
+ chain: cfg.cfg.chain,
317
+ publicClient: createPublicClient({
318
+ chain: cfg.cfg.chain,
319
+ transport: http(cfg.cfg.rpcUrl)
320
+ }),
321
+ walletClient: createWalletClient({
322
+ account: getAccount(),
323
+ chain: cfg.cfg.chain,
324
+ transport: http(cfg.cfg.rpcUrl)
325
+ }),
326
+ pinataJwt: cfg.pinataJwt
327
+ };
328
+ const chainId = cfg.cfg.caip2;
329
+ const named = {
330
+ ...card,
331
+ name: card.name,
332
+ description: card.description
333
+ };
329
334
  s.start("Indexing skills and capabilities from the card");
330
- await agent.setA2A(url);
331
- if (opts.mcp) await agent.setMCP(opts.mcp);
335
+ const mcp = opts.mcp ? {
336
+ endpoint: opts.mcp,
337
+ tools: await mcpTools(opts.mcp)
338
+ } : void 0;
332
339
  s.stop();
333
- agent.setTrust(true, false, false);
334
- agent.setX402Support(card.skills?.some((sk) => sk.tags?.includes("x402")) ?? false);
335
- agent.setActive(true);
336
- s.start("Registering with the ERC-8004 identity registry");
337
- const { result } = await (await agent.registerIPFS()).waitConfirmed();
340
+ const file = (id) => registrationFile({
341
+ cardUrl: url,
342
+ card: named,
343
+ chainId,
344
+ agentId: id,
345
+ mcp
346
+ });
347
+ if (opts.update) {
348
+ const id = parseAgentId(opts.update, chainId);
349
+ s.start(`Updating ERC-8004 agent ${opts.update}`);
350
+ await retryNonce(() => setAgentFile(c, id, file(id)));
351
+ s.stop();
352
+ agentId = `${String(chainId)}:${String(id)}`;
353
+ } else {
354
+ s.start("Registering with the ERC-8004 identity registry");
355
+ const id = await mintAgent(c);
356
+ agentId = `${String(chainId)}:${String(id)}`;
357
+ s.message(`Minted ${agentId}; pinning its registration file`);
358
+ try {
359
+ await retryNonce(() => setAgentFile(c, id, file(id)));
360
+ } catch (e) {
361
+ s.stop();
362
+ throw new Error(`agent ${agentId} was minted but its registration file was not set (${e.message}). Finish it with: fangorn app agent ${url} --update ${agentId}`);
363
+ }
364
+ s.stop();
365
+ }
366
+ }
367
+ const apps = getFangorn().getAppRegistry();
368
+ const bound = opts.update ? await apps.appAgentUri().catch(() => "") : "";
369
+ let txHash = "(already bound)";
370
+ if (bound !== url) {
371
+ s.start("Pointing the app at its card");
372
+ txHash = await retryNonce(() => apps.setAppAgentUri(url));
338
373
  s.stop();
339
- agentId = String(result.agentId);
340
374
  }
341
- s.start("Pointing the app at its card");
342
- const txHash = await getFangorn().getAppRegistry().setAppAgentUri(url);
343
- s.stop();
344
375
  if (agentId) console.log(`Agent ID: ${agentId}`);
345
376
  console.log(`Card: ${url}`);
346
377
  console.log(`Tx: ${txHash}`);
@@ -0,0 +1,54 @@
1
+ import { Address, Chain, Hex, PublicClient, WalletClient } from "viem";
2
+
3
+ //#region src/cli/erc8004.d.ts
4
+ /** The ERC-8004 identity registry by chain id */
5
+ declare const IDENTITY_REGISTRY: Record<number, Address>;
6
+ interface AgentCard {
7
+ name: string;
8
+ description: string;
9
+ skills?: {
10
+ tags?: unknown;
11
+ }[];
12
+ }
13
+ /**
14
+ * Get the agent card URL based on the access worker if defined, else return the carUrl
15
+ * Both params are optional, but at least one must be defined.
16
+ *
17
+ * Agent cards must live at accessWorker/.well-known/agent-card.json
18
+ *
19
+ * @param cardUrl The cardUrl (passthrough when defined)
20
+ * @param accessWorker The (optional) access worker url
21
+ * @returns
22
+ */
23
+ declare function agentCardUrl(cardUrl?: string, accessWorker?: string): string;
24
+ declare function mcpTools(endpoint: string): Promise<string[] | undefined>;
25
+ /**
26
+ * Build a registration file
27
+ * Since it desfines its own agent id,
28
+ * first registration mints without an agent URI and must be set retroactively.
29
+ */
30
+ declare function registrationFile(opts: {
31
+ cardUrl: string;
32
+ card: AgentCard;
33
+ chainId: number;
34
+ agentId: bigint;
35
+ mcp?: {
36
+ endpoint: string;
37
+ tools?: string[];
38
+ };
39
+ now?: number;
40
+ }): Record<string, unknown>;
41
+ /** `84532:10323` or `10323` → the token id, refusing an agent on another chain. */
42
+ declare function parseAgentId(id: string, chainId: number): bigint;
43
+ interface Erc8004Clients {
44
+ chain: Chain;
45
+ publicClient: PublicClient;
46
+ walletClient: WalletClient;
47
+ pinataJwt: string;
48
+ }
49
+ /** Pin `file` and point agent `agentId` at it. */
50
+ declare function setAgentFile(c: Erc8004Clients, agentId: bigint, file: unknown): Promise<Hex>;
51
+ /** Mint an agent with no URI yet, and return its id. */
52
+ declare function mintAgent(c: Erc8004Clients): Promise<bigint>;
53
+ //#endregion
54
+ export { AgentCard, Erc8004Clients, IDENTITY_REGISTRY, agentCardUrl, mcpTools, mintAgent, parseAgentId, registrationFile, setAgentFile };
@@ -0,0 +1,140 @@
1
+ import { parseAbi, parseEventLogs } from "viem";
2
+ import { PinataSDK } from "pinata";
3
+
4
+ //#region src/cli/erc8004.ts
5
+ /** The ERC-8004 identity registry by chain id */
6
+ const IDENTITY_REGISTRY = {
7
+ 84532: "0x8004A818BFB912233c491871b3d84c89A494BD9e",
8
+ 421614: "0x8004A818BFB912233c491871b3d84c89A494BD9e"
9
+ };
10
+ const ABI = parseAbi([
11
+ "function register(string agentURI, (string metadataKey, bytes metadataValue)[] metadata) returns (uint256 agentId)",
12
+ "function setAgentURI(uint256 agentId, string newURI)",
13
+ "event Registered(uint256 indexed agentId, string agentURI, address indexed owner)"
14
+ ]);
15
+ /**
16
+ * Get the agent card URL based on the access worker if defined, else return the carUrl
17
+ * Both params are optional, but at least one must be defined.
18
+ *
19
+ * Agent cards must live at accessWorker/.well-known/agent-card.json
20
+ *
21
+ * @param cardUrl The cardUrl (passthrough when defined)
22
+ * @param accessWorker The (optional) access worker url
23
+ * @returns
24
+ */
25
+ function agentCardUrl(cardUrl, accessWorker) {
26
+ if (cardUrl) return cardUrl;
27
+ if (!accessWorker) throw new Error("No card URL. Pass one, or pass --access-worker <url>.");
28
+ return `${accessWorker.replace(/\/$/, "")}/.well-known/agent-card.json`;
29
+ }
30
+ async function mcpTools(endpoint) {
31
+ try {
32
+ const res = await fetch(endpoint, {
33
+ method: "POST",
34
+ headers: {
35
+ "Content-Type": "application/json",
36
+ Accept: "application/json, text/event-stream"
37
+ },
38
+ body: JSON.stringify({
39
+ jsonrpc: "2.0",
40
+ id: 1,
41
+ method: "tools/list"
42
+ }),
43
+ signal: AbortSignal.timeout(1e4)
44
+ });
45
+ if (!res.ok) return void 0;
46
+ const text = await res.text();
47
+ const body = text.split("\n").find((l) => l.startsWith("data: "))?.slice(6) ?? text;
48
+ const names = (JSON.parse(body).result?.tools ?? []).map((t) => t.name).filter((n) => typeof n === "string");
49
+ return names.length ? names : void 0;
50
+ } catch {
51
+ return;
52
+ }
53
+ }
54
+ /**
55
+ * Build a registration file
56
+ * Since it desfines its own agent id,
57
+ * first registration mints without an agent URI and must be set retroactively.
58
+ */
59
+ function registrationFile(opts) {
60
+ const { cardUrl, card, chainId, agentId, mcp } = opts;
61
+ const tags = [...new Set((card.skills ?? []).flatMap((s) => Array.isArray(s.tags) ? s.tags : []).filter((t) => typeof t === "string"))];
62
+ const services = [{
63
+ name: "A2A",
64
+ endpoint: cardUrl,
65
+ version: "0.30",
66
+ ...tags.length && { a2aSkills: tags }
67
+ }];
68
+ if (mcp) services.push({
69
+ name: "MCP",
70
+ endpoint: mcp.endpoint,
71
+ version: "2025-06-18",
72
+ ...mcp.tools && { mcpTools: mcp.tools }
73
+ });
74
+ return {
75
+ type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
76
+ name: card.name,
77
+ description: card.description,
78
+ services,
79
+ registrations: [{
80
+ agentId: Number(agentId),
81
+ agentRegistry: `eip155:${String(chainId)}:${IDENTITY_REGISTRY[chainId]}`
82
+ }],
83
+ supportedTrust: ["reputation"],
84
+ active: true,
85
+ x402Support: card.skills?.some((s) => Array.isArray(s.tags) && s.tags.includes("x402")) ?? false,
86
+ updatedAt: opts.now ?? Math.floor(Date.now() / 1e3)
87
+ };
88
+ }
89
+ /** `84532:10323` or `10323` → the token id, refusing an agent on another chain. */
90
+ function parseAgentId(id, chainId) {
91
+ const m = /^(?:(\d+):)?(\d+)$/.exec(id.trim());
92
+ if (!m) throw new Error(`not an agent id: ${JSON.stringify(id)} (expected <chainId>:<tokenId>, e.g. 84532:10323)`);
93
+ if (m[1] && Number(m[1]) !== chainId) throw new Error(`agent ${id} is on chain ${m[1]}, but the CLI is configured for ${String(chainId)}`);
94
+ return BigInt(m[2]);
95
+ }
96
+ async function pin(jwt, data) {
97
+ const file = new File([JSON.stringify(data, null, 2)], "agent-registration.json", { type: "application/json" });
98
+ return (await new PinataSDK({ pinataJwt: jwt }).upload.public.file(file)).cid;
99
+ }
100
+ function registry(chain) {
101
+ const address = IDENTITY_REGISTRY[chain.id];
102
+ if (!address) throw new Error(`no ERC-8004 identity registry known for chain ${String(chain.id)}`);
103
+ return address;
104
+ }
105
+ /** Pin `file` and point agent `agentId` at it. */
106
+ async function setAgentFile(c, agentId, file) {
107
+ const cid = await pin(c.pinataJwt, file);
108
+ const hash = await c.walletClient.writeContract({
109
+ address: registry(c.chain),
110
+ abi: ABI,
111
+ functionName: "setAgentURI",
112
+ args: [agentId, `ipfs://${cid}`],
113
+ chain: c.chain,
114
+ account: c.walletClient.account ?? null
115
+ });
116
+ await c.publicClient.waitForTransactionReceipt({ hash });
117
+ return hash;
118
+ }
119
+ /** Mint an agent with no URI yet, and return its id. */
120
+ async function mintAgent(c) {
121
+ const address = registry(c.chain);
122
+ const hash = await c.walletClient.writeContract({
123
+ address,
124
+ abi: ABI,
125
+ functionName: "register",
126
+ args: ["", []],
127
+ chain: c.chain,
128
+ account: c.walletClient.account ?? null
129
+ });
130
+ const minted = parseEventLogs({
131
+ abi: ABI,
132
+ eventName: "Registered",
133
+ logs: (await c.publicClient.waitForTransactionReceipt({ hash })).logs
134
+ }).find((l) => l.address.toLowerCase() === address.toLowerCase());
135
+ if (!minted) throw new Error(`register ${hash} confirmed with no Registered event`);
136
+ return minted.args.agentId;
137
+ }
138
+
139
+ //#endregion
140
+ export { IDENTITY_REGISTRY, agentCardUrl, mcpTools, mintAgent, parseAgentId, registrationFile, setAgentFile };
@@ -1,98 +1,10 @@
1
1
  import "./cli.js";
2
- import * as viem0 from "viem";
2
+ import * as viem5575 from "viem";
3
3
 
4
4
  //#region src/cli/index.d.ts
5
- declare const getChain: (chainStr: string) => {
6
- blockExplorers: {
7
- readonly default: {
8
- readonly name: "Arbiscan";
9
- readonly url: "https://sepolia.arbiscan.io";
10
- readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
11
- };
12
- };
13
- blockTime: 250;
14
- contracts: {
15
- readonly multicall3: {
16
- readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
17
- readonly blockCreated: 81930;
18
- };
19
- };
20
- ensTlds?: readonly string[] | undefined;
21
- id: 421614;
22
- name: "Arbitrum Sepolia";
23
- nativeCurrency: {
24
- readonly name: "Arbitrum Sepolia Ether";
25
- readonly symbol: "ETH";
26
- readonly decimals: 18;
27
- };
28
- experimental_preconfirmationTime?: number | undefined | undefined;
29
- rpcUrls: {
30
- readonly default: {
31
- readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
32
- };
33
- };
34
- sourceId?: number | undefined | undefined;
35
- testnet: true;
36
- custom?: Record<string, unknown> | undefined;
37
- extendSchema?: Record<string, unknown> | undefined;
38
- fees?: viem0.ChainFees<undefined> | undefined;
39
- formatters?: undefined;
40
- prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
41
- phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
42
- }) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
43
- phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
- }) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
45
- runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
46
- }] | undefined;
47
- serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
48
- verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
49
- };
5
+ declare const getChain: (chainStr: string) => viem5575.Chain;
50
6
  declare const handleCancel: (value: unknown) => void;
51
- declare const selectChain: () => Promise<{
52
- blockExplorers: {
53
- readonly default: {
54
- readonly name: "Arbiscan";
55
- readonly url: "https://sepolia.arbiscan.io";
56
- readonly apiUrl: "https://api-sepolia.arbiscan.io/api";
57
- };
58
- };
59
- blockTime: 250;
60
- contracts: {
61
- readonly multicall3: {
62
- readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
63
- readonly blockCreated: 81930;
64
- };
65
- };
66
- ensTlds?: readonly string[] | undefined;
67
- id: 421614;
68
- name: "Arbitrum Sepolia";
69
- nativeCurrency: {
70
- readonly name: "Arbitrum Sepolia Ether";
71
- readonly symbol: "ETH";
72
- readonly decimals: 18;
73
- };
74
- experimental_preconfirmationTime?: number | undefined | undefined;
75
- rpcUrls: {
76
- readonly default: {
77
- readonly http: readonly ["https://sepolia-rollup.arbitrum.io/rpc"];
78
- };
79
- };
80
- sourceId?: number | undefined | undefined;
81
- testnet: true;
82
- custom?: Record<string, unknown> | undefined;
83
- extendSchema?: Record<string, unknown> | undefined;
84
- fees?: viem0.ChainFees<undefined> | undefined;
85
- formatters?: undefined;
86
- prepareTransactionRequest?: ((args: viem0.PrepareTransactionRequestParameters, options: {
87
- phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
88
- }) => Promise<viem0.PrepareTransactionRequestParameters>) | [fn: ((args: viem0.PrepareTransactionRequestParameters, options: {
89
- phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
90
- }) => Promise<viem0.PrepareTransactionRequestParameters>) | undefined, options: {
91
- runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
92
- }] | undefined;
93
- serializers?: viem0.ChainSerializers<undefined, viem0.TransactionSerializable> | undefined;
94
- verifyHash?: ((client: viem0.Client, parameters: viem0.VerifyHashActionParameters) => Promise<viem0.VerifyHashActionReturnType>) | undefined;
95
- }>;
7
+ declare const selectChain: () => Promise<string>;
96
8
  declare function parseGadgetArg(raw: string): {
97
9
  type: string;
98
10
  args: string[];
package/lib/cli/index.js CHANGED
@@ -4,7 +4,7 @@ import { isCancel, select } from "@clack/prompts";
4
4
 
5
5
  //#region src/cli/index.ts
6
6
  const getChain = (chainStr) => {
7
- return getNetwork(chainStr);
7
+ return getNetwork(chainStr).chain;
8
8
  };
9
9
  const handleCancel = (value) => {
10
10
  if (isCancel(value)) process.exit(0);
@@ -15,10 +15,13 @@ const selectChain = async () => {
15
15
  options: [{
16
16
  value: "arbitrumSepolia",
17
17
  label: "Arbitrum Sepolia"
18
+ }, {
19
+ value: "baseSepolia",
20
+ label: "Base Sepolia"
18
21
  }]
19
22
  });
20
23
  handleCancel(chainChoice);
21
- return getNetwork(chainChoice.toString());
24
+ return chainChoice.toString();
22
25
  };
23
26
  function parseGadgetArg(raw) {
24
27
  const match = /^(\w+)\(([^)]*)\)$/.exec(raw);