gpt4 book ai didi

nearprotocol - NEAR 区 block 链中抵押的 NEAR 代币总数

转载 作者:行者123 更新时间:2023-12-05 05:30:23 26 4
gpt4 key购买 nike

我需要以编程方式获取 NEAR 区 block 链中抵押的 NEAR 代币总数,就像 NEAR 浏览器中显示的那样 (https://explorer.near.org/nodes/validators)。 Total Staked in NEAR Blockchain

NEAR 提供 JSON RPC API ( https://docs.near.org/api/rpc/setup ) 以通过点击相应的 RPC 端点来获取一些详细信息。例如,我能够使用以下 RPC 结构获取质押池中质押的 NEAR 代币总数。

endpoint URL: https://rpc.mainnet.near.org
Header = {"Content-Type":"application/json"}
Body:
{
"jsonrpc": "2.0",
"id": 1,
"method": "query",
"params": {
"request_type": "call_function",
"finality": "final",
"account_id": "staking pool id",
"method_name": "get_total_staked_balance",
"args_base64": '{"account_id": “staking account id”}’ in base64 encoding
}
}

但没有类似的详细信息可用于获取 NEAR 区 block 链中的 Total NEAR Staked。如果有人可以帮助我,我将不胜感激。谢谢。

浏览了 NEAR 官方 API 文档(https://docs.near.org/api/rpc/setup)、NEAR 浏览器代码库(https://github.com/near/near-explorer)、NEAR 核心合约代码库(https://github.com/near/core-contracts)

最佳答案

您可以使用方法EXPERIMENTAL_validators_ordered:

curl --location --request POST 'https://archival-rpc.mainnet.near.org/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"id": "dontcare",
"method": "EXPERIMENTAL_validators_ordered",
"params": ["JD8o38fkxG34QsBS4ZwT8hieehNUeJMAPCgKGk6xnbuf"]
}'

这将返回一个包含所有验证者及其权益的列表:

{
"jsonrpc": "2.0",
"result": [
{
"account_id": "figment.poolv1.near",
"public_key": "ed25519:7RjyY1bRKDqkshbKZtgpQdwsdxou8j9my8g1hPKZ9ngM",
"stake": "32093438089641651528322513598448",
"validator_stake_struct_version": "V1"
},
{
"account_id": "astro-stakers.poolv1.near",
"public_key": "ed25519:2nPSBCzjqikgwrqUMcuEVReJhmkC91eqJGPGqH9sZc28",
"stake": "25153541134999320232972613031893",
"validator_stake_struct_version": "V1"
},
{
"account_id": "bzam6yjpnfnxsdmjf6pw.poolv1.near",
"public_key": "ed25519:2ZJqaaCAisK4u8E2i611zFfvNmrvevovnU3M7SpGHkLY",
"stake": "23349905747168797648450246349622",
"validator_stake_struct_version": "V1"
},
...
]
}

您还可以使用 near-cli : near validators current

关于nearprotocol - NEAR 区 block 链中抵押的 NEAR 代币总数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74684776/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com