Skip to content

Instantly share code, notes, and snippets.

@bonedaddy
Last active March 11, 2021 19:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonedaddy/e5fd5dcd213c595c697f232600a47fce to your computer and use it in GitHub Desktop.
Save bonedaddy/e5fd5dcd213c595c697f232600a47fce to your computer and use it in GitHub Desktop.

Step 1

Go to https://remix.ethereum.org and compile the following contract deploying onto a javascript VM instance

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.8.0;

/** 
 * @title Ballot
 * @dev Implements voting process along with vote delegation
 */
contract NameHash {
    function nameHash(
        string calldata name,
        address owner,
        uint256 salt
    ) public pure returns (bytes32) {
         return keccak256(abi.encodePacked(name, owner, salt));
    }
}

2

Once deploy you need to call the function nameHash. name argument is the name you want, owner is your ethereum address, or the address you want to have own the name, salt is any random number.

3

After you fill in the values and press call it gives you a namehash

4

Go to the registrar contract page and connect your web3 client (ie metamask)

https://etherscan.io/address/0x37723287ae6f34866d82ee623401f92ec9013154#writeContract

5

The registration fee is 10RAD so you need to make sure your account has 10RAD available. You also need to approve the Registrar contract to spend your 10RAD.

To do this go to the RAD token contract https://etherscan.io/token/0x31c8eacbffdd875c74b94b077895bd78cf1e64a3#writeContract

6

In the spender argument enter the address of the Registrar contract

  • 0x37723287Ae6F34866d82EE623401f92Ec9013154

In the rawAmount argument enter in 10 in denominations of wei. Note that entering in the following amount is enough for one registration only, if you want to register more names you will need to increase this number

  • 10000000000000000000 (one registration)
  • 20000000000000000000 (two registrations)
  • 30000000000000000000 (three registrations)

Fill these values in and click "write"

7

Expand the commit function and enter the namehash, clicking write to broadcast the transaction

8

Wait 10 blocks

9

On the write contract page expand teh register function and fill in the values that were used to generate the namehash. These must match the values used to generate the namehash supplied to the commit function or this will not work. Note if you attempt to broadcast the transaction with metamask and you get an error about the tx being rejected it usually means you have to wait more time for the "wait period" to pass. Wait another few minutes and try again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment