不得不说,东西是要学的,哪怕是工具,总得搞搞才可以应用。针对区块链1.0,2.0来说,还是3.0时代比较适合我,关于EOS和比特币、以太坊三点的基本问题可以了解下:EOS和比特币、以太坊区别
目录
一、劝退条件
无论使用什么方式的编译,都需要系统具备最低这样的条件,否则是无法编译的
7GB RAM free required
20GB Disk free required
理论上来说,如果是阿里/腾讯云新人,买个3年这个配置还是很划算的,如果愿意,否则就走虚拟机的路子吧,如果电脑开虚拟机也不能满足的话,劝退+1.
二、相关资源
1、相关文档:
官方文档:https://developers.eos.io/eosio-home/docs
比较好的中文文档(C语言的,我就发出来看看)https://eos.readthedocs.io/zh_CN/latest/
EOS 安装调试指南(中文) https://segmentfault.com/a/1190000017385885
EOS 官方调试指南(英文)https://developers.eos.io/eosio-home/docs/setting-up-your-environment
2、压缩包传送门:
EOS-IO: https://github.com/EOSIO/eos/releases/
EOS-IO-CDT https://github.com/EOSIO/eosio.cdt/releases/
过程中需要的包,如果自己网络不行,可以进百度云
链接:https://pan.baidu.com/s/1FL-g_ilqd-5bfJ4L8jV4Sg
提取码:2zbf
3、部分名词简介:
nodeos(node + eos = nodeos)
— 核心EOSIO node守护进程,可以配置插件来运行node,示例用途是块生产、专用API端点和本地开发。
cleos(cli + eos = cleos)
— 命令行接口与区块链交互并管理钱包。
keosd(key + eos = keosd)
— 在钱包中安全存储EOSIO密钥的组件。
eosio-cpp
— 作为eosio.cdt的一部分,它将C++代码编译为WASM并可以生成ABI。
配个官方图示意下。
4、编译安装的方式其实有4种
总体而言我们有四种方式来进行EOS安装
但是鄙人穷狗只配玩虚拟机,走第一种,有兴趣的人可以搞搞docker,后面我看看找些docker的资源
三、开始安装
为了便携于操作与符合本人实际,步骤基于VM搭建的虚拟机来进行操作,选用了下方编译方式中CentOS RPM软件包安装
,借用腾讯云的加速下载是真的很舒服的。下载的过程其实如果开着科学上网的话是不会需要等待太久的。
1、EOS-IO 安装
可以直接进入上方 EOS-IO 连接进入网站选择需要的版本
eosio-1.8.6-1.el7.x86_64.rpm 是我使用的版本
wget https://github.com/EOSIO/eos/releases/download/v1.8.6/eosio-1.8.6-1.el7.x86_64.rpm
sudo yum install ./eosio-1.8.6-1.el7.x86_64.rpm
开发目录:突然想起这个东西也是有点重要的,在后面管理的时候,刚开始看官网还是有点蒙蔽,方便管理
mkdir contracts
cd contracts
2、启动节点并设置
1、启动keosd (主要是钱包操作)
keosd &
然后会出现
info 2019-11-12T06:54:24.789 thread-0 wallet_plugin.cpp:42 plugin_initialize ] initializing wallet plugin
info 2019-11-12T06:54:24.795 thread-0 http_plugin.cpp:554 add_handler ] add api url: /v1/keosd/stop
info 2019-11-12T06:54:24.796 thread-0 wallet_api_plugin.cpp:73 plugin_startup ] starting wallet_api_plugin
info 2019-11-12T06:54:24.796 thread-0 http_plugin.cpp:554 add_handler ] add api url: /v1/wallet/create
info 2019-11-12T06:54:24.796 thread-0 http_plugin.cpp:554 add_handler ] add api url: /v1/wallet/create_key
info 2019-11-12T06:54:24.796 thread-0 http_plugin.cpp:554 add_handler ] add api url: /v1/wallet/get_public_keys
上述rpc接口是可以直接调用的,不过这里是后话了,按回车进入下一步
3、启动nodeos(主要是加载插件)
nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
-d CONTRACTS_DIR/eosio/data \
--config-dir CONTRACTS_DIR/eosio/config \
--filter-on="*" \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors >> nodeos.log 2>&1 &
参数说明:
1、在开发目录下的eosio目录中为区块链数据和配置使用工作目录,这里我们分别使用eosio/data和eosio/config。
这里就用到了上方安装提及的开发目录了
2、运行Nodeos,此命令加载所有基本插件、设置服务器地址、启用CORS并添加一些合约调试和日志记录。
3、启用CORS没有限制(*) --access-control-allow-origin。,开发时尽量还是自己配置需要的参数
4、钱包这些东西是最好不要除本地之外访问,因故默认是绑定本地的
相关插件数据说明: https://www.jianshu.com/p/11c210b6f8f1
运行参数说明: https://www.jianshu.com/p/7ce63119bfc2
停止的方式是:
pkill nodeos
4、校验是否安装完毕
1、检查块是否在生成
tail -f nodeos.log # 属于第三步的日志出去
但凡日志输入不为0,基本都是稳了,但是,还是眼见为实,看到类似下方的创建快,则创建成功
1929001ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366974ce4e2a... #13929 @ 2018-05-23T16:32:09.000 signed by eosio [trxs: 0, lib: 13928, confirmed: 0]
1929502ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366aea085023... #13930 @ 2018-05-23T16:32:09.500 signed by eosio [trxs: 0, lib: 13929, confirmed: 0]
1930002ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366b7f074fdd... #13931 @ 2018-05-23T16:32:10.000 signed by eosio [trxs: 0, lib: 13930, confirmed: 0]
1930501ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366cd8222adb... #13932 @ 2018-05-23T16:32:10.500 signed by eosio [trxs: 0, lib: 13931, confirmed: 0]
1931002ms thread-0 producer_plugin.cpp:585 block_production_loo ] Produced block 0000366d5c1ec38d... #13933 @ 2018-05-23T16:32:11.000 signed by eosio [trxs: 0, lib: 13932, confirmed: 0]
2、使用cleos检查钱包了
cleos wallet list
但凡是第一次安装这个的,我还没有见过不是以下的这个的- -
3、校验节点的端点是否有问题
你可以在控制台上 curl http://localhost:8888/v1/node/get_supported_apis
尝试
{
"apis": [
"/v1/chain/abi_bin_to_json",
"/v1/chain/abi_json_to_bin",
"/v1/chain/get_abi",
"/v1/chain/get_account",
"/v1/chain/get_activated_protocol_features",
"/v1/chain/get_block",
"/v1/chain/get_block_header_state",
"/v1/chain/get_code",
"/v1/chain/get_code_hash",
"/v1/chain/get_currency_balance",
"/v1/chain/get_currency_stats",
"/v1/chain/get_info",
"/v1/chain/get_producer_schedule",
"/v1/chain/get_producers",
"/v1/chain/get_raw_abi",
"/v1/chain/get_raw_code_and_abi",
"/v1/chain/get_required_keys",
"/v1/chain/get_scheduled_transactions",
"/v1/chain/get_table_by_scope",
"/v1/chain/get_table_rows",
"/v1/chain/get_transaction_id",
"/v1/chain/push_block",
"/v1/chain/push_transaction",
"/v1/chain/push_transactions",
"/v1/chain/send_transaction",
"/v1/history/get_actions",
"/v1/history/get_controlled_accounts",
"/v1/history/get_key_accounts",
"/v1/history/get_transaction"
]
}
如果上面这步也不行就不需要多说了,然后随机选一条测试。
curl http://localhost:8888/v1/chain/get_info
(省略一堆不想黏贴的东西)然后内容biubiubiu出来了,完成。
EOS-IO-CDT
EOSIO合约开发工具包,简称CDT,是与合约编译相关的工具集合,后续教程主要使用CDT来编译合约和生成ABI。
(The EOSIO Contract Development Toolkit, CDT for short, is a collection of tools related to contract compilation. Subsequent tutorials use the CDT primarily for compiling contracts and generating ABIs.)[原文给你]
一、安装
可以参考顶部 EOS-IO-CDT 内链接选择自己欢喜的版本,我选了官方当前同款
wget https://github.com/EOSIO/eosio.cdt/releases/download/v1.6.1/eosio.cdt-1.6.1-1.centos-x86_64.rpm
sudo yum install ./eosio.cdt-1.6.1-1.centos-x86_64.rpm
1、跟着官方进入自己预先设置的开发目录
虽然官方强调克隆的位置不重要,但是给出来,总不会平白无故,跟着走,进入安装 EOS-IO 时设置的开发目录
cd contracts
2、你选择的 EOS-IO-CDT 是什么版本就克隆什么版本的仓库
git clone --recursive https://github.com/eosio/eosio.cdt --branch v1.6.1 --single-branch
cd eosio.cdt
很好理解,可以很肆意的,直接将 -branch 后的版本更替就阔以了,这个时间,我是等了将近12分钟,官网说30分钟左右,根据网络而定吧
2.1 构建
./build.sh
疯狂等待中。。。。
2.2 安装
sudo ./install.sh