SlideShare a Scribd company logo
Ethereum Developers
Community
The Ethereum Geth Client
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/)
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
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
• $geth attach
• >personal.newAccount(‘password’)
• miner.start()
• miner.stop()
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++;
})
};
Spending your gas
• In order to spend your gas to transact you need to unlock the
account
• personal.unlockAccount(eth.coinbase)
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 to 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
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>
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

More Related Content

What's hot

WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
Thanachart Numnonda
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
BG Java EE Course
 
Servlets
ServletsServlets
Introduction to WebSockets Presentation
Introduction to WebSockets PresentationIntroduction to WebSockets Presentation
Introduction to WebSockets Presentation
Julien LaPointe
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jspJafar Nesargi
 
SOA unit-3-notes-Introduction to Service Oriented Architecture
SOA unit-3-notes-Introduction to Service Oriented ArchitectureSOA unit-3-notes-Introduction to Service Oriented Architecture
SOA unit-3-notes-Introduction to Service Oriented Architecture
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
Apache web server
Apache web serverApache web server
Apache web server
Rishabh Bahukhandi
 
Jsp(java server pages)
Jsp(java server pages)Jsp(java server pages)
Jsp(java server pages)
Khan Mac-arther
 
Reactive Programming for Real Use Cases
Reactive Programming for Real Use CasesReactive Programming for Real Use Cases
Reactive Programming for Real Use Cases
Alex Soto
 
Servlets
ServletsServlets
Servlets
ZainabNoorGul
 
Ajax ppt
Ajax pptAjax ppt
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
Dhruvin Nakrani
 
Network virtualization
Network virtualizationNetwork virtualization
Network virtualization
Damian Parniewicz
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
sandeep54552
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
Nir Elbaz
 

What's hot (20)

WEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES ServletWEB TECHNOLOGIES Servlet
WEB TECHNOLOGIES Servlet
 
ASP.NET Basics
ASP.NET Basics ASP.NET Basics
ASP.NET Basics
 
Introduction to Web Services
Introduction to Web ServicesIntroduction to Web Services
Introduction to Web Services
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Tomcat
TomcatTomcat
Tomcat
 
Servlets
ServletsServlets
Servlets
 
Introduction to WebSockets Presentation
Introduction to WebSockets PresentationIntroduction to WebSockets Presentation
Introduction to WebSockets Presentation
 
Chapter 3 servlet & jsp
Chapter 3 servlet & jspChapter 3 servlet & jsp
Chapter 3 servlet & jsp
 
SOA unit-3-notes-Introduction to Service Oriented Architecture
SOA unit-3-notes-Introduction to Service Oriented ArchitectureSOA unit-3-notes-Introduction to Service Oriented Architecture
SOA unit-3-notes-Introduction to Service Oriented Architecture
 
Apache web server
Apache web serverApache web server
Apache web server
 
Jsp(java server pages)
Jsp(java server pages)Jsp(java server pages)
Jsp(java server pages)
 
Ajax
AjaxAjax
Ajax
 
Reactive Programming for Real Use Cases
Reactive Programming for Real Use CasesReactive Programming for Real Use Cases
Reactive Programming for Real Use Cases
 
Servlets
ServletsServlets
Servlets
 
Ajax Ppt 1
Ajax Ppt 1Ajax Ppt 1
Ajax Ppt 1
 
Ajax ppt
Ajax pptAjax ppt
Ajax ppt
 
Servlet and servlet life cycle
Servlet and servlet life cycleServlet and servlet life cycle
Servlet and servlet life cycle
 
Network virtualization
Network virtualizationNetwork virtualization
Network virtualization
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Introduction to ajax
Introduction to ajaxIntroduction to ajax
Introduction to ajax
 

Viewers also liked

Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
Arnold Pham
 
Ethereum Smart Contract Tutorial
Ethereum Smart Contract TutorialEthereum Smart Contract Tutorial
Ethereum Smart Contract Tutorial
Arnold Pham
 
Learning Solidity
Learning SolidityLearning Solidity
Learning Solidity
Arnold Pham
 
Mist and parity
Mist and parityMist and parity
Mist and parity
Arnold Pham
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Tomoaki Sato
 
A tour of ethereum ecosystem
A tour of ethereum ecosystemA tour of ethereum ecosystem
A tour of ethereum ecosystem
Chang-Wu Chen
 
Smart contracts & dApps
Smart contracts & dAppsSmart contracts & dApps
Smart contracts & dApps
Shermin Voshmgir
 
Blockchain &amp; the Future of Democracy
Blockchain &amp; the Future of DemocracyBlockchain &amp; the Future of Democracy
Blockchain &amp; the Future of Democracy
Shermin Voshmgir
 
History of Distributed Computing
History of Distributed ComputingHistory of Distributed Computing
History of Distributed Computing
Shermin 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 Techmeetup
James Littlejohn
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvmgha sshee
 
Ethereum @ descon 2016
Ethereum @ descon 2016Ethereum @ descon 2016
Ethereum @ descon 2016
Predrag Radović
 
Introduction to Idea
Introduction to IdeaIntroduction to Idea
Introduction to Idea
James Littlejohn
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchain
James Littlejohn
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfinden
Stephan 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
 
Solidity intro
Solidity introSolidity intro
Solidity intro
Angello Pozo
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mix
gavofyork
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info Wallet
Sjors Provoost
 

Viewers also liked (20)

Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
 
