Introduction to ENS Subdomains
Ethereum Name Service (ENS) subdomains extend the functionality of primary ENS domains by allowing users to create hierarchical name spaces. A subdomain is an independent name that exists under a parent domain—for example, "pay.vitalik.eth" is a subdomain of "vitalik.eth". Each subdomain can hold its own set of records, including cryptocurrency addresses, content hashes, and text records, while remaining fully controlled by the parent domain owner. This guide addresses the most common technical questions and operational procedures for creating and managing ETH subdomains.
What Exactly Is an ETH Subdomain and How Does It Differ from a Primary Domain?
An ETH subdomain is a name registered under an existing ENS domain, but it is not registered on the ENS registry in the same way as a top-level .eth domain. The key distinction lies in ownership and registration:
- Primary domain: Registered directly on the ENS registry contract, with a fixed rental period (usually 1+ years) requiring renewal. Ownership is recorded on-chain.
- Subdomain: Created by the domain owner through the resolver contract. Subdomains do not require separate ETH payments or renewals—they exist as long as the parent domain is valid and the owner chooses to keep them.
- Control: The parent domain owner can create, modify, or delete subdomains at will. Subdomain owners (if transferred) only control records, not the subdomain's existence.
This architecture makes subdomains ideal for temporary allocations, organizational hierarchies, or personal aliases where full domain registration is unnecessary.
Core Prerequisites for Creating a Subdomain
Before initiating subdomain creation, ensure the following conditions are met:
- Own a valid ENS domain: You must be the controller of an existing .eth domain with an active registration (not expired). The domain must have a resolver set (typically the public resolver).
- ETH wallet with gas funds: Subdomain creation requires a transaction on Ethereum (or an L2 like Arbitrum if supported). Have sufficient ETH for gas fees.
- Network access: Connect to Ethereum mainnet or a supported L2 via MetaMask, Ledger, or compatible wallet.
- Resolver configuration: The parent domain must use a resolver that supports subdomain creation (e.g., the ENS public resolver at 0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41).
If you need to verify your domain's ownership and resolver settings, refer to the Ens Name Ownership documentation for detailed contract interaction steps.
Step-by-Step Subdomain Creation Process
The standard method for creating a subdomain involves interacting with the ENS registry and resolver contracts directly, typically through a dApp interface. Here is the precise workflow:
- Navigate to the subdomain manager: Access the ENS Manager app (ens.domains) or a compatible tool. Connect your wallet holding the parent domain.
- Select your parent domain: From the domain list, click on the .eth domain you control. You should see a "Subdomains" section.
- Enter the subdomain name: Type the desired label (e.g., "pay" for "pay.yourdomain.eth"). The name must contain only alphanumeric characters and hyphens (no underscores or special characters).
- Set the subdomain owner: Choose an Ethereum address to own the subdomain. This can be your own address or someone else's. The owner can later modify records.
- Configure resolver and records: Attach a resolver (usually the public resolver) and optionally set initial records (ETH address, BTC address, text records, etc.). The subdomain will inherit no records from the parent by default.
- Submit transaction: Confirm the gas fee and sign the transaction. Wait for block confirmation (typically 1–5 minutes on mainnet).
- Verify creation: After confirmation, the subdomain should appear under your domain's subdomain list. Test resolution by querying the subdomain's records via ENS lookup tools.
For a comprehensive walkthrough covering edge cases and batch creation techniques, consult the Eth Subdomain Creation Guide which includes contract-level examples and gas optimization strategies.
Common Questions and Troubleshooting
1. Can I create a subdomain without owning the parent domain?
No. Only the controller of the parent domain can create subdomains under it. If you want a subdomain under someone else's domain, you must request them to create it for you and transfer ownership to your address.
2. How do I transfer subdomain ownership to another user?
Subdomain ownership is managed through the ENS registry's "setSubnodeOwner" function. As the parent domain owner, you call this function with the subdomain's node hash and the new owner's address. After execution, the new owner can control the subdomain's resolver and records, but you (as parent owner) retain the ability to delete or reassign the subdomain.
3. Can a subdomain expire independently of the parent?
No. Subdomains have no independent expiration. They exist only as long as the parent domain registration is valid. If the parent domain expires, all subdomains become unresolvable until the parent is renewed. This is a critical design consideration for production deployments.
4. What happens to subdomain records if I delete the subdomain?
When you delete a subdomain (by setting its owner to the zero address or removing its resolver), all associated records become inaccessible. The subdomain name itself is freed for potential reuse, but previous records are permanently lost unless backed up off-chain.
5. Can I create subdomains on L2 networks like Arbitrum or Optimism?
Yes, ENS has been deployed on several L2 networks. However, subdomain creation mechanics are identical—the parent domain must exist on the same L2. Cross-chain subdomain management requires bridging and is not natively supported. Always confirm which network your parent domain resides on before attempting creation.
Gas Costs and Optimization Strategies
Creating a subdomain involves one or two transactions (depending on whether you set records simultaneously). Typical gas costs on Ethereum mainnet range from 60,000 to 120,000 gas per subdomain, translating to approximately $5–$20 at average gas prices. To reduce costs:
- Batch creation: Use the ENS multi-call contract to create multiple subdomains in a single transaction. This amortizes the base transaction cost across many subdomains.
- Use L2 networks: Creating subdomains on Arbitrum or Optimism costs under $0.10 per subdomain due to lower gas fees.
- Gas token usage: If supported on your network, use gas tokens (e.g., Chi) during low-demand periods to reduce effective cost.
Record Management and Resolution
After creation, subdomains support the same record types as primary domains:
- ETH address: Maps the subdomain to an Ethereum address (standard ENS resolution).
- Coin addresses: BTC, LTC, DOGE, and others via SLIP-44 coin type identifiers.
- Text records: Email, URL, avatar, description, etc.
- Content hash: For IPFS or Swarm content addressing (e.g., "ipfs://Qm..." encoded as a bytes32).
To modify records, the subdomain owner or parent domain owner must call the resolver's set functions (e.g., setAddr, setText) with the subdomain's node. The node hash is computed as keccak256(parentNode, labelHash), where labelHash is keccak256(subdomainName).
Security Considerations
Subdomains introduce specific attack surfaces:
- Parent domain compromise: If an attacker gains control of the parent domain, they can delete or reassign all subdomains immediately. Use hardware wallets or multisig for high-value parent domains.
- Resolver manipulation: A malicious parent owner can change the resolver for a subdomain without the subdomain owner's consent, redirecting records to different addresses.
- Replay attacks on L2: Subdomains created on L2 are not automatically valid on mainnet. Ensure record consistency if using the same subdomain across multiple networks.
Always verify that the parent domain's controller is a trusted address before accepting a subdomain for production use.
Conclusion
ETH subdomains provide flexible, low-cost name management within the ENS ecosystem. By understanding the creation process, ownership model, and potential pitfalls, developers and domain owners can effectively deploy subdomains for wallets, dApps, or organizational hierarchies. For advanced use cases involving custom resolvers or batch scripting, review the official ENS documentation and test thoroughly on testnets before mainnet deployment. Remember that while subdomains are powerful, they remain dependent on the parent domain's validity and security—plan your architecture accordingly.