Installation
This guide covers everything you need to set up your development environment for working with ENS v2 contracts.System Requirements
Node.js
Version 24 or higher
Foundry
Version 1.3.2 or higher
Bun
Version 1.2 or higher
Install Prerequisites
Install Foundry
Foundry is a blazing fast Ethereum development toolkit written in Rust.Verify installation:
For detailed installation instructions, see the Foundry Book.
Clone and Setup
Install Dependencies
Navigate to the contracts directory and install dependencies:This installs:
- JavaScript dependencies via Bun
- Solidity dependencies via Forge
Project Structure
After installation, your project structure will look like this:Configuration
Foundry Configuration
The project uses these Foundry settings (fromfoundry.toml):
Environment Variables
Create a.env file in the contracts directory for custom configuration:
Running Tests
Verify your installation by running the test suite:- All Tests
- Foundry Tests
- Hardhat Tests
- E2E Tests
Run the complete test suite:This runs both Foundry and Hardhat tests.
Before Running Tests
Before running tests, compile the ENS v1 contracts dependency:This only needs to be done once after initial setup.
Development Workflow
Start Local Devnet
The easiest way to develop is using the local devnet:- Native Devnet
- Docker Devnet
Recommended approach:This starts a local chain at:
- URL:
http://localhost:8545 - Chain ID:
31337
- All ENS v2 contracts deployed
- Pre-configured test accounts with ETH
- ETH Registry with .eth TLD
- Universal Resolver
- Mock ERC20 tokens for testing
Code Formatting
Format Solidity code:Linting
Run Solidity linter:Gas Snapshots
Generate gas usage snapshots:Coverage Reports
Generate test coverage reports:- Foundry coverage (
coverage/forge.lcov) - Hardhat coverage (
coverage/hardhat.lcov) - Combined HTML reports
IDE Setup
Visual Studio Code
Recommended extensions:- Solidity by Juan Blanco
- Hardhat Solidity by Nomic Foundation
- Prettier - Code formatter
VSCode Settings
Add to.vscode/settings.json:
Vim/Neovim
Install Solidity syntax highlighting:Troubleshooting
Compilation Errors
Compilation Errors
If you encounter compilation errors:
-
Clean build artifacts:
-
Reinstall dependencies:
-
Rebuild:
Test Failures
Test Failures
If tests fail:
-
Ensure ENS v1 contracts are compiled:
-
Run tests with verbose output:
-
Run specific test:
Devnet Won't Start
Devnet Won't Start
If the devnet fails to start:
-
Check if port 8545 is in use:
-
Kill any existing processes:
-
Try restarting:
Out of Memory Errors
Out of Memory Errors
If you encounter out of memory errors during compilation:
- The project is configured to NOT use
--via-irto avoid stack too deep errors - If you modify contracts and hit stack too deep, refactor the code instead of enabling
--via-ir - Increase Node.js memory limit:
Additional Tools
Foundry provides additional useful tools:Cast
Command-line tool for Ethereum RPC calls:Anvil
Local Ethereum node (used by devnet):Chisel
Solidity REPL for testing snippets:Next Steps
Quickstart
Deploy and interact with contracts
Core Concepts
Learn the architecture
Testing Guide
Write and run tests
Deployment
Deploy to testnet or mainnet
Getting Help
If you run into issues:- GitHub Issues: Report bugs or request features
- ENS Discord: Join the ENS community
- Documentation: Read the ENS v2 design doc