在 jsonrpc near protocol 中使用 call_function 获取实际数字是什么?
What to get the actual number using call_function in jsonrpc near protocol?
以下查询在 near 协议中使用 call_function in jsonrpc
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'?
"result": [
34,
49,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
34
]
是一个字节数组。 NEAR SDKs默认使用JSON编码输入和输出,但不限于此,所以如果你转换它,你会得到"1000000000000000"
。这是用于转换它的 Python 片段:
>>> 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"'
以下查询在 near 协议中使用 call_function in jsonrpc
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'?
"result": [
34,
49,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
48,
34
]
是一个字节数组。 NEAR SDKs默认使用JSON编码输入和输出,但不限于此,所以如果你转换它,你会得到"1000000000000000"
。这是用于转换它的 Python 片段:
>>> 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"'