ローカル(Windows7)でgethを複数起動してみる
こんにちは。土田です。
表題の通りです。メモ代わりに投稿します。
前回に続き、Ethereum学習中です。
きっかけ
既にgeth乗ってるサーバもあるけど、適当に弄った後に戻したりとか考えると嫌になった。
スマートコントラクトをローカルで適当に開発したくなった。
前提
・OSはWindows 7 Professional (64ビット)でやる。
・Ethereumクライアントはgeth(go-ethereum)で、下記からDLしておく。
https://geth.ethereum.org/downloads/
・プライベートネットワークでやる。
・複数geth起動し、複数ノードが起動してプライベートネットワークで接続することを確認する。
起動手順
1.DLしたgethを任意の場所に配置
C:\geth
2.それぞれのフォルダに「genesis.json」ファイルを用意
{
"nonce": "0x0000000000000042",
"difficulty": "0x0",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x3333333333333333333333333333333333333333",
"timestamp": "0x00",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"extraData": "0x",
"gasLimit": "0X8000000",
"alloc": {},
"config": {}
}
3.gethの初期化
cd C:\geth
geth --datadir ./node1 init genesis.json
geth --datadir ./node2 init genesis.json
それぞれ「Successfully wrote genesis state」みたいになってればOK
4.複数ノードの起動
geth --networkid 4649 --nodiscover --datadir ./node1 --rpc --rpccorsdomain "*" --rpcport 8545 --rpcaddr "0.0.0.0" --rpcapi "web3,eth,net,personal" --port 30303 console 2>> ./node1.log
geth --networkid 4649 --nodiscover --datadir ./node2 --rpc --rpccorsdomain "*" --rpcport 8546 --rpcaddr "0.0.0.0" --rpcapi "web3,eth,net,personal" --port 30304 --ipcdisable console 2>> ./node2.log
「--ipcdisable」オプションを指定して「Fatal: Error starting protocol stack: Access is denied.」というエラーを回避する。今回困ったポイントはこのエラーでした。
5.確認
・addPeerしてノード間の接続を確認する。
・「Solidity」で各Nodeに接続できることも確認しておく。
→接続は下記参照。(「Web3 Provider Endpoint」入力時にgeth起動時に指定したrpcportを使用すること。)
参考
Installation instructions for Windows · ethereum/go-ethereum Wiki · GitHub
Setting up private network or local cluster · ethereum/go-ethereum Wiki · GitHub
starting multiple geth console · Issue #1714 · ethereum/go-ethereum · GitHub
go ethereum - Fatal: Error starting protocol stack: ... Access is denied - Ethereum Stack Exchange
以上です。
書いた人:テレコム第2チーム 土田