@asi-names/sdk 0.0.0-stage → 0.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.
package/README.md CHANGED
@@ -1,3 +1,78 @@
1
- # Temporary Holding Version
1
+ # @asi-names/sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Resolve and register **.asi** names. The registry lives on Ethereum mainnet, and one name resolves
4
+ to an address on **every EVM chain** through ENSIP-11/19 address records. Every lookup is a direct
5
+ onchain call to the .asi UniversalResolver: there are no gateways and no CCIP.
6
+
7
+ ```sh
8
+ npm i @asi-names/sdk viem
9
+ ```
10
+
11
+ ## Resolve
12
+
13
+ ```ts
14
+ import { createAsiClient } from "@asi-names/sdk";
15
+
16
+ const asi = createAsiClient({ rpcUrl: process.env.MAINNET_RPC }); // or { publicClient }
17
+
18
+ await asi.getAddress("alice.asi"); // Ethereum
19
+ await asi.getAddress("alice.asi", { chainId: 8453 }); // Base: falls back to the all-EVM record
20
+ await asi.getText("alice.asi", "url");
21
+ await asi.getContenthash("alice.asi"); // "ipfs://bafy..."
22
+ await asi.getName("0xabc…", { chainId: 42161 }); // verified primary name, or null
23
+ ```
24
+
25
+ Unset records return `null`. RPC failures such as throttling or timeouts throw. They never come back
26
+ as `null`.
27
+
28
+ ## Register
29
+
30
+ ```ts
31
+ import { createAsiClient, registerName } from "@asi-names/sdk";
32
+
33
+ const asi = createAsiClient({ publicClient });
34
+ await registerName(asi, walletClient, {
35
+ name: "myagent", // or "myagent.asi"
36
+ years: 1,
37
+ token: "USDC", // optional: "USDC" | "USDT"; ETH otherwise
38
+ records: {
39
+ address: "0x…", // every EVM chain
40
+ chainAddresses: { 8453: "0x…" }, // per-chain override
41
+ texts: { url: "https://…", description: "…" },
42
+ contenthash: "ipfs://bafy…", // IPFS website
43
+ },
44
+ }, (p) => console.log(p.step, p.description ?? p.secondsLeft));
45
+ ```
46
+
47
+ Registration takes 2 transactions, plus an approval when you pay in a stablecoin: a commit, then
48
+ `register` at least 60 seconds later. The wait is measured in block time. Names are minted
49
+ **wrapped** (ERC-1155), which carries the onchain card art. Before the commit, the SDK checks that
50
+ the owner can receive the ERC-1155 token.
51
+
52
+ Wallet-agnostic builders return `{ to, data, value }`, which you can send from a Safe, an agent
53
+ wallet, ethers and so on:
54
+
55
+ ```ts
56
+ const { tx, secret } = await asi.prepareCommit({ name, owner, records });
57
+ // …wait ≥ 60s after it is mined…
58
+ const txs = await asi.prepareRegister({ name, owner, records, secret, token: "USDC" });
59
+ asi.prepareRenew({ name, years: 1 });
60
+ asi.prepareSetRecords(name, { texts: { avatar: "ipfs://…" } });
61
+ asi.prepareSetPrimaryName(name); // primary on every EVM chain
62
+ ```
63
+
64
+ ## Pricing (per year)
65
+
66
+ | Length | Price |
67
+ |---|---|
68
+ | 1 char | $300 |
69
+ | 2 chars | $100 |
70
+ | 3 chars | $25 |
71
+ | 4+ chars | $3 |
72
+
73
+ Recently expired names start with a premium that decays over 21 days. Use `asi.getPrice(name, { years, token })` for the current price.
74
+
75
+ ## Contracts (mainnet)
76
+
77
+ The addresses are exported as `ASI_CONTRACTS`. All of them are verified on Etherscan and owned by
78
+ the ASI 2-of-3 Safe.