Skip to content

Latest commit

Β 

History

37 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ENS Contract - Ethereum Name Service Smart Contracts

Welcome to the ENS Contract repository! This project contains the core smart contracts and documentation for the Ethereum Name Service (ENS) system.

πŸ“‹ Table of Contents

Project Overview

The ENS Contract repository is the central hub for managing Ethereum Name Service smart contracts. ENS is a decentralized naming system built on the Ethereum blockchain that enables users to own and manage .eth domain names with advanced features including wrapping, emancipation, locking, and signature-based operations.

Repository: DMENTERPRISES/ens-contract
Branch: danish-main
Last Updated: 2026-04-05

πŸ“š Documentation

Core Documentation Files

This project includes comprehensive documentation for all major components:

  1. NameWrapper Documentation

    • Complete guide on wrapping ENS names into ERC1155 tokens
    • Advanced features: emancipation, locking, and fuse management
    • Function reference and state machine lifecycle
    • Installation, testing, and deployment instructions
    • Signature-based operations and upgrade procedures
  2. L2 Reverse Registrar Documentation

    • L2 Reverse Registrar contract implementation
    • Setting reverse records for addresses and contracts
    • Signature verification formats and authentication methods
    • Validator addresses for mainnet and testnet

Key Components

NameWrapper Contract

Location: ./contracts/wrapper/
Documentation: NameWrapper README

The NameWrapper adds powerful new functionality to ENS names:

  • ERC1155 Token Support: Convert ENS names at any level into ERC1155 tokens
  • Emancipation: Allow parent names to revoke control over subdomains
  • Locking: Enable name owners to protect their names from modifications
  • Fuses: Irreversible permission flags that control various aspects of name management
  • Expiry Management: Built-in expiration mechanisms for emancipated and locked names
  • Direct Registration: Register and wrap names in a single transaction
  • Subdomain Management: Create and manage wrapped subdomains directly

Key Features:

  • State machine lifecycle (Unregistered β†’ Unwrapped β†’ Wrapped β†’ Emancipated/Locked)
  • Owner-controlled and parent-controlled fuses
  • Signature-based authorization
  • Built-in upgrade capabilities

L2 Reverse Registrar Contract

Location: ./contracts/reverseRegistrar/
Documentation: Reverse Registrar README

The L2 Reverse Registrar combines resolver and reverse registrar functionality:

Methods for Setting Records:

  • setName() - Set record for msg.sender's address
  • setNameForAddr() - Set record for specific address (owner authorization required)
  • setNameForAddrWithSignature() - Set record with signature verification
  • setNameForOwnableWithSignature() - Set record for contracts with owner signature

Signature Formats:

For setNameForAddrWithSignature:

  • validatorAddress: 0xa4a5CaA360A81461158C96f2Dbad8944411CF3fd (mainnet) / 0xAe91c512BC1da8B00cd33dd9D9C734069e6E0fcd (testnet)
  • functionSignature: 0x2023a04c
  • name, addr, coinTypes, signatureExpiry

For setNameForOwnableWithSignature:

  • validatorAddress: 0xa4a5CaA360A81461158C96f2Dbad8944411CF3fd (mainnet) / 0xAe91c512BC1da8B00cd33dd9D9C734069e6E0fcd (testnet)
  • functionSignature: 0x975713ad
  • name, contractAddr, owner, coinTypes, signatureExpiry

Quick Start

Installation

npm install

Running Tests

npm run test

Test files use suffixes (e.g., _2) to indicate which account is performing operations for multi-user scenarios.

Deploying to Rinkeby Testnet

  1. Create environment file:

    cp .env.org .env
  2. Set your credentials in .env:

    PRIVATE_KEY=your_private_key
    ETHERSCAN_API_KEY=your_etherscan_api_key
    INFURA_API_KEY=your_infura_api_key
    METADATA_HOST=your_metadata_host (optional)
    

    Leave these fields blank:

    SEED_NAME=
    METADATA_ADDRESS=
    WRAPPER_ADDRESS=
    RESOLVER_ADDRESS=
    
  3. Run deployment:

    bun run deploy:rinkeby

    This will deploy contracts and automatically verify them on Etherscan.

Seeding Test Data

After deployment:

  1. Register a name using the deployed account
  2. Set SEED_NAME= to the label in .env (e.g., matoken for matoken.eth)
  3. Run:
    bun run seed:rinkeby

Project Structure

ens-contract/
β”œβ”€β”€ README.md                          # Main documentation (this file)
β”œβ”€β”€ contracts/
β”‚   β”œβ”€β”€ wrapper/
β”‚   β”‚   └── README.md                 # NameWrapper comprehensive guide
β”‚   β”‚       β”œβ”€β”€ Glossary of terms
β”‚   β”‚       β”œβ”€β”€ Name lifecycle states
β”‚   β”‚       β”œβ”€β”€ Fuse definitions and management
β”‚   β”‚       β”œβ”€β”€ Function reference
β”‚   β”‚       β”œβ”€β”€ Installation & testing
β”‚   β”‚       β”œβ”€β”€ Deployment procedures
β”‚   β”‚       └── Upgrade notes
β”‚   └── reverseRegistrar/
β”‚       └── README.md                 # L2 Reverse Registrar guide
β”‚           β”œβ”€β”€ Setting records
β”‚           └── Signature formats
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ deploy.js                      # Deployment script for Rinkeby
β”‚   └── seed.js                        # Seeding script for test data
└── .env.org                           # Environment template

πŸ”— Resources

Official ENS Resources

Solidity & Smart Contracts

Standards & Specifications

Testing & Verification

πŸ“– Important Notes

NameWrapper State Management

Names progress through several states during their lifecycle:

  • Unregistered β†’ Unwrapped β†’ Wrapped β†’ Emancipated/Locked

See the NameWrapper Documentation for detailed state information.

Fuse System

Fuses are irreversible permission flags that can be burned until expiry:

  • CANNOT_UNWRAP - Prevents unwrapping (enables Locked state)
  • CANNOT_BURN_FUSES - Locks all permissions
  • CANNOT_TRANSFER - Prevents transferring the name
  • CANNOT_SET_RESOLVER - Prevents changing resolver
  • CANNOT_CREATE_SUBDOMAIN - Prevents creating subdomains
  • PARENT_CANNOT_CONTROL - Emancipates the name from parent control

For complete fuse reference, see NameWrapper Fuses Documentation.

Expiry Management

Names can be extended using:

  • setChildFuses()
  • setSubnodeOwner()
  • setSubnodeRecord()
  • renew()
  • extendExpiry()

See Expiry Documentation for detailed information.

πŸ›  Development

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Bun (for running scripts with bun run)

Environment Setup

All development requires proper environment configuration. See Quick Start for setup instructions.

Testing Coverage

The test suite includes tests for all major functions. Tests that require multiple accounts use the _2 suffix convention.

πŸ“ License

Please refer to the repository for license information.

🀝 Contributing

For information on contributing to this project, please check the repository guidelines.

πŸ“ž Support

For issues, questions, or discussions:


Organization: DMENTERPRISES
Repository: ens-contract
Branch: danish-main
Created by: @danishahmed111
Date: April 5, 2026