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
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized Applications
1. THE ETHEREUM BLOCKCHAIN
INTRODUCTION TO SMART CONTRACTS AND DECENTRALIZED
APPLICATIONS
Alessandro Sanino
University of Turin
Computer Science Departmen
2. AGENDA
• The Ethereum Blockchain
• Setting up a node
• Introduction to Solidity
• The OpenZeppelin framework
3. AGENDA
• The Truffle Suite
• Deployment of a Smart Contract on local environment
• Testing Smart Contracts
• From test to mainnet
• DApps development principles
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. THE ETHEREUM BLOCKCHAIN
There is one main difference:
Transactions can also trigger computer code execution, which is
stored to correspond a certain address.
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. 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. SETTING UP A NODE
HOW TO SET UP AN ETHEREUM BLOCKCHAIN DIFFERENT KINDS OF
NODES
10. SETTING UP A NODE
• Light node
• Full node
• Archival node
11. FULL NODE
• Standard node
• Full blockchain sync
• Needs a more than average grade machine to sync properly
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. ARCHIVAL NODE
• Big Scary Node ~ Vitalik Buterin
• Downloads all the intermediate states of the blockchain
• Huge requirements (2TB+ SSD and high computation power)
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
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
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
30. THE TRUFFLE SUITE
A complete set of frameworks to develop smart contracts
• Truffle
• Ganache
• Smart Contracts Package Manager (EthPM)
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. GANACHE
A private Ethereum network deployed on your local machine, it
has all the settings customizable via a beautiful UI
33. ETHEREUM PACKAGE MANAGER (ETHPM)
• Like npm but on the Ethereum blockchain
• Contains a lot of Solidity prebuilt contract packages