
Security News
pnpm 11.10 Hardens Registry Authentication to Block Token Redirection
pnpm 11.10 hardens registry auth to block token redirection, tightens pack-app and deploy, and makes the Rust port (v12) installable.
@ensdomains/ens-contracts
Advanced tools
For documentation of the ENS system, see docs.ens.domains.
This repo doubles as an npm package with the compiled JSON contracts
import {
BaseRegistrar,
BaseRegistrarImplementation,
BulkRenewal,
ENS,
ENSRegistry,
ENSRegistryWithFallback,
ETHRegistrarController,
FIFSRegistrar,
LinearPremiumPriceOracle,
PriceOracle,
PublicResolver,
Resolver,
ReverseRegistrar,
StablePriceOracle,
TestRegistrar,
} from '@ensdomains/ens-contracts'
// Registry
import '@ensdomains/ens-contracts/contracts/registry/ENS.sol';
import '@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol';
import '@ensdomains/ens-contracts/contracts/registry/ENSRegistryWithFallback.sol';
import '@ensdomains/ens-contracts/contracts/registry/ReverseRegistrar.sol';
import '@ensdomains/ens-contracts/contracts/registry/TestRegistrar.sol';
// EthRegistrar
import '@ensdomains/ens-contracts/contracts/ethregistrar/BaseRegistrar.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/BaseRegistrarImplementation.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/BulkRenewal.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/ETHRegistrarController.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/LinearPremiumPriceOracle.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/PriceOracle.sol';
import '@ensdomains/ens-contracts/contracts/ethregistrar/StablePriceOracle.sol';
// Resolvers
import '@ensdomains/ens-contracts/contracts/resolvers/PublicResolver.sol';
import '@ensdomains/ens-contracts/contracts/resolvers/Resolver.sol';
If your environment does not have compiler, you can access to the raw hardhat artifacts files at node_modules/@ensdomains/ens-contracts/artifacts/contracts/${modName}/${contractName}.sol/${contractName}.json
The ENS registry is the core contract that lies at the heart of ENS resolution. All ENS lookups start by querying the registry. The registry maintains a list of domains, recording the owner, resolver, and TTL for each, and allows the owner of a domain to make changes to that data. It also includes some generic registrars.
Interface of the ENS Registry.
Implementation of the ENS Registry, the central contract used to look up resolvers and owners for domains.
The new implementation of the ENS Registry after the 2020 ENS Registry Migration.
Implementation of a simple first-in-first-served registrar, which issues (sub-)domains to the first account to request them.
Implementation of the reverse registrar responsible for managing reverse resolution via the .addr.reverse special-purpose TLD.
Implementation of the .test registrar facilitates easy testing of ENS on the Ethereum test networks. Currently deployed on Ropsten network, it provides functionality to instantly claim a domain for test purposes, which expires 28 days after it was claimed.
Implements an ENS registrar intended for the .eth TLD.
These contracts were audited by ConsenSys Diligence; the audit report is available here.
BaseRegistrar is the contract that owns the TLD in the ENS registry. This contract implements a minimal set of functionality:
This separation of concerns provides name owners strong guarantees over continued ownership of their existing names, while still permitting innovation and change in the way names are registered and renewed via the controller mechanism.
EthRegistrarController is the first implementation of a registration controller for the new registrar. This contract implements the following functionality:
The commit/reveal process is used to avoid frontrunning, and operates as follows:
The minimum delay and expiry for commitments exist to prevent miners or other users from effectively frontrunning registrations.
SimplePriceOracle is a trivial implementation of the pricing oracle for the EthRegistrarController that always returns a fixed price per domain per year, determined by the contract owner.
StablePriceOracle is a price oracle implementation that allows the contract owner to specify pricing based on the length of a name, and uses a fiat currency oracle to set a fixed price in fiat per name.
Resolver implements a general-purpose ENS resolver that is suitable for most standard ENS use cases. The public resolver permits updates to ENS records by the owner of the corresponding name.
PublicResolver includes the following profiles that implements different EIPs.
ABI()).addr()).contenthash()).supportsInterface()).name()).pubkey()).text()).This repo runs a husky precommit to prettify all contract files to keep them consistent. Add new folder/files to prettier format script in package.json. If you need to add other tasks to the pre-commit script, add them to .husky/pre-commit
git clone https://github.com/ensdomains/ens-contracts
cd ens-contracts
bun i
bun run test
bun run pub
The only contract in this repo deployed on L2s is L2ReverseRegistrar (and its dependency UniversalSigValidator).
Anyone can deploy this contract onto any L2, however the contract has functionality which allows using one signature across multiple L2s. Given this functionality, and EIP-191's requirement for the intended validator address in the signature, the contract address needs to stay the same between all networks.
To allow for a unified contract address, a Safe and a helper CREATE3 contract are used in the deployment process. The contract can be deployed outside the process, but it means that it will lack the multi-chain signature functionality.
Testnet Safe address: 0x343431e9CEb7C19cC8d3eA0EE231bfF82B584910
Mainnet Safe address: 0x353530FE74098903728Ddb66Ecdb70f52e568eC1
When readying a new deployment of certain contracts, bump the deploy script version number to the appropriate new version. Doing this ensures that the new deployment script will run for each network.
Deployment scripts can be run for any specified network found in the config, with the following:
bun hh --network <network_name> deploy
Only scripts that haven't been run on the specified network before will be run.
To test deploying contracts and the functionality of them after deployment, there are two basic paths for forking:
anvil --fork-url <url>)When access to the owner account is available (testnet only - owner on mainnet is the DAO), you can deploy straight to the fork by replacing the forked network's URL in the hardhat config with your RPC:
const config = {
// ... existing config
networks: {
targetNetwork: {
// ... other network config
url: 'tenderly-or-anvil-url-here',
},
},
}
Without access to the owner account, you can deploy via the impersonation script, which makes impersonated accounts from an external node available to hardhat.
./scripts/deploy-with-impersonation.ts --rpc-url <url> --accounts <addr1> [addr2 ...] [--tags <tags>]
# Testnet usage
./scripts/deploy-with-impersonation.ts --rpc-url <url> --accounts 0x0F32b753aFc8ABad9Ca6fE589F707755f4df2353
# Mainnet usage
./scripts/deploy-with-impersonation.ts --rpc-url <url> --accounts 0xFe89cc7aBB2C4183683ab71653C4cdc9B02D44b7
feature branch from staging branchstagingv1.2.3-RC0. This tagged commit is now subject to our bug bounty.v1.2.3-RC0 -> v.1.2.3-RC1. Repeat as necessary.feature branch. Create GitHub release of the form v1.2.3-testnet from the commit that has the new deployment artifacts.staging branch.staging. Create a GitHub release of the form v1.2.3 from the commit that has the new deployment artifacts.main. Have it reviewed and merged.Certain changes can be released in isolation via cherry-picking, although ideally we would always release from staging.
mainnet.staging into new branch.mainnet.main, make fixes, deploy to testnet (can skip), deploy to mainnetmain and staging immediately after deploystaging.staging branch and main branch should start in syncstaging is intended to be a practice main. Only code that is intended to be released to main can be merged to staging. Consequently:
stagingstaging and main should be deployed to testnet and mainnet respectively i.e. these branches should not have any undeployed codestaging and main will always be a subset of what is deployed, as smart contracts cannot be undeployed.staging and main branch are subject to our bug bountyFAQs
ENS contracts
The npm package @ensdomains/ens-contracts receives a total of 3,562 weekly downloads. As such, @ensdomains/ens-contracts popularity was classified as popular.
We found that @ensdomains/ens-contracts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.10 hardens registry auth to block token redirection, tightens pack-app and deploy, and makes the Rust port (v12) installable.

Security News
/Research
Socket uncovered 17 malicious npm and PyPI packages typosquatting Paysafe, Skrill, and Neteller SDKs to steal developer secrets.

Security News
Node.js is debating whether AI-driven security report volume warrants moving more vulnerability reports into public workflows.