The full code: https://plnkr.co/edit/WYDB9fOvmRoUvCVw

Testing on the mainnet because: ENS on Rinkeby - Network does not support ENS?

1️⃣ setSubnodeOwner works


web3.eth.ens.('dearmoon.eth', 'hack', accounts[0], {from: accounts[0]}).then(function (receipt) {

2️⃣ setResolver works


web3.eth.ens.setResolver('hack.dearmoon.eth', '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', {from: accounts[0]}).then(function (receipt) {

3️⃣ setAddress fails


(Metamask told me it will fail but I send it anyway hoping for some helpful revert message)

web3.eth.ens.setAddress('hack.dearmoon.eth', '0x614962025820c57d6af5acff56b5879237daf559', { from: accounts[0] }).then(function (result) {

I'm using: https://web3js.readthedocs.io/en/v1.2.7/web3-eth-ens.html#setaddress

Do you know why setAddress fails? 🤷‍♀️

Existing research, good links:

  1. https://github.com/ensdomains/subdomain-registrar - not good, the transfer is irrevocable, I need flexibility.

  2. https://www.toptal.com/dapp/ethereum-name-service-dapp-tutorial - this is actually quite clever, including smart contract that does everything in a single transaction: https://github.com/radek1st/ens-subdomain-factory/blob/master/contracts/EnsSubdomainFactory.sol#L73-L79

registry.setSubnodeOwner(domainNamehash, subdomainLabelhash, address(this));
registry.setResolver(subdomainNamehash, resolver);
resolver.setAddr(subdomainNamehash, _target);
registry.setOwner(subdomainNamehash, _owner);

I'm thinking about using it but before doing complicated stuff I prefer to learn basics first.

Longer-term I would like to anyone register a subdomain but without me losing ownership.

1 Answer 1


Super obvious.

In step 2️⃣ should use the address of the public resolver: https://etherscan.io/address/0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41

From Gitter chat:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.