ENS Manager
Complete ENS name management: register new .eth names, create subdomains, and publish IPFS content to decentralized gateways.
Quick Start
Register New ENS Name
CODEBLOCK0
What happens:
- 1. Phase 1: Makes commitment on-chain (anti-frontrunning)
- Phase 2: Waits 60 seconds (required minimum)
- Phase 3: Registers name with payment
Cost: ~$5-20 USD/year (varies by name length and demand)
Check ENS Name Status
CODEBLOCK1
Shows ownership, wrapped status, resolver, and content hash.
Create Subdomain with IPFS
CODEBLOCK2
Creates subdomain.yourname.eth and sets its IPFS content hash in one command.
Complete Workflows
1. Register New ENS Name (Full Process)
Scenario: You want to own INLINECODE2
Step 1: Check Availability
CODEBLOCK3
Output:
CODEBLOCK4
Step 2: Register
CODEBLOCK5
What happens (three phases):
Phase 1: Commitment (TX 1)
CODEBLOCK6
The commitment hash prevents frontrunning (someone stealing your name by seeing your TX and submitting theirs first with higher gas).
Phase 2: Wait 60 Seconds
CODEBLOCK7
This mandatory wait ensures your commitment is on-chain before registration.
Phase 3: Registration (TX 2 with payment)
CODEBLOCK8
Total time: ~2-3 minutes (60s wait + TX confirmations)
Total cost: Registration price + ~$2-4 gas (at 10 gwei)
2. Publishing a Website to ENS
Scenario: You have a static website and want to publish it at INLINECODE3
Prerequisites
- - You own
yourname.eth (registered via Step 1 or app.ens.domains) - Website files ready
- IPFS access (local node or Infura/Pinata)
Steps
1. Add website to IPFS:
CODEBLOCK9
2. Create ENS subdomain and set content hash:
CODEBLOCK10
3. Access your site:
Open https://meetup.yourname.eth.limo in any browser!
Cost: ~$0.05 (at 0.1 gwei base fee)
3. Updating IPFS Content
Scenario: You updated your website and have a new IPFS CID
Option A: Use viem directly
CODEBLOCK11
Option B: Use ENS App
- 1. Go to https://app.ens.domains/subdomain.yourname.eth
- Click "Records"
- Edit "Content Hash"
- Paste new IPFS CID
- Save (sign TX)
4. Checking What's Published
CODEBLOCK12
Shows current IPFS CID and eth.limo URL.
Contract Addresses (Ethereum Mainnet)
All operations use these addresses:
CODEBLOCK13
Where they're used:
- - ENSREGISTRY: Base registry for all names (ownership, resolvers)
- ETHREGISTRARCONTROLLER: Register/renew
.eth names (3-phase process) - NAMEWRAPPER: Create subdomains for wrapped names
- PUBLIC_RESOLVER: Resolve names to addresses/content hashes
Three-Phase Registration Process
Why Three Phases?
Problem: If you submit a registration transaction, miners or bots can see it in the mempool and frontrun you (submit their own TX with higher gas to steal the name).
Solution: Commitment scheme prevents this:
- 1. Commit: Submit a hash of (name + secret). No one knows what name you want.
- Wait: 60 seconds minimum. Your commitment is now on-chain and timestamped.
- Register: Reveal the name + secret. Since your commitment was earlier, you win.
Phase 1: Commitment
What happens:
CODEBLOCK14
Gas cost: ~45,000 gas (~$1-2 at 10 gwei)
Phase 2: Wait
Mandatory 60-second wait ensures:
- - Your commitment is confirmed on-chain
- Timestamp is set
- You can't be frontrun
Technical reason: The contract checks that block.timestamp >= commitmentTimestamp + 60 seconds when you register.
Phase 3: Registration
What happens:
CODEBLOCK15
Gas cost: ~150,000 gas (~$3-5 at 10 gwei) + registration price
Total registration: ~$4-7 gas + registration price (~$5-20/year)
Wrapped vs Unwrapped Names
Check if wrapped:
CODEBLOCK16
Look for "🎁 Wrapped (NameWrapper)" or "📦 Unwrapped (Registry)".
Key differences:
| Feature | Wrapped | Unwrapped |
|---|
| Subdomain creation | INLINECODE8 | INLINECODE9 + INLINECODE10 |
| Label parameter |
String (
"meetup") | Bytes32 hash (keccak256) |
| Owner location | NameWrapper ERC-1155 | Registry mapping |
| Advanced features | Fuses, expiry | None |
The create-subdomain-ipfs.js script handles both automatically.
Current vs Typical Gas Costs
Gas costs vary based on network congestion. The skill shows real-time costs during dry-run.
Registration (2 TXs)
Current conditions (0.22 gwei - very low):
- - Commitment: 45,000 gas = $0.02
- Registration: 265,000 gas = $0.15
- Total gas: $0.17
Typical conditions (10 gwei - normal):
- - Commitment: 45,000 gas = $1.13
- Registration: 265,000 gas = $6.63
- Total gas: $7.75
ENS Name Pricing Tiers (Annual Rental)
| Name Length | Cost/Year | Example |
|---|
| 3 characters | ~$773 | INLINECODE13 |
| 4 characters |
~$193 |
cool.eth |
| 5+ characters | ~$6 |
hello.eth,
example.eth |
Complete Registration Examples
5-letter name (most common):
- - Current: Name ($6) + Gas ($0.17) = $6.17 total
- Typical: Name ($6) + Gas ($7.75) = $13.75 total
4-letter name:
- - Current: Name ($193) + Gas ($0.17) = $193.17 total
- Typical: Name ($193) + Gas ($7.75) = $200.75 total
Recommendation: Use --dry-run to check current costs before registering.
See COSTS.md for detailed cost breakdowns and optimization tips.
Troubleshooting
Registration: "Name not available"
The name is already registered. Try:
CODEBLOCK17
To see who owns it and when it expires.
Registration: "insufficient funds"
You need ETH for:
- 1. Registration price (~$5-20 for most names)
- Gas fees (~$4-7)
Check balance:
CODEBLOCK18
Registration: "Commitment not found" or "Too soon"
If you see this during Phase 3:
- - Too soon: Wait the full 60 seconds
- Commitment not found: Your Phase 1 TX didn't confirm yet. Wait longer or check TX status.
Transaction reverts
Common causes:
- 1. Not the owner - You must own the parent name to create subdomains
- Name is wrapped - Use NameWrapper methods, not Registry
- Gas limit too low - Increase
gas parameter - Commitment too old - If you wait >24 hours between Phase 1 and 3, start over
Content not appearing on eth.limo
- 1. Wait a few minutes (DNS propagation)
- Check content hash is set: INLINECODE19
- Verify IPFS CID is accessible: INLINECODE20
- Check resolver is PUBLIC_RESOLVER (most gateways only read from it)
Manual Operations (Advanced)
Unwrapped Name: Create Subdomain
CODEBLOCK19
Wrapped Name: Create Subdomain
CODEBLOCK20
IPFS Content Hash
Encoding CID
CODEBLOCK21
Setting Content Hash
CODEBLOCK22
Reading Content Hash
CODEBLOCK23
Gateway Access
After setting a content hash, the subdomain becomes accessible via:
- - eth.limo: INLINECODE21
- eth.link: INLINECODE22
- IPFS directly: INLINECODE23
- dweb.link: INLINECODE24
Note: eth.limo/eth.link may take a few minutes to update after setting a new content hash.
Resources
- - ENS Documentation: https://docs.ens.domains
- eth.limo: https://eth.limo
- ENS App (UI): https://app.ens.domains
- NameWrapper Guide: https://docs.ens.domains/wrapper/overview
- Content Hash Spec: See INLINECODE25
- Registrar Controller: https://etherscan.io/address/0x253553366Da8546fC250F225fe3d25d0C782303b
For detailed ENS concepts, wrapped vs unwrapped differences, and content hash encoding, read references/ens-basics.md.
ENS 管理器
完整的ENS名称管理:注册新的.eth名称、创建子域名,并将IPFS内容发布到去中心化网关。
快速开始
注册新的ENS名称
bash
检查可用性和价格(预演模式)
node scripts/register-ens-name.js mynewname --dry-run
注册1年
node scripts/register-ens-name.js mynewname \
--years 1 \
--keystore /path/to/keystore.enc \
--password your-password
执行流程:
- 1. 阶段1: 在链上提交承诺(防止抢跑)
- 阶段2: 等待60秒(最低要求)
- 阶段3: 支付费用并注册名称
费用: 约5-20美元/年(根据名称长度和需求浮动)
检查ENS名称状态
bash
node scripts/check-ens-name.js yourname.eth
显示所有权、封装状态、解析器和内容哈希。
创建带IPFS的子域名
bash
node scripts/create-subdomain-ipfs.js yourname.eth subdomain QmIPFS123... \
--keystore /path/to/keystore.enc \
--password your-password
一键创建subdomain.yourname.eth并设置其IPFS内容哈希。
完整工作流程
1. 注册新的ENS名称(完整流程)
场景: 您希望拥有mynewname.eth
步骤1:检查可用性
bash
node scripts/register-ens-name.js mynewname --dry-run
输出:
🦞 ENS名称注册
========================
📛 名称:mynewname.eth
⏱️ 时长:1年
🔍 正在检查可用性...
✅ 名称可用!
💰 正在计算价格...
注册费用:0.008 ETH
(1年)
✅ 预演完成。
步骤2:注册
bash
node scripts/register-ens-name.js mynewname \
--years 1 \
--keystore ~/.openclaw/workspace/wallet-keystore.enc \
--password keystore-password
执行流程(三个阶段):
阶段1:提交承诺(交易1)
📝 阶段1:正在提交承诺...
承诺:0xabc123...
密钥:0xdef456...
交易哈希:0x789...
等待确认中...
承诺哈希可防止抢跑(他人看到您的交易后,通过提高Gas费抢先提交自己的交易来抢注名称)。
阶段2:等待60秒
⏳ 阶段2:等待60秒(防抢跑保护)...
剩余60秒...
剩余59秒...
...
✅ 等待完成!
此强制等待确保您的承诺在注册前已上链。
阶段3:注册(含支付的交易2)
📝 阶段3:正在注册名称...
发送0.008 ETH...
交易哈希:0xghi789...
🎉 注册完成!
📛 您的ENS名称:mynewname.eth
🔍 在ENS上查看:https://app.ens.domains/mynewname.eth
🔗 注册交易:https://etherscan.io/tx/0xghi789...
后续步骤:
1. 设置地址:ens.domains → 记录 → ETH地址
2. 创建子域名:node create-subdomain-ipfs.js
3. 设置反向记录:ens.domains → 我的账户 → 主名称
总耗时: 约2-3分钟(60秒等待 + 交易确认)
总费用: 注册价格 + 约2-4美元Gas费(10 gwei时)
2. 将网站发布到ENS
场景: 您有一个静态网站,希望发布到meetup.yourname.eth.limo
前置条件
- - 您拥有yourname.eth(通过步骤1或app.ens.domains注册)
- 网站文件已就绪
- IPFS访问权限(本地节点或Infura/Pinata)
步骤
1. 将网站添加到IPFS:
bash
ipfs add -r ./website
输出:added QmABC123... website
2. 创建ENS子域名并设置内容哈希:
bash
node scripts/create-subdomain-ipfs.js yourname.eth meetup QmABC123... \
--keystore ~/.openclaw/workspace/wallet-keystore.enc \
--password keystore-password
3. 访问您的网站:
在任何浏览器中打开https://meetup.yourname.eth.limo!
费用: 约0.05美元(基础费用0.1 gwei时)
3. 更新IPFS内容
场景: 您更新了网站,有了新的IPFS CID
选项A:直接使用viem
javascript
const { createWalletClient, http, namehash } = require(viem);
const { mainnet } = require(viem/chains);
const contentHash = require(content-hash);
const node = namehash(subdomain.yourname.eth);
const encodedHash = 0x + contentHash.encode(ipfs-ns, newCid);
await walletClient.writeContract({
address: PUBLIC_RESOLVER,
abi: [{
name: setContenthash,
type: function,
stateMutability: nonpayable,
inputs: [
{ name: node, type: bytes32 },
{ name: hash, type: bytes }
],
outputs: []
}],
functionName: setContenthash,
args: [node, encodedHash]
});
选项B:使用ENS应用
- 1. 访问 https://app.ens.domains/subdomain.yourname.eth
- 点击记录
- 编辑内容哈希
- 粘贴新的IPFS CID
- 保存(签署交易)
4. 检查已发布内容
bash
node scripts/check-ens-name.js meetup.yourname.eth
显示当前IPFS CID和eth.limo URL。
合约地址(以太坊主网)
所有操作均使用以下地址:
javascript
// 核心ENS合约
const ENS_REGISTRY = 0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e;
// 注册(.eth名称)
const ETHREGISTRARCONTROLLER = 0x253553366Da8546fC250F225fe3d25d0C782303b;
// 封装名称(现代版,带熔断器)
const NAME_WRAPPER = 0xD4416b13d2b3a9aBae7AcD5D6C2BbDBE25686401;
// 默认解析器(最常用)
const PUBLIC_RESOLVER = 0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63;
使用场景:
- - ENSREGISTRY: 所有名称的基础注册表(所有权、解析器)
- ETHREGISTRARCONTROLLER: 注册/续费.eth名称(三阶段流程)
- NAMEWRAPPER: 为封装名称创建子域名
- PUBLIC_RESOLVER: 将名称解析为地址/内容哈希
三阶段注册流程
为什么需要三个阶段?
问题: 如果您提交注册交易,矿工或机器人可以在内存池中看到它并抢先交易(提交自己的交易,使用更高的Gas费来抢注名称)。
解决方案: 承诺方案可防止此情况:
- 1. 提交承诺: 提交(名称+密钥)的哈希值。没有人知道您想要什么名称。
- 等待: 至少60秒。您的承诺现已上链并带有时间戳。
- 注册: 揭示名称+密钥。由于您的承诺更早,您将获胜。
阶段1:提交承诺
执行过程:
javascript
const commitment = keccak256(
encodePacked(
[string, address, uint256, bytes32, address, bytes[], bool, uint16],
[
name, // mynewname(不含.eth)
owner, // 您的钱包地址
duration, // 31536000(1年,以秒计)
secret, // 随机bytes32(已生成)
resolver, // PUBLIC_RESOLVER
[], // 数据(基础注册为空)
true, // reverseRecord(设置主名称)