@ensnode/datasources 0.28.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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 NameHash
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # @ensnode/datasources
2
+
3
+ This package provides contract configurations (chain, names, addresses, abis) for each known **ENS Namespace**. An ENS Namespace represents a single, unified set of ENS names with a distinct onchain `ensroot` **Datasource** and an optional set of additional **Datasource**s on different chains (and, in the future, offchain datasources).
4
+
5
+ For example, the canonical ENS Namespace on mainnet includes:
6
+
7
+ - A `ensroot` Datasource documenting the ENS contracts on mainnet, including the `.eth` subregistry
8
+ - A `basenames` Datasource documenting the Basenames contracts on Base, including the `.base.eth` subregistry
9
+ - A `lineanames` Datasource documenting the Basenames contracts on Linea, including the `.linea.eth` subregistry
10
+ - The `threedns-optimism` and `threedns-base` Datasources documenting the 3DNS contracts on Optimism and Base, respectively
11
+ - 🚧 Various offchain Datasources (e.g. `.cb.id`, `.uni.eth`)
12
+
13
+ Each ENS namespace is logically independent and isolated from the others: for instance, the `sepolia` and `holesky` testnet namespaces manage a set of names that is entirely separate from the canonical `mainnet` namespace, and have distinct `basenames` and `lineanames` **Datasource**s defined.
14
+
15
+ The `ens-test-env` namespace describes the contracts deployed to an _Anvil_ chain for development and testing with the [ens-test-env](https://github.com/ensdomains/ens-test-env) tool.
16
+
17
+ ## Usage
18
+
19
+ To use these configurations in your project:
20
+
21
+ ```ts
22
+ import { getDatasource } from "@ensnode/datasources";
23
+ import { namehash } from "viem";
24
+
25
+ // access the address and abi for the ens root Registry in the canonical mainnet ENS namespace
26
+ const registryConfig = getDatasource('mainnet', 'ensroot').contracts.Registry;
27
+
28
+ // for example, querying the Registry with viem...
29
+ const vitaliksResolverAddress = await publicClient.readContract({
30
+ abi: registryConfig.abi,
31
+ address: registryConfig.address,
32
+ functionName: "resolver",
33
+ args: [namehash("vitalik.eth")],
34
+ });
35
+ ```
36
+
37
+ [See the usage of `@ensnode/datasources` within ENSIndexer for additional context.](https://github.com/namehash/ensnode/blob/main/apps/ensindexer)
38
+
39
+ ## Documentation
40
+
41
+ ### getDatasource(namespace: ENSNamespace, datasourceName: DatasourceName)
42
+
43
+ The primary export of `@ensnode/datasources` is `getDatasource` which returns a selected `Datasource` within the selected ENS namespace.
44
+
45
+ ```ts
46
+ import { getDatasource } from '@ensnode/datasources';
47
+
48
+ // get ensroot datasource relative to mainnet ENS namespace
49
+ const { chain, contracts } = getDatasource('mainnet', 'ensroot');
50
+
51
+ // get ensroot datasource relative to holesky ENS namespace
52
+ const { chain, contracts } = getDatasource('holesky', 'ensroot');
53
+
54
+ // get threedns-base datasource relative to mainnet ENS namespace
55
+ const { chain, contracts } = getDatasource('mainnet', 'threedns-base');
56
+ ```
57
+
58
+ The available `ENSNamespace`s are:
59
+ - `mainnet`
60
+ - `sepolia`
61
+ - `holesky`
62
+ - `ens-test-env` — Represents a local testing namespace running on an Anvil chain (chain id 1337) with deterministic configurations that deliberately start at block zero for rapid testing and development. See [ens-test-env](https://github.com/ensdomains/ens-test-env) for additional context.
63
+
64
+ ### DatasourceName
65
+
66
+ Each ENS namespace my provide **Datasource** entries for any of the possible **DatasourceName**s:
67
+
68
+ The available `DatasourceName`s are:
69
+ - `ensroot` — ENS Root Contracts
70
+ - `basenames` — Basenames
71
+ - `lineanames` — Linea Names
72
+ - `threedns-optimism` — 3DNS (on Optimism)
73
+ - `threedns-base` — 3DNS (on Base)
74
+
75
+ A `Datasource` will only be available within an ENS namespace if it is defined, and typescript will enforce that a valid DatasourceName is used within `getDatasource(...)`.
76
+
77
+ ### Datasource
78
+
79
+ A Datasource describes a source `chain` and the set of contracts on that chain that integrate with the ENS protocol.
80
+
81
+ - `chain` — a `viem#Chain` object
82
+ - `contracts` — a `Record<DatasourceName, ContractConfig>`
83
+
84
+ ### ContractConfig
85
+
86
+ A `ContractConfig` defines the necessary information to interact with a specific contract within a Datasource, and is directly compatible with `ponder#ContractConfig` for ease of use within a [Ponder](https://ponder.sh) indexer.
87
+
88
+ - `abi` — the contract's ABI
89
+ - `address` — (optional) the contract's deployed address
90
+ - `filter` — (optional) array of event signatures to filter logs by
91
+ - `startBlock` — the block number when the contract was deployed
92
+
93
+ A contract can be located either by its static `address` or by filtering for specific event signatures. Note that either `address` or `filter` must be provided, but not both.
94
+
95
+ If a `filter` is provided, the relevant contract is _any_ contract on the indicated chain that emits events following the `filter` spec. This occurs, namely, for `Resolver` contracts — any contract that emits an event that looks like a `Resolver` event should be considered a `Resolver` for the purposes of indexing ENS data.
96
+
97
+ ## Contributions
98
+
99
+ We welcome community contributions and feedback—please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
100
+
101
+ ## Contact Us
102
+
103
+ Visit our [website](https://namehashlabs.org/) to get in contact, or [join us on Telegram](https://t.me/ensnode).
104
+
105
+ ## License
106
+
107
+ Licensed under the MIT License, Copyright © 2025-present [NameHash Labs](https://namehashlabs.org).
108
+
109
+ See [LICENSE](./LICENSE) for more information.