 Allora, grazie molto per avvermi, è bello essere con te, è bello essere con te, è bello essere con te, per avere questa spacchetta. Bene, questo è me, e prima di iniziare, bene, questo è me, non sono più giovani. Bene, prima di iniziare, una breve questione a tutti. Chi sa che c'è un blockchain? E chi sa il concept economico per il blockchain? E cosa è il contratto smart? Bello, solo per capire come va più rapido con la mia presentazione. Ok, non sto parlando di oggi, non sto parlando di market, market per il blockchain, e tutto che è relato, non sto parlando di questa questione, durante la presentazione, almeno, possiamo discutere, se vuoi, ma non è l'interesse della mia presentazione. Stiamo parlando di blockchain come un legger general, come un punto di sviluppo di sviluppo. Quindi, cominciamo con una breve introduzione del concept blockchain e della criptocurrency, poi continuiamo con il contratto smart. Finalmente, vi mostreremo un codere. Non posso provare il codere live, perché non vorrei più tempo di fare il codere live sul contratto smart, ma vi mostreremo un codere realmente lavorato nei miei sessioni di codere live. Che è, basicamente, il blockchain? Il blockchain è un legger distribuito, che è un legger che è qualcosa di sottolineare data e collettare data e mantenere data sempre, più o meno. Il più usato della data è la transazione monetaria al momento, ma non è l'unica data che puoi ricordare. Il blockchain è qualcosa di trasparente che puoi sempre ricordare. Può essere un libro, se considerate il legger, per ottenere generica data, o può essere solo per coin. Ma il principale concept è che è trasparente, quindi tutti potrebbero guardare dentro e vedere la storia del blockchain. Un po' di definizione sul blockchain da Guardia e Wikipedia, una cosa molto importante, un legger digitale, la transazione ricorda, è sicura. La transazione ricorda, ma anche l'aggrimento e il contratto, è sicura di usare la crittografia con un po' di esplorazione, ineritamente resistente alla modificazione di data e può ricordare in un verificabile e permanente modo. Poi puoi ricordare la definizione, ma questo è il più importante concept del blockchain. La transazione è una leggera di transazione e data, è perciutante, sicura e modificata, basata in una trastra computativa, vedremo cosa significa con la trastra computativa. È distribuita e non è potente, che è il più importante caratteristico per un punto di vista sviluppato. La parte transazione è anonimosa, ma la transazione è pubblica e verificata. È una trasparente, come ho detto prima. La trasparente è una transazione che può essere di valore, di criptocurrency, ma non solo, ma può essere di valore e è qualcosa di nuovo. È una trastra di meno per i nodi e per gli usari. È basata in una trastra computativa, ma è una trastra di meno per gli usari. È un concentro più importante e vedremo perché, come e come. Iniziamo con una trasparente basata in una trastra computativa, che è esplorata con un po' di imagini semplici. Questo è un periodo serioso di Tweet che ho fatto l'anno, che ha chiesto di trasparente per imagini. Iniziamo con il primo concept, l'esce. Quando compiti un esce, hai una seta di data e il risultato è un numero. E' semplice compitare questo numero, ma è un npr, quindi è impossibile, per scoprire il numero della data. La più semplice esperienza è che se prendete blu, giallo e i colori di grado e mettete l'esce in una certa quantità per ogni coloro, hai solo un npr, ma io credo che nessun di voi potrebbe capire come molti blu, come molti giallo e come molti grado, hai messo a capire questo npr. Quindi è facile, se sapete la quantità di colori per sempre capire il npr, ma è quasi impossibile, solo guardare il npr e scoprire i colori. La criptografia usa le due data, il giallo privato e il giallo pubblico. Il giallo pubblico usa le due data e mentre il giallo privato è l'unico giallo che puoi usare per unire l'esce. Inoltre, se usate il giallo privato, usate il giallo privato per unire l'esce e puoi ottenere questo unico giallo che è il giallo pubblico. Prendete in qual modo usate il giallo privato e il giallo pubblico. E finalmente perché il giallo pubblico è immutabile? Siamo detto che il giallo pubblico è immutabile, il concepto è l'unico di una torta di carti. Se vuoi cambiare questo carto con un nr4, per esempio, puoi rimuovere questo carto e mettere l'altro, ma rimuovendo questo carto, tutto il tower sarà bloccato e solo per guardare al topo del tower, puoi chiedere che qualcuno fa qualcosa di scelto in base, in tutta la storia. Immagini, come la storia, svegliate al topo, al topo, al topo, al topo, al topo e solo per guardare all'inizio della storia, puoi chiedere che qualcuno puoi cambiare senza permissere la storia. Ok, abbiamo aggiunto una buona presentazione di Consensos. In un blockchain in generale, stiamo cercando di solvere il problema di general Byzantine. Il problema di general Byzantine è che molte parti, abbiamo n generali e alcuni di loro sono traitori. Sì, hanno bisogno di comunicare e aggriare su una strategia per attaccare il Byzantine e solo trovare l'aggriamento e attaccare con la stessa strategia per più di un'alfa di tutti i truppi, si potrebbero ottenere il Byzantine e si potrebbero comunicare solo tra il messaggio e il passaggio. Quindi, abbiamo bisogno di trovare un algoritmo per attaccare questo. Quindi trovare un'aggriamento, un Consensos, tra, almeno, un'alfa di quei truppi, considerando che alcuni di loro sono traitori e che qualcuno è trastare altre parti. Potrebbero essere solvete in diversi modi da un sistema di voto semplice, ma in permissima di un sistema in cui non c'è qualcuno trastare altre parti, un sistema che può trastare i nodi e i generali. Potrebbero essere attacchiati da un attaccio chiamato Sibili. Quindi, se più di un'alfa di questi generali sono traitori, non puoi capire che sono traitori e che gli attacchiati di Bisantio non sono traitori. Quindi, bisogna di provare l'autorità per difensore contro l'attaccio Sibili. L'autorità è un consensuo generale per dire che bisogna di che alcuni parti provano a altri, sono ottenuti e non sono traitori. Come fare questo? Well, the most used algorithm is proof of work. Basically, in proof of work, I'm approving that I'm not traitors because I'm doing a lot of computation. A lot of computation that means money on the end because you spend a lot of energy to do a lot of computation. And so, this proof of ownership is based on computing this puzzle. Only solve the puzzle and mine could be a block and we will see in a demo. But we have a mine in farming like this. This is not one of the biggest one. Bitcoin last year, there is estimation that Bitcoin last year used the same electric power of Switzerland to mine Bitcoin during the year. So, there is other possible algorithm. My presentation is not about those algorithms, but the most used one in public blockchain. We had a presentation before that considering not only public blockchain but also distributed ledger and son using different algorithms. In public blockchain, the other one is proof of ownership using digital asset instead of computational power. More or less, I own my cryptocurrency and I bet with my cryptocurrency on the block that is right. If I bet my cryptocurrency, I don't want to risk this block is discarded because I'm a traitor, because I'm losing my money. Otherwise, I'm getting a little prize if I'm not a traitor and I'm betting on the right block. Even if it seems that it's not democratic because if you own a lot of money, you can vote more. It's in fact more democratic because there is no scaling on your cryptocurrency. My Ethereum, or my Bitcoin, to mention the most famous one is like yours and yours and yours. While my power is different from the one of a big mining farm because there is a scale economy on that, having a very big mine farm is less expensive in terms of how many power I can have than having a lot of laptop. In fact, it became more democratic. I have to speed up a bit. Let's see those concepts in a nice demo. So, we started with Ash. What is an Ash? I compute data and this number, this is a number, is changing. Two things interesting because it's sufficient to change just one word, just one bit in fact and the Ash change, but the same word generate the same Ash, always. Look, if I reuse AA, I get the same Ash that I had before. Ok, how do you use it in a block? What is a block? A block is nothing else than data, a block number and another number called nonce, that means nonsense. And what is that? Is the number, this is for Bitcoin, it's not always true for every cryptocurrency, but for Bitcoin the rules for a valid block, a signed block, is that is Ash start with 40. If I change data, as expected, the Ash change and it's not starting from zero. So, what are doing miners? They are finding the nonsense number to have an Ash because the Ash is computed on block number, nonsense and data that start with 40. And the algorithm, the algorithm is written in a way that is, as I said, extremely hard to start from an Ash and guess data and it's quite easy to start from the data and get the Ash. So, what are doing miners? They are trying with nonsense 1, 2, 3, 4, 5, 6, 7 until they reach an Ash starting with 40. And how is used in a blockchain? Blockchain is nothing else than the chain of those blocks. So, whatever block number, a nonsense, a data, the Ash computed but also another data that is a pointer to previous block. So, what's happening? If I want to change a data in block 2 that is an older block, let's do that. I'm invalidating not only block 2 but all block pointing to that because I'm changing this Ash and so the pointer is no more valid. It's changing the pointer and so it's changing the Ash of the other and so on. And so, like Tower of Card, just looking at the last block that is not valid, I could guess that something has been invalidated in the past. So, it's very hard to change an older block. Why? Because if I'm a miner and I'm a traitor and I want to change an older block and I want to change it. For example, in block 2 there was a transaction that gave one bitcoin by me to him. But, as a traitor, I wanted to write that is the opposite side is giving one bitcoin to me. I have to change data of block 2 and then to have a valid block chain I have to mine this block and then this block and sometimes require a bit of time as you can see. And this block and it's very, very expensive. Very, very expensive and that said, since block chain is distributed so all blocks are copied on every node of block chain before I could finish to mine old block someone else can guess that I'm doing data and mark my node as invalid. This is the reason because it's becoming very, very, very hard to change block chain. Ok. Any question on this? But I told you that it is also distributed and unstoppable. Yes, because every node connects to each other and verifies the chain on other nodes. But this is a very old image from 70 to I think about what is centralized decentralized and distributed system but the interesting part is what happens if a centralized system is under attack the same for decentralized and distributed. For centralized one, this happens. All the system will go down. For decentralized one like cloud a part of the network go down. For distributed system just that. Just the node under attack. And so let's switch to economic concept about block chain. The question I get most when I talk about block chain is ok but why these cryptocurrencies as a value because they are nothing, they are not dollars. There isn't any bank but in economy in general intrinsic value doesn't exist as concept. Things as value because of convention mainly for main four reason I wrote three but it's four. Sorry. It's rare. It's hard to reproduce. It could be exchanged and someone want to buy it. So, some example. Euro. It's rare. It's hard to reproduce. It could be exchanged. It's easy to exchange an euro. And someone want to buy it because we are using as money. But also this this is a paint from Fontana. I don't know how many of you knows contemporary arts. It hasn't value. If you look at this, it's just a slicing the paint. But last last bet was 8 million euros for this paint. Because it's rare. It's hard to reproduce more or less. It could be exchanged and someone want to buy it. What about Bitcoin? Well, 7K euro last year. Not today. Bitcoin is the same. It's rare because there is a limited number of Bitcoin produced in the network. It's hard to reproduce because of cryptocurrency cryptography algorithms that I have tried to explain. It could be exchanged for sure. And a lot of people want to buy it right now. But just just another artist ask the artist thing that is a sheet of artist. 275,000 euro. It's rare. It's hard to reproduce. It could be exchanged. And someone want to buy it. It's strange. So, traditional payment need a central authority, a bank. And it could be done with cash or credit card or whatever. But always need a central authority emitting something. But the question is isn't it ok to simply trust a bank what could happen? Well, what could happen at Lehman and Brothers? So, what is the solution? Grandmama solution? Well, could become a bit un practical if you are lucky to have money. So, the solution could be or is the blockchain. Because transaction could be values and it's trustless about node and user. So, I'm putting my money in a trustless system. Well, depending on what does it mean a trustless system. You are not trusting in peers of transaction or even nodes of the network. You are trusting the protocol itself. Something that you are doing everyday. Everyday already, really. When you use cash. Because you don't trust people giving you cash but you trust cash itself the protocol. And in fact, maybe today you have been in a cafe to get a cafe and you have a big banknote and the bartender doesn't verify your identity. It just verify your money. Because it trust the money. You don't trust you. Ok, that's almost all introducing blockchain in general and the economic concept behind blockchain. I'm going to switch to smart contract. Normal when I do this presentation here I stop for a moment and ask if anyone has any question about what I just presented before switching to smart contract. Do you have any question? Ok, cool. Let's switch to smart contract. What is a smart contract? Well, start by definition again from Wikipedia. A contract is a voluntary arrangement between two or more parties that is enforceable by law as a binding legal agreement. And Wikipedia define a smart contract is a computer protocol intended to facilitate, verify or enforce the negotiation or performance of a contract. In other word smart contract is general proposed computation that take place on the blockchain. A computer program, nothing else. How can we use smart contract to make what is called in blockchain world unstoppable distributed application that is distributed because it run on the blockchain and blockchain is distributed as I just presented. Can transfer money and asset can not necessarily does but can and is state history because what is a computer program a sequence of instruction with state. This state is written on the blockchain so the state itself is unchangeable unmodifiable. We will talk about Ethereum. It is not the only solution nowadays to write a smart contract in a blockchain. There is a lot of other blockchain implementing a smart contract concept. Just a few, like Tron, EOS, NEO are very very promising. Ethereum has been and is the first blockchain implemented smart contract concept. And so it is nice to look at this because everyone is taking ideas from Ethereum and implementing in a different way. Moreover is the most active blockchain in terms of research and development in particular on smart contracts and with a lot of smart guys working on this. Let's try to go quick. Every node is built in virtual machine called Ethereum virtual machine. It provides a compiler from high level language to AVM like JVM for all languages. In Ethereum we have two different kind of account account externally owned account that is user account nothing else is a private key that you can use to transfer Ethereum like the private key you use to transfer Bitcoin and it's the same private key that you use to execute smart contract and the contract account they are controlled by code nothing else that a smart contract in an order that could receive Ethereum money and could receive a call to its code. Ethereum virtual machine is interesting for a lot of reasons the two main reasons is because it is a Turing complete virtual machine so you can do everything with a Turing complete virtual machine and has a lot of high level language compiling for AVM already the most use of this solidity that is Java like syntax written with smart contract and block chain in mind but also viper that is a Python like is quite a user the other one is more for research and development AVM code execution transaction sent to a contract address is nothing else that a call for code like a rest call the important concept is that in order of Ethereum run the code at these address and store the state so every node in the network connected peer to peer with other node execute what is called so not only node you are connecting but all the node on the network will execute your code why? because every node calculate the state block chain and calculated the hash and then everything will be unchangeable as I said before smart contract code can run any program because it is a Turing complete machine read of write state call another contract so you can make a distributed system with multiple contract and could send Ethereum to other address both other contract or also to users so you can write for example a contract that receive an instruction verify some condition and only if those condition has been verified transfer money to the other party so for example again me and him need to transfer some money but this money will be transferred only when my package will be delivered at his home so I send some money to the contract saying that I am sending my package and when he will receive it instead when he sign DHL reciept it call again the smart contract and at that point his money come back to me there is a problem to solve of course in a distributed in every distributed system that is called the alting problem NPR the problem and it's defined by Turing itself and it's possible to determine if a program will finish running or continue to run forever using the same machine so you can't know when you start a program if it will finish or not the most easy example is a cycle with a condition that never verify and on your laptop what happens CPU go to 100% and at some point you decide that it's time for kill the process but in a distributed system it's not possible to do like this because again the code is running on every single node and you don't control any node apart of yours so the solution is to put a fee on every computational step called gas gas is not exactly a currency it's just a unit of measurement for computational step and then using a gas cost this is translated in a cost so everything you run in Ethereum has a cost for you you are paying a computational power of others more or less and you solve the halting problem again with a few images could be clearer when you start a transaction you have some gas cost how many gas you need to do 100 km and you put in each transaction a gas limit so how much you want to spend how many fuel you are putting in your car there is some gas price so combining how many gas you need and how much gas you are going to spend and gas price you determine the cost of the transaction and of course a gas limit for your transaction too low to solve the problem you run out of gas and it means that you are losing what you invested as gas but you don't get the end of the transaction to get the unstoppable world computer the most important point is every full node of Ethereum run the code at the disorders and store the state but what is the problem with that the world computer at the moment performing like this when you run smart contract you have to expect a computational power like a raspberry no more than that and it's busy this is the number of transactions in Ethereum over the years and this is in fact percentagio of utilization so we are reaching full the maximum power all already because in any blockchain there is a problem of scalability of course but scalability is a dilemma in blockchain world because if you put more power on scalability you lose on security and decentralization they are important concept too and so you have to find a solution not losing any of these the three important concepts there is different scalability solution based off chain or on chain off chain solution is out from blockchain sum of the computation on chain solution is to more or less to split blockchain in sub chains and work with more efficient algorithm of consensus like proof of stake let's come to how to write smart contract Solidity is the most used language at the moment not only by Ethereum but for example also Tron and NEO are using Solidity you also write in C++ like language anyway Solidity is a C Java like syntax is statically typed support inheritance even multiple complex user defined types called destructor polymorphism and overriding so it is a complete language, complete modern language let's see some code well this is an easy code to explain written in Solidity what is doing that is a smart notary so we are notarizing some document the idea is to get a document written in pdf word whatever you want compute an hash of this document and write this hash with my account on Ethereum and a date that is the date when I computed the hash why is very important because with this you can prove that document with that specific hash is written by you in a certain date and is written in blockchain and so no one can trick others saying that that document is yours exactly what what a lawyer is doing at least in Italy signing a document for example when you buy an house or a car or everything else so with this solution in the future maybe well it's already possible in some state like Ukraine I don't remember in Hong Kong using smart contract and blockchain to prove that a specific document is signed and unchangeable what we are doing basically we write this smart contract that we will deploy on the blockchain and it's very very easy because you set the file hash this file hash is written in this struct that is file details and this is the state of the program because they are what we would call instance variable in Java but those instance variable is written in the state of the smart contract and the state of smart contract is written on blockchain so we are memorizing on blockchain this struct and this struct is a file details having a timestamp a message sender so the message sender is a special variable containing the address and private public key of who is calling the contract and then everyone well we are paying for that value so when I call this I have to pay so put also some ethereum in my transaction and this payment will be registered to the contract and only the owner only the owner so who created the contract called transfer this balance that is owned by the contracted self to his own address and so getting the money from the contract to me then anyone with a public view so not paying could ask the blockchain given a file when it has written and from this is a very very simple example but giving idea of the power of that and then you can interact with it with just simple javascript the set function is calling this mart notary deployed on my blockchain calling with a file hash and a certain amount of ether and updating the status this is very very simple code but doing already something very powerful and very different from anything else you can do with standard with standard code but of course every smart contract called and most of them transfer money and so there is a lot of security you probably read that the blockchain has been attacked a few times now and ten million euros has been transferred from a contract to another and so on almost attack is not to the blockchain itself no one as far as I know because the consensus algorithm are very robust and the blockchain is really unchangeable but the problem is with smart contract because we are writing a lot of smart contract I read just yesterday that we Ethereum as Ethereum Tron and Neo together as now more than ten thousand smart contract deployed and everyone is doing smart contract and while developer of Ethereum or Bitcoin or Neo and so on are incredible smart people not everyone writing smart contract is the same and so there is a lot of wrong code that you can write in smart contract and have losing money this is one of the most famous attack called the rentancy attack it cost about twenty million euros in Ethereum what is the point the point is that they have a smart contract having a user balance and the opportunity for each user to withdraw their balance the problem is that the user balance is updated after the value has been transferred so what the attack did the attack write another smart contract that is rent with a rentancy code calling again withdraw as on the event of receiving amount so in fact you have a rentancy before the balance has been said so writing a good smart contract doh smart contract is withdrawing everything multiple time until the gas the gas for transaction doesn't end but the user balance is not updated and so it can go on and on this is the the attack of smart contract very very simple function empty payable redo withdraw function empty payable is called every time someone try to pay you even with an error and so doing that they wrote a rentancy code there is a solution of course solution is to move the change of balance just before the withdraw ok in the end of my presentation 50 minutes it's the last minute and I'm ending it's strange because normally I'm going out of time the end of my presentation is behind the terium a very young extremely focused guy and someone looking at this picture or meeting him in person I met him in person last year say well also a bit strange guy well don't you recall another very young extremely focused guy 20 years ago I recall him he is a Linus Torvald of course drinking a beer after release of linux 0.1 thank you