以太坊私有節點搭建
阿新 • • 發佈:2018-11-15
開發 console home disco difficult gin ase nba datadir
我們可以通過搭建以太坊的私有節點,模擬以太坊挖礦、交易、部署運行智能合約,從而達到測試開發的目的。下面具體說明搭建過程:
1. 創建新帳號
geth --datadir {eth_dir} account new //其中 eth_dir 是私有節點的數據目錄
2. 創建 genesis.json 文件,保存創世紀塊的配置信息
{ "config": { "chainId": 1, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0 }, "alloc" : { "f985f8578206c6d317785cf131682259bf84588f": {"balance": "100000001"} }, "coinbase" : "0x0000000000000000000000000000000000000000", "difficulty" : "0x20000", "extraData" : "", "gasLimit" : "0x4c4b40", "nonce" : "0x0001000000000042", "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", "timestamp" : "0x00" }
3.初始化創世紀塊
geth --datadir {eth_dir} init {./genesis.json}
4. 啟動以太坊工作節點
geth --verbosity 6 --datadir e:/eth_dir --networkid 13579 --etherbase f985f8578206c6d317785cf131682259bf84588f
--port 30303 --rpcport 8545 --rpcaddr localhost --rpc --rpccorsdomain http://localhost:3000
--ws --wsorigins "http://localhost:3000" --wsport 8546 --unlock f985f8578206c6d317785cf131682259bf84588f--nodiscover --mine --minerthreads 1 --password e:/eth_dir/passwd console 2>>eth_output.log
以太坊私有節點搭建