This presentation has been used at a Meetup in Heraklion on October 17th 2018. It's a basic introduction on how to develop a Distributed Application using smart contracts in Solidity on an Ethreum blockchain. Part of the presentation were done directly typing on a computer screen and as such are not included. But there is a link at the code used as an example.
A Deep Dive into Secure Product Development Frameworks.pdf
How to Develop a Distributed App on Ethereum
1. HOW TO DEVELOP A
DISTRIBUTED APP ON
ETHEREUM
MARCO OTTOLINI – HERAKLION – 17 OCTOBER 2018
2. WHO AM I
• Hacker since 1980
• Tech Journalist
• Startupper
• Running summer internships in Heraklion since 2012
• Fell in love with Blockchain (Ethereum) since 2016
4. WHY THE BLOCKCHAIN?
• HYPE: after Dec ‘17 Cryptos surge and fall
• SCAM: most of ICOs are scam (https://goo.gl/vgmh8w)
• BUSINESS: nobody really using it
• WHY USE IT: everything could be done with a ”normal” system
Blockchain technology is the fuel of what will be
remembered as “New World”, in the same way as
Internet was what powered the “New Economy” 20
5. WHAT A BLOCKCHAIN IS?
• It’s a Distributed Ledger (DLT)
• It’s NOT a Distributed Database:
• OK Insert and Retrieve
• NOT OK Delete and Update
• It’s immutable
• It’s public
• It’s secure by definition
6. WHAT A DISTRIBUTED APP IS?
Software application that is stored on cloud computing
platforms, that run on multiple systems
simultaneously, is accessible everywhere, is fault
tolerant and can scale up automatically
7. Java VM
Hosted in a
Linux Box
WHAT A DISTRIBUTED APP IS?
Java
Class
Spring
API
8. WHAT A DISTRIBUTED APP IS?
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Load Balancer
DB DB
• Management
• Backup
• Monitoring
• Auto-Scaling
9. ETHEREUM VIRTUAL MACHINE
• Quasi touring complete machine
• EVM bytecodes
• Gas
• Gas price
• Accounts
• External (private key)
• Contract
Ethereum VM
Ethereum
Contract
10. WHAT A DISTRIBUTED APP IS?
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Java VM
Hosted in a
Linux Box
Java
Class
Spring
API
Load Balancer
DB DB
• Management
• Backup
• Monitoring
• Auto-Scaling
Ethereum VM
Ethereum
Contract
11. WHAT AN ACCOUNT IS?
• It’s a hash “created” by a private key
• Key pairs are “generated” from a 12 words phrase:
witch collapse practice feed shame open despair creek road again ice least
• Transactions and balance related to an account are kept on the
blockchain
Private
Key
Account
Account
Account Blockchain
Transaction
12. INTRODUCTION TO REMIX
• Ethereum Solidity IDE in a browser (Like jsfiddle for javascript)
• Open it from http://remix.ethereum.org
13. HELLO WORLD!
pragma solidity ^0.4.25
contract Hello {
string hello;
constructor () public {
hello = "Hello World!";
}
function getHello() public view returns (string){
return hello;
}
}
14. HELLO WORLD ON “REAL” ETHEREUM
• Use Metamask to “connect” to ethereum
• Deploy the contract to a testnet (rinkeby)
• See it on Etherscan (https://rinkeby.etherscan.io/)
• We have a real distributed app!
15. INTRODUCTION TO METAMASK
• It is an Ethereum wallet for a browser
• Take it from https://metamask.io/
• It manages wallet (address) creation and private key storage
16. YOUR FIRST DISTRIBUTED APP -
TICKETING
Event
Manager
Ticket
Buyer
Event
Creates the
Event
Buys a ticket
Ticket
Owns a ticket
Receives money for ticket sale
17. TICKETING
• Two contracts
• Event
• Ticket
• Two actors
• Manager
• Buyer(s)
PHASES
1. Create an Event
2. Buy a Ticket
3. Enforce security
4. Enable payment
5. Emit events
6. Ticket burning
https://github.com/mottolini/hack-session-181017