您正在查看: EOS 分类下的文章

EOS v1.7.2 安装完后,无法找到 nodeos 等程序

又又改目录位置了。。
自己临时手动将新目录添加到环境变量吧
打开环境变量的文件

vi ~/.bashrc

将新的EOS编译安装后的路径添加到文件尾部

#set eosio path
export EOSIO_PATH=/home/surou/opt/eosio/bin
export PATH=$EOSIO_PATH:$PATH

刷新环境变量,使更改生效

source ~/.bashrc

查看版本

surou@eos_test_net:~$ nodeos -v
v1.7.2-dirty

Installing Boost library... 下载不下来

由于各种原因和姿势boost下载不下来,手动传一个包,改下脚本地址,从指定的地方下载把。。
此时上传的是:boost_1_67_0.tar.bz2
当前文件上传的地址:http://dl.aceui.cn/uploads/tools/boost_$BOOST_VERSION.tar.bz2
编辑脚本:vi eosio_build_ubuntu.sh

BOOSTVERSION=$( grep "#define BOOST_VERSION" "$HOME/opt/boost/include/boost/version.hpp" 2>/dev/null | tail -1 | tr -s ' ' | cut -d\  -f3 )
if [ "${BOOSTVERSION}" != "${BOOST_VERSION_MAJOR}0${BOOST_VERSION_MINOR}0${BOOST_VERSION_PATCH}" ]; then
        printf "Installing Boost library...\\n"
        curl -LO http://dl.aceui.cn/uploads/tools/boost_$BOOST_VERSION.tar.bz2 \
        && tar -xjf boost_$BOOST_VERSION.tar.bz2 \

build fails - Unable to find the requested Boost libraries.

cd  ~/opt
rm -rf boost/
./eos_source_dir/eosio_build.sh

One workaround is to cd into ~/opt and remove the boost library there.
Re-compile using ./eosio_build.sh and it should work.

参考:
https://github.com/EOSIO/eos/issues/3464

EOS合约内解析json

示例代码

//demo.hpp
#pragma once

#include <eosiolib/eosio.hpp>
#include <eosiolib/print.hpp>
#include "json.hpp"
#include <string>

using json = nlohmann::json;
using eosio::contract;
using eosio::multi_index;
using eosio::print;

class[[eosio::contract]] demo : public contract
{
  public:
    using contract::contract;

    [[eosio::action]] void demoaction();
};
//demo.cpp
#include "demo.hpp"
using json = nlohmann::json;

// ACTION
void demo::demoaction()
{
    json demoInfo = R"(
    {
        "demoInfo": {
            "hello": "world"
        }
    }
    )"_json;
    std::string demoInfoString = demoInfo.dump();
    json demoInfoJson = json::parse(demoInfoString);
    print("It worked\n");
}

EOSIO_DISPATCH(demo, (demoaction))

json.hpp从https://github.com/nlohmann/json/releases 下载并将其放在同一目录中demo.hpp。

参考

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

Error compiling LLVM and clang with EXPERIMENTAL WASM support

解决方案:

cd /tmp/llvm-compiler/llvm/build
make -j4 install
rm -rf /tmp/llvm-compiler

最终一般会安装在$HOME/opt/wasm
参考地址:https://github.com/EOSIO/eos/issues/1694