gething started - ethereum & using the geth golang client
TRANSCRIPT
Talk Set: Utils and Projects in Go● Identify interesting tools and projects in Go
○ As opposed to focusing only on the language
● Highlight big/awesome projects and inform dev audience it was written in Go
● Encourage open source contribution in Go● Promote daily use tools written in Go● SFO searches Go; BLR searches JSP
○ Courtesy: stackoverflow research data
● For orgs shifting to Go, make available a wider developer pool
Blockchain
A blockchain is a distributed database that maintains a continuously growing list of records called blocks secured from
tampering and revision. Each block contains a timestamp and a link to a
previous block.
4See my more elaborate talk at GDG DevFest: slideshare.net/SathishVJ/blockchain-bitcoin
Bitcoin
A distributed, decentralized, digital cryptocurrency that relies
on Blockchain technology.
6
Ethereum
A blockchain-based distributed computing platform, featuring smart contract functionality. It provides a decentralized virtual machine that
can execute peer-to-peer contracts using a cryptocurrency called ether.
7
Ethereum Clients● Multiple clients based on Ethereum Yellow Paper● In Go, Rust, C++, Python, JavaScript, etc.● The Go based Ethereum client is called geth● Got a dedicated website recently
○ Geth.ethereum.org
● Can also be used a library○ In Mobiles
○ https://ethereum.karalabe.com/talks/2016-devcon.html
Geth Usage● Largest ethereum client is the go client,
geth● Most versions used are up to date, >
1.5.3
Ethereum, Swarm, Whisper● Contracts: decentralized logic● Swarm: decentralized storage● Whisper: decentralized
messaging
Tech Components● DApp: Distributed Application● Solidity: a language to write contracts on ethereum● web3: a library to interact with ethereum blockchain (web3.eth). Contains
other objects like (web3.shh for Whisper)● Import web3.js in your browser to interact with the blockchain ● General term web3
○ No one definition
○ Multiple meanings in books and magazines
○ Here, it signifies an always “on”, distributed web, capable of massive scale
PoW to PoS, Casper & Tendermint● Strategies to arrive at consensus in a distributed network● Proof of Work expends too much energy. ● PoW is skewed towards those who can spend more money.● Proof of Stake puts a certain number of coins to give one a chance to mine.
○ More egalitarian. Greater security with more participating nodes.
● Casper: scenarios where little to no assumptions should be made on the altruism of users or validators, e.g. public blockchains.
● Tendermint: scenarios where participants have existing trust or where chance of attack is less, e.g. consortium or private/hybrid blockchains
Project Links● Github: https://github.com/ethereum/go-ethereum● Releases: https://github.com/ethereum/go-ethereum/releases ● Downloads: https://geth.ethereum.org/downloads/ ● Main site: https://www.ethereum.org● Install command line tools: https://www.ethereum.org/cli
Installing Geth● Bundled as a part of GUI tools like Mist/Ethereum-Wallet● Installable from source● Install with package manager
○ Homebrew, apt-get
● From standalone pre-built bundle
From Pre-built Bundle● My Demo Setup: Google Compute Engine, small VM, Ubuntu, attached and
mounted disk of 100GB● wget
https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.5.5-ff07d548.tar.gz
○ Check for latest version at https://geth.ethereum.org/downloads/
● tar -xvf geth-alltools-linux-amd64-1.5.5-ff07d548.tar.gz
● cd geth-alltools-linux-amd64-1.5.5-ff07d548● ./geth
○ This default command will start an ethereum client node
○ Mining is not automatic/default
● Add geth to PATH if you want
Ethereum Account● Your unique id on the Ethereum platform
○ A number like 0x2f2c...
● Online services can provide you an ethereum account (like email)○ myetherwallet.com, coinbase.com, jaxx.io, etc.
● You can also setup your own account● For convenience, use the GUIs Mist/Ethereum-Wallet
○ Electron based, cross platform Dapp browser/Wallet
● Or use cmd line● geth account list
○ Account #0: {...key...}
/home/ethmine/.ethereum/keystore/UTC--2016-12-16T19-26-20.479741815Z--[key]
New Ethereum Account with Geth● geth account new
Your new account is locked with a password. Please give a password. Do
not forget this password.
Passphrase:
Repeat Passphrase:
Address: {2fcb....}
● geth account list
● Any number of accounts can be created.
Backup Keystore and Password● When you run your own node, backup your keystore and password
○ Imagine if you ran your own email server
● There is no way you can get to your account otherwise● Locations on OSs
○ Windows: C:\Users\username\%appdata%\Roaming\Ethereum\keystore○ Linux: ~/.ethereum/keystore○ Mac: ~/Library/Ethereum/keystore
● Backup entire keystore folder … ● Or individual files that look like UTC--2016-12-03T18-26-12.919550734Z--key
Starting a Node● You will need about 50GB of space as of now● geth --datadir mydatadir --keystore ~/.ethereum
○ Datadir contains the blockchain data
○ I wanted the datadir to be on a different mount point
● A full sync in the beginning takes quite some time (a few days on a 1v-cpu, 1GB machine) ...
● Speed it up on first sync by using the --fast option○ This finished in many minutes
○ Cannot mine with just the fast sync
Exporting and Importing Chaindata● Export & import existing blockchain data from existing sync-d node● To export to binary format
○ geth export <filename>
● To import from binary format○ geth export <filename>
Attaching UI to Node● When UI starts, it checks for a running node● If it exists, UI attaches to node● If not, UI starts a node
○ Default is geth○ Can configure others
● If you want to have a particular client …○ Start the ethereum client on cmd line
○ Then start Mist or Ethereum-Wallet UI
1
2
Dir Structure$ find mydatadir -maxdepth 2
mydatadir
mydatadir/geth
mydatadir/geth/chaindata
mydatadir/geth/nodes
mydatadir/geth/LOCK
mydatadir/geth/nodekey
mydatadir/geth.ipc
$ find ~/.ethereum/ -maxdepth 2
.ethereum/
.ethereum/history
.ethereum/keystore
.ethereum/keystore/UTC--2016-12-16T19-26-20.479741815Z--[your key]
Mining● Run your ethereum node as a miner with --mine option● To be a miner, you need at least one account, the ‘etherbase’ account
Coinbase/Etherbase Account● If you mine a block, you get a reward of ETHs● This is added to your ‘etherbase’ account
○ In bitcoin it is ‘coinbase’. Not to be confused with a company of the same name
● By default it is account ‘0’○ … as listed in geth account list
● But you can specify another one● --mine option without etherbase set will error out
geth console● An interactive javascript console where you can do ‘web3’ programming● Start with
○ geth console
● Exit with Ctrl+D or with >exit● Attach to another running geth instance with
○ geth attach
● Then you can use console functions on one terminal while, say, sync logs show on the other
● If running in a specific dir, ○ geth attach mydatadir/geth.ipc
Console commands● miner.start()● miner.stop()● admin.datadir● net.peerCount● admin.peers● web3.fromWei(eth.getBalance(eth.coinbase), "ether")● personal.newAccount("password")● personal.listAccounts
References● Ethereum fundraiser infogram, with ether supply:
http://i.imgur.com/eI2mffD.png●
Cryptocurrency Investments● Extremely volatile in general● Some gigantic wins; many large losses● Ether is the token/currency (ETH)
○ <1$ -> ~20$ -> 7.5$
○ Was $1B+ Market cap, but lower now
● Very strong technology● Very good, responsive, knowledgeable, open team● Very positive sentiment● Many new, popular projects on Ethereum platform● Long term investors using current lows to enter
Ether Supply● http://ethereum.stackexchange.com/questions/443/what-is-the-total-supply-
of-ether
The issuance model is not fixed yet. It is an ongoing discussion whether or not the costs for the consensus needs to be financed by inflation that basically taxes every coin holder or if transaction fees are sufficient.
Please note that the costs for secure consensus are much lower with Casper compared to current proof of work. More details here
For this reason it is guaranteed, that the current issuance amount will not be increased and might even drop to 0. Another ongoing discussion is whether or not issues of new coins should be used to fund ongoing development. A prerequisites for this would be a DAO with a widely accepted mechanism to control spending of funds effectively. But also in this case the newly issued coins would not increase.
60 million + 12 million + 18million = ~90million
60 million - is the Pre-sale.
12 million - is the dev fund, 0.2coins per 1 coin sold in
the crowdsale.
~18 million - 1 million coins mined per month for 18
months prior to going from POW to POS.
inflation
After a while, 15,626,576 ether won't represent much of the total ether available, making the system dis-inflationary (i.e., inflation perpetually trending towards 0 but never reaching it).