in Blockchain stack, ENS, Smart Contracts

Creating your first ‘domain’ name on Ethereum using ENS (Blockchain stack #2)

ENS Domain Names

Ethereum ENS

ENS is the Ethereum Name Service, a distributed, open, and extensible naming system based on the Ethereum Blockchain.  It is very similar to registering a domain name and using DNS. I will compare DNS and ENS for each step below.

I’m writing a series of posts on the Blockchain Stack, giving simple but fully coded, step by step examples of how each of the element work both independently and collaboratively. This is the third post in the series, here you can find the intro Blockchain stack #0: Introduction of distributed stack vs LAMP.

Before we jump into this, I have changed my set up to use Geth for the JS console and Parity for the node.  The examples moving forward will be using this configuration.  Details of how to install Parity and why I changed can be found in the post Ethereum parity fast setup ropsten testnet.

Loading Javascript APIs to the Ethereum ENS contracts

Make sure Parity is running on testnet in a separate terminal and start the geth console.

$ parity --geth --chain ropsten

In a new terminal, download the JS file which contains the APIs to the ENS contracts and run Geth console (attaching to parity) and load the script.

$ mkdir EthereumJS
$ cd EthereumJS
$ curl -O https://raw.githubusercontent.com/ethereum/ens/master/ensutils.js 
$ cd ~
$ geth attach
> loadScript('./EthereumJS/ensutils.js');

Test it has been loaded correctly:

> testRegistrar.expiryTimes(web3.sha3('name'));
{ [String: '0'] s: 1, e: 0, c: [ 0 ] }

Creating your first (domain) name on Blockchain

Check you have two accounts and they have ETH.  This post tells you how to get Ether on testnet.

First, let’s check if the name has already been registered.  When a name is registered it has an expiry set.  In this case, you can see ‘ianmonk’ has already been registered, whilst ‘ian-monk’ is not registered.

> new Date(testRegistrar.expiryTimes(web3.sha3('ianmonk')).toNumber() * 1000)
Thu Mar 09 2017 18:57:49 GMT+0000 (GMT)
> new Date(testRegistrar.expiryTimes(web3.sha3('ian-monk')).toNumber() * 1000)
Thu Jan 01 1970 00:00:00 GMT+0000 (BST)

A – Register the name (‘buy the domain’)

Now we are going to register ‘ian-monk’ to your default account [0] and pay for this from your second account [1].  This is the equivalent step of buying a domain name.

> personal.unlockAccount( eth.accounts[1] );
> testRegistrar.register(web3.sha3('ian-monk'), eth.accounts[0], {from: eth.accounts[1]});
"0xd99ebe250ca1838d8904df786478bbebf2a945247726d2a159e17445cebd6ea4"

Check it has been mined:

web3.eth.getTransactionReceipt("0xd99ebe250ca1838d8904df786478bbebf2a945247726d2a159e17445cebd6ea4")

or

https://testnet.etherscan.io/tx/0xd99ebe250ca1838d8904df786478bbebf2a945247726d2a159e17445cebd6ea4

The latter can be useful because it can show errors.

This should now return your account address:

> ens.owner(namehash('ian-monk.test'))
"0xda9b1a939350dc7198165ff84c43ce77a723ef73"

B – Set the Resolver (set DSN server)

What you have done so far is set who owns this name (your account[0]).  Now you can choose what Resolver service will provide the address that this name maps/points to.  This is the equivalent on setting the DNS server for your domain name.

In this case we are going to use the publicly defined one named publicResolver (if you view source of ensutils.js you will find publicResolver.address maps to 0x4c641fb9bad9b60ef180c31f56051ce826d21a9a).  This time we will use the default account[0] as the ENS protocol will only allow the account owner of the name to change the resolver address.

> ens.setResolver(namehash('ian-monk.test'), publicResolver.address, {from: eth.accounts[0]});
0xcb8590303fe605837d085b9c15cf27ea9399a12d72ea0b9ccb2552213f015944
> web3.eth.getTransactionReceipt("0xcb8590303fe605837d085b9c15cf27ea9399a12d72ea0b9ccb2552213f015944");

C – Set the account to map to (Set the IP address in the DSN)

Now we (a) own the name and (b) have told it what service/contract resolver to use.  We now need to tell that resolver (publicResolver) what account we want it to map the name to.

Let’s create a new account to reference.

> personal.newAccount()
Passphrase: 
Repeat passphrase: 
"0x1d37a7e0320cb23403cf971ed4194b0e0258aef0"

Check what index was assigned to this new account.  My new account was created under accounts[0], pushing the one the name is registered to into [1] – very annoying!

Now, let’s tell the publicResolver to map our name to this new account.  You’ll note the first account reference (eth.accounts[0]) is where to map it and the second (eth.accounts[1]) is the account that owns the name (and pays the gas).

> publicResolver.setAddr(namehash('ian-monk.test'), eth.accounts[0], {from: eth.accounts[1]})
"0x4816778387307734159f1a35d7f2730bb025df4f92b50efbcc68a7daec692cdf"

Check it has been mined and then that’s it, you should now be able to resolve your name to an address (client account or contract):

> getAddr('ianmonk.test')
"0x1d37a7e0320cb23403cf971ed4194b0e0258aef0"

You can try exiting the console and restarting it to check it has persisted:

$ geth attach
> loadScript('./EthereumJS/ensutils.js');
> getAddr('ianmonk.test')
"0x1d37a7e0320cb23403cf971ed4194b0e0258aef0"

Well done, you have created your first domain name on Ethereum!
 

Next in the Blockchain stack series

Next in the series is Your first Ethereum web page (Blockchain stack #3).

Ziggify Blockchain

There’s a team of us that have come together at Ziggify to work on a Blockchain play. We are in the exploration phase, so if you want to get involved or have an idea please get in touch. I’m based in London and enjoy chewing the Blockchain fat over a cuppa or a beer.

ianmonk

https://twitter.com/IanMonk_uk

https://www.linkedin.com/in/ian-monk-uk/

Write a Comment

Comment

Webmentions

  • LolyCam 18+

    LolyCam 18+

    […]always a significant fan of linking to bloggers that I love but really don’t get a whole lot of link like from[…]

  • مترجم سكس تبادل

    مترجم سكس تبادل

    […]although internet websites we backlink to below are considerably not related to ours, we really feel they are truly really worth a go by way of, so have a look[…]

  • کلیپ سکسی

    کلیپ سکسی

    […]below you’ll come across the link to some internet sites that we feel you need to visit[…]

  • büsum ferienwohnung deichblick

    büsum ferienwohnung deichblick

    […]Here are some of the web sites we recommend for our visitors[…]

  • cyberskin anal dildo

    cyberskin anal dildo

    […]that is the end of this report. Here you’ll obtain some sites that we think you’ll value, just click the hyperlinks over[…]

  • best anal plugs

    best anal plugs

    […]one of our visitors just lately proposed the following website[…]

  • prostate massage

    prostate massage

    […]the time to study or stop by the material or web sites we’ve linked to beneath the[…]

  • vibrating anal beads

    vibrating anal beads

    […]Here is a good Weblog You might Come across Fascinating that we Encourage You[…]

  • anal play

    anal play

    […]Sites of interest we have a link to[…]

  • vibrating dildo

    vibrating dildo

    […]The information talked about in the article are a number of the ideal accessible […]

  • windows vps

    windows vps

    […]just beneath, are quite a few absolutely not connected websites to ours, nonetheless, they’re certainly worth going over[…]

  • бесплатно mp3

    бесплатно mp3

    […]Sites of interest we’ve a link to[…]

  • anal butt plug

    anal butt plug

    […]usually posts some incredibly interesting stuff like this. If you are new to this site[…]

  • adjustable nipple clamps

    adjustable nipple clamps

    […]below you will uncover the link to some sites that we feel it is best to visit[…]

  • best penis extender

    best penis extender

    […]Wonderful story, reckoned we could combine a number of unrelated information, nevertheless seriously really worth taking a search, whoa did one particular learn about Mid East has got much more problerms at the same time […]

  • несуществующий синоним

    несуществующий синоним

    […]Wonderful story, reckoned we could combine some unrelated information, nonetheless definitely really worth taking a look, whoa did one particular master about Mid East has got far more problerms as well […]

  • ихний толковый словарь

    ихний толковый словарь

    […]below you will find the link to some web sites that we think it is best to visit[…]

  • care finder

    care finder

    […]usually posts some very exciting stuff like this. If you’re new to this site[…]

  • 사다리사이트

    사다리사이트

    […]one of our guests recently suggested the following website[…]

  • masturbator toys for men

    masturbator toys for men

    […]The info talked about in the post are a number of the best obtainable […]

  • 안전공원 추천

    안전공원 추천

    […]The facts mentioned inside the article are a number of the top available […]

  • https://trendstwitter.com/brazil

    https://trendstwitter.com/brazil

    […]Here is a superb Weblog You might Locate Interesting that we Encourage You[…]

  • ios pubg mobile hack

    ios pubg mobile hack

    […]The details talked about within the report are some of the most effective obtainable […]

  • 먹튀검증

    먹튀검증

    […]always a large fan of linking to bloggers that I like but really don’t get a whole lot of link really like from[…]

  • canzone per fare il tavolo

    canzone per fare il tavolo

    […]Wonderful story, reckoned we could combine a number of unrelated information, nonetheless actually worth taking a search, whoa did 1 discover about Mid East has got much more problerms too […]

  • багрец

    багрец

    […]we came across a cool web page that you could possibly get pleasure from. Take a appear when you want[…]

  • Examen guardia civil

    Examen guardia civil

    […]we came across a cool web page that you just could possibly take pleasure in. Take a look if you want[…]

  • Haustüren

    Haustüren

    […]Wonderful story, reckoned we could combine a handful of unrelated information, nevertheless actually really worth taking a appear, whoa did one particular discover about Mid East has got far more problerms as well […]

  • #TheConsultants

    #TheConsultants

    […]check below, are some totally unrelated sites to ours, even so, they’re most trustworthy sources that we use[…]

  • Kıbrıs Eleman

    Kıbrıs Eleman

    […]one of our guests lately suggested the following website[…]

  • #YSNJuvy

    #YSNJuvy

    […]usually posts some very interesting stuff like this. If you are new to this site[…]

  • #Rap

    #Rap

    […]Wonderful story, reckoned we could combine a few unrelated information, nonetheless really worth taking a look, whoa did 1 discover about Mid East has got extra problerms too […]

  • 토토사이트

    토토사이트

    […]just beneath, are a lot of completely not associated internet sites to ours, on the other hand, they may be surely really worth going over[…]

  • 안전공원

    안전공원

    […]Sites of interest we have a link to[…]

  • 먹튀검증

    먹튀검증

    […]the time to read or visit the subject material or web-sites we’ve linked to beneath the[…]

  • school workshop

    school workshop

    […]although websites we backlink to beneath are considerably not associated to ours, we really feel they’re truly really worth a go by way of, so possess a look[…]

  • 라이브딜러

    라이브딜러

    […]Here are a few of the web sites we advocate for our visitors[…]

  • 토토사이트

    토토사이트

    […]here are some hyperlinks to websites that we link to simply because we consider they’re worth visiting[…]

  • curved vibrator

    curved vibrator

    […]we came across a cool web page that you just might get pleasure from. Take a look in the event you want[…]

  • prostate massage

    prostate massage

    […]although web-sites we backlink to below are considerably not related to ours, we really feel they are in fact worth a go through, so have a look[…]

  • nipple pump

    nipple pump

    […]we came across a cool web-site that you simply may possibly get pleasure from. Take a appear in the event you want[…]

  • 캐쉬백

    캐쉬백

    […]Sites of interest we have a link to[…]

  • desigirl

    desigirl

    […]check below, are some absolutely unrelated sites to ours, nevertheless, they’re most trustworthy sources that we use[…]

  • افلام سكس جديدة

    افلام سكس جديدة

    […]below you will come across the link to some sites that we feel you must visit[…]

  • Free chaturbate

    Free chaturbate

    […]just beneath, are various entirely not related internet sites to ours, nonetheless, they may be certainly really worth going over[…]

  • Sell my house for cash

    Sell my house for cash

    […]very handful of web sites that come about to become detailed beneath, from our point of view are undoubtedly effectively worth checking out[…]

  • free chat

    free chat

    […]Here are a few of the sites we suggest for our visitors[…]

  • dress

    dress

    […]that would be the finish of this report. Right here you’ll uncover some websites that we think you’ll enjoy, just click the hyperlinks over[…]

  • с добрым утром любимый

    с добрым утром любимый

    […]usually posts some really exciting stuff like this. If you’re new to this site[…]

  • 25 февраля праздник

    25 февраля праздник

    […]Wonderful story, reckoned we could combine a number of unrelated data, nonetheless really really worth taking a search, whoa did a single find out about Mid East has got a lot more problerms as well […]

  • словарь итальянского

    словарь итальянского

    […]Sites of interest we have a link to[…]

  • наталья подольская поздно текст

    наталья подольская поздно текст

    […]we prefer to honor lots of other internet web pages around the net, even when they aren’t linked to us, by linking to them. Underneath are some webpages worth checking out[…]

  • mp3 songs

    mp3 songs

    […]The facts talked about in the post are a few of the most beneficial obtainable […]

  • Fondamenti di biologia

    Fondamenti di biologia

    […]Every when in a whilst we choose blogs that we read. Listed beneath are the latest internet sites that we pick […]

  • Rock backing track

    Rock backing track

    […]Sites of interest we have a link to[…]

  • داستانهای سکسی

    داستانهای سکسی

    […]usually posts some extremely interesting stuff like this. If you are new to this site[…]

  • فیلم سوپر

    فیلم سوپر

    […]although web-sites we backlink to beneath are considerably not associated to ours, we really feel they may be in fact worth a go via, so have a look[…]

  • investment

    investment

    […]very couple of web-sites that take place to be comprehensive below, from our point of view are undoubtedly properly worth checking out[…]

  • Google

    Google

    Below you will obtain the link to some web pages that we feel you must visit.

  • beginner dildo

    beginner dildo

    […]very few sites that take place to become detailed beneath, from our point of view are undoubtedly properly really worth checking out[…]

  • словари

    словари

    […]Every after inside a whilst we pick blogs that we read. Listed below would be the newest sites that we opt for […]

  • rabbit vibrator

    rabbit vibrator

    […]we prefer to honor lots of other internet sites around the internet, even though they aren’t linked to us, by linking to them. Underneath are some webpages really worth checking out[…]

  • solar animal repeller cat dog squirrel repeller ou

    solar animal repeller cat dog squirrel repeller ou

    […]here are some hyperlinks to sites that we link to due to the fact we believe they are really worth visiting[…]

  • 6 inches dildo

    6 inches dildo

    […]we came across a cool site which you might get pleasure from. Take a search should you want[…]

  • anchors: awaporn.mobi

    anchors: awaporn.mobi

    […]we came across a cool web site which you may possibly enjoy. Take a search in the event you want[…]

  • buy real instagram followers and likes

    buy real instagram followers and likes

    […]we came across a cool site that you just may possibly love. Take a look if you want[…]

  • hot hunk sexy

    hot hunk sexy

    […]Sites of interest we’ve a link to[…]

  • فني صحي في الكويت

    فني صحي في الكويت

    […]here are some links to web-sites that we link to due to the fact we believe they may be really worth visiting[…]

  • Comedy rap

    Comedy rap

    […]although sites we backlink to below are considerably not associated to ours, we feel they may be really really worth a go by way of, so possess a look[…]

  • funny hip hop

    funny hip hop

    […]we came across a cool website which you may take pleasure in. Take a search in the event you want[…]

  • Sexy chat

    Sexy chat

    […]the time to read or check out the material or web-sites we’ve linked to beneath the[…]

  • Hot webcam

    Hot webcam

    […]that could be the end of this report. Here you will discover some websites that we assume you will enjoy, just click the links over[…]

  • Tory Burch

    Tory Burch

    […]Wonderful story, reckoned we could combine a few unrelated information, nevertheless seriously worth taking a appear, whoa did one learn about Mid East has got a lot more problerms also […]

  • gucci bags

    gucci bags

    […]usually posts some pretty exciting stuff like this. If you’re new to this site[…]

  • coldplay don t panic

    coldplay don t panic

    […]Every after in a when we pick out blogs that we read. Listed below are the most current web pages that we pick out […]

  • amortization schedule with additional payment

    amortization schedule with additional payment

    […]Wonderful story, reckoned we could combine a number of unrelated data, nonetheless seriously really worth taking a appear, whoa did 1 find out about Mid East has got a lot more problerms as well […]

  • sweet Sofia cam

    sweet Sofia cam

    […]one of our visitors not too long ago suggested the following website[…]

  • sexy Melody webcam

    sexy Melody webcam

    […]one of our guests not long ago proposed the following website[…]

  • sexy gaming Chat

    sexy gaming Chat

    […]Wonderful story, reckoned we could combine a couple of unrelated information, nevertheless definitely really worth taking a look, whoa did 1 study about Mid East has got far more problerms too […]

  • sexy Latina duo

    sexy Latina duo

    […]Wonderful story, reckoned we could combine several unrelated data, nevertheless genuinely really worth taking a appear, whoa did a single find out about Mid East has got much more problerms also […]

  • attacco di panico

    attacco di panico

    […]The information talked about inside the write-up are some of the most beneficial offered […]

  • 55pfl4706 f7

    55pfl4706 f7

    […]that could be the end of this report. Right here you will come across some web sites that we believe you will enjoy, just click the links over[…]

  • Live casino singapore

    Live casino singapore

    […]Wonderful story, reckoned we could combine some unrelated information, nevertheless genuinely worth taking a appear, whoa did 1 understand about Mid East has got more problerms as well […]

  • Sexcams

    Sexcams

    […]very few sites that take place to be comprehensive below, from our point of view are undoubtedly properly worth checking out[…]

  • Sexy adult

    Sexy adult

    […]that would be the finish of this article. Right here you will come across some web pages that we believe you’ll appreciate, just click the links over[…]

  • Google

    Google

    Check beneath, are some completely unrelated internet websites to ours, nevertheless, they may be most trustworthy sources that we use.

  • http://cialisvi.com/

    cialis generic http://cialisvi.com/

    Wow many of very good data!

  • Generic cialis

    cialis tablets http://kawanboni.com/

    Effectively voiced genuinely. .

  • Generic cialis

    cialis from canada http://cialisiv.com/

    Cheers! Wonderful stuff!

  • Cialis online

    cialis 5 mg http://cialisky.com/

    You actually expressed that superbly!

  • writeaessay

    write a paper for me http://gsgfsdgfdhjhjhj.com/

    Helpful advice. Thanks.

  • Blockchain stack #0: Introduction of distributed stack vs LAMP - Ziggify

    […] #2: Creating your first ‘domain’ name on Ethereum using ENS […]

  • Blockchain stack #1: Installing Ethereum Geth and your first smart contract - Ziggify

    […] Next in the series is Creating your first ‘domain’ name on Ethereum using ENS (Blockchain stack #2) […]