ethereum プライベートネットワークをdockerで動かしてみた
参考
↑
これほんとわかりやすい
実行結果だけ載せときます
docker run -it --name geth golang:1.9 /bin/bash
git clone -b release/1.8 https://github.com/ethereum/go-ethereum ~/go-ethereum
cd ~/go-ethereum/
make geth
*以下省略
export PATH=/root/go-ethereum/build/bin:$PATH
geth version
mkdir ~/gethcat << EOS > ~/geth/genesis.json
geth --datadir ~/geth/ init ~/geth/genesis.json
geth --networkid 10 --datadir ~/geth/ console 2>> ~/geth/error.log
eth.getBlock(0)
eth.getBlock(1)
personal.newAccount("password")
eth.accounts[0]
eth.coinbase
miner.start(1)
eth.mining
miner.stop()
eth.getBalance(eth.accounts[0])
マイニングは少し待たないと結果が反映されない
web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
personal.lockAccount(eth.accounts[0])
eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(10, "ether")})
eth.account[0]からeth.account[1]に10ether送金している
eth.getTransaction("0xdd4f3f940c6cc4fb6382eeec9f04cd864547bsybyceajvuci736r9z03c6")
blockNumberが「null」
なのでこのトランザクションは
ブロックに取り込まれていない
ということで
また、マイニングを再開して
ブロックにトランザクションを
取り込んでいく
blockNumberが「35」になったので
トランザクションがブロックに
取り込まれた
web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
実際にeth.account[0]からeth.account[1]に
10ether送金されたことが確認出来た
おわりに
1ブロック毎に5ether報酬をもらってるっぽい