Didn’t find any actual guide online so I’m going to write a not-so-simple one.

Use this if you own a .eth domain, and you want to create and link a subdomain to an ethereum address (eg. to your exchange wallet).

Same goes if you own a subdomain, you just skip the first step.

Below the (very verbose) javascript code with a step-by-step procedure.

var namehash = require('eth-ens-namehash')
var Web3 = require('web3')
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))

var domainHash = namehash.hash('something.eth') // edit here
console.log('This is the hash of your domain:', domainHash)

// don't put something.eth here, ONLY the subdomain
var subdomainSha = web3.sha3('sub') // edit here, this means sub.something.eth
console.log('This is the web3.sha3 string of your subdomain:', subdomainSha)

var subdomainHash = namehash.hash('sub.something.eth') // edit here
console.log('This is the hash of your subdomain:', subdomainHash)

To run this script you have to put this code into a .js file and run it from a terminal with node (node filename.js). BE SURE TO EDIT THE DOMAIN NAMES and put in your own!.

Before you run it, type npm i eth-ens-namehash and npm i web3 in the console to install the required packages.

Then, run the script so you get the hashes you are going to need below.

Steps

First of all, open MyEtherWallet (be VERY careful of scams! Check the domain you land on when you open this link, I might have been hacked or something).

If you need to create your subdomain

  1. Go to Contracts (in the main menu) and select ENS – Registry
  2. Under “Read / Write Contract” choose setSubnodeOwner
  3. Under “node bytes32” insert the DOMAIN hash
  4. Under “label bytes32” insert the SUBDOMAIN web3.sha3 string
  5. Under “owner address” insert the eth address you will use to manage this domain

What you did here is set the eth address as the owner of the subdomain, so you (or someone else) can now manage it.

Set a public registry for the subdomain

  1. Go to Contracts (in the main menu) and select ENS – Registry
  2. Under “Read / Write Contract” choose setResolver
  3. Under “node bytes32” insert SUBDOMAIN hash
  4. Under “resolver address” insert 0x5FfC014343cd971B7eb70732021E26C35B744cc4 (this is the address of ENS – Public Resolver, you can check it on MyEtherWallet)

Resolve the new subdmain to an eth address

  1. Go to Contracts (in the main menu) and select ENS – Public Resolver
  2. Under “Read / Write Contract” choose setAddr
  3. Under “node bytes32” insert the SUBDOMAIN hash
  4. Under “addr address” insert the eth address you would like it to resolve to (eg. your kraken wallet)

You should be done! Wait a couple of minutes for it to refresh and then check https://etherscan.io/address/sub.something.eth to see if it worked.

References

https://github.com/ethereum/ens/blob/master/docs/userguide.rst
https://github.com/ethereum/wiki/wiki/JavaScript-API#web3sha3
https://www.myetherwallet.com/#ens

PS: if you need an .eth domain you can follow the steps on MyEtherWallet to register one if available.

2 thoughts on “Create an ENS (.eth) subdomain

Leave a Reply

Your email address will not be published. Required fields are marked *