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

Loading player…

Miloš Mošić: Introduction to Erebos a JavaScript client for Swarm | Swarm Orange Summit Madrid 2019

SwarmWed, Oct 9, 2019, 12:00 AM

Miloš Mošić: Introduction to Erebos - a JavaScript client for Swarm Erebos is a JavaScript client and CLI for Swarm. It provides: Low-level APIs wrapping the Swarm HTTP endpoints for BZZ and the socket APIs for PSS. Utilities such as handling hex-encoded strings, signature keys and hashing. High-level APIs simplifying application flows, such as feeds polling and the Timeline protocol implementation. This talk is split in two parts: the first one introduces the Erebos library and gives an overview of the APIs it supports, while the second part gets into more depth about the Timeline protocol created in collaboration with the Epic labs team and how it can be used for common application needs. About Miloš Miloš is a Senior Software Engineer at Mainframe, working on the development of MainframeOS and related libraries. His previous role was the CTO of Evercam, where he got a lot of experience with working on fault-tolerant, distributed systems.

Transcript

okay can you guys hear me yeah so Miller sausage I work for a mainframe and I'm gonna give an introduction to your boss it's a client that we made for a swarm and if you're anything like me you were thinking when you saw the title of the talk you were like is there like a second track or something because I don't want to listen to JavaScript and things so hopefully by the end of this talk you're gonna realize that there's some cool things that you make you can make in JavaScript too so but but let me check on that like how many of you actually use JavaScript on daily basis and how many of you actually like JavaScript okay that's what I thought so first of all before we dive into Erebus I should list the existing JavaScript clients there's two of them two notable ones it's 1jw which is a small firm gateway and Swan jeaious so the first one is just like a simple simple library that just it's just just an interface to spawn gateway which enables you to download and upload things to the gateway using busy zero it's it's really simple and swarm jess is it's actually fully featured it covers most of the API and it was it was good enough for for a while but there's there's one problem though both of these libraries are outdated and actually I want to give a shout out to swans is trader Victor mile because he in his repo he links to Heroes saying like you just should just use this so what is it was or at Abbas if you wanted to pronounce it the Greek way it's it's a JavaScript library of course it was created by my coworker Paul and he extracted it from an application that we used in DEFCON 3 it was a chat application running on PSS and then it grew larger and larger and and we made it into an actual library so it has multiple parts we cover a lot of swarm features and some things that are just not available through the swamp HTTP API so if you start with the BCC API we of course we support all the basic ones like download upload upload file uploading directories listing BCC hash gives you a hash of a given domain just like what you would expect but of course that's not all so we have some functions that are specific to the nodejs and implementation and they give you like convenience functions for for using streams to stream at our file or directory directly to the swarm instead of doing it one by one also in the download direction and you can you can tar tar files you can just provide a file path and it's going to automatically either upload the whole directory and of course we support feeds as well so we have all the feeds functions that you would want and and some more the the big thing about feeds when I started working retreats is signing mechanism was really complicated and it was hard to get right and with how yourself we actually figured out how to do it and then we put it in Airbus so other people don't have to like go to the same process and waste hours and hours of time so it has functions for signing feeds and subscribing to feeds in real time and also some other convenience portions but there's too many of them to go one by one so I should I should talk about what problems I was sold for us like what why does it exist at all so for me personally when I started working on which swarm I was really frustrated with breaking changes in swarm like you wouldn't need to know which branch had certain features and you you had to know the exact commit of swarm build that you would use and that your library would support so what we did is we added we added integration tests in Erebus which actually use a local spawn node and like try to simulate the real real life situations where you're just like actually uploading and downloading stuff you're not there's no mock test or anything and the nice thing about it is first we started with just like our own custom build just to make it work and then eventually we made the docker file with a tagged version of swarm and then finally we switch to we switch to the official docker image provided place form I'm going to link to that later in the slides and other thing is providing the higher level abstractions over the HTTP API so it was started as a wrapper over the HTTP API but we added some as abstractions on top of its to make using swarm easier and simple so these are the two two links that I mentioned so the first one is actually a source for the official Swan docker images and the other one is like the place where it's built but docker images are built-in you can just download it and use it there really nicely tagged by a version number so you can be sure that like if that version number works with version of variables it's gonna work in production and yeah a bus has a CLI but you might be wondering what form has like what the hell so are sterilised better it has some things that the swim swim binary just doesn't have and some of these are just like simple busy functions we have some PSS commands which you can use you can use the CLI with these commands to basically debug PSS communication like you would do with vs cat like WS cat if you were using WebSockets and you want to see what what's going on and we have some functions for up setting up and publishing websites directly to the swarm and everything is taking care of you just like pointed to a directory and it would upload all the assets and it was just like how to magically work so another thing that we have is timelines timelines are high-level structure built on top of feeds and it's implemented as a singly linked list and it's used to provide access to the stream of updates and backwards through time so it doesn't really tell you anything if if I don't provide like a use case so one of one of them could be a messaging app so you could have a stream of like chapters and you every every entry it would be like a message or another use case would be version updates so you could have an an app and release multiple versions and then you you could go you could release future versions and then go back in history and just like I referred to earlier version and I need to give a shout out to Xavier who actually first started the implementation of timelines and we made a JavaScript implementation wrapper to make it easier to use and there's too many functions to actually go through but it has all the convenience functions that you would want to to be able to use it in an actual app and I was also supposed feed subscriptions which is which I kind of covered and Eris has its own website with which really extensive documentation and examples so which I think even someone that it's is not familiar with swarm could just like start from here and get up and running I have a website and and just start using swarm even not thinking that swarm is in the background so yeah that's that's basically I was thanks for the

Automatic transcript — names and jargon may be misspelled.