Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized Applications

73 vues

Publié le

This set of slides is about Ethereum Blockchain and and introduction to Ethereum Smart Contracts. Arguments covered:
- Ethereum chain
- Ethereum nodes
- Solidity language
- Truffle suite
- Dapps development principles

Presentation of 05/30/2019 in University of Turin

Publié dans : Logiciels
  • Soyez le premier à commenter

The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized Applications

  1. 1. THE ETHEREUM BLOCKCHAIN INTRODUCTION TO SMART CONTRACTS AND DECENTRALIZED APPLICATIONS Alessandro Sanino University of Turin Computer Science Departmen
  2. 2. AGENDA • The Ethereum Blockchain • Setting up a node • Introduction to Solidity • The OpenZeppelin framework
  3. 3. AGENDA • The Truffle Suite • Deployment of a Smart Contract on local environment • Testing Smart Contracts • From test to mainnet • DApps development principles
  4. 4. THE ETHEREUM BLOCKCHAIN
  5. 5. THE ETHEREUM BLOCKCHAIN • Same high level architecture as Bitcoin or other Blockchains • PoW consensus model • Miners set up a gas price and gas limit to choose which tx to mine
  6. 6. THE ETHEREUM BLOCKCHAIN There is one main difference: Transactions can also trigger computer code execution, which is stored to correspond a certain address.
  7. 7. THE ETHEREUM BLOCKCHAIN Transactions can also trigger computer code execution, which is stored to correspond a certain address The so-called SMART CONTRACTS, can be triggered by querying any node on the network via CALL statements or TRANSACTIONS
  8. 8. SMART CONTRACTS 101 • When validating a state change on the smart contract, every node in the network computes indipendently the result • Decentralized computing • Non Censorable • 100% uptime • Tamper-evident, therefore extremely difficult to corrupt
  9. 9. SETTING UP A NODE HOW TO SET UP AN ETHEREUM BLOCKCHAIN DIFFERENT KINDS OF NODES
  10. 10. SETTING UP A NODE • Light node • Full node • Archival node
  11. 11. FULL NODE • Standard node • Full blockchain sync • Needs a more than average grade machine to sync properly
  12. 12. LIGHT NODE • Lightweight version of the full node • Syncs only block headers, therefore needs a full node to check and verify txs • Can run on almost every device, minimal space requirements
  13. 13. ARCHIVAL NODE • Big Scary Node ~ Vitalik Buterin • Downloads all the intermediate states of the blockchain • Huge requirements (2TB+ SSD and high computation power)
  14. 14. SUPER QUICK DEMO
  15. 15. THE SOLIDITY LANGUAGE INTRODUCTION TO SMART CONTRACTS PROGRAMMING
  16. 16. SOLIDITY • Language to build smart contracts • JS-like syntax • Most popular solution
  17. 17. SOLIDITY Solidity supports a lot of native types, like addresses, uints, strings, arrays, structs and fixed-size bytes arrays. Supports for constructs to gather blockchain data: block, tx, msg Supports multiple inheritance
  18. 18. BLOCK Contains useful data like: • timestamp • number (or height) • coinbase • difficulty • gas limit
  19. 19. TRANSACTION (TX) Contains current transaction data, like: • origin • gas price
  20. 20. MESSAGE (MSG) Contains specific data of the transaction or the call: • sender • Value in wei • Additional custom metadata
  21. 21. OTHER SOLIDITY GLOBALS Time units : (seconds, minutes, hours, days, weeks, now) Ether units: • wei = 1 • szabo = 10^12 • finney = 10^15 • ether = 10^18
  22. 22. HANDLING ERRORS Solidity has specific functions to handle failure cases: • throw • assert • require
  23. 23. ADDITIONAL GOTCHAS • Memory VS Storage variable location • Stack is limited !!! • Every transaction has a cost • Only tx mutates the contract state (and append to the blockchain) • Call operations (read) are free • Big Contract = Bigger deploy costs
  24. 24. JUST AN EXAMPLE
  25. 25. THE OPENZEPPELIN FRAMEWORK
  26. 26. OPENZEPPELIN A framework by the zeppelin foundation, it contains smart contracts which have already been audited by professionals and implement most used use cases (e.g. Tokens, Crowdsales, etc…) https://github.com/OpenZeppelin/openzeppelin-solidity
  27. 27. ERC20 TOKEN WITH ZEPPELIN
  28. 28. BREAK TIME
  29. 29. THE TRUFFLE SUITE
  30. 30. THE TRUFFLE SUITE A complete set of frameworks to develop smart contracts • Truffle • Ganache • Smart Contracts Package Manager (EthPM)
  31. 31. TRUFFLE It is used to develop smart contracts thanks to an easy to use CLI interface You just develop your contracts and use it to compile, migrate and test. Based on Web3JS and Javascript ES6
  32. 32. GANACHE A private Ethereum network deployed on your local machine, it has all the settings customizable via a beautiful UI
  33. 33. ETHEREUM PACKAGE MANAGER (ETHPM) • Like npm but on the Ethereum blockchain • Contains a lot of Solidity prebuilt contract packages
  34. 34. DEMO TIME
  35. 35. CONCLUSIONS
  36. 36. THANK YOU

×