【问题标题】:What to get the actual number using call_function in jsonrpc near protocol?在 jsonrpc near 协议中使用 call_function 获取实际数字是什么?
【发布时间】:2020-11-04 03:50:03
【问题描述】:

以下查询在近协议中使用 jsonrpc 中的 call_function

http post https://rpc.testnet.near.org jsonrpc=2.0 id=test method=query   params:='{
    "request_type": "call_function",
    "finality": "final",
    "account_id": "dev-1591261827342",
    "method_name": "get_total_supply",
    "args_base64": "e30="
  }'

给出以下结果:

{
    "id": "test",
    "jsonrpc": "2.0",
    "result": {
        "block_hash": "FrKNvsEbqPsdT1ijLkUBNoX3SnUQbTCXjoPj7yC2WW5i",
        "block_height": 9616038,
        "logs": [],
        "result": [
            34,
            49,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            34
        ]
    }
}

如何将结果转换为实际数字'1000000000000000'?

【问题讨论】:

    标签: nearprotocol


    【解决方案1】:
    "result": [
                34,
                49,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                48,
                34
            ]
    

    是一个字节数组。 NEAR SDK 默认使用 JSON 编码进行输入和输出,但不限于此,所以如果你转换它,你会得到"1000000000000000"。这是用于转换它的 Python sn-p:

    >>> result = [34, 49, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 34]
    >>> ''.join(chr(x) for x in result)
    '"1000000000000000"'
    

    【讨论】:

      猜你喜欢
      • 2021-08-13
      • 2020-09-27
      • 2021-03-22
      • 2022-09-29
      • 2019-02-09
      • 2021-01-12
      • 1970-01-01
      • 2019-12-05
      • 1970-01-01
      相关资源
      最近更新 更多