ENS: Integration Workshop
ETHGlobal·Sat, Oct 9, 2021, 12:00 AM
Watch Makoto Inoue of ENS in a workshop titled, "ENS Integration," part of ETHOnline 2021, a month-long virtual hackathon with over 1,000 engineers, designers, and creators building new protocols, learning at summits and workshops, and gaining valuable feedback from ecosystem professionals along the way. ---------------------------------------------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.co Email us at: hello@ethglobal.co
Transcript
hello uh welcome to ens integration workshop for ace global hackathons september 2 2021 and today i'm going to talk about uh three topics first we i go quickly go through kind of basic of how to do the ens integration and then i spent the rest of time going deeper into more core of ens uh it's called the one is called resolver and another one is called registrar and i just show it as a kind of key setup i'll explain what this is uh as i go through and therefore the relevance to the hackerson in the past we used to uh give small like hundred hundred dollars worth of uh price too many uh iterations for the basic one and uh this time we want to do uh encouraging you to kind of discover the power of vns and you know take more advantage of it so we will not give price small prices but rather we're going to give bigger price a pool of like three thousand dollars lots of eastward usdc uh we don't know how many the winner is going to be but rather than giving to like 10 prizes we probably gonna give like somewhere between like three to five and in addition to that we are planning to have a enos workshop uh right after the finale of this global and so for some of the winners i would like you to invite to do a bit of a kind of pitch to the community and we are kind of thinking about a kind of community voting so that you can earn extra price okay and that i will go through lots of material but majority of stuff you should be able to find in our dock page equal docs ens.domains or if someone some of the information is actually too new so if it's not in you can just ask me questions on this code i'm i'm very active there okay so ens integration 101 so one thing about great thing about energy integration is quite likely you don't have to install any new things that many client libraries already have ens some of the ers integration the one we also use quite a lot is called esa's js which actually the author of uh esa.js richard rick moon is now part of the ens team so it has a quite tight integration but most of the live js libraries uh especially such as they do good support for kind of read-only operational but kind of looking up enos but when it comes to writing uh you know setting record uh support could be limited uh in that case you could use our es official library called ensjs or uh if you go to the dock there's information about how uh actually most of our smart contract itself is in npm package so you can actually just you know uh include that rnpm package on your either front end where you can import in your solidity contract so uh what is ens uh actually i i don't think i introduced myself and in kind of ethereum world uh my identity is this hexadecimal 0x5 a3a4 rubber bra and the ens provides a kind of human you know readable friendly ways to associate my ecm kind of item your wallet address to this name so if you go to for example metamask or is a scan and if you look at moto dot is you should resolve to these ecm address so that you can send the crypto address or you know you can receive and but it's just going a bit beyond that that like uh initially uh nick johnson who created uh his name subs he started kind of putting uh like his nick d johnson dot is into his twitter profile but like he kind of started uh blowing up when vitalik his vitalik is into his twitter profile and now so many kind of ethereum so-called influencers now put like their edh name and also there's lots of people thanks to the nfd's popularity many people uh outside of crypt world start getting into the uh ethereum and we have lots of ems fairies they kind of have a like famous every day's name and they try to give it to you so but to these people too so that they can be part of this ecm community so it's ens becoming just more than the convenience convenient utility but it's almost becoming your identity on the web 3 world so we started coin as a like your web 3 user name that's kind of a new uh and so to do that and again it's quite easy uh if you so the the forward lookup uh given if you give me the name i return your address that's just done by ens something like esk address if you use web3.js and the reverse is that so for example if you log into for example uni swap or openc and if you connect wallet to their site they immediately recognize your ens name and show it to you if you set this dns name on our manager this doesn't gets done automatically when you get you register so you have to do it manually but once you do that you can start seeing and now i think esa scan does actually show the transaction history with cns so you can actually see who like transaction went from free to food a lot easier way and to do that again it's just almost like one line that this is you example uses a library called esa.js and here it says provider.
lookup address that returns the ens name one important thing is you can when you set the uh address to name you can actually set any names like you don't have to put well technically i can put vitalik dot is to points to my zx5a address then like it people can easily fake it so what adaptive of what should do is we should cross check both reverse lookup and the forward lookup and the both pointing to each other that if you use library like esa.js it does that inside so you don't have to worry about it but if you in case you know you you use your own way you might want you you have to do it okay so second is ens resolver and let me just show you this basic architecture of ens ens is just like any other dap it's smart contract it's one of the oldest smart contra in production we launched back in 2017 and it's it's basic is very simple it's just basically a gigantic phone book where you know like you have a e s name and you and you have like a full list of a unit's name what's interesting is uh it has something called resolver and let me show you the flow that like when user uh look up for example for lookup you fast connect to this ens registry to say hey i wanna know resolve who dot is and registry doesn't return the ecm address of who but instead it returns something called resolver contract address and you the client actually asked to this resolver what's the address of this who dot is person then resolver is in charge of returning yeah so underneath like and the user don't realize but under these basically js client is calling the ens smart pointer twice and how we why we do that is because it makes basically resolve logic extensible and upgradable we have a default one called public resolver which everybody mostly uses and they reset it when you register but you can actually set your own resolver and add extend more features and currently yeah most people know ens has resolved the ecm address but you uh underneath you can actually set other things like a content hash which you know like you generate for ipfs or now we have a support or rv and you can set these then like you can basically even in ipfs site you can resolve with ens name rather than their very long like content id and that yeah so this is how it looks like for example this case uh in the address we have now so-called multi-coin support so not just eth you have btc ltc over 200 address addresses and the important thing is the wallet also has to uh support the multi-coins but once it's supported sorry i think i got random pop-up i got close uh yeah whilst uh for example our trust wallet uh you can basically send btc to bradley.es if you want to and the doing that is again it's quite simple that you know now you know what resolve is right so like if you send me the btc get give me btc address of this result yes you just do like this depending on this this case we are using ensjs so syntax is slightly different but all the other libraries is kind of i think uh this multicore is actually relatively new so esa.js does support but some other libraries may not support multi-coins and updating record is usually like set address or set content hash and in this case i have a setting text where you put the key as test and the record value as text test record and we really want to promote the use of this uh yeah text record and one use case is avatar so i think couple weeks ago well actually three almost a month ago uh zappa announced a new feature where you can set your nft as an avatar which is great right but the problem probably problem is like it's kind of on their own side so that information is not really shared anywhere so we came up like uh kind of talked about that new specification that uh nick johnson who is the creator of ens uh drafted the es avatar field formal specification which is not finalized yet so it's relatively new but like we want to kind of start encouraging user not to put avatar a few of them initially like we just created to put like uh jpeg url but we wanted to allow people to set text record text record itself doesn't have any validation you need to put anything so it comes down to the specification that each uh tab agreed to resolve in a certain way and with using that kind of protocol i did actually added a small feature in the text record but if it says avatar if you specify so this is example the specification that uh eip155 and the one is a chain id and slash erc721 you could also put 1155 then column contract address slash token id then you with this information is enough to fetch the image url from the smart contract so it displays this is my uh yeah people please nft uh image which i have and one thing i added is i can also verify that that i own this smart contract i can't really verify that you know this could be like copy and pasted to different contracts so i can't say this is a canonical all i'm saying here is i own this specific contract and then in this case i put it puts a link to open c so you can actually verify that this contract address is what is it really people please as a contract address or a punk address so that at least like it allows you to buy it on your own and if you try to do that by yourself it's uh it's going to be a bit like this so fast on the line two you do provider.resolve.
name and you do some other note is uh important thing is ownership or what i shouldn't be the for example madokudo is is nft itself so it has an owner information but owners should be point to the address ens resolve to using for lookup because some something like subdomains doesn't have the notion of like a token ownership whereas this resolver name is a consistent ways to type name back to address so you put owner then so token id of the eth name is actually the integer version of so-called label hash which is a label is basically if there's a metallic dot is a vitalic part that's a label right and you if you hash it it becomes so labor hash then you type integer and the token id and what i'm checking here is using erc721 owner of function passing token id it passes who owns it is their own address and then i can check that oh that's the basic directories that's how you usually use it or because we already did it we kind of turned it into kind of metadata service api so if you go to metadata dot ens dot domains and slash avatar slash dot is slash meta it returns all the basically decoded nfd information and also kind of easy owner information by the way this format is keep changing so probably by the time you start hacking it's in a different format uh so you should check the actual yeah but you you will see the latest and we have a lot more features of other like you can we have some different api endpoint uh where it shows the metadata of the uh basically ens name itself and we are working on a dock it should be available under you know slash docs and the one from fun prototype we have in that project is to overlay enos name to on top of the image as associated into other field and this is still very basic version but for maybe for hackathon you could fork this repo and they could go crazy interesting things okay and then so this one i'll go very very briefly but another way of extending resolver is for the off-chain support also called layer 2 scaling that it's good that you can use you know say a lot of interesting information to resolve but every time updating it costs lots of gas so we are working on the ways to offload some of the work into layer 2 of your choice and we recently announced so-called during framework this is a generic ways to retrieve the information from of chain including layer 2 and when you get back to the uh how i explained the uh you know in the very beginning is that if you so resolving the name is like two steps so fast you ask the contract to register read to return the resolver and then resolve a return address the during framework extends a resolver that instead of a resolver returns the cm address it returns a service url and it's so called gateway and gateway is in charge of returning data from layer 2. and if this layer 2 is kind of roll-up model most of the roll-ups should have a ways to verify l2 data in l1 so that yeah the client can verify it uh this this is still very early stage and it's not quite ready yet but we do have some demo of uh verifying optimism and we are we a bit in lack of resource to do ideally we want to basically support all the l2 environment but it's uh yeah we haven't done it yet so one of the hack could be that you know you look into arbitrary more stockwear and see how you could fit their l2 into this during model that could be one of the hack and so the final step is uh registrar uh i'll go back to the false uh diagram that like i mentioned there's a registry and resolver but there is something called registrar which is kind of made up uh terminology representing the ownership of the satan name so that like when you uh when you register a eth name it's actually a erc721nft and it's not neither registry nor resolver rnft it's actually the owner.eth is assigned to a smart contract which emits uh which allows you to register a new name which happens to be nft standard it's called east register so that's and for other domains for example uh you probably know that we recently announced that now you can uh turn your dot com address or z dot i o dot dev and all the domain internet domain name into ens and that's done by so-called dns registrar that it allows you to submit and claim name if you retrieve the ownership information of dns proof and you submit the proof in another contract for dns sec oracle and using that information you can have enos name of dot com and that's kind of different ways you want and for testing purpose you you have fasting faster register as well one thing you could do is uh create your own registrar to issue your own sub domain so for example if i have madokundo is you can issue issue like you know who don't matter is and the prime example is uh decentraland uh the the central is a kind of virtual metabols and when you claim name on their registration page you can set the name but that actually also becomes the sub domain of the dcl.e so i actually do have my dcl.es and yeah so as i mentioned like it can be done by basically setting controller of dcl eth into as their own smart contract and you can actually look into their source code from easter scan and i will briefly go through that they have something called dcl registrar which inherits a erc721 contract and when it gets deployed it passes our registry information and when you register their name you call registry dot set sub node owner and what this will basically create a sub domain under your domain in this case dcl dot is and while you do that you also mint it as nft and that's the basic but one thing you have to be aware that like when i i repeatedly mentioned in this uh talk that the ownership of the nft doesn't and how you resolve the name are not the same thing so issuing meeting the name itself doesn't uh resolve so you also have to set resolver and then set the ecm address to the resolver this is the part you also have to do uh so this is kind of yeah very very basic of the basically how to create a sub domain on the also like you know you you understand number one what other things you can do is resolve it beyond just setting a crm address and there's a lot of information and so i put most of the url i mentioned in the slide into this part and also if you have any questions i'm happy to answer in a discord channel that's it and thank you very much
Automatic transcript — names and jargon may be misspelled.