操做系統要求node
1.Amazon 2017.09 and higherlinux
2.Centos 7ios
3.Fedora 25 and higher (Fedora 27 recommended)git
4. Mint 18github
5. Ubuntu 16.04 LTS (Ubuntu 16.10 recommended)windows
6. Ubuntu 18.04 LTS7. MacOS Darwin 10.12 and higher (MacOS 10.13.x recommended)api
系統需求ide
1.8G內存區塊鏈
2.20G空閒硬盤ui
這是官方給出的支持的操做系統,我的建議,儘可能不要在windows安裝linux虛擬機,會出現不少意想不到的C++安裝包的問題。我用的mac版本是10.13.4。
克隆代碼
git clone https://github.com/EOSIO/eos --recursive
若是克隆代碼時,沒加–recursive屬性,克隆完以後,須要在命令行中cd到下載的eos目錄,再次執行以下命令:
git submodule update --init --recursive
執行編譯腳本
在命令行中進入到eos目錄,執行編譯腳本:
./eosio_build.sh
大概須要10分鐘,看網速狀況了。編譯完成後,出現以下所示log:
請仔細看這裏的error日誌,提示build下面的hello.wast找不到,若是隻有這個error,請忽略它(這是官方的bug,之前編譯是沒有的,並且,這個error也並不會影響後面的正常操做)
安裝可執行腳本
cd build
sudo make install
這個安裝速度會有點慢,個人是1小時左右。安裝成功後,應該能看到以下所示log:
若是編譯腳本或者安裝可執行腳本時,出現部分安裝包安裝不了的狀況,請從新執行命令,或者刪除build目錄,再次執行編譯命令。若是這兩種也都無法解決的,請留言給我,或者帶着error日誌移步到官方issue,目前來講,官方issue是解決問題最多的地方,百度和google並無卵用。
在控制檯中任意目錄執行以下命令
nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --replay-blockchain --max-irreversible-block-age 1801
啓動成功後,會在本地產生區塊,log以下:
經過log分析,能夠看到eosio root,也就是區塊生成後的本地存放地點,以及ip,端口,還有一些RPC形式的API。cd到eosio root目錄下:
luoxiaohui:~ luoxiaohui$ cd /Users/luoxiaohui/Library/Application\ Support/eosio/ luoxiaohui:eosio luoxiaohui$ ls nodeos luoxiaohui:eosio luoxiaohui$ open nodeos/
能夠看到以下目錄:
其中的config.ini,就是本地節點的配置文件了,裏面有各個屬性參數,這裏不一一講了,有想法的本身去改了玩玩。
開啓keosd服務
另外打開一個命令行,執行以下命令:
keosd --http-server-address=127.0.0.1:8900
建立錢包
luoxiaohui:~ luoxiaohui$ cleos wallet create Creating wallet: default Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable."PW5J37EZS54NyQSugYtW6LQsERgUNB9xCpCiEpnauR9qzsJGcN8vQ"
建立密鑰對
luoxiaohui:~ luoxiaohui$ cleos create key Private key: 5JohgswbXLNLFukkLHe8Na5uPBDi7TZBTRTrkLgbfDqwo7ZCA4X Public key: EOS6YnSB38qj7Z6ERet1rF6r4Z9azarPADMAGzrTCrCqjanw9fzXC
建立帳戶
先強調下,我目前所在的EOS版本是1.0.5,EOS幾乎每升級一個小的版本,都會有蠻大的改變。目前1.0.5的坑我是躺平了,後面若是還有升級,升級後執行cleos命令有bug,請第一時間拷貝error日誌到官方issue去找答案。
目前,1.0.5版本去部署bios合約時,有了大的改版,在前面提到的config.ini文件中屏蔽掉private-key,並設置以下屬性:
signature-provider=EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
而後,建立eos的帳戶須要用到密鑰對中的公鑰,而在使用cleos命令建立帳戶以前,須要將此公鑰所對應的私鑰導入到錢包中,才能建立帳戶,不然會報錯。最最重要的,就是隻有部署了合約的帳號,才能去建立帳號,具體命令以下:
luoxiaohui:eos luoxiaohui$ cleos wallet createCreating wallet: default Save password to use in the future to unlock this wallet. Without password imported keys will not be retrievable."PW5Kjfs7MYmbFtN4dFKoNUh1nKMvYV3nvyMcnDpLW3ZbfH7P8VSzn"luoxiaohui:eos luoxiaohui$ cleos wallet import EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV Error 3010003: Invalid private keyPrivate key should be encoded in base58 WIF Error Details: Invalid private key: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV luoxiaohui:eos luoxiaohui$ cleos wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV luoxiaohui:eos luoxiaohui$ cleos set contract eosio build/contracts/eosio.bios -p eosio Reading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...Using already assembled WASM... Publishing contract... executed transaction: ce79d77c59edcafffea30cc94661785c07a89a576e8dc6448745f4812c09548b 3720 bytes 7414 us # eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001621260037f7e7f0060057f7e7e7e7e... # eosio <= eosio::setabi {"account":"eosio","abi":"0e656f73696f3a3a6162692f312e30050c6163636f756e745f6e616d65046e616d650f7065... warning: transaction executed locally, but may not be confirmed by the network yet luoxiaohui:eos luoxiaohui$ cleos create keyPrivate key: 5JLZJyDGjhfZz2k6Yzm3LbRnpBuMrZN3rq2nJYHdRXYSyU4JF9xPublic key: EOS8aG1zYTGTXCLobmwqN5dYQz68st3qhwGiL7ekrYZFT2Jxk5QuV luoxiaohui:eos luoxiaohui$ cleos wallet import 5JLZJyDGjhfZz2k6Yzm3LbRnpBuMrZN3rq2nJYHdRXYSyU4JF9x imported private key for: EOS8aG1zYTGTXCLobmwqN5dYQz68st3qhwGiL7ekrYZFT2Jxk5QuV luoxiaohui:eos luoxiaohui$ cleos create account eosio test1 EOS8aG1zYTGTXCLobmwqN5dYQz68st3qhwGiL7ekrYZFT2Jxk5QuV executed transaction: 0a4175febf8d6001634ee0d525eaee6ee4a2e70730f7af336ff47ad4bb801c82 200 bytes 2740 us # eosio <= eosio::newaccount {"creator":"eosio","name":"test1","owner":{"threshold":1,"keys":[{"key":"EOS8aG1zYTGTXCLobmwqN5dYQz6... warning: transaction executed locally, but may not be confirmed by the network yet luoxiaohui:eos luoxiaohui$ cleos create account eosio test2 EOS8aG1zYTGTXCLobmwqN5dYQz68st3qhwGiL7ekrYZFT2Jxk5QuV executed transaction: 11fa7405e486403ce250b7ecb942aef27b3a2943241e6892abebbfb5a7faef2c 200 bytes 234 us # eosio <= eosio::newaccount {"creator":"eosio","name":"test2","owner":{"threshold":1,"keys":[{"key":"EOS8aG1zYTGTXCLobmwqN5dYQz6... warning: transaction executed locally, but may not be confirmed by the network yet
部署合約
luoxiaohui:eos luoxiaohui$ cleos set contract test1 build/contracts/eosio.token -p test1 Reading WAST/WASM from build/contracts/eosio.token/eosio.token.wasm...Using already assembled WASM... Publishing contract... executed transaction: b5dbab3a5ce41cc59ca3240529e78936155cde8bdea7201a8adecf268c3cc0fc 8104 bytes 5913 us # eosio <= eosio::setcode {"account":"test1","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7e7e7f7f... # eosio <= eosio::setabi {"account":"test1","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d65050874... warning: transaction executed locally, but may not be confirmed by the network yet
建立代幣
切記,只有部署過合約的帳戶,才能建立代幣.
建立一個叫FB的代幣
luoxiaohui:eos luoxiaohui$ cleos push action test1 create '[ "eosio", "100000000.0000 FB" ]' -p test1 executed transaction: 237196f8ffacff045cf8a5e7b8aa0a6b11b8d149f64a9f02465f5da476c1198c 120 bytes 2247 us # test1 <= test1::create {"issuer":"eosio","maximum_supply":"100000000.0000 FB"} warning: transaction executed locally, but may not be confirmed by the network yet luoxiaohui:eos luoxiaohui$ cleos create account eosio test3 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV executed transaction: 8697a79671dd815cb6938e83b10609adccc68bb32931e7ec3043547861751777 200 bytes 212 us # eosio <= eosio::newaccount {"creator":"eosio","name":"test3","owner":{"threshold":1,"keys":[{"key":"EOS6MRyAjQq8ud7hVNYcfnVPJqc... warning: transaction executed locally, but may not be confirmed by the network yet luoxiaohui:eos luoxiaohui$ cleos push action test1 issue '[ "test3","100000000.0000 FB", "memo" ]' -p eosio executed transaction: 00e87d6a189087934ff81e1f33a0c4f004cf1ad1fb73371ab25ae7aa0237be74 128 bytes 2581 us # test1 <= test1::issue {"to":"test3","quantity":"100000000.0000 FB","memo":"memo"} # test1 <= test1::transfer {"from":"eosio","to":"test3","quantity":"100000000.0000 FB","memo":"memo"} # eosio <= test1::transfer {"from":"eosio","to":"test3","quantity":"100000000.0000 FB","memo":"memo"} # test3 <= test1::transfer {"from":"eosio","to":"test3","quantity":"100000000.0000 FB","memo":"memo"} warning: transaction executed locally, but may not be confirmed by the network yet
轉帳
帳戶test3轉帳給test2
1.luoxiaohui:eos luoxiaohui$ cleos push action test1 transfer '[ "test3", "test2", "25.0000 FB", "m" ]' -p test3 2.executed transaction: a5bb2c5bd92d7fee1a24efb4fa0afcc66ac8da39be0036aa55a2cf070049e8ac 128 bytes 595 us 3.# test1 <= test1::transfer {"from":"test3","to":"test2","quantity":"25.0000 FB","memo":"m"} 4.# test3 <= test1::transfer {"from":"test3","to":"test2","quantity":"25.0000 FB","memo":"m"} 5.# test2 <= test1::transfer {"from":"test3","to":"test2","quantity":"25.0000 FB","memo":"m"}
warning: transaction executed locally, but may not be confirmed by the network yet
查詢代幣餘額
這裏的test1,表示建立了FB這個代幣的帳戶,test2表示須要查詢的帳戶,FB表示代幣名稱。
1.luoxiaohui:eos luoxiaohui$ cleos get currency balance test1 test2 FB
2.25.0000 FB
內容來源:羅小輝專欄;
做者:HiBlock&創業股上海技術工坊分享嘉賓 羅小輝
版權聲明:本文內容爲羅小輝原創文章,未經本人許可不得轉載;
Blockathon|48小時極客競賽,區塊鏈馬拉松等你挑戰(成都)
時間:2018年9月14-16日
地點:成都高新區天府五街200號菁蓉國際廣場2號樓A座12樓中韓互聯網+新技術孵化器
招募50名開發者(識別下圖二維碼或點擊「閱讀原文」便可報名)
報名費100元爲參賽押金,參賽者我的緣由不能到場參加活動概不退款;參賽者全程參與活動,待活動結束後現場退還。9月14日18:00開始第一次簽到,9月15日和16日天天早上都要記得簽到哦。
主辦方免費提供2天的食物、飲料,併爲每一位參會者準備一件文化衫