Step 1: Commit
First you need to create your commitment hash.
You’ll need to create a random bytes32 for the secret value. Go to https://npm.runkit.com/ and run this:
'0x' + require('crypto').randomBytes(32).toString('hex')
Then on the read contract for the ETH Registrar Controller (https://etherscan.io/address/0x283af0b28c62c092c9727f1ee09c02ca627eb7f5#readContract), fill in the details for makeCommitmentWithConfig
:
name: The name to register, without the .eth.
owner: The address to set the Registrant and Controller of the name to.
secret: The random 32 bytes you created above.
resolver: The resolver contract to use. On mainnet typically this should be the default public resolver: 0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41
On Ropsten the public resolver contract is 0x42D63ae25990889E35F215bC95884039Ba354115
addr: The address that the ENS name should resolve to (the ETH address record).
Click the query button and the your commitment hash will be created:
Then switch to the Write Contract tab and connect your wallet. Enter your commitment hash into the commit
method, and click on Write to send it to your wallet.
The gas consumed by the Commit method is usually 46267 but to be safer you could set the gas limit higher. Etherscan will send its own estimated gas limit to your wallet, but it’s a good idea to open the gas settings and verify they’re correct.
After your Commit transaction has been confirmed…
Step 2: Register
First make sure to wait at least 1 minute before submitting the register transaction. The contract is setup this way with the two-transaction process to prevent frontrunning by miners/bots.
On the Write Contract tab, open registerWithConfig
, and fill in the details:
payableAmount: This is the actual amount of ETH to send in the transaction, it’s the actual ENS protocol fees. The register page on the ENS manager app will show you how much that is depending on the duration you choose:
name: The name to register, without the .eth.
owner: The address to set the Registrant and Controller of the name to.
duration: The amount of seconds to register the name for. So for 1 year, enter 31556952
secret: The random 32-bytes you created.
resolver: The resolver contract to use. On mainnet typically this should be the default public resolver: 0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41
On Ropsten the public resolver contract is 0x42D63ae25990889E35F215bC95884039Ba354115
addr: The address that the ENS name should resolve to (the ETH address record).
Click on Write to send the transaction to your wallet. The amount of gas consumed by the registerWithConfig method is usually around 253k-275k, I would recommend setting a gas limit of at least 310k though. Etherscan will send its own estimated gas limit to your wallet, but it’s a good idea to open the gas settings and verify they’re correct.
After that transaction is confirmed, you now own the name!
Hope that helps