天天看點

EOS開發:通過docker快速建構安裝EOSIO

先決條件

Docker: Docker管理服務。Docker旨在通過使開發人員在容器内很友善的建立完全配置的系統環境來簡化應用程式部署。系統環境包括在配置好的作業系統中運作各種目标應用程式,這些目标應用程式提供你的應用程式需要的所有運作時支援。開發人員在容器内建立所需的系統配置,然後在打包容器進行分發。

1.擷取鏡像

EOSIO Dev docker鏡像是為本地開發而設計的EOSIO軟體的編譯版本。

從存儲庫中提取鏡像:

開啟EOSIO節點

檢查它的工作情況:

輸出應該類似這樣:

ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block ce4e2a... #13929 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block aea085023... #13930 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block b7f074fdd... #13931 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block cd8222adb... #13932 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block d5c1ec38d... #13933 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block e45c1f235... #13934 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block f98adb324... #13935 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block a0f01daa... #13936 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block e8b36e1e... #13937 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
ms thread-   producer_plugin.cpp:       block_production_loo ] Produced block fe1623... #13938 @ --T16:: signed by eosio [trxs: , lib: , confirmed: ]
           

恭喜!你有一個非常簡單的單節點區塊鍊運作在你的docker中!

也可以通過浏覽器中的這個位址來檢查RPC接口是否工作:

你應該看到類似的資訊:

{
    "server_version": "0961a560",
    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
    "head_block_num": ,
    "last_irreversible_block_num": ,
    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",
    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
    "head_block_time": "2018-05-23T16:30:54",
    "head_block_producer": "eosio",
    "virtual_block_cpu_limit": ,
    "virtual_block_net_limit": ,
    "block_cpu_limit": ,
    "block_net_limit": 
}
           

2.Cleos别名

cleos

是一個指令行接口,負責與區塊鍊互動并管理錢包。

為了友善起見,我們将建立一個bash别名,用于運作在容器中的

cleos

。在終端,運作:

3.确認是否安裝成功

現在試着在你的終端中運作

cleos --help

。你應該看到一個輸出:

Command Line Interface to EOSIO Client
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND

Options:
  -h,--help                   Print this help message and exit
  -u,--url TEXT=http://localhost:8888/
                              the http/https URL where nodeos is running
  --wallet-url TEXT=http://localhost:8900/
                              the http/https URL where keosd is running
  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers
  -n,--no-verify              don't verify peer certificate when using HTTPS
  -v,--verbose                output verbose actions on error

Subcommands:
  version                     Retrieve version information
  create                      Create various items, on and off the blockchain
  get                         Retrieve various items and information from the blockchain
  set                         Set or update blockchain state
  transfer                    Transfer EOS from account to account
  net                         Interact with local p2p network connections
  wallet                      Interact with local wallet
  sign                        Sign a transaction
  push                        Push arbitrary transactions to the blockchain
  multisig                    Multisig contract commands
  system                      Send eosio.system contract action to the blockchain.
           

令人驚歎的!我們跑起來了。

停止EOSIO容器

當需要停止時,請使用:

bash docker stop eosio
           

另:《EOS智能合約與DApp開發入門》教程上線了,歡迎大家學習互動:

EOS教程

本教程幫助你快速入門EOS區塊鍊去中心化應用的開發,内容涵蓋EOS工具鍊、賬戶與錢包、發行代币、智能合約開發與部署、使用代碼與智能合約互動等核心知識點,最後綜合運用React和EOS的各知識點完成一個便簽DApp的開發。

如果你希望學習以太坊相關的内容,可以選擇以下教程:

  • web3j教程,主要是針對java和android程式員進行區塊鍊以太坊開發的web3j詳解。
  • 以太坊教程,主要介紹智能合約與dapp應用開發,适合入門。
  • 以太坊開發,主要是介紹使用node.js、mongodb、區塊鍊、ipfs實作去中心化電商DApp實戰,适合進階。
  • python以太坊,主要是針對python工程師使用web3.py進行區塊鍊以太坊開發的詳解。
  • php以太坊,主要是介紹使用php進行智能合約開發互動,進行賬号建立、交易、轉賬、代币開發以及過濾器和事件等内容。

彙智網原創翻譯,轉載請标明出處。原文