如何在EOS中推送交易?

时间:2018-07-19 13:25:21

标签: request blockchain eos

因此,首先,我发布了一个请求“ get_info”,以检查最后一个不可逆的块:here is a screenshot

然后我通过“ get_block”发布请求:here is a screenshot

检查了有关该区块的信息

然后我尝试通过发布请求here is a screenshot

创建“ push_transaction”

如您所见,存在错误。 那么,如何正确执行此操作? 对不起,我的英语:)

1 个答案:

答案 0 :(得分:0)

在进行交易之前,首先需要对其进行签名。为此,您需要像这样组装事务对象:

{
  "code": "eosio.token",
  "action": "transfer",
  "args": {
    "from": "fromaccount",
    "to": "toaccount",
    "quantity": "1.0000 EOS",
    "memo": "memo"
  }
}

然后使用上述有效负载调用abi_json_to_bin端点,这将返回一个json对象,如下所示:

{
    "binargs": "0000000000ea305500000000487a2b9d102700000000000004454f53000000001163726561746564206279206e6f70726f6d"
}

这样您就可以构造push_transaction对象,它看起来像这样:

{
    "compression": "none",
    "transaction": {
        "expiration": "2018-08-01T06:11:23",
        "ref_block_num": 10855,
        "ref_block_prefix": 473148127,
        "max_net_usage_words": 0,
        "max_cpu_usage_ms": 0,
        "delay_sec": 0,
        "context_free_actions": [],
        "actions": [{
            "account": "eosio.token",
            "name": "transfer",
            "authorization": [{
                "actor": "fromaccount",
                "permission": "active"
            }],
            "data": "0000000000ea305500000000487a2b9d102700000000000004454f53000000001163726561746564206279206e6f70726f6d"
        }],
        "transaction_extensions": [],
        "signatures": null,
        "context_free_data": []
    },
    "signatures": ["SIG_K1_JwLVG5pRdhvLfJGWkDEBPa7wdLbNeqeRFdvFrKDEryahSwCRpPb75m4auZh8frq6cXsm3dHit8GMbmuuBWxEjH"]
}

您可以详细了解here.