您正在查看: EOS-新手问答 分类下的文章

EOS离线下载块历史数据地址

The archive consists of state, blocks, and state-history archives, plus a copy of a portable snapshot made by EOS Sweden on the day prior to the snapshop. This should help if your environment is different. The archives are made with eosio_1.8.1-1-ubuntu-18.04_amd64.deb Debian package.

https://snapshots.eosamsterdam.net/eos/

编译合约没有生成abi文件

如果-o文件名与合同名称不同,则ABI生成失败
比如

struct [[eosio::table, eosio::contract("bcs.ibc")]] extract_token

及此合约文件的名字必须为bcs.ibc.hpp/cpp

https://github.com/EOSIO/eosio.cdt/issues/588

unable to find plugin: eosio::wallet_api_plugin

wallet_api_plugin is no longer supported as part of nodeos. Use keosd instead.
https://developers.eos.io/keosd/docs

参考

https://github.com/EOSIO/eos/issues/7833

eos 1.8 启动 mongo_db_plugin 插件 ENABLE_MONGO

./eosio_build.sh -m // 添加参数支持mongo

支持的参数

function usage() {
   printf "Usage: $0 OPTION...
  -P          Build with pinned clang and libcxx
  -o TYPE     Build <Debug|Release|RelWithDebInfo|MinSizeRel> (default: Release)
  -s NAME     Core Symbol Name <1-7 characters> (default: SYS)
  -b DIR      Use pre-built boost in DIR
  -i DIR      Directory to use for installing dependencies & EOSIO (default: $HOME)
  -y          Noninteractive mode (answers yes to every prompt)
  -c          Enable Code Coverage
  -d          Generate Doxygen
  -m          Build MongoDB dependencies
   \\n" "$0" 1>&2
   exit 1
}

https://github.com/EOSIO/eos/blob/51f6a070200c69eb4d82e21aa2f750d43e8491d1/scripts/eosio_build.sh#L35

EOS 合约中使用eosio::checksum256作为查询索引,查询不到问题

演示合约代码

合约中Table表结构

struct [[eosio::table, eosio::contract("bcskillsurou")]] extract_token {
    uint64_t id;
    eosio::checksum256 transaction_id;                   // 交易单id

    auto primary_key() const { return id; }
    eosio::checksum256 second_key() const { return transaction_id; } // 已hash作为二级索引

    EOSLIB_SERIALIZE(extract_token, (id)(transaction_id))
};
typedef eosio::multi_index<"xxxxtb"_n, extract_token, eosio::indexed_by<"bysubkey"_n, eosio::const_mem_fun<extract_token, eosio::checksum256, &extract_token::second_key>>> xxxx_table;

合约中查询代码

ACTION findtrxid(eosio::checksum256 trx_id){
    ....
    xxx_table xxxtb(_self, _self.value);
    auto sub_extract_index = xxxtb.get_index<"bysubkey"_n>();
    auto itr_xxx = sub_xxx_index.find(trx_id);

    eosio_assert(itr_extract != sub_xxx_index.end(), "Record not found");
    ....
}

使用Cleos 复现问题

cleos push action 合约账户 findtrxid '{"trx_id":0bb0e5901c3b627484c6a1a473ba8e3e3a3ffb4b96f849e08afb2d1e2671b88d}' -p 合约账户

返回

Error 3050003: eosio_assert_message assertion failure
Error Details:
assertion failure with message: {"code":102,"msg":"Record not found 563"}

经过测试发现是因为eosio::checksum256 trx_id传参最终打包不是已字符串打包导致,交易id上传后被识别成了

1116029241376226714100000000000000000000000000000000000000000000

解决方案

修改eosio::checksum256 trx_id为字符串即可

cleos push action 合约账户 findtrxid '{"trx_id":"0bb0e5901c3b627484c6a1a473ba8e3e3a3ffb4b96f849e08afb2d1e2671b88d"}' -p 合约账户

对于其他语言封装,处理eosio::checksum256 trx_id统一字符串打包即可

备注

特殊hash复现

参考

https://eosio.github.io/eosio.cdt/1.6.0/group__multiindex.html