Installation
Install @ensforge/contracts, the ENS ABIs, addresses and constants for viem, and pick the entry point that fits what you need.
@ensforge/contracts holds the ENS contract ABIs, deployment addresses and protocol constants such as interface IDs and role bitmaps. It has no runtime dependencies beyond the viem peer, and it does not depend on Effect or on @ensforge/sdk, so you can use it alone.
Requirements
- Node.js 20.19 or later.
viemversion 2.57 or later.
1. Install the package
npm install @ensforge/contracts viem2. Import what you need
The root entry point has four namespaces:
| Namespace | What it holds |
|---|---|
Abis | ABIs as as const arrays, in Abis.v1, Abis.v2 and Abis.shared. |
Deployments | Addresses, behaviour flags and provenance for mainnet and Sepolia. |
InterfaceIds | ERC-165 interface IDs of registries, resolvers and resolver profiles. |
Roles | ENSv2 role bitmaps for registries and resolvers. |
Example (Importing the Namespaces)
import { Abis, Deployments, InterfaceIds, Roles } from "@ensforge/contracts";
const registryAbi = Abis.v2.permissionedRegistry;
const ethRegistry = Deployments.mainnet.v2.contracts.ethRegistry;
const permissionedResolverId = InterfaceIds.resolver.permissionedResolver;
const renewRole = Roles.registry.renew;Subpath entry points
The same ABIs and constants are also available as flat named exports, which suit bundlers that tree-shake by file.
| Import | What it holds |
|---|---|
@ensforge/contracts/v1 | ENSv1 ABIs and constants, such as baseRegistrarV1Abi. |
@ensforge/contracts/v2 | ENSv2 ABIs, interfaces, role and interface-ID constants and helpers, such as permissionedRegistryV2Abi. |
@ensforge/contracts/shared | ABIs both protocol versions share: token standards, ERC-165, resolver profiles, errors, events. |
@ensforge/contracts/v2/experimental/hca | The experimental HCA (Hosted Contract Account) ABIs and session helpers. |
See the entry points reference for every export.
Use it with the SDK
@ensforge/sdk depends on this package. Use @ensforge/contracts directly when you read or write contracts with viem yourself. See Use ABIs with viem.
Was this page helpful?