SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Ethereum Developers Community
Introduction to Ethereum
Arnold Pham
Lunyr Inc.
https://www.linkedin.com/in/arnoldpham/
Unless otherwise stated, these slides are licensed under the Creative Commons Attribution-NonCommercial 3.0 License
(https://creativecommons.org/licenses/by-nc/3.0/us/)
Computer
State
11/15/2016
07:30:00 PM
11/15/2016
07:30:14 PM
11/15/2016
07:30:28 PM
How it works
14s 14s
• σ , the world state of Ethereum
• t , time
• σt+1 , the next world state of Ethereum
• T , a transaction
• σt+1 ≡ Υ(σt, T)
11/15/2016
07:30:14 PM
11/15/2016
07:30:28 PM
14s
Ethereum State Transition Function (Υ)
State History is represented by the
blockchain
The Ethereum Virtual Machine
Ether -> gas
Ethereum Clients
•Geth (Go-ethereum, implemented in Go)
•Parity (implemented in Rust)
•Pyethapp (implemented in Python)
Ethereum Clients
• By installing and running a client you can
• Mine real ether
• Transfer funds between addresses
• Create contracts and send transactions
• Explore block history
• And more…
Account types that exist in the World State
• Externally Owned Account
• Address (160-bit identifier)
• Nonce
• Balance
• Contract Account
• Address (160-bit identifier)
• Nonce
• Balance
• Storage
• Code
Account addresses
• The last 20 bytes of a public key
• Steps resulting in an address
• During Account Creation
• A 256-bit Private Key is initialized
• Lots of cryptography-related steps in between
• A Public Key is hashed with SHA-3 to produce a 256-bit output
• The lower 160 bits (20 bytes) become the address
Transactions and Messages
• Transactions contain
• Signature identifying sender
• Recipient address
• Ether to send
• Data field (Optional)
• STARTGAS value
• GASPRICE value
Contract Accounts
Contract Accounts – Potential uses
• Maintain a data store
• Forwarding contract which has access policy and some conditions to send
messages
• Ongoing contract such as escrow, crowdfunding
• Library type contract which provides functions to other contracts
Contract Demo
Benefits of Ethereum
• Ubiquitous
• Anyone can upload and request programs to be executed
• 100% uptime
• DDOS Resistant
• Persistent permanent data storage
Benefits of Ethereum
• Auditable
• Interoperability
• Built-in user authentication
• Built-in direct payment system (no 3rd party required)
• Develop and run decentralized applications without relying on
centralized servers
Solidity
• High-level language with JavaScript-like Syntax
A Block
• B = (BH + BT + BU)
JSON
• JSON – a simple (data interchange or serialization) format that uses
human readable text for transmitting data
{
"id": 1,
"name": "A green door",
"price": 12.50,
"tags": ["home", "green"]
}
A little more detail
• If you have some object and you want to store it in a file or send it
over a network or something of that nature, you have to convert it to
a string first, because you can't send objects over a network or write
objects to a file. You can only write strings. And the other end has to
receive that string and reconstitute it into an object before it can
work with it.
Remote Procedure Call (RPC)
• Fancy word which generally means calling procedures with
arguments on remote systems
• Remote Procedure Call (RPC) is a protocol that one program can use
to request a service from a program located in another computer on
a network without having to understand the network's details.
JSON RPC
• A stateless, light-weight remote procedure call (RPC) protocol
• http://www.jsonrpc.org/specification#conventions
• Defines data structures and rules around their processing
• Example rpc call with positional parameters:
• Client → Request object: {"jsonrpc": "2.0", "method": "subtract", "params":
[42, 23], "id": 1} → Server
• Server→ Response object: {"jsonrpc": "2.0", "result": 19, "id": 1} → Client
• Library written to allow developers to focus on developing apps
instead of plumbing to interact with Ethereum clients and ecosystem
• Web3.js (JavaScript)
• Library implementing the JavaScript API for Dapps to conveniently interact with an
Ethereum node
Default JSON-RPC endpoints
• Geth: http://localhost:8545
Compiler
• Solc
• A standalone solidity compiler
• You only need this if you want to use your Dapp or console to compile solidity
code
Test Networks
• Ropsten testnet (--testnet)
• Local private testnet
Setting Up a Test Network
$ geth --testnet --nodiscover --maxpeers --
Flags
• --nodiscover (make sure your node is not discoverable by people who do not
manually add you. )
• --maxpeers (the number of peers you want connecting to your private chain. Set
as 0)
• --gasprice (0 Makes contracts affordable)
• --port (The network listening port. 0 for random)
• --datadir (the data directory that your private chain data will be stored in. Should
be different from the public Ethereum chain folder)
• Don’t use the deprecated –genesis flag
Setting Up a Test Network
• $get --dev attach
• >personal.newAccount(‘password’)
• miner.start()
• miner.stop()
Augur Dapp Demo
• https://app.augur.net/
• git clone https://github.com/AugurProject/augur.git
• cd augur
• npm install
• npm run build
• // build and watch source for changes
• npm run watch
• // run local web server
• npm start
• http://localhost:8080
Geth Console
• JavaScript console
• geth attach
• attempts to open the console on a running geth instance
• accepts an endpoint in case the geth node is runnign with a non default
interprocess communication (ipc) endpoint or you would like to connect
over the remote procedure call (rpc) interface
$ geth attach ipc:/some/custom/path
$ geth attach http://191.168.1.1:8545
$ geth attach ws://191.168.1.1:8546
Starting geth
• By default, doesn’t start the http and websocket service and not all
functionality is provided over these interfaces due to security
• defaults can be overridden with geth --rpcapi and --wsapi
arguments
Managing Accounts with Geth
• It is not possible to access your account without a password
• No forgot my password option
• If you lose your keyfile, and thus your private key, then you lose access to
your account
What you can do
• Create new accounts
• List all existing accounts
• Import an private key into a new account
• Migrate to the newest key format
• Change your password
Create new accounts
• geth account new
• For non-interactive mode supply the --password flag
• geth account --password <passwordfile> new
•Create an account that uses an existing private key
•geth --datadir /someOtherDataDrive account import ./key.prv
• Create an account from geth console
• personal.newAccount(“password”)
List all existing accounts
• geth account list
• For geth console
• eth.accounts
Show primary account address
• From geth console
• eth.coinbase
Convert a number of Wei into a different
unit
Use web3.fromWei(number, unit) converts a number of wei into a
different unit
• unit must be a string
• unit can be a kwei/ada, mwei/babbage, gwei/channon, szabo,
finney, ether, kether/grand/einstein, mether, gether, tether
Checking account balance
• Check the balance (in Wei) of an address
• eth.getBalance(“address”)
• For primary account
• web3.fromWei(eth.getBalance(eth.coinbase), “ether”)
• For a specific address
• web3.fromWei(eth.getBalance(“address”), “ether”)
Print all balances with a JavaScript function
Inside of geth console:
function checkAllBalances() {
var i =0;
eth.accounts.forEach( function(e){
console.log(" eth.accounts["+i+"]: " + e + " tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + "
ether");
i++;
})
};
Sending Ether
• eth.sendTransaction({from:sender, to:receiver, value:amount})
• you can use built-in JavaScript to set variables to values
• var sender = eth.accounts[0];
• var receiver = eth.accounts[1];
• var amount = web3.toWei(0.01, “ether”)
• the value is in Wei
• you must have your account password to complete the
sendTransaction
Mining
• analogous to mining gold or precious metals
• secures the network and verifies computation
Proof of Work
• A block is only valid if it contains proof of work of a given difficulty
• the PoW algorithm is called Ethash
Ethash
• a modified version of Dagger-Hashimoto which involves finding a
nonce input ot the algorithm so that the result is below a certain
threshold depending on the difficulty
• PoW algorithms rely on the assumption that there’s no better
strategy to find such a nonce than enumerating the possibilties
• Verification of a solution is trivial and cheap
Difficulty
• the average time needed to find a nonce depends on the difficulty
threshold
• the difficulty dynamically adjusts so that the network produces a
block every 12 seconds
• the synchronization of system state makes it impossible to maintain
a fork or rewrite history without controlling more than half of the
network mining power
Miners
• The expected revenue of a miner is directly proportional to the
miner’s hashrate (the nonces tried per second normalized by the
total hashrate of the network)
Ethash DAG (Directed Acyclic Graph)
• The algorithm is memory hard, which makes it ASIC resistant
• Calculating the PoW requires choosing subsets of a fixed resource
(the DAG) dependent on the block header and nonce
• several gigabytes of data
• Totally different every 30,000 blocks
• 100 hour window called an epoch
• takes a while to generate
• Since the DAG only depends on the block number, it can be
pregenerated to avoid long wait times at each epoch transition
Ethash DAG
• Geth implements automatic DAG generation by default including
when you use “geth --mine”
• maintains two DAGs at a time for smooth epoch transitions
• Clients share a DAG resource, so if you are running multiple
instances of any client, make sure automatic DAG generation is only
enabled on one client
• to pregenerate a DAG for an arbitrary epoch use
• geth makedag <blocknumber> <outputdir>
Mining with geth
• Set your etherbase (or coinbase)
• Before earning ether, you must have your etherbase (or coinbase) address
set
• setting etherbase on the command line
• use the --etherbase option
• geth --etherbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine 2>>
geth.log
• setting etherbase in the console
• use miner.setEtherbase
• miner.setEtherbase('0xa073edbcac4a489c3c0f71ec50dd6ffcefa49a00')
Extra Data in Block
• As the one who mined the block , you can add a short vanity tag
• Can only be 32 bytes long
• miner.setExtra(“Arnold was here”)
• Interpreted as unicode
Start Mining
• from the command line
• use --mine option
• geth --mine
• from the console
• miner.start()
• miner.stop() to stop
• Check your hashrate
• miner.hashrate
Mining information anomaly
• Often you’ll find a block that never makes it to the canonical chain
• Locally it may show that your mined block, and the mining reward
was credited to your account, however, after a while the better
chain is discovered and the network switches to a chain in which
your block is not included and therefore no mining reward is
credited
• A miner monitoring their coinbase balance will find that it
fluctuates quite a bit for this reason
Spending your gas
• In order to spend your gas to transact you need to unlock the
account
• personal.unlockAccount(eth.coinbase)
Checking a Block Header
• eth.getBlock(blocknumber)
Software Development Principles
The hardest single part of building a software system is deciding
exactly what to build
Behavioral requirements to consider
• Security
• Safety
• Performance
• Timing
• Fault-tolerance
(Bass et al. 2003)
Developmental Quality Attributes
• Testability
• Changeability (Major problem in Dapp development)
• Maintainability (Major problem in Dapp development)
• Reusability
(Bass et al. 2003)
Develop with multi-versions in mind
• even in cases in which only one system intended, systems
inevitably become multi-version as developers better understand
• what they can do for users
• what they can and cannot do within the constraints of cost and schedule
Repair and maintainence problems are costly
• immortal contracts
• cannot change code
• storage expensive

Weitere ähnliche Inhalte

Was ist angesagt?

Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?Jim Flynn
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in SolidityFelix Crisan
 
Intro to smart contract on blockchain en
Intro to smart contract on blockchain enIntro to smart contract on blockchain en
Intro to smart contract on blockchain enNicholas Lin
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrencyBellaj Badr
 
Java and the blockchain - introducing web3j
Java and the blockchain - introducing web3jJava and the blockchain - introducing web3j
Java and the blockchain - introducing web3jConor Svensson
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for DevelopersShimi Bandiel
 
EDCON 2017 sharing @Taipei Ethereum Meetup
EDCON 2017 sharing @Taipei Ethereum Meetup EDCON 2017 sharing @Taipei Ethereum Meetup
EDCON 2017 sharing @Taipei Ethereum Meetup Chang-Wu Chen
 
Academic Ethereum
Academic EthereumAcademic Ethereum
Academic Ethereumgavofyork
 
Intro to Blockchain Slides
Intro to Blockchain SlidesIntro to Blockchain Slides
Intro to Blockchain SlidesShannon Wells
 
Front-End Development for dApps on Tezos
Front-End Development for dApps on TezosFront-End Development for dApps on Tezos
Front-End Development for dApps on TezosNeven6
 
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Svetlin Nakov
 
CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101Blockstrap.com
 
Build your own block chain
Build your own block chainBuild your own block chain
Build your own block chainBohdan Szymanik
 
Metadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN ExplosionMetadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN ExplosionCoin Sciences Ltd
 
Javascript toolset for Ethereum Smart Contract development
Javascript toolset for Ethereum Smart Contract developmentJavascript toolset for Ethereum Smart Contract development
Javascript toolset for Ethereum Smart Contract developmentBugSense
 
2019 03 18_kenneth_simplebitcoinwebsite
2019 03 18_kenneth_simplebitcoinwebsite 2019 03 18_kenneth_simplebitcoinwebsite
2019 03 18_kenneth_simplebitcoinwebsite Hu Kenneth
 

Was ist angesagt? (20)

Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?Intro to Blockchain - And, by the way, what the heck is proof-of-work?
Intro to Blockchain - And, by the way, what the heck is proof-of-work?
 
Ethereum bxl
Ethereum bxlEthereum bxl
Ethereum bxl
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in Solidity
 
Intro to smart contract on blockchain en
Intro to smart contract on blockchain enIntro to smart contract on blockchain en
Intro to smart contract on blockchain en
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrency
 
Java and the blockchain - introducing web3j
Java and the blockchain - introducing web3jJava and the blockchain - introducing web3j
Java and the blockchain - introducing web3j
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for Developers
 
EDCON 2017 sharing @Taipei Ethereum Meetup
EDCON 2017 sharing @Taipei Ethereum Meetup EDCON 2017 sharing @Taipei Ethereum Meetup
EDCON 2017 sharing @Taipei Ethereum Meetup
 
Academic Ethereum
Academic EthereumAcademic Ethereum
Academic Ethereum
 
Writing smart contracts
Writing smart contractsWriting smart contracts
Writing smart contracts
 
Build dapps 1:3 dev tools
Build dapps 1:3 dev toolsBuild dapps 1:3 dev tools
Build dapps 1:3 dev tools
 
Intro to Blockchain Slides
Intro to Blockchain SlidesIntro to Blockchain Slides
Intro to Blockchain Slides
 
Front-End Development for dApps on Tezos
Front-End Development for dApps on TezosFront-End Development for dApps on Tezos
Front-End Development for dApps on Tezos
 
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
 
bitcoin_presentation
bitcoin_presentationbitcoin_presentation
bitcoin_presentation
 
CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101CBGTBT - Part 3 - Transactions 101
CBGTBT - Part 3 - Transactions 101
 
Build your own block chain
Build your own block chainBuild your own block chain
Build your own block chain
 
Metadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN ExplosionMetadata in the Blockchain: The OP_RETURN Explosion
Metadata in the Blockchain: The OP_RETURN Explosion
 
Javascript toolset for Ethereum Smart Contract development
Javascript toolset for Ethereum Smart Contract developmentJavascript toolset for Ethereum Smart Contract development
Javascript toolset for Ethereum Smart Contract development
 
2019 03 18_kenneth_simplebitcoinwebsite
2019 03 18_kenneth_simplebitcoinwebsite 2019 03 18_kenneth_simplebitcoinwebsite
2019 03 18_kenneth_simplebitcoinwebsite
 

Andere mochten auch

A tour of ethereum ecosystem
A tour of ethereum ecosystemA tour of ethereum ecosystem
A tour of ethereum ecosystemChang-Wu Chen
 
Blockchain &amp; the Future of Democracy
Blockchain &amp; the Future of DemocracyBlockchain &amp; the Future of Democracy
Blockchain &amp; the Future of DemocracyShermin Voshmgir
 
History of Distributed Computing
History of Distributed ComputingHistory of Distributed Computing
History of Distributed ComputingShermin Voshmgir
 
日本のIT市場のトピックス
日本のIT市場のトピックス日本のIT市場のトピックス
日本のIT市場のトピックスHiroyasu NOHATA
 
Dapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupDapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupJames Littlejohn
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvmgha sshee
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenStephan Karpischek
 
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter..."Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...Khaled Ben Driss
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchainJames Littlejohn
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mixgavofyork
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletSjors Provoost
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial ENNicholas Lin
 

Andere mochten auch (18)

Mist and parity
Mist and parityMist and parity
Mist and parity
 
A tour of ethereum ecosystem
A tour of ethereum ecosystemA tour of ethereum ecosystem
A tour of ethereum ecosystem
 
Smart contracts & dApps
Smart contracts & dAppsSmart contracts & dApps
Smart contracts & dApps
 
Blockchain &amp; the Future of Democracy
Blockchain &amp; the Future of DemocracyBlockchain &amp; the Future of Democracy
Blockchain &amp; the Future of Democracy
 
History of Distributed Computing
History of Distributed ComputingHistory of Distributed Computing
History of Distributed Computing
 
日本のIT市場のトピックス
日本のIT市場のトピックス日本のIT市場のトピックス
日本のIT市場のトピックス
 
Ethereum @ descon 2016
Ethereum @ descon 2016Ethereum @ descon 2016
Ethereum @ descon 2016
 
Dapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupDapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen Techmeetup
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvm
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfinden
 
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter..."Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
 
Solidity intro
Solidity introSolidity intro
Solidity intro
 
Introduction to Idea
Introduction to IdeaIntroduction to Idea
Introduction to Idea
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchain
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mix
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info Wallet
 
The future of Blockchain
The future of BlockchainThe future of Blockchain
The future of Blockchain
 
Solidity Simple Tutorial EN
Solidity Simple Tutorial ENSolidity Simple Tutorial EN
Solidity Simple Tutorial EN
 

Ähnlich wie Introduction to Ethereum

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsEugene Zharkov
 
Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to knowGökhan Şengün
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application TechnologiesSam Bowne
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek PROIDEA
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackJakub Hajek
 
Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15streamdata.io
 
From Device to Data Center to Insights: Architectural Considerations for the ...
From Device to Data Center to Insights: Architectural Considerations for the ...From Device to Data Center to Insights: Architectural Considerations for the ...
From Device to Data Center to Insights: Architectural Considerations for the ...P. Taylor Goetz
 
Resource slides for blockchain related question
Resource slides for blockchain related questionResource slides for blockchain related question
Resource slides for blockchain related questionLin Lin (Wendy)
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkFabio Tiriticco
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014Christian Wenz
 
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Big Data 2016: Next Gen Big Data Analytics with Apache ApexApache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Big Data 2016: Next Gen Big Data Analytics with Apache ApexApache Apex
 
Jugando con websockets en nodeJS
Jugando con websockets en nodeJSJugando con websockets en nodeJS
Jugando con websockets en nodeJSIsrael Gutiérrez
 
Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...OutSystems
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in GoAll Things Open
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)Panagiotis Kanavos
 

Ähnlich wie Introduction to Ethereum (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
From Device to Data Center to Insights
From Device to Data Center to InsightsFrom Device to Data Center to Insights
From Device to Data Center to Insights
 
SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applications
 
Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to know
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application Technologies
 
Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek Docker Logging and analysing with Elastic Stack - Jakub Hajek
Docker Logging and analysing with Elastic Stack - Jakub Hajek
 
Docker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic StackDocker Logging and analysing with Elastic Stack
Docker Logging and analysing with Elastic Stack
 
Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15Websocket vs SSE - Paris.js - 24/06/15
Websocket vs SSE - Paris.js - 24/06/15
 
From Device to Data Center to Insights: Architectural Considerations for the ...
From Device to Data Center to Insights: Architectural Considerations for the ...From Device to Data Center to Insights: Architectural Considerations for the ...
From Device to Data Center to Insights: Architectural Considerations for the ...
 
Ethereum
EthereumEthereum
Ethereum
 
Resource slides for blockchain related question
Resource slides for blockchain related questionResource slides for blockchain related question
Resource slides for blockchain related question
 
WebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! FrameworkWebSockets wiith Scala and Play! Framework
WebSockets wiith Scala and Play! Framework
 
Windows 8 Apps and the Outside World
Windows 8 Apps and the Outside WorldWindows 8 Apps and the Outside World
Windows 8 Apps and the Outside World
 
How we use Twisted in Launchpad
How we use Twisted in LaunchpadHow we use Twisted in Launchpad
How we use Twisted in Launchpad
 
HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014HTML5/JavaScript Communication APIs - DPC 2014
HTML5/JavaScript Communication APIs - DPC 2014
 
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Big Data 2016: Next Gen Big Data Analytics with Apache ApexApache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
Apache Big Data 2016: Next Gen Big Data Analytics with Apache Apex
 
Jugando con websockets en nodeJS
Jugando con websockets en nodeJSJugando con websockets en nodeJS
Jugando con websockets en nodeJS
 
Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...Training Webinar: Enterprise application performance with server push technol...
Training Webinar: Enterprise application performance with server push technol...
 
How to Build Your First Web App in Go
How to Build Your First Web App in GoHow to Build Your First Web App in Go
How to Build Your First Web App in Go
 
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)Parallel and Asynchronous Programming -  ITProDevConnections 2012 (English)
Parallel and Asynchronous Programming - ITProDevConnections 2012 (English)
 

Kürzlich hochgeladen

Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxmibuzondetrabajo
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxNIMMANAGANTI RAMAKRISHNA
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxAndrieCagasanAkio
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxMario
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesLumiverse Solutions Pvt Ltd
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119APNIC
 

Kürzlich hochgeladen (9)

Unidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptxUnidad 4 – Redes de ordenadores (en inglés).pptx
Unidad 4 – Redes de ordenadores (en inglés).pptx
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
ETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptxETHICAL HACKING dddddddddddddddfnandni.pptx
ETHICAL HACKING dddddddddddddddfnandni.pptx
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
TRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptxTRENDS Enabling and inhibiting dimensions.pptx
TRENDS Enabling and inhibiting dimensions.pptx
 
Company Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptxCompany Snapshot Theme for Business by Slidesgo.pptx
Company Snapshot Theme for Business by Slidesgo.pptx
 
Cybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best PracticesCybersecurity Threats and Cybersecurity Best Practices
Cybersecurity Threats and Cybersecurity Best Practices
 
IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119IP addressing and IPv6, presented by Paul Wilson at IETF 119
IP addressing and IPv6, presented by Paul Wilson at IETF 119
 

Introduction to Ethereum

  • 1. Ethereum Developers Community Introduction to Ethereum Arnold Pham Lunyr Inc. https://www.linkedin.com/in/arnoldpham/ Unless otherwise stated, these slides are licensed under the Creative Commons Attribution-NonCommercial 3.0 License (https://creativecommons.org/licenses/by-nc/3.0/us/)
  • 5. • σ , the world state of Ethereum • t , time • σt+1 , the next world state of Ethereum • T , a transaction • σt+1 ≡ Υ(σt, T) 11/15/2016 07:30:14 PM 11/15/2016 07:30:28 PM 14s Ethereum State Transition Function (Υ)
  • 6. State History is represented by the blockchain
  • 7.
  • 10. Ethereum Clients •Geth (Go-ethereum, implemented in Go) •Parity (implemented in Rust) •Pyethapp (implemented in Python)
  • 11. Ethereum Clients • By installing and running a client you can • Mine real ether • Transfer funds between addresses • Create contracts and send transactions • Explore block history • And more…
  • 12. Account types that exist in the World State • Externally Owned Account • Address (160-bit identifier) • Nonce • Balance • Contract Account • Address (160-bit identifier) • Nonce • Balance • Storage • Code
  • 13. Account addresses • The last 20 bytes of a public key • Steps resulting in an address • During Account Creation • A 256-bit Private Key is initialized • Lots of cryptography-related steps in between • A Public Key is hashed with SHA-3 to produce a 256-bit output • The lower 160 bits (20 bytes) become the address
  • 14. Transactions and Messages • Transactions contain • Signature identifying sender • Recipient address • Ether to send • Data field (Optional) • STARTGAS value • GASPRICE value
  • 15.
  • 17. Contract Accounts – Potential uses • Maintain a data store • Forwarding contract which has access policy and some conditions to send messages • Ongoing contract such as escrow, crowdfunding • Library type contract which provides functions to other contracts
  • 19. Benefits of Ethereum • Ubiquitous • Anyone can upload and request programs to be executed • 100% uptime • DDOS Resistant • Persistent permanent data storage
  • 20. Benefits of Ethereum • Auditable • Interoperability • Built-in user authentication • Built-in direct payment system (no 3rd party required) • Develop and run decentralized applications without relying on centralized servers
  • 21. Solidity • High-level language with JavaScript-like Syntax
  • 22. A Block • B = (BH + BT + BU)
  • 23. JSON • JSON – a simple (data interchange or serialization) format that uses human readable text for transmitting data { "id": 1, "name": "A green door", "price": 12.50, "tags": ["home", "green"] }
  • 24. A little more detail • If you have some object and you want to store it in a file or send it over a network or something of that nature, you have to convert it to a string first, because you can't send objects over a network or write objects to a file. You can only write strings. And the other end has to receive that string and reconstitute it into an object before it can work with it.
  • 25. Remote Procedure Call (RPC) • Fancy word which generally means calling procedures with arguments on remote systems • Remote Procedure Call (RPC) is a protocol that one program can use to request a service from a program located in another computer on a network without having to understand the network's details.
  • 26. JSON RPC • A stateless, light-weight remote procedure call (RPC) protocol • http://www.jsonrpc.org/specification#conventions • Defines data structures and rules around their processing • Example rpc call with positional parameters: • Client → Request object: {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1} → Server • Server→ Response object: {"jsonrpc": "2.0", "result": 19, "id": 1} → Client
  • 27. • Library written to allow developers to focus on developing apps instead of plumbing to interact with Ethereum clients and ecosystem • Web3.js (JavaScript) • Library implementing the JavaScript API for Dapps to conveniently interact with an Ethereum node
  • 28. Default JSON-RPC endpoints • Geth: http://localhost:8545
  • 29. Compiler • Solc • A standalone solidity compiler • You only need this if you want to use your Dapp or console to compile solidity code
  • 30. Test Networks • Ropsten testnet (--testnet) • Local private testnet
  • 31. Setting Up a Test Network $ geth --testnet --nodiscover --maxpeers -- Flags • --nodiscover (make sure your node is not discoverable by people who do not manually add you. ) • --maxpeers (the number of peers you want connecting to your private chain. Set as 0) • --gasprice (0 Makes contracts affordable) • --port (The network listening port. 0 for random) • --datadir (the data directory that your private chain data will be stored in. Should be different from the public Ethereum chain folder) • Don’t use the deprecated –genesis flag
  • 32. Setting Up a Test Network • $get --dev attach • >personal.newAccount(‘password’) • miner.start() • miner.stop()
  • 33. Augur Dapp Demo • https://app.augur.net/ • git clone https://github.com/AugurProject/augur.git • cd augur • npm install • npm run build • // build and watch source for changes • npm run watch • // run local web server • npm start • http://localhost:8080
  • 34. Geth Console • JavaScript console • geth attach • attempts to open the console on a running geth instance • accepts an endpoint in case the geth node is runnign with a non default interprocess communication (ipc) endpoint or you would like to connect over the remote procedure call (rpc) interface $ geth attach ipc:/some/custom/path $ geth attach http://191.168.1.1:8545 $ geth attach ws://191.168.1.1:8546
  • 35. Starting geth • By default, doesn’t start the http and websocket service and not all functionality is provided over these interfaces due to security • defaults can be overridden with geth --rpcapi and --wsapi arguments
  • 36. Managing Accounts with Geth • It is not possible to access your account without a password • No forgot my password option • If you lose your keyfile, and thus your private key, then you lose access to your account
  • 37. What you can do • Create new accounts • List all existing accounts • Import an private key into a new account • Migrate to the newest key format • Change your password
  • 38. Create new accounts • geth account new • For non-interactive mode supply the --password flag • geth account --password <passwordfile> new •Create an account that uses an existing private key •geth --datadir /someOtherDataDrive account import ./key.prv • Create an account from geth console • personal.newAccount(“password”)
  • 39. List all existing accounts • geth account list • For geth console • eth.accounts
  • 40. Show primary account address • From geth console • eth.coinbase
  • 41. Convert a number of Wei into a different unit Use web3.fromWei(number, unit) converts a number of wei into a different unit • unit must be a string • unit can be a kwei/ada, mwei/babbage, gwei/channon, szabo, finney, ether, kether/grand/einstein, mether, gether, tether
  • 42. Checking account balance • Check the balance (in Wei) of an address • eth.getBalance(“address”) • For primary account • web3.fromWei(eth.getBalance(eth.coinbase), “ether”) • For a specific address • web3.fromWei(eth.getBalance(“address”), “ether”)
  • 43. Print all balances with a JavaScript function Inside of geth console: function checkAllBalances() { var i =0; eth.accounts.forEach( function(e){ console.log(" eth.accounts["+i+"]: " + e + " tbalance: " + web3.fromWei(eth.getBalance(e), "ether") + " ether"); i++; }) };
  • 44. Sending Ether • eth.sendTransaction({from:sender, to:receiver, value:amount}) • you can use built-in JavaScript to set variables to values • var sender = eth.accounts[0]; • var receiver = eth.accounts[1]; • var amount = web3.toWei(0.01, “ether”) • the value is in Wei • you must have your account password to complete the sendTransaction
  • 45. Mining • analogous to mining gold or precious metals • secures the network and verifies computation
  • 46. Proof of Work • A block is only valid if it contains proof of work of a given difficulty • the PoW algorithm is called Ethash
  • 47. Ethash • a modified version of Dagger-Hashimoto which involves finding a nonce input ot the algorithm so that the result is below a certain threshold depending on the difficulty • PoW algorithms rely on the assumption that there’s no better strategy to find such a nonce than enumerating the possibilties • Verification of a solution is trivial and cheap
  • 48. Difficulty • the average time needed to find a nonce depends on the difficulty threshold • the difficulty dynamically adjusts so that the network produces a block every 12 seconds • the synchronization of system state makes it impossible to maintain a fork or rewrite history without controlling more than half of the network mining power
  • 49. Miners • The expected revenue of a miner is directly proportional to the miner’s hashrate (the nonces tried per second normalized by the total hashrate of the network)
  • 50. Ethash DAG (Directed Acyclic Graph) • The algorithm is memory hard, which makes it ASIC resistant • Calculating the PoW requires choosing subsets of a fixed resource (the DAG) dependent on the block header and nonce • several gigabytes of data • Totally different every 30,000 blocks • 100 hour window called an epoch • takes a while to generate • Since the DAG only depends on the block number, it can be pregenerated to avoid long wait times at each epoch transition
  • 51. Ethash DAG • Geth implements automatic DAG generation by default including when you use “geth --mine” • maintains two DAGs at a time for smooth epoch transitions • Clients share a DAG resource, so if you are running multiple instances of any client, make sure automatic DAG generation is only enabled on one client • to pregenerate a DAG for an arbitrary epoch use • geth makedag <blocknumber> <outputdir>
  • 52. Mining with geth • Set your etherbase (or coinbase) • Before earning ether, you must have your etherbase (or coinbase) address set • setting etherbase on the command line • use the --etherbase option • geth --etherbase '0xa4d8e9cae4d04b093aac82e6cd355b6b963fb7ff' --mine 2>> geth.log • setting etherbase in the console • use miner.setEtherbase • miner.setEtherbase('0xa073edbcac4a489c3c0f71ec50dd6ffcefa49a00')
  • 53. Extra Data in Block • As the one who mined the block , you can add a short vanity tag • Can only be 32 bytes long • miner.setExtra(“Arnold was here”) • Interpreted as unicode
  • 54. Start Mining • from the command line • use --mine option • geth --mine • from the console • miner.start() • miner.stop() to stop • Check your hashrate • miner.hashrate
  • 55. Mining information anomaly • Often you’ll find a block that never makes it to the canonical chain • Locally it may show that your mined block, and the mining reward was credited to your account, however, after a while the better chain is discovered and the network switches to a chain in which your block is not included and therefore no mining reward is credited • A miner monitoring their coinbase balance will find that it fluctuates quite a bit for this reason
  • 56. Spending your gas • In order to spend your gas to transact you need to unlock the account • personal.unlockAccount(eth.coinbase)
  • 57. Checking a Block Header • eth.getBlock(blocknumber)
  • 59. The hardest single part of building a software system is deciding exactly what to build
  • 60. Behavioral requirements to consider • Security • Safety • Performance • Timing • Fault-tolerance (Bass et al. 2003)
  • 61. Developmental Quality Attributes • Testability • Changeability (Major problem in Dapp development) • Maintainability (Major problem in Dapp development) • Reusability (Bass et al. 2003)
  • 62. Develop with multi-versions in mind • even in cases in which only one system intended, systems inevitably become multi-version as developers better understand • what they can do for users • what they can and cannot do within the constraints of cost and schedule
  • 63. Repair and maintainence problems are costly • immortal contracts • cannot change code • storage expensive