Core Tutorial: Overview of Ethereum modules

Hi! This is a short overview of Streamr’s
Ethereum modules and Streamr is a set of open source tools to automate stream
creation and you can also buy and sell streams on the Streamr Marketplace in
Streamr DATA coins so it’s also a Marketplace to buy and sell streams. And
the tool for creating these streams is called the canvas and I have one canvas
open here. And we have special modules to interact with the Ethereum blockchain. So
the canvas has many different types of inputs and outputs including
HTTP, SQL databases, conventional things, internet sensors. And we also have these modules to interact with the Ethereum blockchain, which makes function calls and also listens to events and you can deploy code and compile code with
our platform too. So the module I have here is the SolidityCompileDeploy
module and as the name implies takes in solidity code and deploys it. In this
case I’ve already deployed it to an address and the Ropsten Network. And we can see that we’re in the Ropsten network by clicking over here and then
we see the network option over there. And you can see also that there’s an Ethereum
account and this is something that I’ve actually given Streamr, it’s a
private key. So if you’re running your jobs on, you have to give
Streamr your private key in order for them to sign transactions and run Ethereum transactions for you. But there’s also the possibility of running
Streamr locally in which case you can automate your jobs on your own machine
and then you never have to give up your private key. But if you want to use the
Marketplace and sell the streams, then you have to use So I’ve
already deployed the contract but let’s take a look at the code here.
In this case it’s a simple stock ticker so this is an example of like an oracle
but a very simple oracle where the owner can publish stock information. And you
get a price ticker timestamp and a price and and then that triggers price updated events. So anyone can listen to the price
updated events, but only the owner can update the price with this one method
over here. So once you’ve compiled and deployed as I’ve done, you get this
contract output and the contract output and in this case is piped to a get events module, which listens for Ethereum events and an
Ethereum call module which which makes transactions on the Ethereum blockchain.
And the contract output contains the ABI, the address of the deployed contract, and
also the network information – so everything you need to listen to events
and make function calls. And in this case you can see that the function is
selected as ‘update price’. There’s only one function in this contract so in that
case, it selects the first one and the inputs over here are auto
populated from the ABI so symbol, timestamp, and price US dollars. These
are all the names of variable inputs to the update price function. And similarly
the outputs over here are the translated string names of the event parameters. So
in this case there is, update price is one function that triggers the
price updated event and the outputs are generated from these names over here,
they’re automatically generated from the ABI and again I’ve selected my key that
I’ve given Streamr here which is a private key but in this case it’s a Ropsten
network so it’s a test transaction. And as inputs to this function I have this
constant stock ticker, which is Streamr over here. I have a clock module
generating my timestamp and one thing to note about the clock module over here is
that you can see that DI is disabled. DI means driving input. And what that means is that whenever it sends, whenever it receives a an input signal it would
trigger the modules function but in this case I don’t want the module to be
triggered every time the clock ticks I want to trigger it myself with this
button. But there are many different ways to trigger your modules. In this toy
example I’m using a button but you can also use a clock to automate a
transaction every ‘X’ number of seconds or you could use a stream and the stream, is then, you could interact with the stream over a REST API and post data
to your stream. And then it would pump data into the module. And even when
you’re not running… even even when you’re not logged in and looking at
the canvas, as long as the canvas is running, your module code is running. So
it runs much like a cron and in the background. And yeah, through also the
the network of distribution is a peer-to-peer network that insurances
reliability, so it’s a robust network. And then I have this pricing in gwei which I’ll
trigger with with the button. So when I press the button it will send a
driving input over here and trigger the module activity, which is in this case to
update the price. And then here I have a GetEvents module, which listens to the
price updated event, and again just like the Ethereum call module, all the outputs
are auto populated based on the names from the ABI and in this case
these are the parameters to the price updated event and then I have the
output of this GetEvents which is the the price updated event, going to a table,
which just displays the information and also this SendToStream module so if you
wanted to package your stream and sell it, you could do that with a SendToStream module and then you can charge for subscriptions in DATA coin. So in
this case it’s kind of a toy example but the data is just piece of test data, but
you can imagine sending real data also and selling that data. So when I
start the module that allows me to start interacting with it. So this is the
set up mode and when you press start, then you start
interacting with the module. So I press start. And when I click the the button
over here I should see some transactions trigger on the Ropsten network so let’s see if that happens. So click on the button and then I see two transactions were just
triggered over here. So when these things finish we should actually see the
results being picked up by the GetEvents module and then displayed in this
table over here. So I’ll wait for those to be confirmed. But in the meantime I’ll tell
you how you can run this thing locally which is to go to github and check out
Streamr-docker-dev, docker image and then you can run all these things
locally. So that’s Streamr-docker-dev on github. And I can see that my
transactions have just gone through so that’s pretty fast sometimes it takes a
few minutes but in this case it happened very quickly. And you can see from the
transaction that the price events are past, the price parameters are
past. So we have the ticker symbol, the timestamp expressed in milliseconds, and then the price which was 1337 was just the price that I gave it
over here and this data is also packaged to a stream called Test Stock Ticker. And
and that’s the benefit for the Ethereum modules. There are many other modules I recommend checking out. Sensor modules as I said. MySQL
modules. Modules for string transformation. All the things you
might imagine you might program with in in modules for automating these
streams in a graphical fashion with these piped inputs. So I find it a very
useful tool just for automating my Ethereum jobs. It’s it’s sort of like a
graphical cron but anyway please check out and take a look at
the canvases and yeah contact us with any any feedback. We’d appreciate it so
thanks! Bye!

Leave a Reply

Your email address will not be published. Required fields are marked *