跳至主要內容

EOS

naijoug大约 5 分钟

reference

Net

网路区块浏览器链 ID
EOS-Mainnetopen in new windowMonitoropen in new windowaca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
EOS-Jungle-Testnetopen in new windowMonitoropen in new window
EOS-Party-Testnetopen in new windowMonitoropen in new window
CryptoKylin-Testnetopen in new windowMonitoropen in new window 5fff1dae8dc8e2fc4d5b23b2c7665c97f9e9d8edf2b6485a86ba311c25639191
  • Kylin Faucet
    • 免费账户 : http://faucet.cryptokylin.io/create_account?new_account_name
    • 获得免费 Token : http://faucet.cryptokylin.io/get_token?your_account_name

Block

ProducerScopeTimeExplain
eosio0 ~ 121502018.06.08-08:08:08
genesisblock12151 ~ 10000002018.06.09-14:14:29主网启动
21 个超级节点1000000 ~投票超过 15%

Website

网址说明
eostracker.ioopen in new windowEOS 区块浏览器工具
eosmonitoropen in new windowEOSTEA 提供的 EOS 区块浏览器工具
eosflareopen in new windoweosflare.io 节点提供的区块浏览器工具
EOS Metaopen in new windowEOSTEA 提供
eosparkopen in new windowEOSpark 提供
eos.hostopen in new window前 30 区块生产者排行榜
EOS Seed Listopen in new windowEOS 种子节点列表
EOS Favoropen in new windowEOS 互助社区
IMEOS.ONEopen in new windowEOS 信息整理网站
bp.json 验证器open in new window检查出块节点小工具

Develop

ABI (Application Binary Interface)

一个 JSON 格式的描述文件,描述了二进制如何转为为用户的 Action

{
    "____comment": "comment...",
    "types": [],
    "structs": [],
    "actions": [],
    "tables": [],
    "ricardian_clauses": [],
    "abi_extensions": []
}
  • ____commit : 注释
  • types : 使用的的类型
  • structs : 合约及引用文件中定义的结构体、类、函数等
  • actions : EOSIO_ABI() 中的函数就是一个 Action
  • tables : 数据库中的表,需要指定主键(primary_key)
  • ricardian_clauses :
  • abi_extensions :

Install

EOS 主网安装脚本

  • Local
# 1. 下载 eos 源码,以及依赖
$ git clone https://github.com/EOSIO/eos --recursive 
# 2. 进入 eos 代码目录,运行编译脚本
$ cd eos
$ ./eosio_build.sh
#   build 指定版本
$ git checkout v1.1.1  
$ git submodule update --init --recursive # 下载依赖
$ ./eosio_build.sh -s EOS
# 3. 将二进制程序安装到 /usr/local/bin
$ cd build
$ sudo make install
  • Mainnet
# 1. 下载 Mainnet eos 源码和依赖
$ git clone https://github.com/EOS-Mainnet/eos --recursive
# 2. 切换到主网分支 mainnet-x.x.x
$ git tag # 查看分支
$ git checkout mainnet-1.1.1 # 切换到主网分支
# 3. 编译
$ cd eos & ./eosio_build.sh
# 4. 安装
$ cd build & sudo make install
# 5. 配置 config.ini
#   chain-state-db-size-mb : 10240 # db 大小
#   http-server-address : 0.0.0.0:8888 # http 节点服务, 0.0.0.0 使得外网IP,127.0.0.1 仅此ip可用 
#   p2p-peer-address : xxx # p2p 节点,用于同步节点
# 6. 初次启动节点,带有 --genesis-json
#       mainnet-genesis.json : mainnet 分支下有改文件
$ nodeos --genesis-json mainnet-genesis.json --config-dir path/to/config --data-dir path/to/data
# 7. 关闭后,再次启动节点
$ nodeos --config-dir path/to/config --data-dir path/to/data
  • Docker
$ docker pull eosio/eos-dev

$ docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev  /bin/bash -c "nodeos -e -p eosio --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console --http-validate-host=false"

$ docker logs --tail 10 eosio

$ alias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://localhost:8888'

$ docker stop eosio

nodeos (node eos)

