BCSkill (Block chain skill )
区块链中文技术社区

只讨论区块链底层技术
遵守一切相关法律政策!

faucet.cryptokylin reach 24 hours max token amount

麒麟网获取测试代币时
http://faucet.cryptokylin.io/get_token?bcskillsurou
返回

{
    msg: "reach 24 hours max token amount"
}

可尝试使用直接ip 访问获取
http://13.230.87.138/get_token?bcskillsurou

get_actions error in version v1.3.+

目前了解到的方案是,nodeos 重新启动,添加以下参数,重建数据,也许之后版本会有新的修复方案

--hard-replay-blockchain

github

[eosiocpp] account_name 与 std:string 互相转换

  • account_name to std:string
auto username = name{from};
std::string from_name = username.to_string();
  • std::string to account_name
account_name from_name = string_to_name(username);

How to pass struct to action

I have a simple struct with one member and want to pass this to an action.

struct field {
    bool is_private;
  };

  // @abi action
  // Create a new profile
  void create(const account_name& account, const field& first_name);

The .abi looks like this:

  "structs": [{
      "name": "field",
      "base": "",
      "fields": [{
          "name": "is_private",
          "type": "bool"
        }
      ]
    },{
      "name": "create",
      "base": "",
      "fields": [{
          "name": "account",
          "type": "name"
        },{
          "name": "first_name",
          "type": "field"
        }
      ]
    }
...

I tried a lot of different variations along the lines of cleos push action "contract" "create" '[acc_name, {"is_private": "true"}]' -p acc_name@active. But none of them seem to work. Are structs supported and if yes how do you pass the argument?

Thanks a lot!


Found the solution myself. You have to recreate the .abi structure in json:
cleos push action contract create '{"account":"acc_name","first_name":{"is_private":true"}}' -p acc_name@active

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

Failed with error: Out of Range (8) read datastream of length 9 over by 1

麒麟测试网部署测试合约时出现一下错误

suroudeMacBook-Pro:contracts surou$ cleos -u http://api.kylin.eosbeijing.one:8880  get table cryptokylinq cryptokylinq results
2018-10-10T14:09:41.215 thread-0   main.cpp:3143                 main                 ] Failed with error: Out of Range (8)
read datastream of length 9 over by 1

开始演示步骤

开始部署合约中表的结构为

//@abi table results i64
    struct approval_info{
        account_name name;
        uint8_t iresult;
        uint64_t primary_key()const { return name; }
        EOSLIB_SERIALIZE(approval_info, (name)(iresult))
    };

    typedef eosio::multi_index<N(results),approval_info> result_table;

然后直接修改了 iresultstd::string

//@abi table results i64
    struct approval_info{
        account_name name;
        std::string iresult;
        uint64_t primary_key()const { return name; }
        EOSLIB_SERIALIZE(approval_info, (name)(iresult))
    };

    typedef eosio::multi_index<N(results),approval_info> result_table;

由于前面合约已部署,就像数据库中表字段的类型已经建好了,下次再部署时,导致表错乱,所以改个表名或者重新部署个账号测试把。等后面发现好的办法再跟帖