1. 程式人生 > >Ubuntu-開源區塊鏈軟體“以太坊”安裝  安裝solidity

Ubuntu-開源區塊鏈軟體“以太坊”安裝  安裝solidity

Ubuntu-開源區塊鏈軟體“以太坊”安裝 

openthings

  openthings 釋出於 2016/09/22 14:18 

字數 972

閱讀 644

收藏 5

點贊 0

 評論 1

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

1. 安裝git,node,npm

如果已經安裝了最新版本的git,node,和npm,就跳過這一步。如果沒有安裝,請輸入以下命令安裝:

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,在終端中執行:

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的更多參考:

2. 安裝solc

輸入以下命令安裝solc:

sudo npm install -g solc

安裝完後,我們就會發現在終端中輸入solc命令返回一個出錯資訊。這是因為solc只是一個程式集,如果我們想要在終端中使用solc程式編譯智慧合約,則需要安裝solc-cli,這是solc的命令列介面。

輸入以下命令安裝solc-cli:

sudo npm install -g solc-cli

輸入以下命令可以一併安裝solc和solc-cli(推薦使用此命令安裝):

sudo npm install -g solc solc-cli --save-dev

如果輸入solc --version命令,有以下輸出,則表明solc和solc-cli安裝成功:

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

注意

如果你安裝了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