Ethereum Smart Contract Tutorial
Ethereum Smart Contract TutorialEthereum Smart Contract Tutorial
Ethereum Smart Contract Tutorial
 
Learning Solidity
Learning SolidityLearning Solidity
Learning Solidity
 
Mist and parity
Mist and parityMist and parity
Mist and parity
 
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereumDappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
 
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市場のトピックス
 
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
 
Ethereum @ descon 2016
Ethereum @ descon 2016Ethereum @ descon 2016
Ethereum @ descon 2016
 
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
 
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
 
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
 

Similar to The Ethereum Geth Client

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
orkaplan
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshop
Pad Kankipati
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain Implementation
GlobalLogic Ukraine
 
Open source security
Open source securityOpen source security
Open source securitylrigknat
 
Blockchain Technology Introduction and Basics
Blockchain Technology  Introduction and BasicsBlockchain Technology  Introduction and Basics
Blockchain Technology Introduction and Basics
jayasris2023
 
Resource slides for blockchain related question
Resource slides for blockchain related questionResource slides for blockchain related question
Resource slides for blockchain related question
Lin Lin (Wendy)
 
Dapper performance
Dapper performanceDapper performance
Dapper performance
Suresh Loganatha
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
Jurriaan Persyn
 
Owning computers without shell access dark
Owning computers without shell access darkOwning computers without shell access dark
Owning computers without shell access dark
Royce Davis
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application Technologies
Sam Bowne
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
Sujit Kumar
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
Sathish VJ
 
Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
Danilo Ercoli
 
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
gree_tech
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
MouDhara1
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
kstalin2
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
KhushalChoudhary14
 
Ethereum - MetaMask&Remix&Smartcontract
Ethereum - MetaMask&Remix&SmartcontractEthereum - MetaMask&Remix&Smartcontract
Ethereum - MetaMask&Remix&Smartcontract
Hu Kenneth
 
Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to know
Gökhan Şengün
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
Nishit Charania
 

Similar to The Ethereum Geth Client (20)

introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
BlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshopBlockchainConf.tech - Build a private blockchain workshop
BlockchainConf.tech - Build a private blockchain workshop
 
Node.js Blockchain Implementation
Node.js Blockchain ImplementationNode.js Blockchain Implementation
Node.js Blockchain Implementation
 
Open source security
Open source securityOpen source security
Open source security
 
Blockchain Technology Introduction and Basics
Blockchain Technology  Introduction and BasicsBlockchain Technology  Introduction and Basics
Blockchain Technology Introduction and Basics
 
Resource slides for blockchain related question
Resource slides for blockchain related questionResource slides for blockchain related question
Resource slides for blockchain related question
 
Dapper performance
Dapper performanceDapper performance
Dapper performance
 
Introduction to memcached
Introduction to memcachedIntroduction to memcached
Introduction to memcached
 
Owning computers without shell access dark
Owning computers without shell access darkOwning computers without shell access dark
Owning computers without shell access dark
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application Technologies
 
SFDC Outbound Integrations
SFDC Outbound IntegrationsSFDC Outbound Integrations
SFDC Outbound Integrations
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
 
Improve WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of codeImprove WordPress performance with caching and deferred execution of code
Improve WordPress performance with caching and deferred execution of code
 
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
Common Pitfalls of Functional Programming and How to Avoid Them: A Mobile Gam...
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet.ppt
Servlet.pptServlet.ppt
Servlet.ppt
 
Servlet1.ppt
Servlet1.pptServlet1.ppt
Servlet1.ppt
 
Ethereum - MetaMask&Remix&Smartcontract
Ethereum - MetaMask&Remix&SmartcontractEthereum - MetaMask&Remix&Smartcontract
Ethereum - MetaMask&Remix&Smartcontract
 
Http - All you need to know
Http - All you need to knowHttp - All you need to know
Http - All you need to know
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 

Recently uploaded

The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 

Recently uploaded (16)

The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 

The Ethereum Geth Client

  • 1. Ethereum Developers Community The Ethereum Geth Client 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/)
  • 2. 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"] }
  • 3. 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.
  • 4. 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.
  • 5. 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
  • 6. • 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
  • 7. Default JSON-RPC endpoints • Geth: http://localhost:8545
  • 8. Compiler • Solc • A standalone solidity compiler • You only need this if you want to use your Dapp or console to compile solidity code
  • 9. Test Networks • Ropsten testnet (--testnet) • Local private testnet
  • 10. Setting Up a Test Network $ geth --testnet 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
  • 11. Setting Up a Test Network • $geth attach • >personal.newAccount(‘password’) • miner.start() • miner.stop()
  • 12. 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
  • 13. 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
  • 14. 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
  • 15. 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
  • 16. 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”)
  • 17. List all existing accounts • geth account list • For geth console • eth.accounts
  • 18. Show primary account address • From geth console • eth.coinbase
  • 19. 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
  • 20. 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”)
  • 21. 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++; }) };
  • 22. Spending your gas • In order to spend your gas to transact you need to unlock the account • personal.unlockAccount(eth.coinbase)
  • 23. 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
  • 24. Mining • analogous to mining gold or precious metals • secures the network and verifies computation
  • 25. Proof of Work • A block is only valid if it contains proof of work of a given difficulty • the PoW algorithm is called Ethash
  • 26. Ethash • a modified version of Dagger-Hashimoto which involves finding a nonce input to 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
  • 27. 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
  • 28. 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)
  • 29. 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
  • 30. 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>
  • 31. 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
  • 32. 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
  • 33. 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