hawk-names 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dotrobinxyz
4
+
5
+ The contracts under `contracts/` are a fork of ensdomains/ens-contracts
6
+ (https://github.com/ensdomains/ens-contracts), Copyright (c) ENS Labs Ltd and
7
+ contributors, also licensed under the MIT License. Robin-specific additions
8
+ live under `contracts/contracts/robin/`.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # hawk-names
2
+
3
+ Resolve and register `.hawk` names on Base — ENS-standard resolution with a
4
+ one-line viem config, built for the agent economy.
5
+
6
+ Hawk implements the exact ENS interfaces (ERC-137 registry, standard
7
+ resolver profiles, ENSIP namehash, reverse records, a UniversalResolver), so
8
+ **the ENS tooling you already use works unchanged** — stock viem, wagmi, and
9
+ ethers resolve `.hawk` once they know where the registry lives.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm i hawk-names viem
15
+ ```
16
+
17
+ ## Use
18
+
19
+ ```ts
20
+ import { createPublicClient, http } from "viem";
21
+ import { base } from "hawk-names"; // ← Base with Hawk wired in as its ENS
22
+
23
+ const client = createPublicClient({ chain: base, transport: http() });
24
+
25
+ // reverse: address → name (render this instead of 0x…)
26
+ await client.getEnsName({ address: "0x882220CF716aEF2421b6ab283E63427D81497d8c" });
27
+ // → "genesis.hawk"
28
+
29
+ // forward: name → address (payments, transfers, search)
30
+ await client.getEnsAddress({ name: "genesis.hawk" });
31
+
32
+ // profile records
33
+ await client.getEnsText({ name: "genesis.hawk", key: "url" });
34
+ await client.getEnsAvatar({ name: "genesis.hawk" });
35
+ ```
36
+
37
+ With wagmi, pass the chain into your config and use the stock hooks —
38
+ `useEnsName`, `useEnsAddress`, `useEnsText`, `useEnsAvatar`. Nothing else
39
+ changes. Already have your own Base chain object? Wrap it:
40
+ `withHawk(myChainConfig)`.
41
+
42
+ ## Agents
43
+
44
+ Hawk is agent identity: one parent name per operator, one subname per agent
45
+ — `bot1.bankr.hawk` cryptographically hangs off `bankr.hawk`. Subnames are
46
+ real ERC-1155 tokens (transferable, revocable), and text records are the
47
+ agent's machine-readable capability card (`url`, `agent.capabilities`,
48
+ `agent.operator`, …).
49
+
50
+ ## Also exported
51
+
52
+ - `HAWK_ADDRESSES`, `getHawkAddresses` — the deployed contract addresses
53
+ - `getHawkName` / `getHawkAddress` / `getHawkText` / `getHawkAvatar` —
54
+ standalone actions when you don't want to touch your chain object
55
+ - `makeRegistration`, `makeCommitment`, `randomSecret`, `validateLabel` —
56
+ commit–reveal registration helpers
57
+ - `normalize`, `namehash`, `labelhash` (re-exported from `viem/ens`)
58
+ - Typed ABIs for every deployed contract
59
+
60
+ ## More
61
+
62
+ - App: <https://dothawk.xyz>
63
+ - Source: [github.com/dotrobinxyz/hawk](https://github.com/dotrobinxyz/hawk) — `packages/sdk`
64
+ - Deployed addresses: `contracts/deployments/hawk-base.json` in the repo
65
+
66
+ MIT © dotrobinxyz
@@ -0,0 +1,24 @@
1
+ import type { Address, Client } from "viem";
2
+ /**
3
+ * Thin, explicit wrappers over viem's ENS actions. If your client's chain
4
+ * comes from this SDK (`base` / `withHawk`), viem's own
5
+ * `getEnsName`/`getEnsAddress`/... already resolve .hawk — use whichever
6
+ * reads better in your codebase.
7
+ */
8
+ /** Primary name for an address (reverse resolution), or null. */
9
+ export declare function getHawkName(client: Client, params: {
10
+ address: Address;
11
+ }): Promise<string | null>;
12
+ /** Forward-resolves a .hawk name to its address, or null. */
13
+ export declare function getHawkAddress(client: Client, params: {
14
+ name: string;
15
+ }): Promise<Address | null>;
16
+ /** Reads a text record (e.g. "com.twitter", "url", "description"). */
17
+ export declare function getHawkText(client: Client, params: {
18
+ name: string;
19
+ key: string;
20
+ }): Promise<string | null>;
21
+ /** Resolves the avatar record to a usable URI, or null. */
22
+ export declare function getHawkAvatar(client: Client, params: {
23
+ name: string;
24
+ }): Promise<string | null>;
@@ -0,0 +1,26 @@
1
+ import { getEnsAddress, getEnsAvatar, getEnsName, getEnsText, normalize, } from "viem/ens";
2
+ /**
3
+ * Thin, explicit wrappers over viem's ENS actions. If your client's chain
4
+ * comes from this SDK (`base` / `withHawk`), viem's own
5
+ * `getEnsName`/`getEnsAddress`/... already resolve .hawk — use whichever
6
+ * reads better in your codebase.
7
+ */
8
+ /** Primary name for an address (reverse resolution), or null. */
9
+ export async function getHawkName(client, params) {
10
+ return getEnsName(client, { address: params.address });
11
+ }
12
+ /** Forward-resolves a .hawk name to its address, or null. */
13
+ export async function getHawkAddress(client, params) {
14
+ return getEnsAddress(client, { name: normalize(params.name) });
15
+ }
16
+ /** Reads a text record (e.g. "com.twitter", "url", "description"). */
17
+ export async function getHawkText(client, params) {
18
+ return getEnsText(client, {
19
+ name: normalize(params.name),
20
+ key: params.key,
21
+ });
22
+ }
23
+ /** Resolves the avatar record to a usable URI, or null. */
24
+ export async function getHawkAvatar(client, params) {
25
+ return getEnsAvatar(client, { name: normalize(params.name) });
26
+ }
@@ -0,0 +1,42 @@
1
+ import type { Address } from "viem";
2
+ /** Every Hawk contract for one deployment. */
3
+ export type HawkAddresses = {
4
+ registry: Address;
5
+ baseRegistrar: Address;
6
+ controller: Address;
7
+ priceOracle: Address;
8
+ wrapper: Address;
9
+ metadata: Address;
10
+ reservedList: Address;
11
+ publicResolver: Address;
12
+ reverseRegistrar: Address;
13
+ defaultReverseRegistrar: Address;
14
+ universalResolver: Address;
15
+ usdc: Address;
16
+ };
17
+ /**
18
+ * Canonical deployments by chain id.
19
+ *
20
+ * - 8453 — Base mainnet (populated at mainnet deploy)
21
+ * - 84532 — Base Sepolia testnet (populated at testnet deploy)
22
+ *
23
+ * For a local/anvil deployment, build your own with `hawkAddressesFrom`
24
+ * using the deploy script's deployments/hawk-local.json.
25
+ */
26
+ export declare const HAWK_ADDRESSES: Record<number, HawkAddresses>;
27
+ /** Maps a deployments/hawk-<network>.json record to HawkAddresses. */
28
+ export declare function hawkAddressesFrom(deployment: {
29
+ HawkRegistry: Address;
30
+ HawkBaseRegistrar: Address;
31
+ HawkRegistrarController: Address;
32
+ HawkPriceOracle: Address;
33
+ HawkWrapper: Address;
34
+ HawkMetadata: Address;
35
+ HawkReservedList: Address;
36
+ PublicResolver: Address;
37
+ ReverseRegistrar: Address;
38
+ DefaultReverseRegistrar: Address;
39
+ UniversalResolver: Address;
40
+ usdc: Address;
41
+ }): HawkAddresses;
42
+ export declare function getHawkAddresses(chainId: number): HawkAddresses;
@@ -0,0 +1,65 @@
1
+ const ZERO = "0x0000000000000000000000000000000000000000";
2
+ /**
3
+ * Canonical deployments by chain id.
4
+ *
5
+ * - 8453 — Base mainnet (populated at mainnet deploy)
6
+ * - 84532 — Base Sepolia testnet (populated at testnet deploy)
7
+ *
8
+ * For a local/anvil deployment, build your own with `hawkAddressesFrom`
9
+ * using the deploy script's deployments/hawk-local.json.
10
+ */
11
+ export const HAWK_ADDRESSES = {
12
+ 8453: {
13
+ registry: "0x5DAF4DF48b022Bf0Fb454DBe9CB2592d3A32b0b2",
14
+ baseRegistrar: "0x83dcABD50E531325C76b9CB07F4C04Aca187722E",
15
+ controller: "0x65Acb254B2EF5af1FDFf7B8C77427Ca051Ff4F71",
16
+ priceOracle: "0x697b2C75652b6895D507b9C8E2Cb3b3C8EfccA29",
17
+ wrapper: "0x0B922e8B56c778667AbDbBBa522880F98362c6C8",
18
+ metadata: "0xA972f32580C2DD8eEf379e27B4B91b205BF3437F",
19
+ reservedList: "0x351c51AA3079e7f7EbeFb5079A92279b22a0AB6c",
20
+ publicResolver: "0xC7cAB8Af20fF52346F4e93c143Cc8e9d6384e26b",
21
+ reverseRegistrar: "0x4221F2953294ec98Ddf54964DB293E281db71daB",
22
+ defaultReverseRegistrar: "0x34acC481E26Ee9566d868F455BecD05353Bae257",
23
+ universalResolver: "0x1Ebbe68AfA011ADBE561De6215B1AA1Fe0e4bc6C",
24
+ usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
25
+ },
26
+ 84532: {
27
+ registry: ZERO,
28
+ baseRegistrar: ZERO,
29
+ controller: ZERO,
30
+ priceOracle: ZERO,
31
+ wrapper: ZERO,
32
+ metadata: ZERO,
33
+ reservedList: ZERO,
34
+ publicResolver: ZERO,
35
+ reverseRegistrar: ZERO,
36
+ defaultReverseRegistrar: ZERO,
37
+ universalResolver: ZERO,
38
+ usdc: ZERO,
39
+ },
40
+ };
41
+ /** Maps a deployments/hawk-<network>.json record to HawkAddresses. */
42
+ export function hawkAddressesFrom(deployment) {
43
+ return {
44
+ registry: deployment.HawkRegistry,
45
+ baseRegistrar: deployment.HawkBaseRegistrar,
46
+ controller: deployment.HawkRegistrarController,
47
+ priceOracle: deployment.HawkPriceOracle,
48
+ wrapper: deployment.HawkWrapper,
49
+ metadata: deployment.HawkMetadata,
50
+ reservedList: deployment.HawkReservedList,
51
+ publicResolver: deployment.PublicResolver,
52
+ reverseRegistrar: deployment.ReverseRegistrar,
53
+ defaultReverseRegistrar: deployment.DefaultReverseRegistrar,
54
+ universalResolver: deployment.UniversalResolver,
55
+ usdc: deployment.usdc,
56
+ };
57
+ }
58
+ export function getHawkAddresses(chainId) {
59
+ const addresses = HAWK_ADDRESSES[chainId];
60
+ if (!addresses || addresses.registry === ZERO) {
61
+ throw new Error(`Hawk is not deployed on chain ${chainId} in this SDK version — ` +
62
+ `pass addresses explicitly (hawkAddressesFrom) or upgrade hawk-names.`);
63
+ }
64
+ return addresses;
65
+ }
@@ -0,0 +1,21 @@
1
+ import { type Chain } from "viem";
2
+ import { type HawkAddresses } from "./addresses.js";
3
+ /**
4
+ * Base mainnet (8453), with Hawk wired in as the chain's ENS —
5
+ * `getEnsName`, `getEnsAddress`, `getEnsText`, `getEnsAvatar` and every
6
+ * other viem/wagmi ENS action work out of the box against .hawk names.
7
+ */
8
+ export declare const base: Chain;
9
+ /** Base Sepolia testnet (84532), Hawk wired in. */
10
+ export declare const baseSepolia: Chain;
11
+ /**
12
+ * Wires Hawk resolution into any viem Chain object — the one-line
13
+ * integration for dapps that already have their own chain config:
14
+ *
15
+ * ```ts
16
+ * import { withHawk } from "hawk-names";
17
+ * const chain = withHawk(myBaseChainConfig);
18
+ * // viem's getEnsName / getEnsAddress now resolve .hawk
19
+ * ```
20
+ */
21
+ export declare function withHawk(chain: Chain, addresses?: HawkAddresses): Chain;
package/dist/chains.js ADDED
@@ -0,0 +1,82 @@
1
+ import { defineChain } from "viem";
2
+ import { HAWK_ADDRESSES } from "./addresses.js";
3
+ const ZERO = "0x0000000000000000000000000000000000000000";
4
+ function ensContracts(addresses) {
5
+ if (!addresses || addresses.registry === ZERO)
6
+ return {};
7
+ return {
8
+ ensRegistry: { address: addresses.registry },
9
+ ensUniversalResolver: { address: addresses.universalResolver },
10
+ };
11
+ }
12
+ /**
13
+ * Base mainnet (8453), with Hawk wired in as the chain's ENS —
14
+ * `getEnsName`, `getEnsAddress`, `getEnsText`, `getEnsAvatar` and every
15
+ * other viem/wagmi ENS action work out of the box against .hawk names.
16
+ */
17
+ export const base = defineChain({
18
+ id: 8453,
19
+ name: "Base",
20
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
21
+ rpcUrls: {
22
+ default: { http: ["https://mainnet.base.org"] },
23
+ },
24
+ blockExplorers: {
25
+ default: {
26
+ name: "Basescan",
27
+ url: "https://basescan.org",
28
+ },
29
+ },
30
+ contracts: {
31
+ multicall3: {
32
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
33
+ },
34
+ ...ensContracts(HAWK_ADDRESSES[8453]),
35
+ },
36
+ });
37
+ /** Base Sepolia testnet (84532), Hawk wired in. */
38
+ export const baseSepolia = defineChain({
39
+ id: 84532,
40
+ name: "Base Sepolia",
41
+ testnet: true,
42
+ nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
43
+ rpcUrls: {
44
+ default: { http: ["https://sepolia.base.org"] },
45
+ },
46
+ blockExplorers: {
47
+ default: {
48
+ name: "Basescan",
49
+ url: "https://sepolia.basescan.org",
50
+ },
51
+ },
52
+ contracts: {
53
+ multicall3: {
54
+ address: "0xcA11bde05977b3631167028862bE2a173976CA11",
55
+ },
56
+ ...ensContracts(HAWK_ADDRESSES[84532]),
57
+ },
58
+ });
59
+ /**
60
+ * Wires Hawk resolution into any viem Chain object — the one-line
61
+ * integration for dapps that already have their own chain config:
62
+ *
63
+ * ```ts
64
+ * import { withHawk } from "hawk-names";
65
+ * const chain = withHawk(myBaseChainConfig);
66
+ * // viem's getEnsName / getEnsAddress now resolve .hawk
67
+ * ```
68
+ */
69
+ export function withHawk(chain, addresses) {
70
+ const hawk = addresses ?? HAWK_ADDRESSES[chain.id];
71
+ if (!hawk || hawk.registry === ZERO) {
72
+ throw new Error(`No Hawk deployment known for chain ${chain.id} — pass addresses explicitly.`);
73
+ }
74
+ return {
75
+ ...chain,
76
+ contracts: {
77
+ ...chain.contracts,
78
+ ensRegistry: { address: hawk.registry },
79
+ ensUniversalResolver: { address: hawk.universalResolver },
80
+ },
81
+ };
82
+ }