操做系统要求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天的食物、饮料,并为每一位参会者准备一件文化衫