目的
记录一下本人在Ubuntu环境下配置以太坊开发环境的过程,希望对后来者有所帮助。
过程
首先安装npm和NodeJS
sudo apt-get install npm
sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
然后用npm安装solc和solc的命令行工具solc-cli
sudo npm install -g solc solc-cli --save-dev
运行命令solcjs测试是否安装成功,如果没有输出则尝试重新启动shell或者重新连SSH。
安装solc二进制包
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
安装testrpc和truffle,这两个用npm就可以安装
sudo npm install -g ethereumjs-testrpc
sudo npm install -g truffle
测试一下
root@server-01:~# testrpc
EthereumJS TestRPC v6.0.3 (ganache-core: 2.0.2)
Available Accounts
==================
(0) 0x3675e40d6bfe7566************************
(1) 0x08d58806fc0594b9************************
(2) 0xb03848d8e9359c13************************
(3) 0xc3161063b46b2ca7************************
(4) 0x026c1c6020e8bdb4************************
(5) 0xe16f58c2ce883c7b************************
(6) 0x77ef98fe516c2b27************************
(7) 0x9ea92133dfccc26b************************
(8) 0xc417d04c5c3a07fe************************
(9) 0x9a2057c26ca2f31b************************
Private Keys
==================
(0) 7257cca8f9dedc96e5763f65b************************
(1) e1e0966f65791b770f5f02889************************
(2) e06e8b51551acf86911218e2b************************
(3) c5c5541ff80373e67250da33f************************
(4) 84fcce7aa99ae2fb2daeb3d39************************
(5) b4a85007439171cb749c8a735************************
(6) d915802e5ed351f580e647dd4************************
(7) f968d8be8c8eca6921e096f0f************************
(8) 8ad639d0ab8cba1330d0166d0************************
(9) 3832604233464c554487c4638************************
HD Wallet
==================
Mnemonic: talent eyebrow split nasty belt crane minor tenant text exact arrow bronze
Base HD Path: m/44'/60'/0'/0/{account_index}
安装Geth客户端(go-ethereum)
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
测试一下效果
root@server-01:~# geth
WARN [02-07|22:25:13] No etherbase set and no accounts found as default
INFO [02-07|22:25:13] Starting peer-to-peer node instance=Geth/v1.7.3-stable-4bb3c89d/linux-amd64/go1.9
INFO [02-07|22:25:13] Allocated cache and file handles database=/root/.ethereum/geth/chaindata cache=128 handles=1024
INFO [02-07|22:25:13] Initialised chain configuration config="{ChainID: 1 Homestead: 1150000 DAO: 1920000 DAOSupport: true EIP150: 246
3000 EIP155: 2675000 EIP158: 2675000 Byzantium: 4370000 Engine: ethash}"
INFO [02-07|22:25:13] Disk storage enabled for ethash caches dir=/root/.ethereum/geth/ethash count=3
INFO [02-07|22:25:13] Disk storage enabled for ethash DAGs dir=/root/.ethash count=2
INFO [02-07|22:25:13] Initialising Ethereum protocol versions="[63 62]" network=1
INFO [02-07|22:25:13] Loaded most recent local header number=1689199 hash=33deb6…58ab28 td=26797004748806845550
INFO [02-07|22:25:13] Loaded most recent local full block number=0 hash=d4e567…cb8fa3 td=17179869184
INFO [02-07|22:25:13] Loaded most recent local fast block number=1682884 hash=3ae41f…d86991 td=26497997153318071852
INFO [02-07|22:25:13] Loaded local transaction journal transactions=0 dropped=0
INFO [02-07|22:25:13] Regenerated local transaction journal transactions=0 accounts=0
INFO [02-07|22:25:13] Upgrading chain index type=bloombits percentage=72
INFO [02-07|22:25:13] Starting P2P networking
INFO [02-07|22:25:16] UDP listener up self=enode://2351f92b96adcaaa0f648e4646677052ca20943756a7005f378907420aa85ac2671
721b0048496ec535611624b25442689d1f5f94764276598b8f31949e5a6de@[::]:30303
INFO [02-07|22:25:16] RLPx listener up self=enode://2351f92b96adcaaa0f648e4646677052ca20943756a7005f378907420aa85ac2671
721b0048496ec535611624b25442689d1f5f94764276598b8f31949e5a6de@[::]:30303
INFO [02-07|22:25:16] IPC endpoint opened: /root/.ethereum/geth.ipc
总结
这样以太坊的开发环境的配置就大功告成了。以太坊是一个分布式的账本数据库,在机器上运行geth后,该机器就成为以太坊的一个P2P节点,会不断更新本机的以太坊分布式账本数据库。
网友评论