# 进入 nodeos 目录
$ cd build/programs/nodeos
# 1. 参数启动 nodeos
#   -e : enable-stale-production = true
#   -p eosio : producer-name = eosio
#   --plugin : 启动插件
#   --config-dir : 自定义配置文件 config.ini 目录
#   --data-dir : 自定义数据存放目录
#   --replay-blockchain : 
$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
# 2. 默认配置文件路径启动
# config : macOS: ~/Library/Application Support/eosio/nodeos/config
#          Linux: ~/.local/share/eosio/nodeos/config
# data : macOS: ~/Library/Application Support/eosio/nodeos/data
#        Linux: ~/.local/share/eosio/nodeos/data
$ nodeos 
# 3. 自定义配置文件路径启动
$ nodeos --config-dir path/to/config --data-dir path/to/data
###### nodeos 其它命令 ######
$ nodeos --print-genesis-json # 从 blocks.log 读取创世区块信息打印到 console
$ nodeos --extract-genesis-json genesis.json # 从 block.log 读取创世区块信息写入到 genesis.json 文件
$ nodeos --delete-all-block # 删除旧的区块数据重新启动

keosd (key eos)

# 进入 keosd 目录
$ cd build/programs/keosd
# 启动 keosd
#   默认目录启动 : ~/eosio-wallet
$ keosd --http-server-address 127.0.0.1:8900
#   自定义目录启动
$ keosd --config-dir ~/path/to/config --data-dir ~/path/to/data

eosiocpp

# 新建名为 hello 的合约
$ eosiocpp -n hello 
# 编译 wast
$ eosiocpp -o hello.wast hello.cpp
# 编译 abi
$ eosiocpp -g hello.abi hello.cpp

Main Plugin

  • main (主函数, 配置 nodeos 版本 和 eosio root 目录)
  • chain_plugin (区块链管理插件)
  • wallet_plugin (钱包管理插件)
  • http_plugin (Web 服务插件)
  • net_plugin (网络插件)
  • producer_plugin (区块生成者插件)

API Plugin

  • wallet_api_plugin (钱包 API 插件)

    • /v1/wallet/create
    • /v1/wallet/create_key
    • /v1/wallet/get_public_keys
    • /v1/wallet/import_key
    • /v1/wallet/list_keys
    • /v1/wallet/list_wallets
    • /v1/wallet/lock
    • /v1/wallet/lock_all
    • /v1/wallet/open
    • /v1/wallet/set_timeout
    • /v1/wallet/sign_digest
    • /v1/wallet/sign_transaction
    • /v1/wallet/unlock
  • chain_api_plugin (区块链 API 插件)

    • /v1/chain/abi_bin_to_json
    • /v1/chain/abi_json_to_bin
    • /v1/chain/get_abi
    • /v1/chain/get_account
    • /v1/chain/get_block
    • /v1/chain/get_block_header_state
    • /v1/chain/get_code
    • /v1/chain/get_currency_balance
    • /v1/chain/get_currency_stats
    • /v1/chain/get_info
    • /v1/chain/get_producers
    • /v1/chain/get_required_keys
    • /v1/chain/get_table_rows
    • /v1/chain/push_block
    • /v1/chain/push_transaction
    • /v1/chain/push_transactions
  • history_api_plugin (历史 API 插件)

    • /v1/history/get_actions
    • /v1/history/get_controlled_accounts
    • /v1/history/get_key_accounts
    • /v1/history/get_transaction

Error

Build Error

  • Could not find a package configuration file provided by "LLVM" : 43open in new window

    Solution : export LLVM_DIR=/usr/local/Cellar/llvm/4.0.0_1/lib/cmake

  • Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR) : 2028open in new window

    Solution : brew unlink gettext && brew link --force gettext

Startup Error

  • db.revision() >= head->block_num: fork database is inconsistent with shared memory : 3140open in new window

    Solution : nodeos --replay-blockchain

  • Genesis state can only be set on a fresh blockchain : 3755open in new window

    Solution : 仅在第一次启动时加上 --genesis-json 参数,之后启动不需要加

  • database dirty flag set (likely due to unclean shutdown): replay required : 4742open in new window

    Solution : 是因为没有正常关掉服务引起的 mongodb 数据库错误。删除旧数据文件,使用参数 nodeos --replay-blockchain --hard-replay-blockchain 重新启动

  • std::exception::what: unrecognised option 'wallet-dir' : 5742open in new window

    Solution : 删除 config.ini 中的无法识别的配置

Command Error

  • Error 3080004: transaction exceeded the current CPU usage limit imposed on the transaction

    Solution : CPU 资源不足,需要抵押 EOS 换取 CPU 资源

  • Error 3081001: transaction reached the deadline set due to leeway on account CPU limits

    Solution : CPU 资源不足,需要抵押 EOS 换取 CPU 资源

  • Error 3040003: transaction should have at least one required authority

    Solution : 需要授权