Ethereum入門読んでみた③
この記事は前回の続きです。
chanichiwasshoi.hateblo.jp
このページを読んでます。
etherを採掘する - Ethereum入門
Ethereumコンソールへの接続
※gethのインストールや初期化などは記事を見て行ってください。
なんやかんやでGethをインストールして起動ができたら、ターミナルで次のコマンドを実行してコンソールを起動してください。
geth --networkid "15" --nodiscover --datadir "." console 2>> ./geth_err.log
すると、Gethのコンソールが起動しコマンドが打てるようになります。試しに以下のコマンドを実行してGenesisブロック(一番最初のブロック)の中身を確認してください。
> eth.getBlock(0) { difficulty: 16384, extraData: "0x00", gasLimit: 134217728, (中略) miner: "0x3333333333333333333333333333333333333333", nonce: "0x0000000000000042", number: 0, parentHash: "0x0000000000000000000000000000000000000000000000000000000000000000", (後略) }
アカウント関連のコマンド
1. EOAの確認
> eth.accounts ['0x23233...', '0xd1938..."]
EOAの作成
> personal.newAccount("some_password") '0x2f841a...'
マイニング報酬を受け取るアカウント
//報酬を受け取るアカウントの確認 > eth.coinbase '0x819f01...' //報酬を受け取るアカウントの変更 > miner.setEtherbase(eth.accounts[1])
etherの採掘
// 採掘の開始 > miner.start() null //採掘の停止 > miner.stop() true // 採掘されたブロック数 > eth.blockNumber 145 // 採掘中かどうか確認 > eth.mining true // 採掘速度の確認 > eth.hashrate 445445
採掘したブロックの内容を調べる
> eth.getBlock(100) { difficulty: '137447', extraData: '0x476574682f76312e302e312f6c696e75782f676f312e342e32', gasLimit: 3141592, gasUsed: 0, hash: '0x4d3063b91cbaa12bf2de81014c1319febc9f197c93f81b0746afaffaa9496620', logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', miner: '0x24afe6c0c64821349bc1bfa73110512b33fa18e1', nonce: '0x28fda83cb19ed497', number: 100, parentHash: '0x5885cdec1d1410580eaaf1fb7ef9db245a735822d48e816c73d926b7c9872f15', sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347', size: 536, stateRoot: '0xacf2c3dfc512373ae6d9693207b3ac43fd4811791fec994c2eecd8fdd3333699', timestamp: 1439451765, totalDifficulty: '13551548', transactions: [ ], transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421', uncles: [ ] } > eth.getBlock(101) { difficulty: '137514', extraData: '0x476574682f76312e302e312f6c696e75782f676f312e342e32', gasLimit: 3141592, gasUsed: 0, hash: '0xca9b241dabe753ed83d6242f226c0ad6b559c722edf5d24baff126670f70a30c', ... }
報酬の確認
> eth.getBalance(eth.accounts[0]) ' 51500000000000'