 Okay, thank you for coming. This is a talk slash workshop on the topic of smart contracts on Ethereum It was announced in the schedule English and I think Weird, okay. I heard some English speaking people talking English Okay, so we keep this in English It's rather late and usually you have something like Hacker Jeopardy at this time. We're doing smart contracts or perhaps we could also do Yeah Let's take the schedule so As I said, this is a workshop. So please To speed it up a little there is a browser plugin called meter mask. We will need that later. It is an Interface to the Ethereum network so between your browser and the Ethereum network So while I do this boring introduction talk you can already install this exciting plug-in Yeah, so blockchains blockchains are these weird is this weird world where people buy expensive hardware and actually even manufacturer specialized hardware and lease Airplanes just that they get the new hardware one week earlier than their competition and then they waste tons of electricity to produce virtual coins somehow and then there are these other people who Who try to scam Common people into investing millions of dollars into their project which then somehow doesn't work out and it's a project on some some tropical island instead and There's also this company which was called which used to be called Long Island ice tea and They renamed themselves into long blockchain and their Their stock price increased fourfold over a day or something like that and then There are Yeah, people who want to put blockchain into everything blockchain in your car blockchain in your house blockchain in your dog and When they when when you take a closer look at their blockchain you realize for Yeah, 99% of the cases Yeah, they that the blockchain isn't really an essential part of their project It doesn't benefit from having a blockchain but there is something below all this and I hope we can talk a little or I can Yeah, bring this a little closer to you in the next hour and The thing is that Wasting electricity and proof of work is not essential for blockchains. There's something called proof of stake Which is currently still under research But it looks promising that it can completely replace proof of work and so you don't have a waste of electricity and most of these ICO tokens are scams but Creating a token and having a crowdfunding is actually an interesting can be an interesting way to fund a project if it's done, right and There actually are some good use cases for blockchains and I I will tell you about two use cases and One of them is called swarm or more general the topic of a decentralized incentivized file storage IPFS is also developing something along these lines and The idea is that you use bit torrent for backups that might sound weird because usually you just use bit torrent for downloading movies but If you use bit torrent as a general file storage system, then you have two problems unpopular files are deleted and if if a file is deleted from bit torrent then It's gone or at least it's much harder to get the data the fewer people It have and your personal backups. I mean who would care to keep you all personal but backups and The second problem is that some people only download they do not upload and it's actually I mean it Don't have an advantage of in uploading so you could modify your software to just download and Blockchains could solve these two problems and the swarm project tries to do that and the first idea is that you just pay people for storing your files so You ask someone to store your file actually you ask the whole network to store tiny chunks of all your files in distributed way and You pay for that so people get a reward by So that you can rent out their hard disk and Of course as in these game ICOs they could just take your money and run run away and delete your files immediately but they have to put a deposit into a smart contract and If you request the file later on and they cannot provide it then they lose their deposit so they have an incentive to actually keep your data and the second thing is that With we talked about this problem that some people only download so Even if they have your file they might give it to you Only very slowly because they don't want to waste their their the uplink capacity and that can be solved by just paying them to do that so in This is done in a way such that you always measure the The data going in one direction on link and going in the other direction on the same link And if there's an imbalance then the person who downloads more has to pay for that data and In general Designing these yeah mechanisms where you pay We have to pay where you where you reward or where you punish people in cryptocurrencies This is called crypto economics or more general the the mathematical branch of mechanism design And a blockchain allows you to add that to an existing protocol Then the second example is Yeah, HTTPS or SSL without trusted CAs the CAs or certificate authority problem is a well-known problem and Currently as far as I know SSL certificates are tied to host names only via these CAs and this means so a certificate authority signs the key that belongs to a server or to a host name and They are supposed to check the ownership of that domain, but it's not part of the protocol They can do it, but they don't really have to and they can easily create fake certificates and basically disguise as as as anyone and there are many of these CAs out there and But a blockchain based system could solve that problem and it could solve it By just making this domain ownership check or at least the Distribution of domains and the transfer of domains part of the protocol. So the blockchain stores who owns which domain name and Of course, so who here is so people are identified by a public private key pair. So a public key is tied to a host name and if you want to sell it you can only sell it or yeah or if you want to transfer it you can only transfer it with a signature from that key and You can just you can yeah the the the certificate can be stored directly together with this With the name in the blockchain and Yeah, the Ethereum name serves Ethereum name system is built like that Yes, it's a hierarchical DNS like system of names for Ethereum and And In a similar way you could build a corruption resistant land registry So land ownership registry of course in Germany This is not such a hot topic because land registries usually work quite well, but there are countries where you can just go to To the authorities pay a little sum and then you own a Piece of land. You're actually not supposed to own Okay, when are blockchains useful in general? They are useful. I'm sorry, this really doesn't work well They are useful for application that are already digitized so blockchains have a problem with interfacing with the real world so you can't yeah, I mean an Application on a blockchain actually cannot download a website. It cannot check if a package was delivered correctly but if you already have a digitized application BitTorrent as an example then it can be useful in addition Participants have to have conflicting goals if everyone has the same goal then yeah, there's no you don't need something to to yeah resolve disputes and also They should not be a central trusted party if there's a central trusted party you can that party can just run the server and you put everything on that server and it works much better than with a blockchain and So I think these three These three characteristics must be set and in addition Yeah, they have to be much more important than Yeah, sorry, how do you say that so If you run it on a blockchain that it it will be much more expensive and it will be much slower than running a traditional server. So it means These three topics here have to be as important to you such that these higher costs and the reduced performance are not a problem in comparison good so what is Ethereum Ethereum is in a sense in a sense essence a Database or a virtual computer a database with stored procedures and This this virtual computer is built on a decentralized network a peer-to-peer network where Everyone can just join and if you join your computer forms seemingly chaotic connections to other computers and out of this network emerges a single Yeah, virtualized computer and Everything that runs on this computer is transparent. So everyone sees what everyone else is doing it is Manipulation resistant so it is hard to change anything that was done in the past or almost impossible Authenticated this means that Everyone who interacts with that virtual computer is known in the sense of has to send a message signed with a private key So you always know where Where a transaction originates and it's publicly accessible. So anyone can go to this network and use this computer Okay, we will go more into detail later, but are there any questions already I see a lot of question marks No, okay, actually, we will not go more into detail on these parts Instead we will just treat Ethereum as a single computer That is somehow that somehow emerges out of this peer-to-peer network. I won't go into detail how that actually happens Because you want to write smart contracts and we only have one hour Okay, what are smart contracts? Smart contracts are neither smart nor are they contracts although the name might suggest otherwise it is just a term that was coined Yeah, many years ago and it kind of stuck for this This use case smart contracts are just programs running on the blockchain. Nothing else or you could also See it as stored procedures in a blockchain based database. So there's no law aspect No AI aspect. It's just simple programs Yeah Okay, that was the introduction already. So Let's try to write some smart contracts. I put instructions at this link here It's the same link at that is at the end of the description in the schedule the GitHub one exactly and It starts by telling you to install this browser plugin. I will walk you through that So yeah, these links are important later and if you want to know more here is the Solidity is the high-level language I'm developing and Crypto Zombies is an interactive tutorial to learn that language made by someone in the community actually I didn't really register there because you have to sign up with username and password Which is really weird in the blockchain space, but somehow they do that But I heard that it should be nice Good so I'll install meter mask in Chrome here. Although I will use Firefox later Okay, that's the website. I click on the extension so meter mask Connects your browser to a single computer that is connected to the peer-to-peer network and you have to More or less trust that single computer So if you want to do serious things then you should not do it like that You should run your own at least light client that directly connects to the peer-to-peer network and not Connect to some other computer that connects to the peer-to-peer network But for the workshop here, it's really convenient Okay, I installed it now. Here's this Fox icon in the in the top right corner. I Click on it. It will tell me to accept some Legal stuff Yep and Now ask me to create a new password Now these are 12 words which are of course Now known to you So I don't have to copy it somewhere self So I mean, this is all just for testing stuff. So When you uninstall so yeah when you uninstall the plug-in later, then you don't have to copy it now I have one account and It tells me that it's on the main network. So this is really important switch it from the main network to rinkabee Someone who knows Swedish might correct my pronunciation so rinkabee is a test network and the reason why we're using a test network is that Everything you do on Ethereum Costs money that might sound weird, but it's the only way the blockchain community has come up with That prevents DOS attacks, so I Can go to this computer and ask it to do computation tasks for me and If just about anyone could do that without paying money Then it would be easy to do as that computer to to yeah bring it to a halt and because of that for everything you do you have to pay with a Unit called gas and on this test network This gas is so or ether as it is also called This is worth nothing and can be easily obtained now Yeah, and since everything costs ether we have to get ether first. This is the most complicated part In this link, there's a way to get a testnet ether wire Twitter If you don't want to do that then We can use IRC and I just give you some ether so I'm on this channel called smart contracts in In the same network where the Easter heck Channel also is if you go there and paste your address which can be so you can get that by clicking on these three dots and then click on copy address to clipboard and just paste it there and I will send you some ether so I will switch to firefox now which contains a meter mask plug-in that actually has some ether I Can also increase the font size a little Okay, there. We have one address Now what I do is I take my meter mask plug-in. I click on send I put the address there and I send one ether and I click on next and what now happens is it it signs the transaction or yeah tells me to to confirm that it will sign the transaction and There's some more details, which are probably too small on the screen. So I click submit and then it I Can yeah when I click on pending here I get the same transaction in something that is called a block explorer and this is just also again a single node connected to the peer-to-peer network which You can trust but you can also use your own one, but this is yeah again convenient to use and Note that it says rinkabee here. This is important because otherwise you're on the wrong network It's so the URL is rinkabee.ethascand.io and now when we look at this pending Transaction it has pending which means it is not included in the blockchain yet. This will only happen after some time because there's this mining process that determines the order of the transactions and once this Worked which should be around after 15 seconds. Okay took a little longer this time then we have oops success here and I just sent someone one ether which don't know who it was Okay, and now let's take a look at this the details here if you use the the Twitter method to get tested ether There will also be a link that leads to this page. I think There's a transaction hash this identifies the transaction It says the transaction worked. This is the the number of the block it was included in so the a Blockchain is yeah a sequence of blocks which are linked to each other and where each block builds on top of the next and This is just the the number of the block starting from the first one It has a timestamp. It has an address where them the money was sent from this is just a 160-bit hex number which is roughly a public key and Then it has a a two address where the money was sent the amount of money one ether ether has I think 10 to the 18 subdivisions, so it's Has the smallest amount you can send is 10 to the minus 18 Then there's this gas limit. We talked about that earlier. So everything you do costs Gas and gas is kind of a measure of the amount of computation that needs to be done And We will we will run smart contracts later. So we will run programs and some of you might know You can't you can't in general predict what programs will do and because of that we have to Specify an upper limit of how much you want to run there So if it for example, if it has an infinite loop, then you want to provide an upper limit so that it doesn't really run forever because that would yeah and That's what this gas limit is for and 21,000 is the smallest Number you can have because the transact itself already costs 21,000 and then it used up all this gas so Guess that is not used up. Do you get refunded gas that is not used up in the end and You can also specify a gas price. That is something that is most confusing for some people That's the basically exchange rate between gas and ether. So If you want to pay more for your gas then your transaction is more likely to be included in the next block because The miners who create that block receive this gas as a fee And that is the actual Amount of ether that the transaction cost Nons is just something that is Yeah, it's not important No, it's so a Transaction is always atomic. There's no parallelism So it it runs. I didn't understand the question. What do you mean by it's 18 blocks away and where did you get that 18? Oh Sorry, yeah, does it mean it needs 18 blocks? Maybe 18 blocks Where did you get this number 18 mine? Until the smart contract has been executed what what does mean with with the is a gas price binding Please explain it again. Okay Gas is just a unit of resources that are consumed fuel I need to I need to fill a tank with fuel that the machine is running. That's how I Understand it. So gas is the number of steps the machine runs for example It's a little bit more complicated because you also take into account memory and Yeah, but more or less, it's the number of steps the computation runs and the gas limit is the maximal number of steps you want To wait for it to terminate to finish and the gas price is the Amount of ether you want to pay per step If you pay more per step then miners are more likely to process your transaction early. That's yeah, exactly That's what I want to know. Okay Did that answer or I Got it. Okay. So in in Bitcoin you have transaction fee and Guess but but since Bitcoin transaction transactions are more or less Consume more or less the same resources all the time the you only have the simple transaction fee per transaction But in Ethereum transactions can be more or less heavy with regards to computations. So you have to Scale the amount of resources amount of computation. It doesn't buy the gas price Okay More questions. I just hand out some more money I think the instructions already contain the next step. Do they You can also send money between yourselves Once you have some okay, and once you received some ether Me too much should show a balance here, which is non-zero Okay More people need of ether more people need of answers Okay, then Please interrupt me if you need more ether or have questions and the next step now is to go to a website called remix.etherium.org this is an Online browser only IDE for writing smart contracts on Ethereum It shows a rather complicated smart contract We will replace that by a simpler one and you can find it Whoops, what was it? Yeah, you can find it here e1 simple contract and let's just copy that and Paste it into the IDE Try that again What you can also do is you can look at addresses here in the block explorer and We tell us if this Tesla person really didn't get any or and just wants another one. Oh, yeah Did someone else receive Something does it work at all? Okay, so we should get a penny transaction here actually Yep, okay, so Let's take a look at remix question, okay on the left here you have a kind of tree view of the files in the middle you have the The source code and on the right you have some tools This is a source code of a smart contract it starts with specifying a version for the programming language and then you have this contract thingy which looks similar to a Java or C++ class and that's yeah and The thing is that so smart contracts have a storage area where they can store permanent data and only the smart contract itself can modify its own storage area and We use that to map member variables, so the stored number is a unsigned integer value that is permanently stored on the blockchain and Public means that you can yeah, you have a convenience function to yeah It generates a getter function to read the value then you have a function called name Which is also public available visible? it is pure which means it Neither modifies nor reads the state the blockchain state and returns a string the string is my nickname and Then you have a function called store number. It takes an unsigned integer and stores it inside this member variable What is not visible here is that unsigned integers in solidity or Ethereum are 256 bits wide Any questions here Basic understanding questions store numbers are P We will see what is a question what store number is basically is it? Visible AP can it be called from yes, so all functions that are public can be called from outside. They can be called from a Contract like the one you just created Sorry, they can be called from an account like the one you just created and but they can also be called from other contracts and what we will now do is we Will compile this contract and deploy it on the blockchain Yeah, if you click this auto compile auto compiles, which is quite nice It would tell you any problems with the source code immediately so Yeah We have a warning here which we ignore Okay, let's take a look Yeah, okay the gas requirement is high The reason is so it estimates how much gas a function takes and it says that the name function can take arbitrary amount of gas and the reason is that the string is a dynamic data type and you don't really know the length Although you actually know it, but yeah, okay So The run tab here allows you to create smart contracts and call functions on smart contracts This environment drop-down here is important It tells you it uses injected web 3 injected web 3 means it uses metamask and it says it uses the rinkeby network here So everything you do down here will have an effect or will create transactions on the rinkeby blockchain You can also switch to JavaScript VM in that case it will use a simulated blockchain that only exists in the browser That's the account we will send from that's the gas limit the yeah maximum time we want functions to run and Yeah, we don't want to send any ether with the function call that we could do here Okay, you select the smart contract here my named account and click on create now metamask will pop up and ask you to Confirm this transaction you want to Send here It again tells you the gas limit was not different because there's actually some work to be done We confirm that Now we wait a little It would tell you some details here don't look nice So this is a pending transaction now. Oh, yeah, it just got confirmed. It says contract published here Which should also mean that? No Yes, something broke in my system. He'll try it again So something should appear down here for you if it worked What did I enter under account? I just use the default There's just one thing for me. Yeah, your contract is visible in it. I scan Yeah, okay, but remix doesn't see that. That's I'll just reload. Sorry. So remix has some glitches Does it work for you? Does anyone have problems? Okay, then I'll try a trick and I go to either scan I see that so when a contract is created the address at which that contract is created will only be determined after creation so but I can copy that contract that address here and just Tell remix. Oh, I know that a contract of that type is present at that address I paste the address here and I click at address and now I get the same interface You get when you or I would get when the contract is correctly created. Okay now I have three buttons one button per function store number is red because it triggers the transaction because it Changes something in the database in the blockchain name is blue because it's just a query function Just read something from a blockchain if I click it It will still query the ethereum node But it you won't have to pay anything for it because it's just reading data and it should Display Chris ethyl. That's the string that is returned in this name function And if I click on store number, ah, sorry if I click on stored number Then I get the the value that is stored in this member function should be zero exactly and Now I can store a different number here And if I click the button now it will again ask me to confirm a transaction and now we have to wait a little Yeah, that looks better. It now tells me a link to ethers scan or you can take a look at the transaction So that's what I meant when I said it's not as fast as a non blockchain solution Yeah, okay remix now tells me that it already worked although ethers scan still has it pending and Now you have this details and debug buttons here when you click on details It will tells you details on the transaction if you click on debug it will fire up a debugger Okay Sorry Perhaps that worked you won't believe me when I tell you it worked perfectly fine when I tried it yesterday Yeah, okay, we can also go to ethers scan and use tools and utilities here and Click on remix debugger. This is similar to the remix debugger. You would have seen But it doesn't resolve local variables, but it shows you How it actually executes the the bytecode that is generated here and so this slide is just the This point in the execution Because you can't do anything about the transaction any way anymore. You can easily Yeah, go back and forth through it The question was if all of these instruction cost one gas No, some of them are more expensive. Some of them are less expensive. Hmm. It will block Again the world will block of that cost gas Not every single instruction. So everything looks single instruction costs gas, but some of them are more expensive than one gas so The approximation to get to gas is yeah, the number of steps And if every instruction would cost one gas then it would be just number of steps But it's not exactly that because a multiplication is more expensive than an addition for example, okay But if you if you click on step detail here, then you see the remaining gas here And if my screen was larger, I could steps through it and we would see that it gradually Decreases with every single step and it tells you that the amount of gas this single instruction costs good More questions. Did he try to change the name here? Who changed the name? so Let's do something more interesting Let's deploy the Easter hacks contract. Okay, the Easter hacks contract Is a token contract. So It has a mapping whoops. It has a mapping that contains The balances for every conceivable address. So every address is assigned a balance all the balances are initially zero and it has a total supply the number of Easter hack tokens in existence. So this is a standardized contract interface called ERC-20 and the idea is that As long as you keep to the standard You can just use any Possible and even future token together with your application so if someone creates a new type of token and Your application is compatible with the ERC-20 standard. You can use You can just use that token with your application and Yeah, each token has a name a symbol number of decimals Then you have a function where you can create the balance of an account. It just returns balances at that point Then you have a function called transfer Where you can send tokens to someone you can send a number of tokens. So this value to someone and the way it works is that it of course Checks that you have at least that money. Oh, yeah MSG.Center I said earlier that every transaction ethereum is signed by the person who initiated that transaction and it actually goes so and Smart contracts can call other smart contracts all these contracts are done synchronously and MSG.Center always contains the The address one higher up in the call chain. So MSG.Center is always who called this function and If you call The function transfer then you voice the intent to send a number of tokens to an address and because of that We can use MSG.Center here. So And this is this is the interesting part you do not need to know any cryptography for that Usually you would have to sign Data you need elliptic curves Signatures and all that but this is all abstracted away It's just a computing platform that knows who called which function and by that you don't need signatures Okay, we check if the sender has at least that Amount of tokens room would reduce the balance of the sender by that amount We increase the balance of the recipient by that amount and we emit an event. So this is Just to to send a signal to the outside world that something happened This is just logging or something like that We said the transfer happened From here to here with that amount of tokens and then we have a special function that is not part of the official ERC-20 Standard it is marked internal which means that it cannot be called from outside and This can be used to create new tokens. So it increases the balance of the sender by one and Increases the total supply by one and emits a special transfers event From the zero address to the recipient and then we have also again another public function Which is not part of the standard you can call that to request such an egg or an egg Only until Monday Yeah, let's deploy that contract and try to call that function So I will now Create that smart contract and I will tell you the address where it was created and Then you need to copy that source code and use the add address feature. Okay. Yeah, that's annoying Okay, now The way to go is okay Why is it? Yeah, the test net is not in best shape today Because I mean that is something all that I can always happen in a blockchain or The node we are connected to here already says the contract was created and the node if the scan is connected to it Did not yet have that information so but the older transactions get the more reliable they are and Already after 10 minutes you can be quite sure that it will never change Okay, this is I will paste that into IRC and I will also Make a comment on the on the Just Okay, now what you do is you take I mean you do exactly the same thing as I so you you copy paste The source code here, of course and Then you check that it says Easter hex here You paste the address into the address field and click on add address smart contracts Okay, you have to remove this space here. It seems smart contracts on Hack into this Okay, my time estimate is a little bit off We didn't get Okay, we can check some information here Decimals zero name Easter hacks that worked symbol EHG total supply should be zero. Yep and I can request an egg Let's see what happens Guess estimation failed That happens that the error is not the best So that happens because of this require or not of that require Yeah, this happens because The request hack function calls The name function on the sender, okay, it And of course the sender here doesn't have a name function because it isn't even a smart contract. It's just a Public-private key account. It's not a smart contract. So this call fails and When a call fails then Every everything in the transaction will be wrote back and It depending on how it fails it might cost all the gas you provide That's that or yeah, the more gas you provide the more will be consumed. So it can really estimate the gas that's the reason and So this means an external account cannot request an egg here Because it doesn't have that name function. So only accounts that have the name function Can request an egg Okay, so what we need to do is we have to create an account smart contract, of course that has the name function and An example is here this named account, which is below here It has the name function. So we take that And create a new file here on this plus icon Paste it here and we implement it. Yeah. Yes, it doesn't matter. So We only have five minutes left, but there's nothing after this event. So So one thing so I said earlier that this is this compliant to the ERC ERC-20 standard and This blockchain explorer has support for that standard, but it's much nicer if I tell so The smart contract is given in source code form, but it's compiled to bytecode and only the bytecode is sent to the blockchain and Because of that the sort this blockchain explorer doesn't know the source code It only knows the bytecode But it's much more useful if we also tell it how the source code looks and we do that by just copying everything here We okay. I can't copy two things at the same time We go to that address here That's something only I have to do now because we already reused the same thing Okay, it knows it's a it's a smart contract It has the code here, but it's just bytecode, but we can use this verifying publish feature here and We need the source code for that There's a half automated version using the swarm project I mentioned earlier But it's not implemented in either scan yet. Now we have to tell it the Contract name and select the same compiler version So what it will do is we it will take the source code and recompile it and check whether it matches The bytecode that is stored in the blockchain Yeah centralized services Okay, that worked and now we have the source code here and We're still in the verify Setting if we go to the account now It will give us more options. It will first tell us the source code And it will allows us to read smart contract, which is yeah, similar to what we can do in remix We can call functions that are query only and I doesn't yet know that it is an ERC 20 Contract because that is actually triggered by this event we saw so if if the scan sees that this transfer event then Here then it will see that it's an ERC 20 token Okay for that someone needs to get an egg and that Can be done with the request egg function that someone already find out how it works So we need to call that function from a smart contract that has a name function So let's create a smart contract that has a name function and also add a function that will call that request function now Yeah, okay, okay So we need to tell this named account contract the interface of the Easterhex Contract and that can be done by just pasting it here. Okay. I could have done that easier I guess and now we pretend that That at this address of the Easterhex contract we actually have a Easterhex contract So that's a explicit type conversion. I think this is also linked somewhere and then we call EH dot request heck Okay, did everyone get that? You need to use the same address here. I mean, that's the address you I pasted into the chat Okay, now if you create that Okay, we have multiple contracts here now in this file. So we have to select the correct one the drop-down and Click create It might be that Firefox Does that the plug it doesn't work really well in Firefox? Are there more questions while we're waiting So to conclude all this For example, if the the get heck is for example a ticket for the Easterhex conference. Yes You could completely deploy the ticket sales Into the blockchain and have a fully distributed blockchain ticket sales solution for example If you can associate Physical persons with public keys So you can check the tickets at the entrance. Yeah. Yeah in principle. Yes But and this so because we have this transfer function the tickets can also be transferred to other people and Since the transfer function can be called by smart contracts you can actually also sell the tickets and selling means you have an atomic transaction that Both transfers the ticket and transfers the money in the other direction at the same time And not only send a sale tickets from the central as the Organization but also people could sell sell their tickets to each other. Yeah, sure. Yeah, but but then in the end that means You said each each transaction here costs a little bit of money or a little bit of ether that means depending on if you if you start the ticket sale in December of 2017 or now you you have a different dollar value that you need to even get the ticket by where we are this method Because of this exchange rate of ether. Yes. Yeah, I mean it kind of so it also depends on how much activity You have you have on the blockchain Because if you have more activity on the blockchain then the gas price will increase because there's more demand and there's only a limited amount transaction that fit into a block Because of that because of that the gas price will increase and if you have I mean If there's almost no activity you can also get away with a very very low gas price and because of that a very very low fee So it depends on multiple factors The question was if cryptic it is makes it too expensive The kid is was a very popular application in December Which cost the gas price to increase tremendously and yeah, so these are factors so Ethereum is working on scaling solutions, which means a way such that It does not get more expensive if the blockchain is used more heavily, but that will still take some time As a question what what is your personal? Environment toolset are using parity and Visa studio code To be honest, I don't Deploy I don't use blockchains very much Because I'm not an application developer. I'm I work on on on Solidity, so I developed the high-level language and So in general the so the Ethereum Foundation is a non-profit organization with the goal of Developing and extending the Ethereum platform and we do not develop Application on top of the platform. We do it develop some very basic application like the Ethereum name system, but not Yeah Non-basic applications, okay, and since so I mean the smart contract language Doesn't need a blockchain only needs a virtual machine to run on because of that. I don't really use blockchains that often So I Copy the contract address now and now I can use it in remix Yeah, so we have a named account at that address. Let's check what the name function works. It works It doesn't return a string now. It returns an hex encoded version of it That is a limitation that will be removed with the next version of the compiler But for now, it's yeah, but it's 32 hex encoded And if I click on get egg now it will call the Request function and Hopefully be assigned an egg and what we can do now is we can take a look at the ether scan interface Another question Did the rest get the new Address from the new contact or is this not I know so everyone can deploy their own So the name contract Okay, the idea is that every one of you creates this named account contract and Fetch as an egg basically Okay, so and now if we take a look at the transaction here It says this transaction included token transfer from the zero address So it the token was created to this address and now if we can we can take a look at this your C20 Easter hex token and Ether scan will provide us with a shiny interface That lists all the transfers. So, yeah Some of you successfully Got some of these tokens and we can get a list of token holders. Yes, some already have to Can even have a chart Yeah, so and and this is this is just a tiny glimpse into what is possible with smart contracts And especially due to the fact that smart contracts can interact with each other and their interfaces are public you can so Yeah, you mentioned cryptic caddies earlier. This is a yeah kind of funny gamified thing where you can breed Cats and they have a genetic code that is stored on the blockchain and if they made then this genetic code is Combined to form a new cat which then looks different but shares some properties and But it's it's everything is stored in a smart contract on the blockchain. So people can Create new smart contract and interact with that existing smart contract. So people Took that game and extended it with a version where you can also buy hats and put them onto your cats or There's another game where you So all these cats have Different feeds that are derived from the genetic code and now someone created a game where you can have cats race against each other and If they have the appenter feed that they are faster and things like that So and this is of course just yeah stupid games but if you imagine that with real useful applications that Could get rather interesting Okay, I have some more things we can do with this egg contract, but I'm sure if it doesn't make sense I think everyone is rather tired We could Do an ad hoc session tomorrow perhaps to continue if there's demand interest Not sure if we if that is how I said, okay, we can put it in the schedule, right? So yeah There was another question Was there's a smart contract and was something that automatically? Got activated when something happens in the Yeah, that is that is my that is commonly stated, but it's wrong. Yeah, it's wrong, right? Yeah, so yeah News articles always say oh, yeah smart contracts are contracts that automatically trigger when something happens And then they settle some stuff. That's wrong. So yeah, like stop loss Contracts. Yeah, so smart contracts always have to be pushed. Okay, so you always have to First set them up and then call them. Yeah, okay. They do nothing on their own. Okay, having said that of course because it's a You can of course create a smart contract to pay people To trigger your smart contract when certain things happen for example at certain points in time Right. Yeah, okay, okay And that way the smart track smart contact themselves do not get active on their own But because we have humans who like to get money We can make use of these humans to activate the smart contracts And so what is also important smart contracts cannot read anything from the environment They cannot download websites everything has to be fed into them And the reason is because smart contracts are executed in every single computer that is part of the peer-to-peer network and These executions have to come to exactly the same result in the end And because of that you cannot have any external input that might be Yeah over some flaky connection It they have to be yeah, basically mathematical functions, which always you deal the same result More questions Yeah in the back Hi So you had to specify the the interface for the get hack function. So doesn't mean that that Whenever I want to call a contract from another contract I have to somehow get the interface to that contract Yes, I mean you yes, I mean, okay, thanks Yeah, you you want to know what that contract does anyway, right? So you actually don't even want to know the interface. You also want to know its semantics and In the case of your C20 for example, these semantics are kind of implied by the interface, but You can actually create a token where this transfer function You can create an ERC 20 token where the transfer function does some weird other things So and this is this is actually also something interesting. So On Ethereum, you can easily create new currencies new tokens and They can have very weird mechanics. For example Random tokens being destroyed every day or random tokens being created every day You can have something that is kind of similar to to basic income using tokens on Ethereum Yes, I have a question you said that a smart contract is executed many times and then the only when when the results are equal then it is Then it is put into into place I Always understood that the miner that was writing the next block, right that he would execute the contract One time on on that machine where the mining is done and Then he would receive an ether He would receive the gas or the ether for executing that contract one time. Yes I didn't think it was a parallel process. That's correct So the miner executes the transaction determines the outcome and then sends the block containing the transaction to everyone else But everyone else re executes and re verifies that that was actually the correct outcome and If they come up with something else, they just drop the block So that's where the security comes from everyone Re-executes everything all the time to check. Yeah, it's a common misconception that the miner actually checks Anything of the block So basically minor just needs to find a hash that matches the difficulty and and most Yeah, it depends on how you define mining, but usually it also includes The minor trust trusts another node or another person in a mining pool Yeah, yeah, but but someone has to execute the transactions in the mining pool Okay, but when the small contract is executed on the blockchain Then the results are written to the blockchain and then they remain there. So it's not interacting with any other System on the internet or something. No, no, so Okay Yeah, there was another question If all the function have to be all the functions have to be deterministic and everybody has to get to the same result How do you implement a function that as you earlier mentioned kills random totems? It has to be pseudo random, of course. Yeah, so it cannot be actually random, but that's The case for most of the randomness in computers. So Yes one way to get something like randomness is using the hash of the current or hash of the previous block that is accessible from the smart contract It's not a take some kind of outside Unpredictable input, but that is Universally agreed on in the network I mean it is written inside the smart corner the smart products has take the hash of the previous block Unpredictable. Yes. So miners can manipulate it to some degree so It always depends on how it's used, but it's some kind of randomness so if you have I don't know if you have a lottery and You have a zero one chance of winning then a miner can run it and if the miner doesn't win They just try again And for such cases it would be bad to use the blocker I think there was another question. Yeah, I understand that the transactions and the data that Come into a smart contract or are attached to that contract or part of that contracts Chain So if I have variables that are defined within the contract maybe a struct and I'm adding to this then that data is associated with this contract Somehow my the point I'm I'm wondering about is if I publish a new contract with a bug fix let's say mm-hmm and then I Want and my application relies on the data that was submitted to the previous version of the contract What happens to that data when I publish a new version of the contract? Okay? That's an important point so as I said earlier, so for example this this Total supply The only point where this is referenced is here at the bottom Where a new egg is created? That's the only way to change that variable because it's imprinted into the code and Furthermore once a smart contract is deployed. It is impossible to change its code. So you cannot Publish a new version of the smart contract, of course You can you can change the source code and publish a new contract, but it would be a different contract with a different storage area so my question is about a production application that might be using Ethereum and the smart contracts that relies on transactions that are ongoing or maybe that happened weeks months or years ago There's there's gonna be a need to change the contract or or Fix it bug. It'll never be perfect. Yeah, that is that is a tricky thing about blockchain so You want to have some kind of way to update the code but then the question is who is allowed to do that and So if you have a single person who is in charge to update that contract and so I mean updating the contract I mean usually you think of updates in oh, yeah small patches applied, but it's just I mean it's new code It can be totally different. It can change the behavior drastically from from yeah from one transaction to the next and There are methods to do that But it it's always a trade-off do you want to allow that or not and it's also it's so by default Code cannot be changed, but there are ways to kind of update the code and keep the data So many two summarizes differently we have this database this global database and it's Once something is in it. It's immutable. Is the microphone switch on Just look like it It's a song Okay, so stream it's on. Okay, so The usual thing you do when you have immutable data is to create a new copy with and Do whatever you need to do to that copy and Agree that this is the new Version so is there maybe you need to form cause some kinds of some kind of consensus to to switch to the new version Of your contract So yes, there are several ways to do that and if you separate code and data Then you can deploy a new code that references the same data You can also create snapshots and recreate the same data at a different place But it's always a trade-off between costs and convenience and security. I think this is What goes in this direction? Yeah, okay key Shall we go to the lounge? Okay, then thanks a lot as I said, so yeah, if you have more questions just approach me I Will only be here until tomorrow evening So if you have questions often tomorrow and perhaps we do a continuation of this workshop tomorrow. Okay. Thanks a lot