Ubuntu-開源區塊鏈軟件「以太坊」安裝

以太坊(https://ethereum.org/)是一個區塊鏈(BlockChain)技術的開源(https://github.com/ethereum)平臺。這裏介紹在Ubuntu上面安裝以太坊相關軟件的方法(參見以太坊安裝方法),也能夠將其安裝在Docker中(方法參見【這裏】),從而更好地與其餘運行環境相隔離、進行遷移或者實現一個集羣的快速部署。html

1. 安裝git,node,npm

若是已經安裝了最新版本的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

2. 安裝solc

輸入如下命令安裝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
智能合約初體驗

3. 安裝testrpc

輸入如下命令:

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

4. 安裝truffle

輸入如下命令:

sudo npm install -g truffle

若是輸入truffle version命令,有如下輸出,則代表truffle安裝成功:

zcc[@ubuntu](https://my.oschina.net/u/555627):~$ truffle version
Truffle v2.0.0

*參考

ConsenSys/truffle

5. 安裝Ethereum客戶端

有多種以太坊客戶端,安裝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

6. 安裝Mix IDE

Mix IDE是Ubuntu PPA的一部分,所以須要安裝完cpp-ethereum前提下才能安裝Mix,不然安裝過程當中會提示缺乏依賴集。

安裝完cpp-ethereum後,輸入如下命令開始安裝Mix:

sudo apt-get install mix-ide
mix-ide
相關文章
相關標籤/搜索