 Welcome everybody, my name is Lars Brunnes, I'm the Director of Education at IOHK and in this short video I want to help you get started with Jelle, the language designed by runtime verification to power smart contracts on Cardano. We look at a very simple example of a program written in Jelle and show how to deploy it to the Jelle testnet. You can of course write Jelle from scratch but to begin it's maybe easier to start with a contract written in Solidity, compile it to Jelle and then look at the resulting code and modify it. So we'll do just that and as an example I'll take the same example I used in another video where I showed how to compile Solidity using the command line tool mallet and then deploy it on the Jelle testnet. So let's briefly look at this simple contract, it's called counter, it has one int variable x of state, the constructor sets x to 0 and there are two functions, one to increment x by a given increment a and the other to return the value of x. Let's compile, we do that with mallet connecting to the Jelle testnet and the command is Jelle.compile, takes the file name, let's check the result and there we see the field Jelle code which contains the Solidity contract compiled to Jelle. So in order to save that we use node.js fs write file, file name, let's call it counter.jelle, we use c.jelle code and we must provide an error handler but we don't expect any errors. So let's do it like this. Let's check and there we are. Let's look at this in editor, so I'm starting with, okay, so first of all we notice that this is actually quite easy to read, at least it's much more easy to read Jelle than it is to read EVM and we can see the structure of our original Solidity contract. So we have the contract name, we have the store variable x, we have the constructor, the increment function and the get x function. So let's look at that in a bit more detail. So this status variable x is indicated with an add symbol, then function names also preceded by an add, then we have labels in this function in the constructor, we have three entry, return and throw. So labels are the destinations of branching statements. In the first line, we have a local variable, a register prefixed with a percentage sign and we assign to this register call value result of calling the special function Jelle call value which returns the value of the transaction. So register call value now contains the value of the transaction and in this line we do a conditional branch. So it takes two arguments, the variable to base the conditional on and the label where to jump to. So if this is greater than zero, so if this transaction has a value, then we jump to label throw which is down here and we revert. So we expect it to be zero, in that case nothing will happen and we reach this line where store variable x, this one here, our counter is set to zero. So the constructor first checks whether the transaction value is zero and if it is, it sets x to zero, otherwise it reverts. And after setting x to zero, it returns void nothing. In the increment function, we have an argument to the function also indicated with this percentage sign called a zero. We again check that no value is transferred, otherwise we revert here. Then we introduce a register x dot well, load the value of x into it, introduce a second register TMP and assign the sum of register x well and a zero to it. And x well has the value of x. So temp now contains the sum of x and the argument to the function a zero. And finally we store the sum back into x and we return void. Finally in the get x function, again we check that no value is transferred, otherwise we jump to throw and revert. We load the value of x into register x dot well. We introduce a second register underscore one, assign to it x dot well. Then we jump to label return. This now only has one argument, so it's an unconditional jump, it will always jump, so it jumps to this line and returns the value of register underscore one, which is the value of x dot well, which is the value of x as expected. Now that we understand how this works, let's try to improve on it a bit. First of all the double quotes around the names are only necessary to escape special characters, so as long as we stick with simple names, they are not necessary. So let's get rid of all the double quotes and simplify the names. We call this simply counter, this simply ink x, this simply get x. Then the variable names we can also improve, so here instead of a zero we just call it a, instead of x y, just call it x, instead of temp give it a clear name sum, down here same. So now that we have renamed the registers, let's look at other things. For example the labels to these entry labels, we don't need them because we never jump to them. We do jump to the throw, so we leave that, but we don't jump to this return statement, so we can get rid of that. Same here. Here we actually do jump to the return statement, but it's an unconditional jump and as you can see, you just jump from this line to the very next line, so we can get rid of all three. We remove the jump and the label and then there is one final thing we can do, this underscore one is unnecessary. Here we load the value of x into the register x, then we load the value of the register x into register underscore one and then we return underscore one. So we can simply return x directly and get rid of this one. Now that we are happy with the yellow code, let's generate bytecode, so we fire up mallet again and we again use yellow compile, only this time we give our yellow file as source and c.result is the bytecode we want, but just for fun, let's compare this with the bytecode we would have gotten if we had used the original version. So let's compare that with yellow compile where we compile the solidity and grab the bytecode, let's not overwrite our c and we see that was much longer. So our hand optimization indeed made the resulting code shorter and cheaper and faster. Now that we have the bytecode, let's quickly deploy and test the smart contract. So in mallet, I first have to select an account. So I simply list all accounts, grab the first one and select that. Now I use yellow create contract where I have to specify some gas, let's use 100,000. Then the value zero and most importantly the code, which is just our c.result, I must provide the password for the account and let's grab the receipt in order to get to the contract address. That's not available yet, that is. So the contract address is r.contract address, right? Now we have deployed the contract, now we can test it. So let's first increment the counter, yellow contract call, specify the contract address with this now counter, some gas, let's again use 100,000, value again zero. Now I need the function name, which is ink x and finally the arguments. So if you want to increase increment by seven, we use this again, my password, let's wait for the receipt to see whether the call succeeded, okay, status code is zero, so it succeeded. Now finally let's call get x to check whether the counter is now indeed on seven. So for that function, I don't need arguments, password again, get receipt. Let's grab the result, okay, and in the return data, the seven is encoded, so if I want to decode that, I can require the RLP library and use its decode function applied to r.returndata, and there we go, seven. So we deployed the contract and we tested it and it seems to work. So to summarize, we have seen how to compile a Solidity contract to yellow, we have walked through some very simple example and seen the most important commands like using local registers, assigning values to them, branching, branching conditionally, adding numbers, returning values, we have seen how you can optimize yellow code, make the resulting byte code smaller and faster, and we have seen how to deploy such a smart contract to the yellow testnet. And of course we have only scratched the surface, so if you want to find out more about yellow, you should have a look at the home page at runtime verification, yellow semantics on GitHub, and there you find lots of information like the complete syntax, the design decisions made, and a lot of more interesting things.