New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

EthJS: Precision Ethereum Javascript Architecture for dApps

DevconSun, Oct 7, 2018, 12:00 AM

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more. https://archive.devcon.org/archive/watch/3/ethjs-precision-ethereum-javascript-architecture-for-dapps EthJS is a collection of presently 16 precision JS modules made over the past year to support the dApp developers of the Ethereum community. Currently, the modules are being used in the Truffle Suite, web3.js, wafr developer tool, and uport libraries among many other projects. Speaker(s): Nick Dodson Skill level: Advanced Track: Developer Infrastructure Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum Learn more about devcon: https://www.devcon.org/ Learn more about ethereum: https://ethereum.org/ Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. Devcon 3 was held in Cancún, Mexico on Nov 1 - 4, 2017 Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

Transcript

[Music] okay so I'm gonna do a quick presentation on some aetherium JavaScript stuff and you guys hear me okay so everything good all right cool so it's going to be on some alternatives that are available in the ecosystem that you may not be aware of and I think it should open you up to kind of the possibilities on the RPC layer and and kind of how you want to approach designing your app or Deb so right now the etherium ecosystem especially on the RPC layer is kind of dominated by these modules web 3 theory MJS parity api ethers j/s which was just recently released and eath j/s which has kind of been in the background for a little while so to go through a bit of an overview ejs is a small organization that has a few modules 15 in total and we have one boilerplate and a few development tools so some command line stuff as well everything's fully documented everything's fully exemplified and MIT licensed its production ready although there's one module that you probably shouldn't use because it's not a IP 155 so Richard tells me and 100% test coverage and 98% build up time as a general policy so this is kind of the organization as a whole and it's it's on github so just github.com slash eath j/s and we've had 20 repositories so initially a few months ago I had gotten a little frustrated with web 3 and I had also been working and talking with Richard Moore on a few different points and kind of wrote a different approach when three so and also a little different approach to how ethers Janis was doing it at the time and I definitely encourage you to check out all the alternatives and kind of make a decision for what's right if you do want to use an alternative to web three and so basically there's a few different philosophies and things and to keep in mind so each s can be used as an alternative to web three but I actually like it to be used more for architecture it's used in quite a few projects I'll go over in a bit I think diversity and modules and libraries kind of makes the community stronger I think you know having different options and different opinions and different ways to interact with aetherium is kind of critical to building a stronger community and stronger infrastructure companion libraries help influence each other's design so some of each s kind of helped web 31.0 ethers j/s helped me build some interests of so and in fact I use some of some of their modules in in my libraries and of course we still follow all the RPC specifications and the provider models that people are used to but we kind of have different opinions on approaching how to interact with it and so the way that I've kind of constructed eath j/s at least the core interface there is you give your contract module filtering modules and so forth this has become kind of a standard practice now I have my querying layer which combines both an RPC module and a formatting module and basically formats all your input inputs and outputs to the RPC layer automatically and each jeaious schema is actually I think one of the the better things that I definitely did here so I just laid out in a JSON file the entire RPC specification and all the inputs and outputs so you can basically take that and auto generate the entire RPC query layer and and have that an automated process so this is kept it to be very you know easy process for me to update or for others to come along and add my methods and so forth it really is all automatic and so just a little more in-depth on some of the modules is some providers for signing HTTP HTTP querying some unit handling formatting event filtering contract handling transaction signing although definitely just use ethers for that because the IP 155 and accounts so just generating and managing accounts although you have to be very careful because you do have to supply your own good source of entropy and while I do supply some sources of entropy with random bytes which is known to be safe it's basically you want to bring a lot of entropy to the table that's very healthy and some util modules and some ENS resolving modules so here's the schema that I was talking about so this just lays out the entire RPC specification in a very data lean format I'm not gonna say it's particularly standardized but it essentially lays out all the inputs and outputs so if you want to take this and go into you know objective-c or if you want to take this and go into another language and build an RPC layer for aetherium you can just take this JSON and automatically generate the whole thing so and I actually encourage people as well one thing that I've found with doing a lot of these modules is it's helped people learn more about what the RPC layer is and what it's actually doing because it's really simple like what web freeze job is or ethers or ETS is basically just to help you interact with the node on the RPC layer and format some data and that's it and it's a very straightforward process number handling and these other things are is well something that should be simple but turned out to be a little complicated for some reason I don't know why so here's just each J's kind of an action looks very similar to web 3 and I follow a very similar format to web 3 and other other libraries don't necessarily so just just to give you an idea of what that looks like so the modules are all designed with the same kind of documentation and standards in mind around testing and so forth and try to make the exports clean and simple and easy to update and upgrade so basically like you know I wanted to build a set of modules that the community could help out with and if anything just learn about the layer and also if they need things for certain architecture pieces they can use these modules so if chess is used in production for meta masks and Fuhrer and truffle mainly for certain bits of encoding and decoding and RPC layer stuff and just to go over a little bit of the thinking behind how its developed so I like safe versioning where while I call it safe versioning where you don't have floating NPM versions across the modules just because I found that when modules update the NPM versions they shove up to the top and then potentially cause problems you can't foresee so I like to use hardened versions across NPM and just kind of keep the updating kind of slow and boring but more meticulous and more tested all the modules are driven by what their dependencies are so there's a lot of nice isolation between all the different the various modules it's built with the DAP and app architecture kind target in mind small and concise async only and I try to fail as loudly as quickly as possible everywhere strong types as best as you can get JavaScript strong types although I do support some a morphic number handling and I'm kind of looking to remove that is well community driven design so keeping the code clean simple and being able to be upgraded very easily and as well trying to keep opinions off the table as best as possible and keep configurability really high across the whole stack so a big feature and kind of a big note is that we use be naso not big number j/s and the pros of that are that its absolute precision by default so it doesn't support decimals and floats which are potentially very dangerous considering you know that we're working with money and rounding is not necessarily the greatest thing and it's heavily used in interoperable Viator MJS and ethers Jess but the cons are that it's not necessarily interoperable with big number Jas web 3 and sometimes it accepts invalid values i'm prefix X which is somewhat dangerous but we kind of take care of that on another layer so you don't really have to think about that but it's just something to consider so signing providers and account generation so just simple providers to kind of shove in sign transaction packets and and kind of handle accounts we provide those too and as for some of the dev tools that we offer so this is a tool that I've been working on for quite some time so it's a highly configurable multistage language agnostic contract deployment facility so the idea here is is that you have something similar to web pack where you have this single JavaScript module it's a highly configured deployment stage module and basically the idea is you take all these raw imports like JSON files contracts you know things that need to be plotted out you shove them through loaders that you can define yourself like web pack and then you run them through a deployment module that can basically take that data it's formatted the way you want and now you you run the deployment staging the way that you want it and then you kind of fire done at the end and then you can output your data with simple output formatting plugins and the result is that you get this very complex deployment staging facility for contracts that you can kind of tuck into mocha you can tuck into whatever testing facility you want and you can also define your environment really easily so you're just putting in the raw provider object and a name and your default transactions and objects and then you're just going to run that deployment sequence and the thing is is there's a lot of tools out there like truffle and everything and they're getting better all the time but the this essentially what I wanted from the beginning which is just the sequence tool that I could run complex deployments with and just do that in a very fluent way it is high configurability which means there's a high you know set up overhead when you when you initially start using it but basically once once you get your deployment environment the way that you want it with the loaders that you want so soul sea and some environment loading and stuff then you don't have to do anything you can just reuse your same modules over and over again so this is one thing that's going to be moved into ejs right now it only has about 30 percent test coverage so I need to get that around 104 I'm moving into its HS so but that's called eath deploy and that's available on my github so silence is Rho /e deploy so a bit of the roadmap so I'm gonna move the ABI work from each s just over to ethers J s because Richard Moore is literally the God you've never met yet and it's amazing so he's in the room he's in the room personal hero so as well the removal of buffer across the modules which should reduce the non account handling module to around 50 kilobytes and as well better account handling and filtering so right now I've pretty good filtering and event handling but I think I'd like to get that better some people complained about certain certain aspects of that so that'll get improved I really want to integrate some new bounties networks that are coming about so bounties dot network it's very cool and get coin and and that's just for keeping the libraries updated and and keeping bugs you know way removing a morphic number handling so basically right now we support multiple kinds of types going into number handling I think I'm just gonna support probably just big numbers and while that's a little bulkier and definitely not everyone's favorite sometimes I prefer that just because it keeps type strong and then as well more detailed error handling so just I'd like the errors right now they are pretty detailed but I'd like them to also be user-friendly for new users I think that's that's pretty critical to new people entering the space and then give book documentation right now the documentation is in a in a repo through read Me's so I'd like to move that skip book and just as well so because I have just a few minutes yeah so there's definitely been a lot of discussion before I just thank all the people that heavily influenced my thinking there's definitely a lot of discussion around like alternatives to web 3 I think web 3 has been quite a journey i-i've been using aetherium since proof of concept 5 so I've kind of sludged through the journey at every stage when etherium barely worked and there was no tools - now it's fantastically working and there's so many tools but still a lot of you know room to grow I think you know the architecture is growing significantly and we have a lot of really cool stuff coming up and I think the thing with alternatives and especially having kind of a diverse set of tools at this layer is just you know this is like the front door to aetherium and it's very critical that everything works properly that errors are thrown where they should be the throat loudly that you know early users to our technology can kind of get a great experience out of it because right now it's not a great experience and right now we have a lot of you know junior devs and stuff who are definitely melting when they start using aetherium when they shouldn't be it should be a very simple process and I think that we kind of need to get more realistic with our expectations and what we want to achieve especially when it comes to just like an effing RPC layer that has some data formatting and some contract handling like it drives me crazy I'm like so you know I think if you see potential to fix modules or to make them better or even to do your own you should definitely do that you should definitely expand the eCos and and try to help out where you can on existing modules and you know once again like my personal favorites definitely lieth with ethers je s and and the modules that I've been using and I actively developed apps so I'm currently developing board room which has been in stealth mode for like two and a half years a super old project and so I'm constantly using this tech that that I've been implementing and that's kind of giving me a completely different perspective on architecture but as well I just like to be a little more old-school with my thinking so you know the UNIX philosophy and all that sort of stuff in mind has kind of led me to this sort of design so yeah just special thanks to a few people so Richard Moore for doing Easy's J s web 3j s and Fabian for you know Manning the ship and like holy it's been just like a crazy ride and now there's like a bazillion people in the DEF CON room and not just like a hundred and in Dan Finley from meadow mask and Pele and martin betsy and metallic for creating a cerium which I always think at the end I just think it's great you know and then Joe and consensus for funding everything this is my contact and that's the link to EJ s and thank you [Music]

Automatic transcript — names and jargon may be misspelled.