Contract Overview
Location:contracts/dnsregistrar/DNSRegistrar.sol
Inheritance: IDNSRegistrar, IERC165
The DNSRegistrar bridges traditional DNS with ENS by:
- Accepting DNSSEC proofs of DNS ownership
- Validating proofs through the DNSSEC oracle
- Creating ENS records for proven DNS domains
- Managing the public suffix list
State Variables
Immutable References
ens: The ENS registry contractoracle: The DNSSEC oracle for proof validationpreviousRegistrar: Previous registrar for migration supportresolver: Default resolver for claimed domains
Public Suffix List
Inception Tracking
Constructor
_previousRegistrar: Address of the previous registrar for migration_resolver: Default resolver address for new domains_dnssec: DNSSEC oracle contract_suffixes: Public suffix list contract_ens: ENS registry contract
Core Functions
proveAndClaim
Submits DNSSEC proofs and claims a DNS name in ENS.name: The DNS name to claim, in DNS wire formatinput: Chain of signed DNS RRSETs ending with a TXT record proving ownership
- Verifies the DNSSEC proof through the oracle
- Validates the parent domain is an enabled public suffix
- Checks for a TXT record at
_ens.<name>containing the owner address - Sets the ENS owner to the address from the TXT record
proveAndClaimWithResolver
Claims a DNS name and sets a custom resolver and address in one transaction.name: The DNS name to claiminput: Chain of signed DNS RRSETsresolver: Custom resolver address to setaddr: Address to set in the resolver (optional, use address(0) to skip)
msg.sendermust match the owner specified in the DNS TXT record- If
addris provided,resolvermust not be address(0)
enableNode
Enables a public suffix node in ENS, making it available for claiming.domain: The domain to enable, in DNS wire format
- Domain must be in the public suffix list
- Validates domain is a recognized public suffix
- Recursively creates parent nodes if needed
- Sets the registrar as owner of intermediate nodes
- Sets the default resolver for the node
Administrative Functions
setPublicSuffixList
Updates the public suffix list contract._suffixes: New PublicSuffixList contract address
NewPublicSuffixList(address suffixes)
Internal Functions
_claim
Internal function that handles the core claiming logic.- Verifies the DNSSEC proof through the oracle
- Extracts the first label and parent name
- Enables the parent node if needed
- Validates proof is not stale using inception time
- Extracts owner address from TXT record
- Emits Claim event
parentNode: ENS node of the parent domainlabelHash: Keccak256 hash of the claimed labeladdr: Owner address from the TXT record
_enableNode
Recursively enables a domain and its parents in ENS.domain: Domain in DNS wire formatoffset: Current offset in the domain name
- Recursively processes from right to left (TLD to subdomain)
- Creates ENS records for unclaimed nodes
- Sets registrar as owner of intermediate nodes
- Takes over nodes owned by the previous registrar
Events
Claim
Emitted when a DNS name is successfully claimed.node: ENS node hash of the claimed nameowner: Ethereum address that now owns the namednsname: DNS name in wire formatinception: Signature inception time from the DNSSEC proof
NewPublicSuffixList
Emitted when the public suffix list is updated.suffixes: Address of the new PublicSuffixList contract
Errors
NoOwnerRecordFound
PermissionDenied
msg.sender doesn’t match the required owner.
PreconditionNotMet
StaleProof
InvalidPublicSuffix
DNS Wire Format
DNS names must be provided in DNS wire format, which encodes labels with length prefixes: Example:example.com becomes:
\x07= length of “example” (7 bytes)example= the label\x03= length of “com” (3 bytes)com= the label\x00= root label (empty)
TXT Record Format
The owner TXT record must be placed at_ens.<yourdomain> and contain:
Public Suffix List
The PublicSuffixList interface:comis a public suffix (can be used as parent)example.comis NOT a public suffix (cannot be used as parent for other claims)
Integration Example
Security Considerations
Proof Validation
All DNSSEC proofs are validated through the oracle before accepting claims. This ensures:- Signatures are cryptographically valid
- Chain of trust extends to root anchors
- Signatures are temporally valid
Stale Proof Prevention
The inception tracking prevents replay of old DNSSEC signatures:Ownership Changes
To change ownership of a DNS-claimed ENS name:- Update the DNS TXT record with the new address
- Submit a new DNSSEC proof with
proveAndClaim
Related Contracts
- DNSSEC Oracle - Validates DNSSEC proofs
- DNSClaimChecker - Parses TXT records
- RRUtils - DNS record utilities