以太坊(https://ethereum.org/)是一个区块链(BlockChain)技术的开源(https://github.com/ethereum)平台。这里介绍在Ubuntu上面安装以太坊相关软件的方法(参见以太坊安装方法),也能够将其安装在Docker中(方法参见【这里】),从而更好地与其余运行环境相隔离、进行迁移或者实现一个集群的快速部署。html
若是已经安装了最新版本的git,node,和npm,就跳过这一步。若是没有安装,请输入如下命令安装:node
sudo apt-get install git sudo apt-get install nodejs-legacy sudo apt-get install npm
Ubuntu 14.04自带的Node.js版本太老,且我试了下安装并不成功,因此须要添加Node.js PPA安装最新版的Node.js,在终端中执行:python
sudo apt-get update sudo apt-get install -y python-software-properties software-properties-common #nodejs没有Ubuntu官方源,须要本身编译,网传的这个源已经无法用了。 #sudo add-apt-repository ppa:chris-lea/node.js #若是安装了上面的,必定要删掉,方法以下: #sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list #获取新的源,目前实验能够用: #curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - sudo apt-get update sudo apt-get install nodejs
Ubuntu安装Nodejs的更多参考:linux
输入如下命令安装solc:git
sudo npm install -g solc
安装完后,咱们就会发如今终端中输入solc命令返回一个出错信息。这是由于solc只是一个程序集,若是咱们想要在终端中使用solc程序编译智能合约,则须要安装solc-cli,这是solc的命令行界面。github
输入如下命令安装solc-cli:web
sudo npm install -g solc-cli
输入如下命令能够一并安装solc和solc-cli(推荐使用此命令安装):npm
sudo npm install -g solc solc-cli --save-dev
若是输入solc --version命令,有如下输出,则代表solc和solc-cli安装成功:ubuntu
zcc[@ubuntu](https://my.oschina.net/u/555627):~$ solc --version solc, the solidity compiler commandline interface Version: 0.3.5-0/RelWithDebInfo-Linux/g++/Interpreter
注意bash
若是你安装了webthree-umbrella,那么solc就会默认安装,可是咱们在终端输入solc并无显示可用的命令,咱们须要输入如下命令手动创建软连接:
sudo ln -s /home/zcc/webthree-umbrella/solidity/build/solc/solc /bin/solc
这样就能直接在终端使用solc程序了。
参考
Solidity开发文档 NPM小结 solc-npm solc-cli-npm 智能合约初体验
输入如下命令:
sudo npm install -g ethereumjs-testrpc
若是输入testrpc命令,有如下输出,则代表testrpc安装成功:
zcc[@ubuntu](https://my.oschina.net/u/555627):~$ testrpc EthereumJS TestRPC v2.0.9 Available Accounts==================(0) 0x3aaf37e090b570596c47eeb83dee6d7eb6010b87(1) 0x2ab74e4872f69f59ddfb19535e731b5abe012748(2) 0x5c393ac0eccb6236641b5e3fadae83b745aab893(3) 0xa23e3e6c2c11a26b58f0656168dadb4f4965648e(4) 0xf15a17d9ecfeed966721e2dddccb1709568c5b83(5) 0xb7eadd05c6661884f29dee4f77dfb634b1925729(6) 0x77a4609285693d7773b809af4218a0a3702fac2f(7) 0xb62e0d887bc7b17810159108f1b6a32eb8c5f51a(8) 0xeddcef43e382e4150465d8bd113e5fbc02077aaf(9) 0xb2f5addd09b2fb9c94bf41e851a3d537b88748a1 Private Keys==================(0) 452b5601745b2c65c3a88f6a56b4bc393511f453646031097fc8d18948f46581(1) aaea0670b3eff9db750db8641f3b08ec8268373945f837bf393cf3e494ec8da6(2) c9be77fd26933d26ae309a3fe5dbd1cb9747d4f5e872fff3f07921f0b5ff15c7(3) 8767cbcd5eafbf914ee66590de121c7fbf951a793d1c7f9376b5d1ba064808ea(4) 2e2117afb334e870f15760e74c9d1f72f3c15d59fb047b603590be8d67a5338e(5) 017221e1344fdad12ff90b644979052525d048e10596cb88ae4411dcd6cbe3be(6) 13a47c99a21403f30579b08ce6116af50028af21b9de13bab05b8d1c45349593(7) 24c9f2b3bbf9ebd193c2c9aa3ab62c58005ecb20b9fb28f43b54f9bec7d5b4fb(8) e048a57d2d68f5f198b6dc23e8596f88e155bdb2157e616af6247392f49b2e2e(9) 16e49075f5cbe265cbb6c7af181d9d6b4e017f39a861d6e2655a7899ad2288f0HD Wallet================== Mnemonic: cliff evolve motion suit citizen crack borrow churn way glare series trust Base HD Path: m/44'/60'/0'/0/{account_index} Listening on localhost:8545
参考网页中的命令没有sudo,可是由于-g参数是表示全局安装,则须要使用root权限才能安装成功。
参考:
ethereumjs/testrpc
输入如下命令:
sudo npm install -g truffle
若是输入truffle version命令,有如下输出,则代表truffle安装成功:
zcc[@ubuntu](https://my.oschina.net/u/555627):~$ truffle version Truffle v2.0.0
*参考
ConsenSys/truffle
有多种以太坊客户端,安装go-ethereum输入如下命令:
sudo apt-get install software-properties-common sudo add-apt-repository -y ppa:ethereum/ethereum sudo add-apt-repository -y ppa:ethereum/ethereum-dev sudo apt-get update sudo apt-get install ethereum
安装cpp-ethereum输入如下命令:
sudo add-apt-repository ppa:ethereum/ethereum-qt sudo add-apt-repository ppa:ethereum/ethereum sudo apt-get update sudo apt-get install cpp-ethereum
参考
go-ethereum源码 Ethereum Homestead
Mix IDE是Ubuntu PPA的一部分,所以须要安装完cpp-ethereum前提下才能安装Mix,不然安装过程当中会提示缺乏依赖集。
安装完cpp-ethereum后,输入如下命令开始安装Mix:
sudo apt-get install mix-ide mix-ide