From 6e9902df55ce3796068c73577272871742a967cd Mon Sep 17 00:00:00 2001 From: Volodymyr Bilyk Date: Thu, 13 Feb 2025 17:42:02 +0200 Subject: [PATCH] Lantstool - RPC Examples (#2466) * Rework RPC Access Keys, add new templates for all methods * Rework RPC - block-chunk * Rework RPC - contracts * Rework RPC - transactions * Rework RPC - gas, maintenance-windows, network, protocol * Update RPC - Access Keys examples * Update RPC - Contracts examples * Update RPC - Block-Chunk examples * Update RPC - Transactions, MW examples * Update RPC - Gas examples * Update RPC - Network, Protocol examples --- docs/5.api/rpc/access-keys.md | 957 +--------- .../error-schema-table.mdx | 84 + .../view-access-key-changes-all/index.mdx | 52 + .../request-bash.mdx | 11 + .../request-js.mdx | 6 + .../request-json.mdx | 12 + .../response-json.mdx | 53 + .../error-schema-table.mdx | 84 + .../view-access-key-changes-single/index.mdx | 52 + .../request-bash.mdx | 16 + .../request-js.mdx | 11 + .../request-json.mdx | 17 + .../response-json.mdx | 38 + .../error-schema-table.mdx | 131 ++ .../view-access-key-list/index.mdx | 51 + .../view-access-key-list/request-bash.mdx | 11 + .../view-access-key-list/request-js.mdx | 7 + .../view-access-key-list/request-json.mdx | 12 + .../view-access-key-list/response-json.mdx | 38 + .../view-access-key/error-schema-table.mdx | 149 ++ .../rpc/access-keys/view-access-key/index.mdx | 55 + .../view-access-key/request-bash.mdx | 12 + .../view-access-key/request-js.mdx | 8 + .../view-access-key/request-json.mdx | 13 + .../view-access-key/response-json.mdx | 24 + docs/5.api/rpc/block-chunk.md | 822 +------- .../block-details/block-hash/request-bash.mdx | 9 + .../block-details/block-hash/request-js.mdx | 5 + .../block-details/block-hash/request-json.mdx | 10 + .../block-height/request-bash.mdx | 9 + .../block-details/block-height/request-js.mdx | 5 + .../block-height/request-json.mdx | 10 + .../block-details/error-schema-table.mdx | 84 + .../block-details/finality/request-bash.mdx | 9 + .../block-details/finality/request-js.mdx | 5 + .../block-details/finality/request-json.mdx | 10 + .../rpc/block-chunk/block-details/index.mdx | 91 + .../block-details/response-json.mdx | 237 +++ .../block-hash/request-bash.mdx | 9 + .../block-hash/request-js.mdx | 5 + .../block-hash/request-json.mdx | 10 + .../block-height/request-bash.mdx | 9 + .../block-height/request-js.mdx | 5 + .../block-height/request-json.mdx | 10 + .../changes-in-block/error-schema-table.mdx | 84 + .../finality/request-bash.mdx | 9 + .../changes-in-block/finality/request-js.mdx | 5 + .../finality/request-json.mdx | 10 + .../block-chunk/changes-in-block/index.mdx | 92 + .../changes-in-block/response-json.mdx | 47 + .../block-id-shard-id/request-bash.mdx | 10 + .../block-id-shard-id/request-js.mdx | 3 + .../block-id-shard-id/request-json.mdx | 11 + .../chunk-details/chunk-id/request-bash.mdx | 9 + .../chunk-details/chunk-id/request-js.mdx | 5 + .../chunk-details/chunk-id/request-json.mdx | 10 + .../chunk-details/error-schema-table.mdx | 112 ++ .../rpc/block-chunk/chunk-details/index.mdx | 69 + .../chunk-details/response-json.mdx | 58 + docs/5.api/rpc/contracts.md | 1690 +---------------- .../complex-call/request-bash.mdx | 13 + .../complex-call/request-js.mdx | 9 + .../complex-call/request-json.mdx | 14 + .../complex-call/response-json.mdx | 15 + .../error-schema-table.mdx | 164 ++ .../call-a-contract-function/index.mdx | 97 + .../simple-call/request-bash.mdx | 14 + .../simple-call/request-js.mdx | 9 + .../simple-call/request-json.mdx | 14 + .../simple-call/response-json.mdx | 15 + .../error-schema-table.mdx | 84 + .../contracts/view-account-changes/index.mdx | 51 + .../view-account-changes/request-bash.mdx | 11 + .../view-account-changes/request-js.mdx | 6 + .../view-account-changes/request-json.mdx | 12 + .../view-account-changes/response-json.mdx | 41 + .../view-account/error-schema-table.mdx | 131 ++ .../rpc/contracts/view-account/index.mdx | 50 + .../contracts/view-account/request-bash.mdx | 11 + .../rpc/contracts/view-account/request-js.mdx | 7 + .../contracts/view-account/request-json.mdx | 12 + .../contracts/view-account/response-json.mdx | 15 + .../error-schema-table.mdx | 84 + .../view-contract-code-changes/index.mdx | 51 + .../request-bash.mdx | 11 + .../view-contract-code-changes/request-js.mdx | 6 + .../request-json.mdx | 12 + .../response-json.mdx | 22 + .../view-contract-code/error-schema-table.mdx | 146 ++ .../contracts/view-contract-code/index.mdx | 51 + .../view-contract-code/request-bash.mdx | 11 + .../view-contract-code/request-js.mdx | 7 + .../view-contract-code/request-json.mdx | 12 + .../view-contract-code/response-json.mdx | 12 + .../error-schema-table.mdx | 84 + .../view-contract-state-changes/index.mdx | 53 + .../request-bash.mdx | 12 + .../request-js.mdx | 6 + .../request-json.mdx | 13 + .../response-json.mdx | 35 + .../error-schema-table.mdx | 166 ++ .../contracts/view-contract-state/index.mdx | 68 + .../view-contract-state/request-bash.mdx | 12 + .../view-contract-state/request-js.mdx | 8 + .../view-contract-state/request-json.mdx | 13 + .../view-contract-state/response-json.mdx | 20 + docs/5.api/rpc/gas.md | 208 +- .../gas/gas-price/block-hash/request-bash.mdx | 7 + .../gas/gas-price/block-hash/request-js.mdx | 5 + .../gas/gas-price/block-hash/request-json.mdx | 8 + .../gas-price/block-height/request-bash.mdx | 7 + .../gas/gas-price/block-height/request-js.mdx | 3 + .../gas-price/block-height/request-json.mdx | 8 + .../rpc/gas/gas-price/error-schema-table.mdx | 63 + docs/5.api/rpc/gas/gas-price/index.mdx | 89 + .../rpc/gas/gas-price/latest/request-bash.mdx | 7 + .../rpc/gas/gas-price/latest/request-js.mdx | 3 + .../rpc/gas/gas-price/latest/request-json.mdx | 8 + .../5.api/rpc/gas/gas-price/response-json.mdx | 9 + .../rpc/general/error-schema-description.mdx | 27 + docs/5.api/rpc/maintenance-windows.md | 129 +- .../error-schema-table.mdx | 28 + .../maintenance-windows/index.mdx | 51 + .../maintenance-windows/request-bash.mdx | 9 + .../maintenance-windows/request-json.mdx | 10 + .../maintenance-windows/response-json.mdx | 10 + docs/5.api/rpc/network.md | 1404 +------------- .../network-info/error-schema-table.mdx | 28 + docs/5.api/rpc/network/network-info/index.mdx | 43 + .../rpc/network/network-info/request-bash.mdx | 7 + .../rpc/network/network-info/request-json.mdx | 8 + .../network/network-info/response-json.mdx | 26 + .../node-status/error-schema-table.mdx | 28 + docs/5.api/rpc/network/node-status/index.mdx | 48 + .../rpc/network/node-status/request-bash.mdx | 7 + .../rpc/network/node-status/request-js.mdx | 3 + .../rpc/network/node-status/request-json.mdx | 8 + .../rpc/network/node-status/response-json.mdx | 117 ++ .../epoch-hash/request-bash.mdx | 9 + .../epoch-hash/request-json.mdx | 10 + .../validation-status/error-schema-table.mdx | 63 + .../rpc/network/validation-status/index.mdx | 67 + .../validation-status/latest/request-bash.mdx | 7 + .../validation-status/latest/request-json.mdx | 8 + .../validation-status/response-json.mdx | 706 +++++++ docs/5.api/rpc/protocol.md | 665 +------ .../genesis-config/error-schema-table.mdx | 28 + .../rpc/protocol/genesis-config/index.mdx | 47 + .../protocol/genesis-config/request-bash.mdx | 6 + .../protocol/genesis-config/request-js.mdx | 5 + .../protocol/genesis-config/request-json.mdx | 7 + .../protocol/genesis-config/response-json.mdx | 158 ++ .../protocol-config/error-schema-table.mdx | 53 + .../rpc/protocol/protocol-config/index.mdx | 49 + .../protocol/protocol-config/request-bash.mdx | 9 + .../protocol/protocol-config/request-js.mdx | 5 + .../protocol/protocol-config/request-json.mdx | 10 + .../protocol-config/response-json.mdx | 311 +++ docs/5.api/rpc/transactions.md | 1384 +------------- .../receipt-by-id/error-schema-table.mdx | 62 + .../rpc/transactions/receipt-by-id/index.mdx | 44 + .../receipt-by-id/request-bash.mdx | 9 + .../receipt-by-id/request-json.mdx | 10 + .../receipt-by-id/response-json.mdx | 39 + .../error-schema-table.mdx | 30 + .../send-transaction-async/index.mdx | 46 + .../send-transaction-async/request-bash.mdx | 9 + .../send-transaction-async/request-json.mdx | 10 + .../send-transaction-async/response-json.mdx | 7 + .../error-schema-table.mdx | 95 + .../send-transaction-await/index.mdx | 40 + .../send-transaction-await/request-bash.mdx | 9 + .../send-transaction-await/request-json.mdx | 10 + .../send-transaction-await/response-json.mdx | 74 + .../send-tx/error-schema-table.mdx | 95 + docs/5.api/rpc/transactions/send-tx/index.mdx | 46 + .../rpc/transactions/send-tx/request-bash.mdx | 10 + .../rpc/transactions/send-tx/request-json.mdx | 11 + .../transactions/send-tx/response-json.mdx | 74 + .../error-schema-table.mdx | 96 + .../index.mdx | 58 + .../request-bash.mdx | 11 + .../request-js.mdx | 7 + .../request-json.mdx | 12 + .../response-json.mdx | 182 ++ .../transaction-status/error-schema-table.mdx | 96 + .../transactions/transaction-status/index.mdx | 58 + .../transaction-status/request-bash.mdx | 11 + .../transaction-status/request-js.mdx | 7 + .../transaction-status/request-json.mdx | 12 + .../transaction-status/response-json.mdx | 124 ++ .../transactions/tx-status-result/index.mdx | 29 + 192 files changed, 7449 insertions(+), 7199 deletions(-) create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/error-schema-table.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/index.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/request-bash.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/request-js.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/request-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-all/response-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/error-schema-table.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/index.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/request-bash.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/request-js.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/request-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-changes-single/response-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/error-schema-table.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/index.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/request-bash.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/request-js.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/request-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key-list/response-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/error-schema-table.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/index.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/request-bash.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/request-js.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/request-json.mdx create mode 100644 docs/5.api/rpc/access-keys/view-access-key/response-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-hash/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-hash/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-hash/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-height/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-height/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/block-height/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/error-schema-table.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/finality/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/finality/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/finality/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/index.mdx create mode 100644 docs/5.api/rpc/block-chunk/block-details/response-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/error-schema-table.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/finality/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/finality/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/finality/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/index.mdx create mode 100644 docs/5.api/rpc/block-chunk/changes-in-block/response-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-bash.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-js.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-json.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/error-schema-table.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/index.mdx create mode 100644 docs/5.api/rpc/block-chunk/chunk-details/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/complex-call/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/index.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/call-a-contract-function/simple-call/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-account-changes/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-account/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code-changes/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-code/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state-changes/response-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/error-schema-table.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/index.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/request-bash.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/request-js.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/request-json.mdx create mode 100644 docs/5.api/rpc/contracts/view-contract-state/response-json.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-hash/request-bash.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-hash/request-js.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-hash/request-json.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-height/request-bash.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-height/request-js.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/block-height/request-json.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/error-schema-table.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/index.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/latest/request-bash.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/latest/request-js.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/latest/request-json.mdx create mode 100644 docs/5.api/rpc/gas/gas-price/response-json.mdx create mode 100644 docs/5.api/rpc/general/error-schema-description.mdx create mode 100644 docs/5.api/rpc/maintenance-windows/maintenance-windows/error-schema-table.mdx create mode 100644 docs/5.api/rpc/maintenance-windows/maintenance-windows/index.mdx create mode 100644 docs/5.api/rpc/maintenance-windows/maintenance-windows/request-bash.mdx create mode 100644 docs/5.api/rpc/maintenance-windows/maintenance-windows/request-json.mdx create mode 100644 docs/5.api/rpc/maintenance-windows/maintenance-windows/response-json.mdx create mode 100644 docs/5.api/rpc/network/network-info/error-schema-table.mdx create mode 100644 docs/5.api/rpc/network/network-info/index.mdx create mode 100644 docs/5.api/rpc/network/network-info/request-bash.mdx create mode 100644 docs/5.api/rpc/network/network-info/request-json.mdx create mode 100644 docs/5.api/rpc/network/network-info/response-json.mdx create mode 100644 docs/5.api/rpc/network/node-status/error-schema-table.mdx create mode 100644 docs/5.api/rpc/network/node-status/index.mdx create mode 100644 docs/5.api/rpc/network/node-status/request-bash.mdx create mode 100644 docs/5.api/rpc/network/node-status/request-js.mdx create mode 100644 docs/5.api/rpc/network/node-status/request-json.mdx create mode 100644 docs/5.api/rpc/network/node-status/response-json.mdx create mode 100644 docs/5.api/rpc/network/validation-status/epoch-hash/request-bash.mdx create mode 100644 docs/5.api/rpc/network/validation-status/epoch-hash/request-json.mdx create mode 100644 docs/5.api/rpc/network/validation-status/error-schema-table.mdx create mode 100644 docs/5.api/rpc/network/validation-status/index.mdx create mode 100644 docs/5.api/rpc/network/validation-status/latest/request-bash.mdx create mode 100644 docs/5.api/rpc/network/validation-status/latest/request-json.mdx create mode 100644 docs/5.api/rpc/network/validation-status/response-json.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/error-schema-table.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/index.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/request-bash.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/request-js.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/request-json.mdx create mode 100644 docs/5.api/rpc/protocol/genesis-config/response-json.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/error-schema-table.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/index.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/request-bash.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/request-js.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/request-json.mdx create mode 100644 docs/5.api/rpc/protocol/protocol-config/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/receipt-by-id/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/receipt-by-id/index.mdx create mode 100644 docs/5.api/rpc/transactions/receipt-by-id/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/receipt-by-id/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/receipt-by-id/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-async/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-async/index.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-async/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-async/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-async/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-await/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-await/index.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-await/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-await/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-transaction-await/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-tx/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/send-tx/index.mdx create mode 100644 docs/5.api/rpc/transactions/send-tx/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/send-tx/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/send-tx/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/index.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/request-js.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status-with-receipts/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/error-schema-table.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/index.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/request-bash.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/request-js.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/request-json.mdx create mode 100644 docs/5.api/rpc/transactions/transaction-status/response-json.mdx create mode 100644 docs/5.api/rpc/transactions/tx-status-result/index.mdx diff --git a/docs/5.api/rpc/access-keys.md b/docs/5.api/rpc/access-keys.md index 259959ca5ce..7d2693926eb 100644 --- a/docs/5.api/rpc/access-keys.md +++ b/docs/5.api/rpc/access-keys.md @@ -3,960 +3,19 @@ id: access-keys title: Access Keys --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; -import { LantstoolLabel } from '@site/src/components/lantstool/LantstoolLabel/LantstoolLabel'; -import { TryOutOnLantstool } from '@site/src/components/lantstool/TryOutOnLantstool'; +import ViewAccessKey from './access-keys/view-access-key/index.mdx'; +import ViewAccessKeyList from './access-keys/view-access-key-list/index.mdx'; +import ViewAccessKeyChangesSingle from './access-keys/view-access-key-changes-single/index.mdx'; +import ViewAccessKeyChangesAll from './access-keys/view-access-key-changes-all/index.mdx'; The RPC API enables you to retrieve information about an account's access keys. --- - -## View access key {#view-access-key} - -Returns information about a single access key for given account. - -If `permission` of the key is `FunctionCall`, it will return more details such as the `allowance`, `receiver_id`, and `method_names`. - -- method: `query` -- params: - - `request_type`: `view_access_key` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: _`"example.testnet"`_ - - `public_key`: _`"example.testnet's public key"`_ - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_access_key", - "finality": "final", - "account_id": "client.chainlink.testnet", - "public_key": "ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW" - } -} -``` - - - - - -```js -const response = await near.connection.provider.query({ - request_type: "view_access_key", - finality: "final", - account_id: "client.chainlink.testnet", - public_key: "ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "view_access_key", - "finality": "final", - "account_id": "client.chainlink.testnet", - "public_key": "ed25519:H9k5eiU4xXS3M4z8HzKJSLaZdqGdGwBG49o7orNC4eZW" - }' -``` - - - - }> - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "nonce": 85, - "permission": { - "FunctionCall": { - "allowance": "18501534631167209000000000", - "receiver_id": "client.chainlink.testnet", - "method_names": ["get_token_price"] - } - }, - "block_height": 19884918, - "block_hash": "GGJQ8yjmo7aEoj8ZpAhGehnq9BSWFx4xswHYzDwwAP2n" - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `view_access_key` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
UNKNOWN_ACCESS_KEY200The requested public_key has not been found while viewing since the public key has not been created or has been already deleted -
    -
  • Check the public_key
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
UNAVAILABLE_SHARD200The node was unable to found the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View access key list {#view-access-key-list} - -You can query all access keys for a given account. - -- method: `query` -- params: - - `request_type`: `view_access_key_list` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: _`"example.testnet"`_ - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_access_key_list", - "finality": "final", - "account_id": "example.testnet" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "view_access_key_list", - finality: "final", - account_id: "example.testnet", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "view_access_key_list", - "finality": "final", - "account_id": "example.testnet" - }' -``` - - - - }> - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "keys": [ - { - "public_key": "ed25519:2j6qujbkPFuTstQLLTxKZUw63D5Wu3SG79Gop5JQrNJY", - "access_key": { - "nonce": 17, - "permission": { - "FunctionCall": { - "allowance": "9999203942481156415000", - "receiver_id": "place.meta", - "method_names": [] - } - } - } - }, - { - "public_key": "ed25519:46etzhzZHN4NSQ8JEQtbHCX7sT8WByS3vmSEb3fbmSgf", - "access_key": { - "nonce": 2, - "permission": { - "FunctionCall": { - "allowance": "9999930655034196535000", - "receiver_id": "dev-1596616186817-8588944", - "method_names": [] - } - } - } - }, - { - "public_key": "ed25519:4F9TwuSqWwvoyu7JVZDsupPhC7oYbYNsisBV2yQvyXFn", - "access_key": { - "nonce": 0, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:4bZqp6nm1btr92UfKbyADDzJ4oPK9JetHXqEYqbYZmkD", - "access_key": { - "nonce": 2, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:6ZPzX7hS37jiU9dRxbV1Waf8HSyKKFypJbrnZXzNhqjs", - "access_key": { - "nonce": 2, - "permission": { - "FunctionCall": { - "allowance": "9999922083697042955000", - "receiver_id": "example.testnet", - "method_names": [] - } - } - } - }, - { - "public_key": "ed25519:81RKfuo7mBbsaviTmBsq18t6Eq4YLnSi3ye2CBLcKFUX", - "access_key": { - "nonce": 8, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:B4W1oAYTcG8GxwKev8jQtsYWkGwGdqP24W7eZ6Fmpyzc", - "access_key": { - "nonce": 0, - "permission": { - "FunctionCall": { - "allowance": "10000000000000000000000", - "receiver_id": "dev-1594144238344", - "method_names": [] - } - } - } - }, - { - "public_key": "ed25519:BA3AZbACoEzAsxKeToFd36AVpPXFSNhSMW2R6UYeGRwM", - "access_key": { - "nonce": 0, - "permission": { - "FunctionCall": { - "allowance": "10000000000000000000000", - "receiver_id": "new-corgis", - "method_names": [] - } - } - } - }, - { - "public_key": "ed25519:BRyHUGAJjRKVTc9ZqXTTSJnFmSca8WLj8TuVe1wXK3LZ", - "access_key": { - "nonce": 17, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:DjytaZ1HZ5ZFmH3YeJeMCiC886K1XPYeGsbz2E1AZj2J", - "access_key": { - "nonce": 31, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:DqJn5UCq6vdNAvfhnbpdAeuui9a6Hv9DKYDxeRACPUDP", - "access_key": { - "nonce": 0, - "permission": "FullAccess" - } - }, - { - "public_key": "ed25519:FFxG8x6cDDyiErFtRsdw4dBNtCmCtap4tMTjuq3umvSq", - "access_key": { - "nonce": 0, - "permission": "FullAccess" - } - } - ], - "block_height": 17798231, - "block_hash": "Gm7YSdx22wPuciW1jTTeRGP9mFqmon69ErFQvgcFyEEB" - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `view_access_key_list` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
UNAVAILABLE_SHARD200The node was unable to find the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View access key changes (single) {#view-access-key-changes-single} - -Returns individual access key changes in a specific block. You can query multiple keys by passing an array of objects containing the `account_id` and `public_key`. - -- method: `EXPERIMENTAL_changes` -- params: - - `changes_type`: `single_access_key_changes` - - `keys`: `[{ account_id, public_key }]` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes", - "params": { - "changes_type": "single_access_key_changes", - "keys": [ - { - "account_id": "example-acct.testnet", - "public_key": "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM" - } - ], - "finality": "final" - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes({ - changes_type: "single_access_key_changes", - keys: [ - { - account_id: "example-acct.testnet", - public_key: "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM", - }, - ], - finality: "final", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes \ - params:='{ - "changes_type": "single_access_key_changes", - "keys": [ - { - "account_id": "example-acct.testnet", - "public_key": "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM" - } - ], - "finality": "final" - }' -``` - - - - }> - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "4kvqE1PsA6ic1LG7S5SqymSEhvjqGqumKjAxnVdNN3ZH", - "changes": [ - { - "cause": { - "type": "transaction_processing", - "tx_hash": "HshPyqddLxsganFxHHeH9LtkGekXDCuAt6axVgJLboXV" - }, - "type": "access_key_update", - "change": { - "account_id": "example-acct.testnet", - "public_key": "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM", - "access_key": { - "nonce": 1, - "permission": "FullAccess" - } - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong?{#what-could-go-wrong-2} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes_in_block` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View access key changes (all) {#view-access-key-changes-all} - -Returns changes to all access keys of a specific block. Multiple accounts can be quereied by passing an array of `account_ids`. - -- method: `EXPERIMENTAL_changes` -- params: - - `changes_type`: `all_access_key_changes` - - `account_ids`: `[ "example.testnet", "example2.testnet"]` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes", - "params": { - "changes_type": "all_access_key_changes", - "account_ids": ["example-acct.testnet"], - "block_id": "4kvqE1PsA6ic1LG7S5SqymSEhvjqGqumKjAxnVdNN3ZH" - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes({ - changes_type: "all_access_key_changes", - account_ids: "example-acct.testnet", - finality: "final", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes \ - params:='{ - "changes_type": "all_access_key_changes", - "account_ids": ["example-acct.testnet"], - "block_id": "4kvqE1PsA6ic1LG7S5SqymSEhvjqGqumKjAxnVdNN3ZH" - }' -``` - - - - }> - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "4kvqE1PsA6ic1LG7S5SqymSEhvjqGqumKjAxnVdNN3ZH", - "changes": [ - { - "cause": { - "type": "transaction_processing", - "tx_hash": "HshPyqddLxsganFxHHeH9LtkGekXDCuAt6axVgJLboXV" - }, - "type": "access_key_update", - "change": { - "account_id": "example-acct.testnet", - "public_key": "ed25519:25KEc7t7MQohAJ4EDThd2vkksKkwangnuJFzcoiXj9oM", - "access_key": { - "nonce": 1, - "permission": "FullAccess" - } - } - }, - { - "cause": { - "type": "receipt_processing", - "receipt_hash": "CetXstu7bdqyUyweRqpY9op5U1Kqzd8pq8T1kqfcgBv2" - }, - "type": "access_key_update", - "change": { - "account_id": "example-acct.testnet", - "public_key": "ed25519:96pj2aVJH9njmAxakjvUMnNvdB3YUeSAMjbz9aRNU6XY", - "access_key": { - "nonce": 0, - "permission": "FullAccess" - } - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong?{#what-could-go-wrong-3} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/error-schema-table.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/index.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/index.mdx new file mode 100644 index 00000000000..8a42400fa11 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/index.mdx @@ -0,0 +1,52 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## View access key changes (all) {#view-access-key-changes-all} + +Returns changes to all access keys of a specific block. +Multiple accounts can be quereied by passing an array of `account_ids`. + +- method: `EXPERIMENTAL_changes` +- params: + - `changes_type`: `all_access_key_changes` + - `account_ids`: `[ "example.testnet", "example2.testnet"]` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong?{#what-could-go-wrong-3} + + + +Here is the exhaustive list of the error variants that can be returned +by `EXPERIMENTAL_changes` method: + + diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-bash.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-bash.mdx new file mode 100644 index 00000000000..6b53ccf58f3 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes \ + params:='{ + "changes_type": "all_access_key_changes", + "account_ids": ["account.rpc-examples.testnet"], + "block_id": 187309655 + }' +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-js.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-js.mdx new file mode 100644 index 00000000000..e147a0996a2 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-js.mdx @@ -0,0 +1,6 @@ +```js +const response = await near.connection.provider.accessKeyChanges( + ["account.rpc-examples.testnet"], + { blockId: 187309655 }, +); +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-json.mdx new file mode 100644 index 00000000000..52e87121b92 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes", + "params": { + "changes_type": "all_access_key_changes", + "account_ids": ["account.rpc-examples.testnet"], + "block_id": 187309655 + } +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-all/response-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-all/response-json.mdx new file mode 100644 index 00000000000..7b8b760696b --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-all/response-json.mdx @@ -0,0 +1,53 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "6EDgS3zF9aoBMfdHqthQTQtudt7JzdLBbkTb6Jn4wfP9", + "changes": [ + { + "cause": { + "receipt_hash": "9meU2ibDyJS2ga4se7j5knsWetKrXaw5qBpwrYgN1Qeh", + "type": "receipt_processing" + }, + "change": { + "access_key": { + "nonce": 187309654000000, + "permission": "FullAccess" + }, + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + }, + "type": "access_key_update" + }, + { + "cause": { + "receipt_hash": "9meU2ibDyJS2ga4se7j5knsWetKrXaw5qBpwrYgN1Qeh", + "type": "receipt_processing" + }, + "change": { + "access_key": { + "nonce": 187309654000000, + "permission": { + "FunctionCall": { + "allowance": "150000000000000000000000", + "method_names": [ + "write_record", + "get_record", + "get_greeting", + "__contract_abi", + "contract_source_metadata" + ], + "receiver_id": "contract.rpc-examples.testnet" + } + } + }, + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + }, + "type": "access_key_update" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/error-schema-table.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/index.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/index.mdx new file mode 100644 index 00000000000..136d5ee3e76 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/index.mdx @@ -0,0 +1,52 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## View access key changes (single) {#view-access-key-changes-single} + +Returns individual access key changes in a specific block. You can query multiple +keys by passing an array of objects containing the `account_id` and `public_key`. + +- method: `EXPERIMENTAL_changes` +- params: + - `changes_type`: `single_access_key_changes` + - `keys`: `[{ account_id, public_key }]` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong?{#what-could-go-wrong-2} + + + +Here is the exhaustive list of the error variants that can be returned +by `EXPERIMENTAL_changes_in_block` method: + + diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-bash.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-bash.mdx new file mode 100644 index 00000000000..9aa4bd339eb --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-bash.mdx @@ -0,0 +1,16 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes \ + params:='{ + "changes_type": "single_access_key_changes", + "keys": [ + { + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + } + ], + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + }' +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-js.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-js.mdx new file mode 100644 index 00000000000..965d0ffa371 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-js.mdx @@ -0,0 +1,11 @@ +```js +const response = await near.connection.provider.singleAccessKeyChanges( + [ + { + account_id: "account.rpc-examples.testnet", + public_key: "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd", + }, + ], + { blockId: "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" }, +); +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-json.mdx new file mode 100644 index 00000000000..e0a00d30c46 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/request-json.mdx @@ -0,0 +1,17 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes", + "params": { + "changes_type": "single_access_key_changes", + "keys": [ + { + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + } + ], + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + } +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-changes-single/response-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-changes-single/response-json.mdx new file mode 100644 index 00000000000..e3665bce164 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-changes-single/response-json.mdx @@ -0,0 +1,38 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", + "changes": [ + { + "cause": { + "tx_hash": "J3KbUXF9YPu2eGnbDCACxGvmMDZMdP7acGYhVLHGu9y2", + "type": "transaction_processing" + }, + "change": { + "access_key": { + "nonce": 187309654000001, + "permission": { + "FunctionCall": { + "allowance": "142924791772640836536480", + "method_names": [ + "write_record", + "get_record", + "get_greeting", + "__contract_abi", + "contract_source_metadata" + ], + "receiver_id": "contract.rpc-examples.testnet" + } + } + }, + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + }, + "type": "access_key_update" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/error-schema-table.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/error-schema-table.mdx new file mode 100644 index 00000000000..24e4e44fce0 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/error-schema-table.mdx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to find the requested data because it does not track + the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/index.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/index.mdx new file mode 100644 index 00000000000..d7cbb674ea6 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/index.mdx @@ -0,0 +1,51 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## View access key list {#view-access-key-list} + +You can query all access keys for a given account. + +- method: `query` +- params: + - `request_type`: `view_access_key_list` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: _`"example.testnet"`_ + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? + + + +Here is the exhaustive list of the error variants that can be returned +by `view_access_key_list` request type: + + diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/request-bash.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/request-bash.mdx new file mode 100644 index 00000000000..6ac2af7ebf8 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id="dontcare" \ + method=query \ + params:='{ + "request_type": "view_access_key_list", + "finality": "final", + "account_id": "account.rpc-examples.testnet" + }' +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/request-js.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/request-js.mdx new file mode 100644 index 00000000000..15f626aea5a --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/request-js.mdx @@ -0,0 +1,7 @@ +```js +const response = await near.connection.provider.query({ + request_type: "view_access_key_list", + finality: "final", + account_id: "account.rpc-examples.testnet", +}); +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/request-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/request-json.mdx new file mode 100644 index 00000000000..9b1880fe0f6 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "view_access_key_list", + "finality": "final", + "account_id": "account.rpc-examples.testnet" + } +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key-list/response-json.mdx b/docs/5.api/rpc/access-keys/view-access-key-list/response-json.mdx new file mode 100644 index 00000000000..1abf26c1d97 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key-list/response-json.mdx @@ -0,0 +1,38 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "29G6xeV4ufkVsY24YZPfiRwLMTNoKrAMitrjg6nvVZqq", + "block_height": 187319080, + "keys": [ + { + "access_key": { + "nonce": 187309654000000, + "permission": "FullAccess" + }, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + }, + { + "access_key": { + "nonce": 187309654000001, + "permission": { + "FunctionCall": { + "allowance": "149788200694421800000000", + "method_names": [ + "write_record", + "get_record", + "get_greeting", + "__contract_abi", + "contract_source_metadata" + ], + "receiver_id": "contract.rpc-examples.testnet" + } + } + }, + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key/error-schema-table.mdx b/docs/5.api/rpc/access-keys/view-access-key/error-schema-table.mdx new file mode 100644 index 00000000000..81abde07b53 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/error-schema-table.mdx @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
UNKNOWN_ACCESS_KEY200 + The requested public_key has not been found while viewing + since the public key has not been created or has been already deleted + +
    +
  • + Check the public_key +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to found the requested data because it does not + track the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/access-keys/view-access-key/index.mdx b/docs/5.api/rpc/access-keys/view-access-key/index.mdx new file mode 100644 index 00000000000..22318105d29 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/index.mdx @@ -0,0 +1,55 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## View access key {#view-access-key} + +Returns information about a single access key for given account. + +If `permission` of the key is `FunctionCall`, it will return more details such +as the `allowance`, `receiver_id`, and `method_names`. + +- method: `query` +- params: + - `request_type`: `view_access_key` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: _`"example.testnet"`_ + - `public_key`: _`"example.testnet's public key"`_ + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? + + + +Here is the exhaustive list of the error variants that can be returned by +`view_access_key` request type: + + diff --git a/docs/5.api/rpc/access-keys/view-access-key/request-bash.mdx b/docs/5.api/rpc/access-keys/view-access-key/request-bash.mdx new file mode 100644 index 00000000000..15bcb2ff421 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/request-bash.mdx @@ -0,0 +1,12 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "view_access_key", + "finality": "final", + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + }' +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key/request-js.mdx b/docs/5.api/rpc/access-keys/view-access-key/request-js.mdx new file mode 100644 index 00000000000..91fb0e658a8 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/request-js.mdx @@ -0,0 +1,8 @@ +```js +const response = await near.connection.provider.query({ + request_type: "view_access_key", + finality: "final", + account_id: "account.rpc-examples.testnet", + public_key: "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd", +}); +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key/request-json.mdx b/docs/5.api/rpc/access-keys/view-access-key/request-json.mdx new file mode 100644 index 00000000000..9632d2651e4 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/request-json.mdx @@ -0,0 +1,13 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "view_access_key", + "finality": "final", + "account_id": "account.rpc-examples.testnet", + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd" + } +} +``` diff --git a/docs/5.api/rpc/access-keys/view-access-key/response-json.mdx b/docs/5.api/rpc/access-keys/view-access-key/response-json.mdx new file mode 100644 index 00000000000..0e31b334801 --- /dev/null +++ b/docs/5.api/rpc/access-keys/view-access-key/response-json.mdx @@ -0,0 +1,24 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "J1zkrK8sHuzzV8pkXsEPrZH7SQZeJ2NSEs9L1hSWzVgg", + "block_height": 187316844, + "nonce": 187309654000001, + "permission": { + "FunctionCall": { + "allowance": "149788200694421800000000", + "method_names": [ + "write_record", + "get_record", + "get_greeting", + "__contract_abi", + "contract_source_metadata" + ], + "receiver_id": "contract.rpc-examples.testnet" + } + } + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/block-chunk.md b/docs/5.api/rpc/block-chunk.md index 2af3d931752..214c226d1a4 100644 --- a/docs/5.api/rpc/block-chunk.md +++ b/docs/5.api/rpc/block-chunk.md @@ -3,826 +3,16 @@ id: block-chunk title: Block / Chunk --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import BlockDetails from './block-chunk/block-details/index.mdx'; +import ChangesInBlock from './block-chunk/changes-in-block/index.mdx'; +import ChunkDetails from './block-chunk/chunk-details/index.mdx'; The RPC API enables you to query the network and get details about specific blocks or chunks. --- - -## Block details {#block-details} - -> Queries network and returns block for given height or hash. You can also use `finality` param to return latest block details. - -**Note**: You may choose to search by a specific block _or_ finality, you can not choose both. - -- method: `block` -- params: - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -`finality` example: - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "block", - "params": { - "finality": "final" - } -} -``` - - - - -```js -const response = await near.connection.provider.block({ - finality: "final", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=block \ - params:='{ - "finality": "final" - }' -``` - - - - -`[block_id]` - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "block", - "params": { - "block_id": 17821130 - } -} -``` - - - - -```js -const response = await near.connection.provider.block({blockId: 17821130}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=block \ - params:='{ - "block_id": 17821130 - }' -``` - - - - -`[block_hash]` - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "block", - "params": { - "block_id": "7nsuuitwS7xcdGnD9JgrE22cRB2vf2VS4yh1N9S71F4d" - } -} -``` - - - - -```js -const response = await near.connection.provider.block( - {blockId: "7nsuuitwS7xcdGnD9JgrE22cRB2vf2VS4yh1N9S71F4d"} -); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=block \ - params:='{ - "block_id": "7nsuuitwS7xcdGnD9JgrE22cRB2vf2VS4yh1N9S71F4d" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "author": "bitcat.pool.f863973.m0", - "header": { - "height": 17821130, - "epoch_id": "7Wr3GFJkYeCxjVGz3gDaxvAMUzXuzG8MjFXTFoAXB6ZZ", - "next_epoch_id": "A5AdnxEn7mfHieQ5fRxx9AagCkHNJz6wr61ppEXiWvvh", - "hash": "CLo31YCUhzz8ZPtS5vXLFskyZgHV5qWgXinBQHgu9Pyd", - "prev_hash": "2yUTTubrv1gJhTUVnHXh66JG3qxStBqySoN6wzRzgdVD", - "prev_state_root": "5rSz37fySS8XkVgEy3FAZwUncX4X1thcSpuvCgA6xmec", - "chunk_receipts_root": "9ETNjrt6MkwTgSVMMbpukfxRshSD1avBUUa4R4NuqwHv", - "chunk_headers_root": "HMpEoBhPvThWZvppLwrXQSSfumVdaDW7WfZoCAPtjPfo", - "chunk_tx_root": "7tkzFg8RHBmMw1ncRJZCCZAizgq4rwCftTKYLce8RU8t", - "outcome_root": "7tkzFg8RHBmMw1ncRJZCCZAizgq4rwCftTKYLce8RU8t", - "chunks_included": 1, - "challenges_root": "11111111111111111111111111111111", - "timestamp": 1601280114229875635, - "timestamp_nanosec": "1601280114229875635", - "random_value": "ACdUSF3nehbMTwT7qjUB6Mm4Ynck5TVAWbNH3DR1cjQ7", - "validator_proposals": [], - "chunk_mask": [true], - "gas_price": "100000000", - "rent_paid": "0", - "validator_reward": "0", - "total_supply": "1042339182040791154864822502764857", - "challenges_result": [], - "last_final_block": "AaxTqjYND5WAKbV2UZaFed6DH1DShN9fEemtnpTsv3eR", - "last_ds_final_block": "2yUTTubrv1gJhTUVnHXh66JG3qxStBqySoN6wzRzgdVD", - "next_bp_hash": "3ZNEoFYh2CQeJ9dc1pLBeUd1HWG8657j2c1v72ENE45Q", - "block_merkle_root": "H3912Nkw6rtamfjsjmafe2uV2p1XmUKDou5ywgxb1gJr", - "approvals": [ - "ed25519:4hNtc9vLhn2PQhktWtLKJV9g8SBfpm6NBT1w4syNFqoKE7ZMts2WwKA9x1ZUSBGVKYCuDGEqogLvwCF25G7e1UR3", - "ed25519:2UNmbTqysMMevVPqJEKSq57hkcxVFcAMdGq7CFhpW65yBKFxYwpoziiWsAtARusLn9Sy1eXM7DkGTXwAqFiSooS6", - "ed25519:4sumGoW9dnQCsJRpzkd4FQ5NSJypGQRCppWp7eQ9tpsEcJXjHZN8GVTCyeEk19WmbbMEJ5KBNypryyHzaH2gBxd4", - "ed25519:3fP2dri6GjYkmHgEqQWWP9GcoQEgakbaUtfr3391tXtYBgxmiJUEymRe54m7D8bQrSJ3LhKD8gTFT7qqdemRnizR", - "ed25519:3mwdqSWNm6RiuZAoZhD6pqsirC2cL48nEZAGoKixpqbrsBpAzqV3W2paH4KtQQ4JPLvk5pnzojaint2kNBCcUyq1", - "ed25519:D4hMnxqLyQW4Wo29MRNMej887GH46yJXDKNN4es8UDSi9shJ9Y4FcGqkxdV4AZhn1yUjwN5LwfgAgY6fyczk5L3", - null, - "ed25519:4WCVm4dn88VJxTkUgcvdS7vs34diBqtQY4XWMRctSN1NpbgdkwwVyxg7d2SbGC22SuED7w4nrToMhcpJXrkhkDmF", - "ed25519:JqtC7TFP7U14s7YhRKQEqwbc2RUxoctq75mrBdX91f7DuCWsPpe6ZTTnfHPmuJPjTzFHVZTsaQJWzwfSrrgNpnc", - "ed25519:ngGUpWc2SyHmMCkWGTNNNfvZAJQ5z7P92JCmDqB7JW3j8fNH6LobvFFXb2zVdssibJKgnjwBj8CRe6qiZtuYQZM", - "ed25519:5kzW6RbjukyJZiw9NTzTPPsQdoqN6EecafjVFEoWmTxQ4uSv1uSXhQYcHK2eq4m84oMmPABQDz2mm73Qx8mDdCQX", - "ed25519:5wHnuuxwJJiZ4bXNq5cESnr4YovFU2yaUcuHRDUw3DnLoxkqc15CsegoyUSQKEwtCZ4yETv8Z9QcD6Wr9zHV4AUk", - "ed25519:3F9XzWBxto31e8RAcBShAJBzJPgSJQsWbPXR38AfQnJn6AiveGz3JjebQm9Ye63BrnNA57QrPshwknxpzSrcNEZW", - "ed25519:2g5s4SKsHt9PMdekkDqVtwwtz14v4edhqdBX1MYA8tB6nDpj3vDCDCTy9pEU8dX31PoQe5ygnf88aTZukMBMK1Yt", - "ed25519:3Xz4jqhdyS3qs6xTmWdgjwt5gJraU5czMA89hPhmvbAN4aA7SUKL1HkevpmutRQqqxe7c7uCFeGiDHvDcxhhmD8W", - null, - "ed25519:55xs3vwPEys39egf9Z8SNyn1JsHPRMgj9HCX1GE7GJsVTcAuutQUCo91E12ZdXkuToYRXb9KzoT8n9XQRCNuLpwY", - null, - "ed25519:28JrFw7KnhnQPN89qZnnw17KDBjS6CDN7zB1hTg7KGg8qQPoCzakz9DNnaSnx39ji7e2fQSpZt4cNJaD7K7Yu7yo", - "ed25519:41hAr5qhtvUYpdD2NK9qqTVnpG325ZoAiwrcmk1MJH7fdpxm7oSKXvXZqh7bTmPhv61hH2RpHnhcGuN4QqLzK2zt", - "ed25519:4QacMsQ5FJgvecAYDFq8QBh19BBjh4qU8oeD5bV7p6Zhhu3e6r2iSHTvDBU2Q62RZAaWQQkkEwDUC9rsXdkGVhAt", - "ed25519:27smtCZ3WobEvBuD5DggY6kkGxjB9qRVY6kPixgwqvBT1eKbRVoV8cLj1z51S8RTcp7YzAr1vhHJUHgksatR9Udz", - "ed25519:4wspCWoAbhYxb3th2eX6ZXvKep1Fsco7mFP5zBodXBR8Wr344ANXSUCri3gUgNCCSoQ2CKSdqDEsvE6Y2jQ9hmbB", - "ed25519:46XpYf9ZB9gjDfdnJLHqqhYJpQCuvCgB9tzKWS88GANMCb2j9BM3KXyjaEzynSsaPK8VrKFXQuTsTzgQSeo9cWGW", - null, - "ed25519:Y5ehsrhEpTRGjG6fHJHsEXj2NYPGMmKguiJHXP7TqsCWHBvNzaJbieR7UDp78hJ1ib7C18J5MB2kCzTXBCF9c3b", - "ed25519:3P9363Dc8Kqvgjt3TsNRncUrncCHid7aSRnuySjF4JYmQbApkAxomyMu8xm9Rgo3mj9rqXb16PM7Xjn7hKP6TyVr", - null, - null, - "ed25519:65ATjGsigZ3vMp7sGcp1c4ptxoqhHPkBeAaZ5GWJguVDLyrRLPJrtXhLGjH9DpXd7CZswjyMYq5aRtorLnmmJ7GW", - null, - "ed25519:5SvqSViXbtsLoFMdtCufyyDgZnrEK7LheFi38X5M2ic17gfV5cz37r85RyixjUv98MbAmgVdmkxVFDGfSbeoHW7X", - null, - null, - "ed25519:2n3fQiBEiDKkB84biXWyQmvnupKX7B8faugY37jVi8hVXuWLggJmaEjqub511RCYwFnwW1RBxYpuJQ455KaniCd4", - "ed25519:2K9xKFLJ2fW74tddXtghFGFurKWomAqaJmkKYVZKHQT6zHe5wNSYT3vzMotLQcez5JD1Ta57N9zQ4H1RysB2s5DZ", - null, - null, - "ed25519:3qeCRtcLAqLtQ2YSQLcHDa26ykKX1BvAhP9jshLLYapxSEGGgZJY8sU72p9E78AkXwHP3X2Eq74jvts7gTRzNgMg", - null, - "ed25519:2czSQCF8wBDomEeSdDRH4gFoyJrp2ppZqR6JDaDGoYpaFkpWxZf2oGDkKfQLZMbfvU6LXkQjJssVHcLCJRMzG8co" - ], - "signature": "ed25519:58sdWd6kxzhQdCGvHzxqvdtDLJzqspe74f3gytnqdxDLHf4eesXi7B3nYq2YaosCHZJYmcR4HPHKSoFm3WE4MbxT", - "latest_protocol_version": 35 - }, - "chunks": [ - { - "chunk_hash": "EBM2qg5cGr47EjMPtH88uvmXHDHqmWPzKaQadbWhdw22", - "prev_block_hash": "2yUTTubrv1gJhTUVnHXh66JG3qxStBqySoN6wzRzgdVD", - "outcome_root": "11111111111111111111111111111111", - "prev_state_root": "HqWDq3f5HJuWnsTfwZS6jdAUqDjGFSTvjhb846vV27dx", - "encoded_merkle_root": "9zYue7drR1rhfzEEoc4WUXzaYRnRNihvRoGt1BgK7Lkk", - "encoded_length": 8, - "height_created": 17821130, - "height_included": 17821130, - "shard_id": 0, - "gas_used": 0, - "gas_limit": 1000000000000000, - "rent_paid": "0", - "validator_reward": "0", - "balance_burnt": "0", - "outgoing_receipts_root": "H4Rd6SGeEBTbxkitsCdzfu9xL9HtZ2eHoPCQXUeZ6bW4", - "tx_root": "11111111111111111111111111111111", - "validator_proposals": [], - "signature": "ed25519:4iPgpYAcPztAvnRHjfpegN37Rd8dTJKCjSd1gKAPLDaLcHUySJHjexMSSfC5iJVy28vqF9VB4psz13x2nt92cbR7" - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong?? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `block` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Changes in Block {#changes-in-block} - -> Returns changes in block for given block height or hash. You can also use `finality` param to return latest block details. - -**Note**: You may choose to search by a specific block _or_ finality, you can not choose both. - -- method: `EXPERIMENTAL_changes_in_block` -- params: - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -`finality` - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes_in_block", - "params": { - "finality": "final" - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes_in_block({ - finality: "final", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes_in_block \ - params:='{ - "finality": "final" - }' -``` - - - - -`[block_id]` - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes_in_block", - "params": { - "block_id": 17821135 - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes_in_block( - 17821135 -); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes_in_block \ - params:='{ - "block_id": 17821135 - }' -``` - - - - -`block_hash` - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes_in_block", - "params": { - "block_id": "81k9ked5s34zh13EjJt26mxw5npa485SY4UNoPi6yYLo" - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes_in_block( - "81k9ked5s34zh13EjJt26mxw5npa485SY4UNoPi6yYLo" -); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes_in_block \ - params:='{ - "block_id": "81k9ked5s34zh13EjJt26mxw5npa485SY4UNoPi6yYLo" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "81k9ked5s34zh13EjJt26mxw5npa485SY4UNoPi6yYLo", - "changes": [ - { - "type": "account_touched", - "account_id": "lee.testnet" - }, - { - "type": "contract_code_touched", - "account_id": "lee.testnet" - }, - { - "type": "access_key_touched", - "account_id": "lee.testnet" - } - ] - }, - "id": "dontcare" -} -``` - -

-
- - -#### What Could Go Wrong?? {#what-could-go-wrong-1} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes_in_block` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Chunk Details {#chunk-details} - -> Returns details of a specific chunk. You can run a [block details](/api/rpc/block-chunk#block-details) query to get a valid chunk hash. - -- method: `chunk` -- params: - - `chunk_id` _OR_ [`block_id`, `shard_id`](/api/rpc/setup#using-block_id-param) - -`chunk_id` example: - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "chunk", - "params": {"chunk_id": "EBM2qg5cGr47EjMPtH88uvmXHDHqmWPzKaQadbWhdw22"} -} -``` - - - - -```js -const response = await near.connection.provider.chunk({ - chunk_id: "EBM2qg5cGr47EjMPtH88uvmXHDHqmWPzKaQadbWhdw22" -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=chunk params:='{"chunk_id": "EBM2qg5cGr47EjMPtH88uvmXHDHqmWPzKaQadbWhdw22"}' id=dontcare -``` - - - - -`block_id`, `shard_id` example: - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "chunk", - "params": {"block_id": 58934027, "shard_id": 0} -} -``` - - - - -```js -const response = await near.connection.provider.chunk({ - block_id: 58934027, shard_id: 0 -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=chunk params:='{"block_id": 58934027, "shard_id": 0}' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "author": "bitcat.pool.f863973.m0", - "header": { - "chunk_hash": "EBM2qg5cGr47EjMPtH88uvmXHDHqmWPzKaQadbWhdw22", - "prev_block_hash": "2yUTTubrv1gJhTUVnHXh66JG3qxStBqySoN6wzRzgdVD", - "outcome_root": "11111111111111111111111111111111", - "prev_state_root": "HqWDq3f5HJuWnsTfwZS6jdAUqDjGFSTvjhb846vV27dx", - "encoded_merkle_root": "9zYue7drR1rhfzEEoc4WUXzaYRnRNihvRoGt1BgK7Lkk", - "encoded_length": 8, - "height_created": 17821130, - "height_included": 17821130, - "shard_id": 0, - "gas_used": 0, - "gas_limit": 1000000000000000, - "rent_paid": "0", - "validator_reward": "0", - "balance_burnt": "0", - "outgoing_receipts_root": "H4Rd6SGeEBTbxkitsCdzfu9xL9HtZ2eHoPCQXUeZ6bW4", - "tx_root": "11111111111111111111111111111111", - "validator_proposals": [], - "signature": "ed25519:4iPgpYAcPztAvnRHjfpegN37Rd8dTJKCjSd1gKAPLDaLcHUySJHjexMSSfC5iJVy28vqF9VB4psz13x2nt92cbR7" - }, - "transactions": [], - "receipts": [] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong?? {#what-could-go-wrong-2} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `chunk` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
UNKNOWN_CHUNK200The requested chunk can't be found in a database -
    -
  • Check that the requested chunk is legit
  • -
  • If the chunk had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_SHARD_ID200Provided shard_id does not exist -
    -
  • Provide shard_id for an existing shard
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested chunk is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/block-chunk/block-details/block-hash/request-bash.mdx b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-bash.mdx new file mode 100644 index 00000000000..228f7687ef9 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=block \ + params:='{ + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + }' +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/block-hash/request-js.mdx b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-js.mdx new file mode 100644 index 00000000000..fe4d53b8f50 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.block({ + blockId: "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", +}); +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/block-hash/request-json.mdx b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-json.mdx new file mode 100644 index 00000000000..bd975a4de34 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-hash/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "block", + "params": { + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/block-height/request-bash.mdx b/docs/5.api/rpc/block-chunk/block-details/block-height/request-bash.mdx new file mode 100644 index 00000000000..c9c83acfb6b --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-height/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=block \ + params:='{ + "block_id": 187310138 + }' +```` diff --git a/docs/5.api/rpc/block-chunk/block-details/block-height/request-js.mdx b/docs/5.api/rpc/block-chunk/block-details/block-height/request-js.mdx new file mode 100644 index 00000000000..ecbf17418d1 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-height/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.block({ + blockId: 187310138, +}); +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/block-height/request-json.mdx b/docs/5.api/rpc/block-chunk/block-details/block-height/request-json.mdx new file mode 100644 index 00000000000..9dd6eeb235d --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/block-height/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "block", + "params": { + "block_id": 187310138 + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/error-schema-table.mdx b/docs/5.api/rpc/block-chunk/block-details/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/block-chunk/block-details/finality/request-bash.mdx b/docs/5.api/rpc/block-chunk/block-details/finality/request-bash.mdx new file mode 100644 index 00000000000..5a129ca284c --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/finality/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=block \ + params:='{ + "finality": "final" + }' +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/finality/request-js.mdx b/docs/5.api/rpc/block-chunk/block-details/finality/request-js.mdx new file mode 100644 index 00000000000..af111fb1123 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/finality/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.block({ + finality: "final", +}); +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/finality/request-json.mdx b/docs/5.api/rpc/block-chunk/block-details/finality/request-json.mdx new file mode 100644 index 00000000000..dae61692564 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/finality/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "block", + "params": { + "finality": "final" + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/block-details/index.mdx b/docs/5.api/rpc/block-chunk/block-details/index.mdx new file mode 100644 index 00000000000..f8adffa4513 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/index.mdx @@ -0,0 +1,91 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import FinalityRequestJson from "./finality/request-json.mdx"; +import FinalityRequestJs from "./finality/request-js.mdx"; +import FinalityRequestBash from "./finality/request-bash.mdx"; +import BlockHeightRequestJson from "./block-height/request-json.mdx"; +import BlockHeightRequestJs from "./block-height/request-js.mdx"; +import BlockHeightRequestBash from "./block-height/request-bash.mdx"; +import BlockHashRequestJson from "./block-hash/request-json.mdx"; +import BlockHashRequestJs from "./block-hash/request-js.mdx"; +import BlockHashRequestBash from "./block-hash/request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## Block details {#block-details} + +> Queries network and returns block for given height or hash. You can also use +> `finality` param to return latest block details. + +**Note**: You may choose to search by a specific block _or_ finality, you can not choose both. + +- method: `block` +- params: + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +`finality` example: + + + + + + + + + + + + }> + + + + +`block_height` example: + + + + + + + + + + + + }> + + + + +`block_hash` example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong?? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `block` method: + + diff --git a/docs/5.api/rpc/block-chunk/block-details/response-json.mdx b/docs/5.api/rpc/block-chunk/block-details/response-json.mdx new file mode 100644 index 00000000000..d7ee867e838 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/block-details/response-json.mdx @@ -0,0 +1,237 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "author": "node2", + "chunks": [ + { + "balance_burnt": "0", + "bandwidth_requests": null, + "chunk_hash": "CzPafxtJmM1FnRoasKWAVhceJzZzkz9RKUBQQ4kY9V1v", + "congestion_info": { + "allowed_shard": 1, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 308, + "encoded_merkle_root": "6z9JwwtVfS5nRKcKeJxgzThRRs2wCNvbH88T3cuARe6W", + "gas_limit": 1000000000000000, + "gas_used": 0, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "11111111111111111111111111111111", + "outgoing_receipts_root": "AChfy3dXeJjgD2w5zXkUTFb6w8kg3AYGnyyjsvc7hXLv", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "cRMk2zd2bWC1oBfGowgMTpqW9L5SNG2FeE72yT1wpQA", + "rent_paid": "0", + "shard_id": 0, + "signature": "ed25519:L1iCopW8gY5rqwfuZT8Y3bHHXvuvWT87X9rwdY6LmFi8LGZdMhj2CkQCXLGrzdfYXD8B54wPTM9TqJAHcKfFDyW", + "tx_root": "CMwUsP8q4DTBUYxXm12jVwC8xTD8L1T1n3jdKLQVh6bm", + "validator_proposals": [], + "validator_reward": "0" + }, + { + "balance_burnt": "0", + "bandwidth_requests": null, + "chunk_hash": "44MZBWmPgXszAyojsffzozvNEdRsJcsq7RrdAV4Y7CLm", + "congestion_info": { + "allowed_shard": 2, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 8, + "encoded_merkle_root": "5TxYudsfZd2FZoMyJEZAP19ASov2ZD43N8ZWv8mKzWgx", + "gas_limit": 1000000000000000, + "gas_used": 0, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "11111111111111111111111111111111", + "outgoing_receipts_root": "AChfy3dXeJjgD2w5zXkUTFb6w8kg3AYGnyyjsvc7hXLv", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "EQ5mcUAzJA4du33f9g9YzKvdte2ukyRHMMHbbqdazZvU", + "rent_paid": "0", + "shard_id": 1, + "signature": "ed25519:4ktZTtEfxXSXPVj6Kii52d2T684HKKtEMzrd3dNc7UyxmgkKcLtxD1fawtbj8KsmjbZPGj8YMzanDeViEhxRJtDX", + "tx_root": "11111111111111111111111111111111", + "validator_proposals": [], + "validator_reward": "0" + }, + { + "balance_burnt": "38449649514500000000", + "bandwidth_requests": null, + "chunk_hash": "7eB8V8zMmNp9GxfRt3oHA3DS7YTgPvZ761pBzoziLay8", + "congestion_info": { + "allowed_shard": 3, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 1804, + "encoded_merkle_root": "6aZKpB3jZbhAq3kDtXaM6s1hYRLYEM624yiKkKvd957m", + "gas_limit": 1000000000000000, + "gas_used": 384496495145, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "D7ojhJ8UAgWf8A51Ekcundn3Kzdc577p5LFxqxcZurdB", + "outgoing_receipts_root": "3CK2q73iJmWa36EbaceqGcTz7pD7pia8BsUDE3gixwnF", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "7bSk4ev8EhZFSjb8Zb6ftkEZAUYQdbyPPz2ZkrvjLPuK", + "rent_paid": "0", + "shard_id": 2, + "signature": "ed25519:2sQ4JfYSMFcwpjbmonk67mMCMvuQyCNzvvk3iqCLMR7mnHauy3i7aTbySXwoqnrDjdmNjQ3gJMaA53LSRxYmoyAD", + "tx_root": "11111111111111111111111111111111", + "validator_proposals": [], + "validator_reward": "0" + }, + { + "balance_burnt": "0", + "bandwidth_requests": null, + "chunk_hash": "9pTjB74BgVSoP4Wb68BjkgnyABvZQUzAvv54YiVgse1B", + "congestion_info": { + "allowed_shard": 4, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 8, + "encoded_merkle_root": "5TxYudsfZd2FZoMyJEZAP19ASov2ZD43N8ZWv8mKzWgx", + "gas_limit": 1000000000000000, + "gas_used": 0, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "11111111111111111111111111111111", + "outgoing_receipts_root": "AChfy3dXeJjgD2w5zXkUTFb6w8kg3AYGnyyjsvc7hXLv", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "JDHeuYmX4kvsTPKyJYtJTrm7UK3JHTf4rw7hcHXYEfCn", + "rent_paid": "0", + "shard_id": 3, + "signature": "ed25519:5AejTPwZGWqdZjGCUbhLCcgasNDtsYKRJhS33uYR5Psu6NcCiaeLZnV8Q7dtWK4hLJ1iA48DA2WeqEeUyGhqWAGT", + "tx_root": "11111111111111111111111111111111", + "validator_proposals": [], + "validator_reward": "0" + }, + { + "balance_burnt": "32741908829000000000", + "bandwidth_requests": null, + "chunk_hash": "2xQwSvBiCb1mkoPxBJhSRg7pjmnrmKMEffatDz73Y8Jj", + "congestion_info": { + "allowed_shard": 5, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 1042, + "encoded_merkle_root": "5XpktxfgMp6thB2nH3PxdSg3K84p2wmpihHxUCqeQA6c", + "gas_limit": 1000000000000000, + "gas_used": 327419088290, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "69ZXwcYi41NY6cx1rZog8YavBPQvN75pmkNHZsFjWfUW", + "outgoing_receipts_root": "FqGVK8H8x2P3BbvuFMo7VCTy8cCNTzT1jd5JoLXfYRNG", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "BJePbZUt8VzJBwKf1j1sRUJJJEx4D2fUu4SCHiWs331o", + "rent_paid": "0", + "shard_id": 4, + "signature": "ed25519:2QSda4eMn25hmmTY31wN6RnBpBLjamSLrQRoVZ1yEoWyhtMhtg8rUv9Ko1tEdSftwhNEhL1ETixaAz4qcmvHUvD1", + "tx_root": "6qbqA8B9oyeVG33JXH25xbA2DiqvHRnxipurYUBJ9D8B", + "validator_proposals": [], + "validator_reward": "0" + }, + { + "balance_burnt": "0", + "bandwidth_requests": null, + "chunk_hash": "EVkgySRKpB9HrEJz8f18p9pWmJzhtL9WeYMwDSeY1827", + "congestion_info": { + "allowed_shard": 0, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 8, + "encoded_merkle_root": "5TxYudsfZd2FZoMyJEZAP19ASov2ZD43N8ZWv8mKzWgx", + "gas_limit": 1000000000000000, + "gas_used": 0, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "11111111111111111111111111111111", + "outgoing_receipts_root": "AChfy3dXeJjgD2w5zXkUTFb6w8kg3AYGnyyjsvc7hXLv", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "GkcYxyvnet4nvL7LFdbKxiscFBpe5WSzy5g2pW58LSRs", + "rent_paid": "0", + "shard_id": 5, + "signature": "ed25519:573WUDx8Sm4Fi16PFQkELXYq2SYezcbQP4CuhseqNizDtSTf2c2TKMWf2ZuACiWCSa8ARw8eWB2ZKWaY1uy7xd14", + "tx_root": "11111111111111111111111111111111", + "validator_proposals": [], + "validator_reward": "0" + } + ], + "header": { + "approvals": [ + null, + "ed25519:5GhoQTPXsWpgGPq2ZHZCfP9iY9GSmHMNsnydzxBxnibGvC43PFUAD58aUSNyfepRY4dAMbjbf8CduMyQU83HBxAt", + "ed25519:3Vc7sgrrgvpFXRr94mx3CD32Std1MRprR7igChZUisJvUm6f2yJmUGaXk38CYbh2wT1gfsKJ2UHf9icRome3jFYw", + "ed25519:3DZqMDGrk3eNUcZ8FiTtdw2piMXVcmVDDs89kHdRdDDgTr88GnQPEym4kfX9FUE81MnbytmotPry2sXD6MvbVprp", + "ed25519:5qtN8dU2iCtZxqPNszhPJ2Rgio88QL2wseLPhLH5Ev56WuxcNsmFZbNREvA6cKAKz4aDwQFFmmj888h6EEZuS2TV", + "ed25519:3gKUWzXU7Am5xdZqgMN3TC5wGVrf1kp6WQoqqtLFaF9JtBQKqqpZ67CKBm6KfejHPhiRkp1PbDJbppiNCpN3spr6", + "ed25519:3wgeF9tcjx1vX2bLpXfm8fYUQnai524XjTNb3Wt2LHMZnNoXzW4D2XBynj8sK41H5wtSbeVYpN3vGY1r23y56BaY", + "ed25519:ek5uvofwn5ZJidjYwiqS8Xpd1Y521FAUWrPyU9w3F8UT9yhviWuzPBCJUyMFVKnYUW6k6tZSZxT3NZibGfrGWA4", + "ed25519:4UcHZyKNzGDsMSNfQjLA9EE8yXiq3aroLUz4WJATzkKkUfMNVRkWxGc5tih2jDwzKfY3Ni5YiPoBbPzPCxNrusLf", + "ed25519:2hXaGXtAxngCjEWvnUUEgnnPCsXYzPzDadGHdw9sz6ng5oDQDPhnTm1MCG37xvv7xgCVhj3tqRZy8v74uap7WFC5", + "ed25519:kLuyqcTUynL1P77uMaaRs2MzxiaE1uyVGPjAVxpufK9A19G6LDUfK2GcbFXkqCgvKBJEGZKFPUbBqs7EmDdLPD7", + "ed25519:5ebABgQGk7idMAQgiEgc9a78v6fsD1nKXfevdBRJPFCn8bRuuFpthzzCp3NQXcr2XgSpNo6HJp8EZzzZHkSLfTDc", + "ed25519:4hTb2qFydXaiMKfv1pCxU4S9TQYQTHhqUPuGy8dejqxt2FFHD2sdFsYCv8Mf8qWRSob77QMuQbj37aQfEuJR2hH4", + null, + "ed25519:65jkXVzQ8pGsRDApBvVFx4xR7j4gruJaL2wumRHEHWib61M5Ztvtt7TTkz2DMN1nrRy6C7Pfhe3U3KpdSVEKKYAN", + null, + "ed25519:3kNRvMnpP8t4D9Dgs1YDAXyPNg7V3fpNa3GEWyCNNq5EvXxnyEoXRyPtbrZQM2FbapKsL2DnaNGvewHwBRQz5DbD", + "ed25519:5JQugH24LahiK7sn85akbprCtpAWfnZ2ffazxQ61kt9f6pe8b8s2LrHVKV3Wf4Sg3xHuP7fuUZJRyA4MWz3EQ83i", + "ed25519:2zXba2vAyGEq1fWauB3Kj6HbExTZG1S9KXKe6xcLxEpJHP9JHE6P3mJzpc765WpNsP21evNGj6mffJAwRHtwRny4", + null + ], + "block_body_hash": "6oSbpNUWcAUuaKWx79qTwyRPDLukg9hZ1RCa2PS5rcGt", + "block_merkle_root": "DWK6gpunDXHgxU1KJi3Dx8o2HcKqQmUQJEaisK4M3ovD", + "block_ordinal": 139413603, + "challenges_result": [], + "challenges_root": "11111111111111111111111111111111", + "chunk_endorsements": [ + [255, 255], + [251, 127], + [255, 31], + [255, 247], + [255, 239, 1], + [255, 63] + ], + "chunk_headers_root": "4MjChqi5JChDhaiU4zkhN1jeygZiMd66KeHe3Gz9Vs7s", + "chunk_mask": [true, true, true, true, true, true], + "chunk_receipts_root": "7nEtD9XsDbRJy7MwvUg4QX5zDUktiEVRP9nM6hHpsHmX", + "chunk_tx_root": "44YKYmcG1JTocmPSMGpriLwN8CTi29sD8z5FcocMZAKo", + "chunks_included": 6, + "epoch_id": "HkFsp3sn9K3KDWVoWPCfUSQocgf5bH4icgjHijePc2aX", + "epoch_sync_data_hash": null, + "gas_price": "100000000", + "hash": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", + "height": 187310138, + "last_ds_final_block": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "last_final_block": "71qgTQCVFfjQkimSdnhxR8iWSP6o9jqumLcZ9k5g25mT", + "latest_protocol_version": 73, + "next_bp_hash": "AWcwcDPWUjcW9zGiAt7UEUZzZ5Ue77537turbvBLbsiB", + "next_epoch_id": "FQBXgdi9oWKanYBXPP1sNUD93KMquocjT5mVrjQ4PH7E", + "outcome_root": "7Qkowo41AoiMdNfyiT83DwvwyReMeqhrkpqTzGm4Z19T", + "prev_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_height": 187310137, + "prev_state_root": "AiApSbMNq9kPPEiLLWhFpSrX5HoPToaBXztM9fePX2ap", + "random_value": "Br6a6tgEhNBZm9iPtxCLhwqwCr2eoEAGGMeVYZnU6fVF", + "rent_paid": "0", + "signature": "ed25519:YSuWifP5B3VBPuEVJppWt13AShXsWZ64Qus8uHmtddE2mY6u4jnZVv6Gz4tFvWXfBAkZDk5xtd95rUterEdQm5t", + "timestamp": 1739254177539033760, + "timestamp_nanosec": "1739254177539033760", + "total_supply": "2515615267787707740507051994761921", + "validator_proposals": [], + "validator_reward": "0" + } + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-bash.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-bash.mdx new file mode 100644 index 00000000000..19a2fda7e58 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes_in_block \ + params:='{ + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + }' +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-js.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-js.mdx new file mode 100644 index 00000000000..96756170b55 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.blockChanges({ + blockId: "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", +}); +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-json.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-json.mdx new file mode 100644 index 00000000000..88bdb3f08d5 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-hash/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes_in_block", + "params": { + "block_id": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w" + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-bash.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-bash.mdx new file mode 100644 index 00000000000..ce7d56b8a8e --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes_in_block \ + params:='{ + "block_id": 187310138 + }' +```` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-js.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-js.mdx new file mode 100644 index 00000000000..a3daf78c12d --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.blockChanges({ + blockId: 187310138, +}); +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-json.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-json.mdx new file mode 100644 index 00000000000..3b9c5f6d694 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/block-height/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes_in_block", + "params": { + "block_id": 187310138 + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/error-schema-table.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-bash.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-bash.mdx new file mode 100644 index 00000000000..22fd1d14c23 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes_in_block \ + params:='{ + "finality": "final" + }' +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-js.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-js.mdx new file mode 100644 index 00000000000..a13399a72d9 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.blockChanges({ + finality: "final", +}); +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-json.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-json.mdx new file mode 100644 index 00000000000..d8b94cdc4a5 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/finality/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes_in_block", + "params": { + "finality": "final" + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/index.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/index.mdx new file mode 100644 index 00000000000..e90a3e674ff --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/index.mdx @@ -0,0 +1,92 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import FinalityRequestJson from "./finality/request-json.mdx"; +import FinalityRequestJs from "./finality/request-js.mdx"; +import FinalityRequestBash from "./finality/request-bash.mdx"; +import BlockHeightRequestJson from "./block-height/request-json.mdx"; +import BlockHeightRequestJs from "./block-height/request-js.mdx"; +import BlockHeightRequestBash from "./block-height/request-bash.mdx"; +import BlockHashRequestJson from "./block-hash/request-json.mdx"; +import BlockHashRequestJs from "./block-hash/request-js.mdx"; +import BlockHashRequestBash from "./block-hash/request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## Changes in Block {#changes-in-block} + +> Returns changes in block for given block height or hash. You can also use +> `finality` param to return latest block details. + +**Note**: You may choose to search by a specific block _or_ finality, you can not choose both. + +- method: `EXPERIMENTAL_changes_in_block` +- params: + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +`finality` example: + + + + + + + + + + + + }> + + + + +`block_height` example: + + + + + + + + + + + + }> + + + + +`block_hash` example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong-1} + + + +Here is the exhaustive list of the error variants that can be returned by +`EXPERIMENTAL_changes_in_block` method: + + diff --git a/docs/5.api/rpc/block-chunk/changes-in-block/response-json.mdx b/docs/5.api/rpc/block-chunk/changes-in-block/response-json.mdx new file mode 100644 index 00000000000..1aa201f4b25 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/changes-in-block/response-json.mdx @@ -0,0 +1,47 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", + "changes": [ + { + "account_id": "account.rpc-examples.testnet", + "type": "account_touched" + }, + { + "account_id": "dev2-nsp.testnet", + "type": "account_touched" + }, + { + "account_id": "ping-account.testnet", + "type": "account_touched" + }, + { + "account_id": "v1.signer-dev.testnet", + "type": "account_touched" + }, + { + "account_id": "account.rpc-examples.testnet", + "type": "access_key_touched" + }, + { + "account_id": "ping-account.testnet", + "type": "access_key_touched" + }, + { + "account_id": "dev2-nsp.testnet", + "type": "data_touched" + }, + { + "account_id": "dev2-nsp.testnet", + "type": "data_touched" + }, + { + "account_id": "v1.signer-dev.testnet", + "type": "data_touched" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-bash.mdx b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-bash.mdx new file mode 100644 index 00000000000..f3c997a0601 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-bash.mdx @@ -0,0 +1,10 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=chunk \ + params:='{ + "block_id": 187310138, + "shard_id": 0 + }' +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-js.mdx b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-js.mdx new file mode 100644 index 00000000000..36582cd24c7 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-js.mdx @@ -0,0 +1,3 @@ +```js +const response = await near.connection.provider.chunk([187310138, 0]); +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-json.mdx b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-json.mdx new file mode 100644 index 00000000000..c16bf3fe39d --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/block-id-shard-id/request-json.mdx @@ -0,0 +1,11 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "chunk", + "params": { + "block_id": 187310138, + "shard_id": 0 + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-bash.mdx b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-bash.mdx new file mode 100644 index 00000000000..c513e41f78e --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=chunk \ + params:='{ + "chunk_id": "CzPafxtJmM1FnRoasKWAVhceJzZzkz9RKUBQQ4kY9V1v" + }' +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-js.mdx b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-js.mdx new file mode 100644 index 00000000000..5ee6e03ba7c --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.chunk( + "CzPafxtJmM1FnRoasKWAVhceJzZzkz9RKUBQQ4kY9V1v", +); +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-json.mdx b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-json.mdx new file mode 100644 index 00000000000..13b3efd22a5 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/chunk-id/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "chunk", + "params": { + "chunk_id": "CzPafxtJmM1FnRoasKWAVhceJzZzkz9RKUBQQ4kY9V1v" + } +} +``` diff --git a/docs/5.api/rpc/block-chunk/chunk-details/error-schema-table.mdx b/docs/5.api/rpc/block-chunk/chunk-details/error-schema-table.mdx new file mode 100644 index 00000000000..d9e76168c8f --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/error-schema-table.mdx @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
UNKNOWN_CHUNK200The requested chunk can't be found in a database +
    +
  • Check that the requested chunk is legit
  • +
  • + If the chunk had been produced more than 5 epochs ago, try to send + your request to an archival node +
  • +
+
INVALID_SHARD_ID200 + Provided shard_id does not exist + +
    +
  • + Provide shard_id for an existing shard +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested chunk is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/block-chunk/chunk-details/index.mdx b/docs/5.api/rpc/block-chunk/chunk-details/index.mdx new file mode 100644 index 00000000000..4fef95cbc7e --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/index.mdx @@ -0,0 +1,69 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import ChunkIdRequestJson from "./chunk-id/request-json.mdx"; +import ChunkIdRequestJs from "./chunk-id/request-js.mdx"; +import ChunkIdRequestBash from "./chunk-id/request-bash.mdx"; +import BlockIdShardIdRequestJson from "./block-id-shard-id/request-json.mdx"; +import BlockIdShardIdRequestJs from "./block-id-shard-id/request-js.mdx"; +import BlockIdShardIdRequestBash from "./block-id-shard-id/request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## Chunk Details {#chunk-details} + +> Returns details of a specific chunk. You can run a [block details](/api/rpc/block-chunk#block-details) +> query to get a valid chunk hash. + +- method: `chunk` +- params: + - `chunk_id` _OR_ [`block_id`, `shard_id`](/api/rpc/setup#using-block_id-param) + +`chunk_id` example: + + + + + + + + + + + + }> + + + + +`[block_id, shard_id]` example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong?? {#what-could-go-wrong-2} + + + +Here is the exhaustive list of the error variants that can be returned by `chunk` method: + + diff --git a/docs/5.api/rpc/block-chunk/chunk-details/response-json.mdx b/docs/5.api/rpc/block-chunk/chunk-details/response-json.mdx new file mode 100644 index 00000000000..74715fc67c0 --- /dev/null +++ b/docs/5.api/rpc/block-chunk/chunk-details/response-json.mdx @@ -0,0 +1,58 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "author": "kiln.pool.f863973.m0", + "header": { + "balance_burnt": "0", + "bandwidth_requests": null, + "chunk_hash": "CzPafxtJmM1FnRoasKWAVhceJzZzkz9RKUBQQ4kY9V1v", + "congestion_info": { + "allowed_shard": 1, + "buffered_receipts_gas": "0", + "delayed_receipts_gas": "0", + "receipt_bytes": 0 + }, + "encoded_length": 308, + "encoded_merkle_root": "6z9JwwtVfS5nRKcKeJxgzThRRs2wCNvbH88T3cuARe6W", + "gas_limit": 1000000000000000, + "gas_used": 0, + "height_created": 187310138, + "height_included": 187310138, + "outcome_root": "11111111111111111111111111111111", + "outgoing_receipts_root": "AChfy3dXeJjgD2w5zXkUTFb6w8kg3AYGnyyjsvc7hXLv", + "prev_block_hash": "Wj6B3RTv73EWDNbSammRDeA9315RaPyRrJYmiP4nG4X", + "prev_state_root": "cRMk2zd2bWC1oBfGowgMTpqW9L5SNG2FeE72yT1wpQA", + "rent_paid": "0", + "shard_id": 0, + "signature": "ed25519:L1iCopW8gY5rqwfuZT8Y3bHHXvuvWT87X9rwdY6LmFi8LGZdMhj2CkQCXLGrzdfYXD8B54wPTM9TqJAHcKfFDyW", + "tx_root": "CMwUsP8q4DTBUYxXm12jVwC8xTD8L1T1n3jdKLQVh6bm", + "validator_proposals": [], + "validator_reward": "0" + }, + "receipts": [], + "transactions": [ + { + "actions": [ + { + "FunctionCall": { + "args": "eyJyZWNvcmRfaWQiOjEsInJlY29yZCI6IkhlbGxvLCBOZWFyIFByb3RvY29sISJ9", + "deposit": "0", + "gas": 50000000000000, + "method_name": "write_record" + } + } + ], + "hash": "J3KbUXF9YPu2eGnbDCACxGvmMDZMdP7acGYhVLHGu9y2", + "nonce": 187309654000001, + "priority_fee": 0, + "public_key": "ed25519:EddTahJwZpJjYPPmat7DBm1m2vdrFBzVv7e3T4hzkENd", + "receiver_id": "contract.rpc-examples.testnet", + "signature": "ed25519:3opUQgg5eNQmE2LJ8zJiitBAVLDFR3svk8LC5VtVGorQuq8jWLocKAt7B4xb6n7DhH8zSVCWcRRrmVL9f1wHiVXa", + "signer_id": "account.rpc-examples.testnet" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts.md b/docs/5.api/rpc/contracts.md index c01fa750791..1bc8a847398 100644 --- a/docs/5.api/rpc/contracts.md +++ b/docs/5.api/rpc/contracts.md @@ -3,1690 +3,28 @@ id: contracts title: Accounts / Contracts --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import ViewAccount from './contracts/view-account/index.mdx'; +import ViewAccountChanges from './contracts/view-account-changes/index.mdx'; +import ViewContractCode from './contracts/view-contract-code/index.mdx'; +import ViewContractState from './contracts/view-contract-state/index.mdx'; +import ViewContractStateChanges from './contracts/view-contract-state-changes/index.mdx'; +import ViewContractCodeChanges from './contracts/view-contract-code-changes/index.mdx'; +import CallAContractFunction from './contracts/call-a-contract-function/index.mdx'; The RPC API enables you to view details about accounts and contracts as well as perform contract calls. --- - -## View account {#view-account} - -> Returns basic account information. - -- method: `query` -- params: - - `request_type`: `view_account` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: _`"example.testnet"`_ - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_account", - "finality": "final", - "account_id": "nearkat.testnet" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "view_account", - finality: "final", - account_id: "nearkat.testnet", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "view_account", - "finality": "final", - "account_id": "nearkat.testnet" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "amount": "399992611103597728750000000", - "locked": "0", - "code_hash": "11111111111111111111111111111111", - "storage_usage": 642, - "storage_paid_at": 0, - "block_height": 17795474, - "block_hash": "9MjpcnwW3TSdzGweNfPbkx8M74q1XzUcT1PAN8G5bNDz" - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `view_account` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
UNAVAILABLE_SHARD200The node was unable to find the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View account changes {#view-account-changes} - -> Returns account changes from transactions in a given account. - -- method: `EXPERIMENTAL_changes` -- params: - - `changes_type`: `account_changes` - - `account_ids`: [`"example.testnet"`] - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes", - "params": { - "changes_type": "account_changes", - "account_ids": ["your_account.testnet"], - "block_id": 19703467 - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes({ - changes_type: "account_changes", - account_ids: ["nearkat.testnet"], - block_id: 19703467, -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes \ - params:='{ - "changes_type": "account_changes", - "account_ids": ["your_account.testnet"], - "block_id": 19703467 - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "6xsfPSG89s6fCMShxxxQTP6D4ZHM9xkGCgubayTDRzAP", - "changes": [ - { - "cause": { - "type": "transaction_processing", - "tx_hash": "HLvxLKFM7gohFSqXPp5SpyydNEVpAno352qJJbnddsz3" - }, - "type": "account_update", - "change": { - "account_id": "your_account.testnet", - "amount": "499999959035075000000000000", - "locked": "0", - "code_hash": "11111111111111111111111111111111", - "storage_usage": 182, - "storage_paid_at": 0 - } - }, - { - "cause": { - "type": "receipt_processing", - "receipt_hash": "CPenN1dp4DNKnb9LiL5hkPmu1WiKLMuM7msDjEZwDmwa" - }, - "type": "account_update", - "change": { - "account_id": "your_account.testnet", - "amount": "499999959035075000000000000", - "locked": "0", - "code_hash": "11111111111111111111111111111111", - "storage_usage": 264, - "storage_paid_at": 0 - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong-1} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View contract code {#view-contract-code} - -> Returns the contract code (Wasm binary) deployed to the account. Please note that the returned code will be encoded in base64. - -- method: `query` -- params: - - `request_type`: `view_code` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: `"guest-book.testnet"`, - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_code", - "finality": "final", - "account_id": "guest-book.testnet" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "view_code", - finality: "final", - account_id: "guest-book.testnet", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "view_code", - "finality": "final", - "account_id": "guest-book.testnet" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "code_base64": "47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", - "hash": "7KoFshMQkdyo5iTx8P2LbLu9jQpxRn24d27FrKShNVXs", - "block_height": 17814234, - "block_hash": "GT1D8nweVQU1zyCUv399x8vDv2ogVq71w17MyR66hXBB" - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong-2} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `view_code` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
NO_CONTRACT_CODE200The account does not have any contract deployed on it -
    -
  • Use different account
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
UNAVAILABLE_SHARD200The node was unable to find the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View contract state {#view-contract-state} - -> Returns the state (key value pairs) of a contract based on the key prefix (base64 encoded). Pass an empty string for `prefix_base64` if you would like to return the entire state. Please note that the returned state will be base64 encoded as well. - -- method: `query` -- params: - - `request_type`: `view_state` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: `"guest-book.testnet"`, - - `prefix_base64`: `""` - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "view_state", - "finality": "final", - "account_id": "guest-book.testnet", - "prefix_base64": "" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "view_state", - finality: "final", - account_id: "guest-book.testnet", - prefix_base64: "", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "view_state", - "finality": "final", - "account_id": "guest-book.testnet", - "prefix_base64": "" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "values": [ - { - "key": "bTo6MA==", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJqb3NoZm9yZC50ZXN0bmV0IiwidGV4dCI6ImhlbGxvIn0=", - "proof": [] - }, - { - "key": "bTo6MQ==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiY2hhZG9oIiwidGV4dCI6ImhlbGxvIGVyeWJvZHkifQ==", - "proof": [] - }, - { - "key": "bTo6MTA=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoic2F0b3NoaWYudGVzdG5ldCIsInRleHQiOiJIaWxsbyEifQ==", - "proof": [] - }, - { - "key": "bTo6MTE=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidmFsZW50aW5lc29rb2wudGVzdG5ldCIsInRleHQiOiJIaSEifQ==", - "proof": [] - }, - { - "key": "bTo6MTI=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJobngudGVzdG5ldCIsInRleHQiOiJoZWxsbyJ9", - "proof": [] - }, - { - "key": "bTo6MTM=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJobngudGVzdG5ldCIsInRleHQiOiJzZCJ9", - "proof": [] - }, - { - "key": "bTo6MTQ=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiamdoZy50ZXN0bmV0IiwidGV4dCI6IktoZyJ9", - "proof": [] - }, - { - "key": "bTo6MTU=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiYWNjb3VudC50ZXN0bmV0IiwidGV4dCI6IldoZW4gSUNPPyJ9", - "proof": [] - }, - { - "key": "bTo6MTY=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiYWNjb3VudC50ZXN0bmV0IiwidGV4dCI6IlRlc3QgMiJ9", - "proof": [] - }, - { - "key": "bTo6MTc=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidGVzdC1kcm9wLTEwLnRlc3RuZXQiLCJ0ZXh0IjoiRnJlZSBtZXNzYWdlcyBhcmUgdGhlIGJlc3QifQ==", - "proof": [] - }, - { - "key": "bTo6MTg=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidGVzdC1kcm9wLTEwLnRlc3RuZXQiLCJ0ZXh0IjoiV2hlbiBJQ08/In0=", - "proof": [] - }, - { - "key": "bTo6MTk=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidGVzdC1kcm9wLTEwLnRlc3RuZXQiLCJ0ZXh0IjoiV2hlbiBJQ08/In0=", - "proof": [] - }, - { - "key": "bTo6Mg==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoibnVsbCIsInRleHQiOiJ1bmRlZmluZWQifQ==", - "proof": [] - }, - { - "key": "bTo6MjA=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidGVzdC04NDEudGVzdG5ldCIsInRleHQiOiJXaGVuIElDTz8ifQ==", - "proof": [] - }, - { - "key": "bTo6MjE=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidGVzdC04NDEudGVzdG5ldCIsInRleHQiOiJoZXkgaGV5IGhleSJ9", - "proof": [] - }, - { - "key": "bTo6MjI=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiam9zaGZvcmQudGVzdG5ldCIsInRleHQiOiJoaSJ9", - "proof": [] - }, - { - "key": "bTo6MjM=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiam9zaGZvcmQudGVzdG5ldCIsInRleHQiOiJoaSB4MiJ9", - "proof": [] - }, - { - "key": "bTo6MjQ=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoibWFzdGVydGh5c2VsZi50ZXN0bmV0IiwidGV4dCI6ImhhbmRzaGFrZS5oYWNrbWVkb21haW4vICJ9", - "proof": [] - }, - { - "key": "bTo6MjU=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJtYXN0ZXJ0aHlzZWxmLnRlc3RuZXQiLCJ0ZXh0IjoiSGVsbG8gQ29zbW9zLCBob21lLmNvc21hdHJpeGNvbm5lY3Rpb25zLyJ9", - "proof": [] - }, - { - "key": "bTo6MjY=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJtYXN0ZXJ0aHlzZWxmLnRlc3RuZXQiLCJ0ZXh0IjoiYnVpbGQsIGJ1aWxkLCBidWlsZCBpIGNhbWUgdG8gYnVpbGQgYSBicmlkZ2UgaW4gUEVBQ0UsIHNvIGNvbWUgbGV0cyBidWlsZC4uLnNvbmcgYnkgXCJOYWhrbyBCZWFyXCIgIn0=", - "proof": [] - }, - { - "key": "bTo6Mjc=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJtYXN0ZXJ0aHlzZWxmLnRlc3RuZXQiLCJ0ZXh0IjoiYnVpbGQgYSBicmlkZ2UgKGh0dHBzOi8vd3d3Lmdvb2dsZS5jb20vdXJsP3NhPXQmcmN0PWomcT0mZXNyYz1zJnNvdXJjZT13ZWImY2Q9JmNhZD1yamEmdWFjdD04JnZlZD0yYWhVS0V3ajA0ZGlnMTlqckFoV05tbGtLSGR5X0FnUVEzeXd3QUhvRUNBVVFBZyZ1cmw9aHR0cHMlM0ElMkYlMkZ3d3cueW91dHViZS5jb20lMkZ3YXRjaCUzRnYlM0Rlb1RYNWZmOVplMCZ1c2c9QU92VmF3MFoxZzFIMkZzeF85d3FJSmg5RTk2UCkifQ==", - "proof": [] - }, - { - "key": "bTo6Mjg=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJtYXN0ZXJ0aHlzZWxmLnRlc3RuZXQiLCJ0ZXh0IjoiaHR0cDovL3RyaXBweS7wn42EbWFnaWMvIn0=", - "proof": [] - }, - { - "key": "bTo6Mjk=", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJtYXN0ZXJ0aHlzZWxmLnRlc3RuZXQiLCJ0ZXh0IjoiaHR0cDovL3VuaXRlLnJhaW5ib3d0cmliZXMvIn0=", - "proof": [] - }, - { - "key": "bTo6Mw==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiam9zaGZvcmQudGVzdG5ldCIsInRleHQiOiJobW1tbW1tIn0=", - "proof": [] - }, - { - "key": "bTo6MzA=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiZXhlbXBsYXJ5LnRlc3RuZXQiLCJ0ZXh0IjoiaGVsbG8ifQ==", - "proof": [] - }, - { - "key": "bTo6MzE=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiYWRpMjMudGVzdG5ldCIsInRleHQiOiJobW0ifQ==", - "proof": [] - }, - { - "key": "bTo6MzI=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiYWRpMjMudGVzdG5ldCIsInRleHQiOiJ3aGF0In0=", - "proof": [] - }, - { - "key": "bTo6MzM=", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoidmxhZGJhc2gudGVzdG5ldCIsInRleHQiOiJIaSJ9", - "proof": [] - }, - { - "key": "bTo6NA==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoibnVsbCIsInRleHQiOiIgIn0=", - "proof": [] - }, - { - "key": "bTo6NQ==", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJ0ZXN0YWNjb3VudDEudGVzdG5ldCIsInRleHQiOiJ0ZXN0In0=", - "proof": [] - }, - { - "key": "bTo6Ng==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiZXVnZW5ldGhlZHJlYW0iLCJ0ZXh0IjoibnVsbCJ9", - "proof": [] - }, - { - "key": "bTo6Nw==", - "value": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiZGVtby50ZXN0bmV0IiwidGV4dCI6Ikkgb25seSB3cml0ZSBmcmVlIG1lc3NhZ2VzLiJ9", - "proof": [] - }, - { - "key": "bTo6OA==", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJqb3NoZm9yZC50ZXN0bmV0IiwidGV4dCI6IkkgcHJlZmVyIHByZW1pdW0gbWVzc2FnZXMifQ==", - "proof": [] - }, - { - "key": "bTo6OQ==", - "value": "eyJwcmVtaXVtIjp0cnVlLCJzZW5kZXIiOiJuZXdsZWRnZXIzLnRlc3RuZXQiLCJ0ZXh0IjoiTGVkZ2VyIn0=", - "proof": [] - }, - { - "key": "bTpsZW4=", - "value": "MzQ=", - "proof": [] - } - ], - "proof": [], - "block_height": 17814234, - "block_hash": "GT1D8nweVQU1zyCUv399x8vDv2ogVq71w17MyR66hXBB" - }, - "id": "dontcare" -} -``` -

- -**Note**: Currently, the response includes a `proof` field directly in the -`result`, and a `proof` fields on each element of the `values` list. In -the future, the `result.proof` will be included only if the result is **not empty**, -and the `proof` field will be removed from all `values`. When parsing the result, you -should accept objects with or without these fields set. - -
- -> **Heads up** -> -> There is a limitation on default RPC nodes. You won't be able to get the contract state if it is too big. The default limit of for contract state is 50kb of state size. You're able to change the limits if you [run your own RPC node](https://near-nodes.io/validator/compile-and-run-a-node) with adjusted `trie_viewer_state_size_limit` value in `config.json` - -#### What Could Go Wrong? {#what-could-go-wrong-3} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `view_state` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
NO_CONTRACT_CODE200The account does not have any contract deployed on it -
    -
  • Query and account with contract deployed
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
TOO_LARGE_CONTRACT_STATE200The requested contract state is too large to be returned from this node (the default limit is 50kb of state size) -
    -
  • Send the request to a node with larger limits in order to view the requested state
  • -
  • Spin up your own node where you can increase the limits to view state
  • -
-
UNAVAILABLE_SHARD200The node was unable to find the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View contract state changes {#view-contract-state-changes} - -> Returns the state change details of a contract based on the key prefix (encoded to base64). Pass an empty string for this param if you would like to return all state changes. - -- method: `EXPERIMENTAL_changes` -- params: - - `changes_type`: `data_changes` - - `account_ids`: `["example.testnet"]`, - - `key_prefix_base64`: `"base64 encoded key value"`, - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes", - "params": { - "changes_type": "data_changes", - "account_ids": ["guest-book.testnet"], - "key_prefix_base64": "", - "block_id": 19450732 - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes({ - changes_type: "data_changes", - account_ids: ["guest-book.testnet"], - key_prefix_base64: "", - block_id: 19450732, -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes \ - params:='{ - "changes_type": "data_changes", - "account_ids": ["guest-book.testnet"], - "key_prefix_base64": "", - "block_id": 19450732 - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "6U8Yd4JFZwJUNfqkD4KaKgTKmpNSmVRTSggpjmsRWdKY", - "changes": [ - { - "cause": { - "type": "receipt_processing", - "receipt_hash": "9ewznXgs2t7vRCssxW4thgaiwggnMagKybZ7ryLNTT2z" - }, - "type": "data_update", - "change": { - "account_id": "guest-book.testnet", - "key_base64": "bTo6Mzk=", - "value_base64": "eyJwcmVtaXVtIjpmYWxzZSwic2VuZGVyIjoiZmhyLnRlc3RuZXQiLCJ0ZXh0IjoiSGkifQ==" - } - }, - { - "cause": { - "type": "receipt_processing", - "receipt_hash": "9ewznXgs2t7vRCssxW4thgaiwggnMagKybZ7ryLNTT2z" - }, - "type": "data_update", - "change": { - "account_id": "guest-book.testnet", - "key_base64": "bTpsZW4=", - "value_base64": "NDA=" - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong-4} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## View contract code changes {#view-contract-code-changes} - -> Returns code changes made when deploying a contract. Change is returned is a base64 encoded WASM file. - -- method: `EXPERIMENTAL_changes` -- params: - - `changes_type`: `contract_code_changes` - - `account_ids`: `["example.testnet"]`, - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_changes", - "params": { - "changes_type": "contract_code_changes", - "account_ids": ["dev-1602714453032-7566969"], - "block_id": 20046655 - } -} -``` - - - - -```js -const response = await near.connection.provider.experimental_changes({ - changes_type: "contract_code_changes", - account_ids: ["dev-1602714453032-7566969"], - block_id: 20046655, -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_changes \ - params:='{ - "changes_type": "contract_code_changes", - "account_ids": ["dev-1602714453032-7566969"], - "block_id": 20046655 - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "block_hash": "3yLNV5zdpzRJ8HP5xTXcF7jdFxuHnmKNUwWcok4616WZ", - "changes": [ - { - "cause": { - "type": "receipt_processing", - "receipt_hash": "CEm3NNaNdu9cijh9NvZMM1srbtEYSsBVwGbZxFQYKt5B" - }, - "type": "contract_code_update", - "change": { - "account_id": "dev-1602714453032-7566969", - "code_base64": "AGFzbQEAAAABpAM3YAF/AGAAAX9gAn9+AGADf35+AGAEf35+fgF+YAZ/fn5+fn4BfmADf35+AX5gAn9+AX5gAn9/AX9gAn9/AGADf39/AX9gAX8BfmACfn4AYAF+AX5gAX4AYAABfmADfn5+AGAAAGAIfn5+fn5+fn4BfmAJfn5+fn5+fn5+AX5gAn5+AX5gA35+fgF+YAd+fn5+fn5+AGAEfn5+fgBgCX5+fn5+fn5+fgBgBX5+fn5+AX5gA39/fwBgAX8Bf2ACf3wAYAR/f39+AGAFf39/fn8AYAV/f39/fwBgBH9/f38AYAN/f38BfmADf39+AGACf38BfmAFf39/f38Bf2AEf39/fwF/YAZ/f39/f38AYAV/f35/fwBgBH9+f38Bf2ACf34Bf2AHf35+f39+fwBgBX9/f39+AGAEf35+fgBgCX9+fn5+fn5+fgF+YAp/fn5+fn5+fn5+AX5gCH9+fn5+fn5+AGAFf35+fn4AYAp/fn5+fn5+fn5+AGAHf39/f39/fwBgBH98f38Bf2AGf39/f39..." - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong-5} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
NOT_SYNCED_YET200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Call a contract function {#call-a-contract-function} -> Allows you to call a contract method as a [view function](../../tools/near-cli#contract). - -- method: `query` -- params: - - `request_type`: `call_function` - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - - `account_id`: _`"example.testnet"`_ - - `method_name`: `name_of_a_example.testnet_method` (example [`view` methods](https://github.com/near/core-contracts/blob/master/staking-pool/src/lib.rs#L317) - - `args_base64`: `method_arguments_base_64_encoded` - -Example (`get_num`): - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "call_function", - "finality": "final", - "account_id": "dev-1588039999690", - "method_name": "get_num", - "args_base64": "e30=" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "call_function", - finality: "final", - account_id: "dev-1588039999690", - method_name: "get_num", - args_base64: "e30=", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "call_function", - "finality": "final", - "account_id": "dev-1588039999690", - "method_name": "get_num", - "args_base64": "e30=" - }' -``` - - - - -Example (`get_account_staked_balance`): - -The `args_base64` in this example is decoded as `{"account_id":"dev-1588039999690"}`. The `account_id` would likely be the validator and not the same account for this particular view function. - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "query", - "params": { - "request_type": "call_function", - "finality": "final", - "account_id": "dev-1588039999690", - "method_name": "get_account_staked_balance", - "args_base64": "eyJhY2NvdW50X2lkIjoiZGV2LTE1ODgwMzk5OTk2OTAifQ==" - } -} -``` - - - - -```js -const response = await near.connection.provider.query({ - request_type: "call_function", - finality: "final", - account_id: "dev-1588039999690", - method_name: "get_account_staked_balance", - args_base64: "eyJhY2NvdW50X2lkIjoiZGV2LTE1ODgwMzk5OTk2OTAifQ==", -}); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=query \ - params:='{ - "request_type": "call_function", - "finality": "final", - "account_id": "dev-1588039999690", - "method_name": "get_account_staked_balance", - "args_base64": "eyJhY2NvdW50X2lkIjoiZGV2LTE1ODgwMzk5OTk2OTAifQ==" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "result": [48], - "logs": [], - "block_height": 17817336, - "block_hash": "4qkA4sUUG8opjH5Q9bL5mWJTnfR4ech879Db1BZXbx6P" - }, - "id": "dontcare" -} -``` - -**Note**: `[48]` is an array of bytes, to be specific it is an ASCII code of `0`.`near-sdk-rs` and `near-sdk-js` return JSON-serialized results. - -

-
- -#### What Could Go Wrong? {#what-could-go-wrong-6} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `call_function` request type: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INVALID_ACCOUNT200The requested account_id is invalid -
    -
  • Provide a valid account_id
  • -
-
UNKNOWN_ACCOUNT200The requested account_id has not been found while viewing since the account has not been created or has been already deleted -
    -
  • Check the account_id
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
NO_CONTRACT_CODE200The requested contract_code has not been found while viewing -
    -
  • Check the public_key
  • -
  • Specify a different block or retry if you request the latest state
  • -
-
CONTRACT_EXECUTION_ERROR200The execution of the view function call failed (crashed, run out of the default 200 TGas limit, etc) -
    -
  • Check error.cause.info for more details
  • -
-
UNAVAILABLE_SHARD200The node was unable to find the requested data because it does not track the shard where data is present -
    -
  • Send a request to a different node which might track the shard
  • -
-
NO_SYNCED_BLOCKS200The node is still syncing and the requested block is not in the database yet -
    -
  • Wait until the node finish syncing
  • -
  • Send a request to a different node which is synced
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-bash.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-bash.mdx new file mode 100644 index 00000000000..7c7db5fa511 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-bash.mdx @@ -0,0 +1,13 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "call_function", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "method_name": "get_record", + "args_base64": "ewogICJyZWNvcmRfaWQiOiAxCn0=" + }' +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-js.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-js.mdx new file mode 100644 index 00000000000..f07a7f7d0bf --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-js.mdx @@ -0,0 +1,9 @@ +```js +const response = await near.connection.provider.query({ + request_type: "call_function", + finality: "final", + account_id: "contract.rpc-examples.testnet", + method_name: "get_record", + args_base64: "ewogICJyZWNvcmRfaWQiOiAxCn0=", +}); +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-json.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-json.mdx new file mode 100644 index 00000000000..120aaada8d1 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/request-json.mdx @@ -0,0 +1,14 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "call_function", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "method_name": "get_record", + "args_base64": "ewogICJyZWNvcmRfaWQiOiAxCn0=" + } +} +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/response-json.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/response-json.mdx new file mode 100644 index 00000000000..c5934a80777 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/complex-call/response-json.mdx @@ -0,0 +1,15 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "8Gp8x1ZcanL3C2ris9rgk1nY8v6MuickLWeM6Gj2jGKs", + "block_height": 187445443, + "logs": [], + "result": [ + 34, 72, 101, 108, 108, 111, 44, 32, 78, 101, 97, 114, 32, 80, 114, 111, + 116, 111, 99, 111, 108, 33, 34 + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/error-schema-table.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/error-schema-table.mdx new file mode 100644 index 00000000000..1595af48dcc --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/error-schema-table.mdx @@ -0,0 +1,164 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
NO_CONTRACT_CODE200 + The requested contract_code has not been found while + viewing + +
    +
  • + Check the public_key +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
CONTRACT_EXECUTION_ERROR200 + The execution of the view function call failed (crashed, run out of the + default 200 TGas limit, etc) + +
    +
  • + Check error.cause.info for more details +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to find the requested data because it does not track + the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/index.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/index.mdx new file mode 100644 index 00000000000..5ada5869d23 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/index.mdx @@ -0,0 +1,97 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import SimpleCallRequestJson from "./simple-call/request-json.mdx"; +import SimpleCallRequestJs from "./simple-call/request-js.mdx"; +import SimpleCallRequestBash from "./simple-call/request-bash.mdx"; +import SimpleCallResponseJson from "./simple-call/response-json.mdx"; +import ComplexCallRequestJson from "./complex-call/request-json.mdx"; +import ComplexCallRequestJs from "./complex-call/request-js.mdx"; +import ComplexCallRequestBash from "./complex-call/request-bash.mdx"; +import ComplexCallResponseJson from "./complex-call/response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Call a contract function {#call-a-contract-function} + +> Allows you to call a contract method as a [view function](../../tools/near-cli#contract). + +- method: `query` +- params: + - `request_type`: `call_function` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: _`"example.testnet"`_ + - `method_name`: `get_method_name` (example [`view` methods](https://github.com/near/core-contracts/blob/master/staking-pool/src/lib.rs#L317)) + - `args_base64`: `method_arguments_base_64_encoded` + +`get_greeting` example: + + + + + + + + + + + + }> + + + + +
+ Example response: +

+ + **Note**: `[34, 71, ..., 33, 34]` + is an array of bytes, to be specific it is an ASCII code of + `"Greetings from NEAR Protocol!"`. `near-sdk-rs` and `near-sdk-js` + return JSON-serialized results. +

+
+ +--- + +`get_record` example : + +The `args_base64` in this example can be decoded as +``` json +{ + "record_id": 1 +} +``` + + + + + + + + + + + + }> + + + + +
+ Example response: +

+ + **Note**: `[34, 72, ..., 108, 33, 34]` is an array of bytes, to be specific it is an ASCII code of + `"Hello, Near Protocol!"`. `near-sdk-rs` and `near-sdk-js` return JSON-serialized results. +

+
+ +#### What Could Go Wrong? {#what-could-go-wrong-6} + + + +Here is the exhaustive list of the error variants that can be returned by `call_function` request type: + + diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-bash.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-bash.mdx new file mode 100644 index 00000000000..86992ef8c9a --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-bash.mdx @@ -0,0 +1,14 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "call_function", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "method_name": "get_greeting", + "args_base64": "" + }' +``` + diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-js.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-js.mdx new file mode 100644 index 00000000000..412625787e6 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-js.mdx @@ -0,0 +1,9 @@ +```js +const response = await near.connection.provider.query({ + request_type: "call_function", + finality: "final", + account_id: "contract.rpc-examples.testnet", + method_name: "get_greeting", + args_base64: "", +}); +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-json.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-json.mdx new file mode 100644 index 00000000000..d35e05f9ee1 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/request-json.mdx @@ -0,0 +1,14 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "call_function", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "method_name": "get_greeting", + "args_base64": "" + } +} +``` diff --git a/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/response-json.mdx b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/response-json.mdx new file mode 100644 index 00000000000..e74c35ac089 --- /dev/null +++ b/docs/5.api/rpc/contracts/call-a-contract-function/simple-call/response-json.mdx @@ -0,0 +1,15 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "GTZdXfNmnL6TkJFdBeVMHCadgLuKChVfRNCSVsEQoJ7L", + "block_height": 187444191, + "logs": [], + "result": [ + 34, 71, 114, 101, 101, 116, 105, 110, 103, 115, 32, 102, 114, 111, 109, + 32, 78, 69, 65, 82, 32, 80, 114, 111, 116, 111, 99, 111, 108, 33, 34 + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-account-changes/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-account-changes/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-account-changes/index.mdx b/docs/5.api/rpc/contracts/view-account-changes/index.mdx new file mode 100644 index 00000000000..b7985f9116b --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/index.mdx @@ -0,0 +1,51 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View account changes {#view-account-changes} + +> Returns account changes from transactions in a given account. + +- method: `EXPERIMENTAL_changes` +- params: + - `changes_type`: `account_changes` + - `account_ids`: [`"example.testnet"`] + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong-1} + + + +Here is the exhaustive list of the error variants that can be returned by +`EXPERIMENTAL_changes` method: + + diff --git a/docs/5.api/rpc/contracts/view-account-changes/request-bash.mdx b/docs/5.api/rpc/contracts/view-account-changes/request-bash.mdx new file mode 100644 index 00000000000..69aacbefff2 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes \ + params:='{ + "changes_type": "account_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "block_id": 187310139 + }' +``` diff --git a/docs/5.api/rpc/contracts/view-account-changes/request-js.mdx b/docs/5.api/rpc/contracts/view-account-changes/request-js.mdx new file mode 100644 index 00000000000..060e7f1ff8d --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/request-js.mdx @@ -0,0 +1,6 @@ +```js +const response = await near.connection.provider.accountChanges( + ["contract.rpc-examples.testnet"], + { blockId: 187310139 }, +); +``` diff --git a/docs/5.api/rpc/contracts/view-account-changes/request-json.mdx b/docs/5.api/rpc/contracts/view-account-changes/request-json.mdx new file mode 100644 index 00000000000..a8043c82c3f --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes", + "params": { + "changes_type": "account_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "block_id": 187310139 + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-account-changes/response-json.mdx b/docs/5.api/rpc/contracts/view-account-changes/response-json.mdx new file mode 100644 index 00000000000..54943e53e47 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account-changes/response-json.mdx @@ -0,0 +1,41 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "8woqfx6kyjgfgU1S2L6Kur27h5jpBtDTmG8vQ8vpAUut", + "changes": [ + { + "cause": { + "receipt_hash": "FseKd4rmjPSAuEz9zh9b5PfUS4jJV4rB6XkeHwVkyXkk", + "type": "receipt_processing" + }, + "change": { + "account_id": "contract.rpc-examples.testnet", + "amount": "4999184472524996100000000", + "code_hash": "GVvBFWDPNmomMwXH4LvQW2cRaZJ8N6gxsdBhbJ8ReVJf", + "locked": "0", + "storage_paid_at": 0, + "storage_usage": 81621 + }, + "type": "account_update" + }, + { + "cause": { + "receipt_hash": "FseKd4rmjPSAuEz9zh9b5PfUS4jJV4rB6XkeHwVkyXkk", + "type": "action_receipt_gas_reward" + }, + "change": { + "account_id": "contract.rpc-examples.testnet", + "amount": "4999212038891301300000000", + "code_hash": "GVvBFWDPNmomMwXH4LvQW2cRaZJ8N6gxsdBhbJ8ReVJf", + "locked": "0", + "storage_paid_at": 0, + "storage_usage": 81621 + }, + "type": "account_update" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-account/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-account/error-schema-table.mdx new file mode 100644 index 00000000000..24e4e44fce0 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/error-schema-table.mdx @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to find the requested data because it does not track + the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-account/index.mdx b/docs/5.api/rpc/contracts/view-account/index.mdx new file mode 100644 index 00000000000..aa108a5ac7e --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/index.mdx @@ -0,0 +1,50 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View account {#view-account} + +> Returns basic account information. + +- method: `query` +- params: + - `request_type`: `view_account` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: _`"example.testnet"`_ + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `view_account` request type: + + diff --git a/docs/5.api/rpc/contracts/view-account/request-bash.mdx b/docs/5.api/rpc/contracts/view-account/request-bash.mdx new file mode 100644 index 00000000000..e547acd8d5a --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "view_account", + "finality": "final", + "account_id": "account.rpc-examples.testnet" + }' +``` diff --git a/docs/5.api/rpc/contracts/view-account/request-js.mdx b/docs/5.api/rpc/contracts/view-account/request-js.mdx new file mode 100644 index 00000000000..23fdd52ac1d --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/request-js.mdx @@ -0,0 +1,7 @@ +```js +const response = await near.connection.provider.query({ + request_type: "view_account", + finality: "final", + account_id: "account.rpc-examples.testnet", +}); +``` diff --git a/docs/5.api/rpc/contracts/view-account/request-json.mdx b/docs/5.api/rpc/contracts/view-account/request-json.mdx new file mode 100644 index 00000000000..bab7f648801 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "view_account", + "finality": "final", + "account_id": "account.rpc-examples.testnet" + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-account/response-json.mdx b/docs/5.api/rpc/contracts/view-account/response-json.mdx new file mode 100644 index 00000000000..e6286f998ed --- /dev/null +++ b/docs/5.api/rpc/contracts/view-account/response-json.mdx @@ -0,0 +1,15 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "amount": "999788200694421800000000", + "block_hash": "56xEo2LorUFVNbkFhCncFSWNiobdp1kzm14nZ47b5JVW", + "block_height": 187440904, + "code_hash": "11111111111111111111111111111111", + "locked": "0", + "storage_paid_at": 0, + "storage_usage": 410 + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/index.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/index.mdx new file mode 100644 index 00000000000..13c39330f96 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/index.mdx @@ -0,0 +1,51 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View contract code changes {#view-contract-code-changes} + +> Returns code changes made when deploying a contract. Change is returned is a +> base64 encoded WASM file. + +- method: `EXPERIMENTAL_changes` +- params: + - `changes_type`: `contract_code_changes` + - `account_ids`: `["example.testnet"]`, + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong-5} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: + + diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/request-bash.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/request-bash.mdx new file mode 100644 index 00000000000..35b3df1cb5e --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes \ + params:='{ + "changes_type": "contract_code_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "block_id": 187309439 + }' +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/request-js.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/request-js.mdx new file mode 100644 index 00000000000..a90807b4010 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/request-js.mdx @@ -0,0 +1,6 @@ +```js +const response = await near.connection.provider.contractCodeChanges( + ["contract.rpc-examples.testnet"], + { blockId: 187309439 }, +); +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/request-json.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/request-json.mdx new file mode 100644 index 00000000000..c8f7488fac5 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes", + "params": { + "changes_type": "contract_code_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "block_id": 187309439 + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code-changes/response-json.mdx b/docs/5.api/rpc/contracts/view-contract-code-changes/response-json.mdx new file mode 100644 index 00000000000..984b5b31653 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code-changes/response-json.mdx @@ -0,0 +1,22 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "D1ZY3y51Z2v5tXq2nZPmXHgA3zZsPBzbtwHXjCvAEuLV", + "changes": [ + { + "cause": { + "receipt_hash": "AR4cxtxc52WfnZcGEZHmPfQ1Dk3vQNb7vjSyicykfJWZ", + "type": "receipt_processing" + }, + "change": { + "account_id": "contract.rpc-examples.testnet", + "code_base64": "AGFzbQEAAAABugEbYAJ/fwF/YAN/f38Bf2ACf38AYAN/..." + }, + "type": "contract_code_update" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-contract-code/error-schema-table.mdx new file mode 100644 index 00000000000..3ba0ec9d5db --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/error-schema-table.mdx @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
NO_CONTRACT_CODE200 + The account does not have any contract deployed on it + +
    +
  • Use different account
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to find the requested data because it does not track + the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-contract-code/index.mdx b/docs/5.api/rpc/contracts/view-contract-code/index.mdx new file mode 100644 index 00000000000..4373fc204c7 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/index.mdx @@ -0,0 +1,51 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View contract code {#view-contract-code} + +> Returns the contract code (Wasm binary) deployed to the account. +> Please note that the returned code will be encoded in base64. + +- method: `query` +- params: + - `request_type`: `view_code` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: `"example.testnet"`, + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong-2} + + + +Here is the exhaustive list of the error variants that can be returned by `view_code` request type: + + diff --git a/docs/5.api/rpc/contracts/view-contract-code/request-bash.mdx b/docs/5.api/rpc/contracts/view-contract-code/request-bash.mdx new file mode 100644 index 00000000000..038a9c5eafd --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "view_code", + "finality": "final", + "account_id": "contract.rpc-examples.testnet" + }' +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code/request-js.mdx b/docs/5.api/rpc/contracts/view-contract-code/request-js.mdx new file mode 100644 index 00000000000..a11b4ede6a1 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/request-js.mdx @@ -0,0 +1,7 @@ +```js +const response = await near.connection.provider.query({ + request_type: "view_code", + finality: "final", + account_id: "contract.rpc-examples.testnet", +}); +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code/request-json.mdx b/docs/5.api/rpc/contracts/view-contract-code/request-json.mdx new file mode 100644 index 00000000000..8134a3820db --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "view_code", + "finality": "final", + "account_id": "contract.rpc-examples.testnet" + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-code/response-json.mdx b/docs/5.api/rpc/contracts/view-contract-code/response-json.mdx new file mode 100644 index 00000000000..d3d5f1d8763 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-code/response-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "bxucHpnP8VsiB3pLvA7DpBwri9x1DCZxVfBNkrdWbqn", + "block_height": 187441984, + "code_base64": "AGFzbQEAAAABugEbYAJ/fwF/YAN/f38Bf2ACf38AYAN/...", + "hash": "GVvBFWDPNmomMwXH4LvQW2cRaZJ8N6gxsdBhbJ8ReVJf" + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/error-schema-table.mdx new file mode 100644 index 00000000000..bedfef792ef --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/error-schema-table.mdx @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
NOT_SYNCED_YET200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/index.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/index.mdx new file mode 100644 index 00000000000..3888b9ecb4f --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/index.mdx @@ -0,0 +1,53 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View contract state changes {#view-contract-state-changes} + +> Returns the state change details of a contract based on the key prefix +> (encoded to base64). Pass an empty string for this param if you would like +> to return all state changes. + +- method: `EXPERIMENTAL_changes` +- params: + - `changes_type`: `data_changes` + - `account_ids`: `["example.testnet"]`, + - `key_prefix_base64`: `"base64 encoded key value"`, + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What Could Go Wrong? {#what-could-go-wrong-4} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_changes` method: + + diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/request-bash.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/request-bash.mdx new file mode 100644 index 00000000000..cc72e7835fb --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/request-bash.mdx @@ -0,0 +1,12 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_changes \ + params:='{ + "changes_type": "data_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "key_prefix_base64": "", + "block_id": 187310139 + }' +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/request-js.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/request-js.mdx new file mode 100644 index 00000000000..994440ec45c --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/request-js.mdx @@ -0,0 +1,6 @@ +```js +const response = await near.connection.provider.contractStateChanges( + ["contract.rpc-examples.testnet"], + { blockId: 187310139 }, +); +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/request-json.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/request-json.mdx new file mode 100644 index 00000000000..89a35337427 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/request-json.mdx @@ -0,0 +1,13 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_changes", + "params": { + "changes_type": "data_changes", + "account_ids": ["contract.rpc-examples.testnet"], + "key_prefix_base64": "", + "block_id": 187310139 + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state-changes/response-json.mdx b/docs/5.api/rpc/contracts/view-contract-state-changes/response-json.mdx new file mode 100644 index 00000000000..c2a7daec187 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state-changes/response-json.mdx @@ -0,0 +1,35 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "8woqfx6kyjgfgU1S2L6Kur27h5jpBtDTmG8vQ8vpAUut", + "changes": [ + { + "cause": { + "receipt_hash": "FseKd4rmjPSAuEz9zh9b5PfUS4jJV4rB6XkeHwVkyXkk", + "type": "receipt_processing" + }, + "change": { + "account_id": "contract.rpc-examples.testnet", + "key_base64": "U1RBVEU=", + "value_base64": "HQAAAEdyZWV0aW5ncyBmcm9tIE5FQVIgUHJvdG9jb2whAQAAAHI=" + }, + "type": "data_update" + }, + { + "cause": { + "receipt_hash": "FseKd4rmjPSAuEz9zh9b5PfUS4jJV4rB6XkeHwVkyXkk", + "type": "receipt_processing" + }, + "change": { + "account_id": "contract.rpc-examples.testnet", + "key_base64": "cgEAAAAAAAAA", + "value_base64": "FQAAAEhlbGxvLCBOZWFyIFByb3RvY29sIQ==" + }, + "type": "data_update" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state/error-schema-table.mdx b/docs/5.api/rpc/contracts/view-contract-state/error-schema-table.mdx new file mode 100644 index 00000000000..04cd7015bb8 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/error-schema-table.mdx @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INVALID_ACCOUNT200 + The requested account_id is invalid + +
    +
  • + Provide a valid account_id +
  • +
+
UNKNOWN_ACCOUNT200 + The requested account_id has not been found while viewing + since the account has not been created or has been already deleted + +
    +
  • + Check the account_id +
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
NO_CONTRACT_CODE200 + The account does not have any contract deployed on it + +
    +
  • Query and account with contract deployed
  • +
  • + Specify a different block or retry if you request the latest state +
  • +
+
TOO_LARGE_CONTRACT_STATE200 + The requested contract state is too large to be returned from this node + (the default limit is 50kb of state size) + +
    +
  • + Send the request to a node with larger limits in order to view the + requested state +
  • +
  • + Spin up your own node where you can increase the limits to view + state +
  • +
+
UNAVAILABLE_SHARD200 + The node was unable to find the requested data because it does not track + the shard where data is present + +
    +
  • + Send a request to a different node which might track the shard +
  • +
+
NO_SYNCED_BLOCKS200 + The node is still syncing and the requested block is not in the database + yet + +
    +
  • Wait until the node finish syncing
  • +
  • Send a request to a different node which is synced
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/contracts/view-contract-state/index.mdx b/docs/5.api/rpc/contracts/view-contract-state/index.mdx new file mode 100644 index 00000000000..b3c87f382e6 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/index.mdx @@ -0,0 +1,68 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## View contract state {#view-contract-state} + +> Returns the state (key value pairs) of a contract based on the key prefix +> (base64 encoded). Pass an empty string for `prefix_base64` if you would like +> to return the entire state. Please note that the returned state will be base64 +> encoded as well. + +- method: `query` +- params: + - `request_type`: `view_state` + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + - `account_id`: `"example.testnet"`, + - `prefix_base64`: `""` + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + + + **Note**: Currently, the response includes a `proof` field directly in the + `result`, and a `proof` fields on each element of the `values` list. In + the future, the `result.proof` will be included only if the result is **not empty**, + and the `proof` field will be removed from all `values`. When parsing the result, you + should accept objects with or without these fields set. +
+ +> **Heads up** +> +> There is a limitation on default RPC nodes. You won't be able to get the +> contract state if it is too big. The default limit of for contract state is 50kb +> of state size. You're able to change the limits if you +> [run your own RPC node](https://near-nodes.io/validator/compile-and-run-a-node) +> with adjusted `trie_viewer_state_size_limit` value in `config.json` + +#### What Could Go Wrong? {#what-could-go-wrong-3} + + + +Here is the exhaustive list of the error variants that can be returned by `view_state` request type: + + diff --git a/docs/5.api/rpc/contracts/view-contract-state/request-bash.mdx b/docs/5.api/rpc/contracts/view-contract-state/request-bash.mdx new file mode 100644 index 00000000000..1724eacc3ec --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/request-bash.mdx @@ -0,0 +1,12 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=query \ + params:='{ + "request_type": "view_state", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "prefix_base64": "" + }' +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state/request-js.mdx b/docs/5.api/rpc/contracts/view-contract-state/request-js.mdx new file mode 100644 index 00000000000..0a963caa040 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/request-js.mdx @@ -0,0 +1,8 @@ +```js +const response = await near.connection.provider.query({ + request_type: "view_state", + finality: "final", + account_id: "contract.rpc-examples.testnet", + prefix_base64: "", +}); +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state/request-json.mdx b/docs/5.api/rpc/contracts/view-contract-state/request-json.mdx new file mode 100644 index 00000000000..f2deceb72e0 --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/request-json.mdx @@ -0,0 +1,13 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "query", + "params": { + "request_type": "view_state", + "finality": "final", + "account_id": "contract.rpc-examples.testnet", + "prefix_base64": "" + } +} +``` diff --git a/docs/5.api/rpc/contracts/view-contract-state/response-json.mdx b/docs/5.api/rpc/contracts/view-contract-state/response-json.mdx new file mode 100644 index 00000000000..5ffdf5ab8cb --- /dev/null +++ b/docs/5.api/rpc/contracts/view-contract-state/response-json.mdx @@ -0,0 +1,20 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "block_hash": "GN5R7S8mMTEkUT1njWu9jARV29G7izVDjdSNs976BJVw", + "block_height": 187442491, + "values": [ + { + "key": "U1RBVEU=", + "value": "HQAAAEdyZWV0aW5ncyBmcm9tIE5FQVIgUHJvdG9jb2whAQAAAHI=" + }, + { + "key": "cgEAAAAAAAAA", + "value": "FQAAAEhlbGxvLCBOZWFyIFByb3RvY29sIQ==" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/gas.md b/docs/5.api/rpc/gas.md index 7a887152386..f94719b449d 100644 --- a/docs/5.api/rpc/gas.md +++ b/docs/5.api/rpc/gas.md @@ -3,214 +3,10 @@ id: gas title: Gas --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import GasPrice from './gas/gas-price/index.mdx'; The RPC API enables you to query the gas price for a specific block or hash. --- - -## Gas Price {#gas-price} - -> Returns gas price for a specific `block_height` or `block_hash`. -> -> - Using `[null]` will return the most recent block's gas price. - -- method: `gas_price` -- params: `[block_height]`, `["block_hash"]`, or `[null]` - -`[block_height]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "gas_price", - "params": [17824600] -} -``` - - - - -```js -const response = await near.connection.provider.gasPrice(17824600); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=gas_price params:='[17824600]' id=dontcare -``` - - - - -`["block_hash"]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "gas_price", - "params": ["AXa8CHDQSA8RdFCt12rtpFraVq4fDUgJbLPxwbaZcZrj"] -} -``` - - - - -```js -const response = await near.connection.provider.gasPrice( - "AXa8CHDQSA8RdFCt12rtpFraVq4fDUgJbLPxwbaZcZrj" -); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=gas_price params:='["AXa8CHDQSA8RdFCt12rtpFraVq4fDUgJbLPxwbaZcZrj"]' id=dontcare -``` - - - - -`[null]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "gas_price", - "params": [null] -} -``` - - - - -```js -const response = await near.connection.provider.gasPrice(null); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=gas_price params:='[null]' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "gas_price": "100000000" - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `gas_price` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/gas/gas-price/block-hash/request-bash.mdx b/docs/5.api/rpc/gas/gas-price/block-hash/request-bash.mdx new file mode 100644 index 00000000000..fbb26a42749 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-hash/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=gas_price \ + params:='["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"]' +``` diff --git a/docs/5.api/rpc/gas/gas-price/block-hash/request-js.mdx b/docs/5.api/rpc/gas/gas-price/block-hash/request-js.mdx new file mode 100644 index 00000000000..8cee409ba5e --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-hash/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.gasPrice( + "6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w", +); +``` diff --git a/docs/5.api/rpc/gas/gas-price/block-hash/request-json.mdx b/docs/5.api/rpc/gas/gas-price/block-hash/request-json.mdx new file mode 100644 index 00000000000..e3362b77191 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-hash/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "gas_price", + "params": ["6RWmTYhXCzjMjoY3Mz1rfFcnBm8E6XeDDbFEPUA4sv1w"] +} +``` diff --git a/docs/5.api/rpc/gas/gas-price/block-height/request-bash.mdx b/docs/5.api/rpc/gas/gas-price/block-height/request-bash.mdx new file mode 100644 index 00000000000..14b555d9a05 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-height/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=gas_price \ + params:='[187310138]' +```` diff --git a/docs/5.api/rpc/gas/gas-price/block-height/request-js.mdx b/docs/5.api/rpc/gas/gas-price/block-height/request-js.mdx new file mode 100644 index 00000000000..b6dba159e64 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-height/request-js.mdx @@ -0,0 +1,3 @@ +```js +const response = await near.connection.provider.gasPrice(187310138); +``` diff --git a/docs/5.api/rpc/gas/gas-price/block-height/request-json.mdx b/docs/5.api/rpc/gas/gas-price/block-height/request-json.mdx new file mode 100644 index 00000000000..c362dd39a45 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/block-height/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "gas_price", + "params": [187310138] +} +``` diff --git a/docs/5.api/rpc/gas/gas-price/error-schema-table.mdx b/docs/5.api/rpc/gas/gas-price/error-schema-table.mdx new file mode 100644 index 00000000000..b007180049c --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/error-schema-table.mdx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to an archival node +
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/gas/gas-price/index.mdx b/docs/5.api/rpc/gas/gas-price/index.mdx new file mode 100644 index 00000000000..476770a2860 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/index.mdx @@ -0,0 +1,89 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import BlockHeightRequestJson from "./block-height/request-json.mdx"; +import BlockHeightRequestJs from "./block-height/request-js.mdx"; +import BlockHeightRequestBash from "./block-height/request-bash.mdx"; +import BlockHashRequestJson from "./block-hash/request-json.mdx"; +import BlockHashRequestJs from "./block-hash/request-js.mdx"; +import BlockHashRequestBash from "./block-hash/request-bash.mdx"; +import LatestRequestJson from "./latest/request-json.mdx"; +import LatestRequestJs from "./latest/request-js.mdx"; +import LatestRequestBash from "./latest/request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Gas Price {#gas-price} + +> Returns gas price for a specific `block_height` or `block_hash`. +> +> - Using `[null]` will return the most recent block's gas price. + +- method: `gas_price` +- params: `[block_height]`, `["block_hash"]`, or `[null]` + +`null` example: + + + + + + + + + + + + }> + + + + +`block_height` example: + + + + + + + + + + + + }> + + + + +`block_hash` example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `gas_price` method: + + diff --git a/docs/5.api/rpc/gas/gas-price/latest/request-bash.mdx b/docs/5.api/rpc/gas/gas-price/latest/request-bash.mdx new file mode 100644 index 00000000000..48c6355c666 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/latest/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=gas_price \ + params:='[null]' +``` diff --git a/docs/5.api/rpc/gas/gas-price/latest/request-js.mdx b/docs/5.api/rpc/gas/gas-price/latest/request-js.mdx new file mode 100644 index 00000000000..5da5e19f348 --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/latest/request-js.mdx @@ -0,0 +1,3 @@ +```js +const response = await near.connection.provider.gasPrice(null); +``` diff --git a/docs/5.api/rpc/gas/gas-price/latest/request-json.mdx b/docs/5.api/rpc/gas/gas-price/latest/request-json.mdx new file mode 100644 index 00000000000..550b27b82ec --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/latest/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "gas_price", + "params": [null] +} +``` diff --git a/docs/5.api/rpc/gas/gas-price/response-json.mdx b/docs/5.api/rpc/gas/gas-price/response-json.mdx new file mode 100644 index 00000000000..7020758f84d --- /dev/null +++ b/docs/5.api/rpc/gas/gas-price/response-json.mdx @@ -0,0 +1,9 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "result": { + "gas_price": "100000000" + } +} +``` diff --git a/docs/5.api/rpc/general/error-schema-description.mdx b/docs/5.api/rpc/general/error-schema-description.mdx new file mode 100644 index 00000000000..bb53e14cd25 --- /dev/null +++ b/docs/5.api/rpc/general/error-schema-description.mdx @@ -0,0 +1,27 @@ +When API request fails, RPC server returns a structured error response with a +limited number of well-defined error variants, so client code can exhaustively +handle all the possible error cases. Our JSON-RPC errors follow +[verror](https://github.com/joyent/node-verror) convention for structuring +the error response: + +```json +{ + "error": { + "name": , + "cause": { + "info": {..}, + "name": + }, + "code": -32000, + "data": String, + "message": "Server error" + }, + "id": "dontcare", + "jsonrpc": "2.0" +} +``` + +> **Heads up** +> +> The fields `code`, `data`, and `message` in the structure above are considered +> legacy ones and might be deprecated in the future. Please, don't rely on them. diff --git a/docs/5.api/rpc/maintenance-windows.md b/docs/5.api/rpc/maintenance-windows.md index 1664151f7a7..9d06bc7f707 100644 --- a/docs/5.api/rpc/maintenance-windows.md +++ b/docs/5.api/rpc/maintenance-windows.md @@ -3,130 +3,11 @@ id: maintenance-windows title: Maintenance Windows --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import MaintenanceWindows from './maintenance-windows/maintenance-windows/index.mdx'; -The RPC API enables you to query future maintenance windows for a specific validator in current epoch +The RPC API enables you to query future maintenance windows for a specific validator +in current epoch --- - -## Maintenance windows {#maintenance-windows} - -> The maintenance windows for a specific validator are future block height ranges in current epoch, in which the validator does not need produce block or chunk -> If the provided account is not a validator, then it will return the range from now to the end of the epoch. - - -- method: `EXPERIMENTAL_maintenance_windows` -- params: - - `account_id` - - -example: - - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_maintenance_windows", - "params": { - "account_id": "node0" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_maintenance_windows \ - params:='{ - "account_id": "node0" - }' -``` - - - - -
-Example response: -

-The result will be a list of future maintenance windows in current epoch. -For example a window `[1028, 1031]` includes 1028, 1029 and 1030. - -```json -{ - "jsonrpc": "2.0", - "result": [ - [ - 1028, - 1031 - ], - [ - 1034, - 1038 - ], - ], - "id": "dontcare" -} -``` - -

-
- -#### What Could Go Wrong?? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -Here is the exhaustive list of the error variants that can be returned by `maintenance_windows` method: - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
+ +--- diff --git a/docs/5.api/rpc/maintenance-windows/maintenance-windows/error-schema-table.mdx b/docs/5.api/rpc/maintenance-windows/maintenance-windows/error-schema-table.mdx new file mode 100644 index 00000000000..a936ad23c19 --- /dev/null +++ b/docs/5.api/rpc/maintenance-windows/maintenance-windows/error-schema-table.mdx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/maintenance-windows/maintenance-windows/index.mdx b/docs/5.api/rpc/maintenance-windows/maintenance-windows/index.mdx new file mode 100644 index 00000000000..531bab7baf5 --- /dev/null +++ b/docs/5.api/rpc/maintenance-windows/maintenance-windows/index.mdx @@ -0,0 +1,51 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Maintenance windows {#maintenance-windows} + +> The maintenance windows for a specific validator are future block height +> ranges in current epoch, in which the validator does not need produce block or chunk +> If the provided account is not a validator, then it will return the range +> from now to the end of the epoch. + +- method: `EXPERIMENTAL_maintenance_windows` +- params: + - `account_id` + +Example: + + + + + + + + + }> + + + + +
+ Example response: +

+ The result will be a list of future maintenance windows in current epoch. + For example a window `[1028, 1031]` includes 1028, 1029 and 1030. + +

+
+ +#### What Could Go Wrong?? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `maintenance_windows` method: + + diff --git a/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-bash.mdx b/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-bash.mdx new file mode 100644 index 00000000000..63f958d84a9 --- /dev/null +++ b/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_maintenance_windows \ + params:='{ + "account_id": "node0" + }' +``` diff --git a/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-json.mdx b/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-json.mdx new file mode 100644 index 00000000000..6c9cf721c1c --- /dev/null +++ b/docs/5.api/rpc/maintenance-windows/maintenance-windows/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_maintenance_windows", + "params": { + "account_id": "node0" + } +} +``` diff --git a/docs/5.api/rpc/maintenance-windows/maintenance-windows/response-json.mdx b/docs/5.api/rpc/maintenance-windows/maintenance-windows/response-json.mdx new file mode 100644 index 00000000000..3626e1bcbb8 --- /dev/null +++ b/docs/5.api/rpc/maintenance-windows/maintenance-windows/response-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "result": [ + [1028, 1031], + [1034, 1038] + ] +} +``` diff --git a/docs/5.api/rpc/network.md b/docs/5.api/rpc/network.md index 48ea415472f..1a6d2fbee25 100644 --- a/docs/5.api/rpc/network.md +++ b/docs/5.api/rpc/network.md @@ -3,1408 +3,16 @@ id: network title: Network --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import NodeStatus from './network/node-status/index.mdx'; +import NetworkInfo from './network/network-info/index.mdx'; +import ValidationStatus from './network/validation-status/index.mdx'; The RPC API enables you to query status information for nodes and validators. --- - -## Node Status {#node-status} - -> Returns general status of a given node (sync status, nearcore node version, protocol version, etc), and the current set of validators. - -- method: `status` -- params: `[]` - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "status", - "params": [] -} -``` - - - - -```js -const response = await near.connection.provider.status(); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=status params:='[]' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "version": { - "version": "1.14.0-rc.1", - "build": "effa3b7a-modified" - }, - "chain_id": "testnet", - "protocol_version": 35, - "latest_protocol_version": 35, - "rpc_addr": "0.0.0.0:3030", - "validators": [ - { - "account_id": "node3", - "is_slashed": false - }, - { - "account_id": "node0", - "is_slashed": false - }, - { - "account_id": "staked.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "01node.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "node2", - "is_slashed": false - }, - { - "account_id": "dokia.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "node1", - "is_slashed": false - }, - { - "account_id": "lowfeevalidation.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "sl1sub.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "zainy.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "chorus-one.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "thepassivetrust.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "certusone.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "joe1.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "bisontrails.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "valeraverim.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "lunanova.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "bazilik.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "dsrvlabs.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "kronos.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "nodeasy.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "kytzu.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "bitcat.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "pool_easy2stake.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "fresh_lockup.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "staking-power.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "syncnode.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "inotel.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "zpool.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "aquarius.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "cloudpost.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "staked.pool.6fb1358", - "is_slashed": false - }, - { - "account_id": "moonlet.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "jazza.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "orangeclub.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "blazenet.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "pathrock.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "stakin.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "northernlights.stakingpool", - "is_slashed": false - }, - { - "account_id": "alexandruast.pool.f863973.m0", - "is_slashed": false - }, - { - "account_id": "top.pool.f863973.m0", - "is_slashed": false - } - ], - "sync_info": { - "latest_block_hash": "44kieHwr7Gg5r72V3DgU7cpgV2aySkk5qbBCdvwens8T", - "latest_block_height": 17774278, - "latest_state_root": "3MD3fQqnm3JYa9UQgenEJsR6UHoWuHV4Tpr4hZY7QwfY", - "latest_block_time": "2020-09-27T23:59:38.008063088Z", - "syncing": false - }, - "validator_account_id": "nearup-node8" - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `status` method: - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Network Info {#network-info} - -> Returns the current state of node network connections (active peers, transmitted data, etc.) - -- method: `network_info` -- params: _none_ - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "network_info", - "params": [] -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=network_info params:='[]' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "active_peers": [ - { - "id": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", - "addr": "35.193.24.121:24567", - "account_id": null - } - ], - "num_active_peers": 34, - "peer_max_count": 40, - "sent_bytes_per_sec": 17754754, - "received_bytes_per_sec": 492116, - "known_producers": [ - { - "account_id": "node0", - "addr": null, - "peer_id": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX" - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-1} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `network_info` method: - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Validation Status {#validation-status} - -> Queries active validators on the network returning details and the state of -validation on the blockchain. - -- method: `validators` -- params: `["block hash"]`, `[block number]`, `{"epoch_id": "epoch id"}`, -`{"block_id": block number}`, `{"block_id": "block hash"}`, or -`[null]` for the latest block - -**Note:** If you want the latest `block hash`, `block number` and `epoch id`, -you will need to query from the last block in an epoch. You can also query -validators endpoint for past epochs if you input `block hash`, `block number` -or `epoch id` of the past epoch that you want. - -Example: - -input: `[block number]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": [17791098] -} -``` - - - - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=validators params:='[17791098]' id=dontcare -``` - - - - - -input: `["block hash"]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": ["FiG2nMjjue3YdgYAyM3ZqWXSaG6RJj5Gk7hvY8vrEoGw"] -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=validators params:='["FiG2nMjjue3YdgYAyM3ZqWXSaG6RJj5Gk7hvY8vrEoGw"]' id=dontcare -``` - - - - - -input: `{"block_id": "block hash"}` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": { - "block_id": "FiG2nMjjue3YdgYAyM3ZqWXSaG6RJj5Gk7hvY8vrEoGw" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=validators \ - params:='{ - "block_id": "FiG2nMjjue3YdgYAyM3ZqWXSaG6RJj5Gk7hvY8vrEoGw" - }' -``` - - - - - -input: `{"block_id": block number}` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": { - "block_id": 17791098 - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=validators \ - params:='{ - "block_id": 17791098 - }` -``` - - - - - -input: `{"epoch_id": "epoch id"}` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": { - "epoch_id": "8hJSZNNyimPvsCA1v3dMr3Hg5ucYeLUbTvEfhr6jaWJy" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=validators \ - params:='{ - "epoch_id": "8hJSZNNyimPvsCA1v3dMr3Hg5ucYeLUbTvEfhr6jaWJy" - }` -``` - - - - - -input: `[null]` - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "validators", - "params": [null] -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=validators params:='[null]' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "current_validators": [ - { - "account_id": "01node.pool.f863973.m0", - "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL", - "is_slashed": false, - "stake": "176429739989396285019500901780", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "alexandruast.pool.f863973.m0", - "public_key": "ed25519:A3XJ3uVGxSi9o2gnG2r8Ra3fqqodRpL4iuLTc6fNdGUj", - "is_slashed": false, - "stake": "151430394143736014372434860532", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "aquarius.pool.f863973.m0", - "public_key": "ed25519:8NfEarjStDYjJTwKUgQGy7Z7UTGsZaPhTUsExheQN3r1", - "is_slashed": false, - "stake": "130367563121508828296664196836", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "bazilik.pool.f863973.m0", - "public_key": "ed25519:3pDJwDQ6Y5B9QeW1jz8KunhZH4D4GQG86reTmrRfdD7c", - "is_slashed": false, - "stake": "169013447850997135034919151338", - "shards": [0], - "num_produced_blocks": 211, - "num_expected_blocks": 213 - }, - { - "account_id": "bisontrails.pool.f863973.m0", - "public_key": "ed25519:8g4P5EXyp2b2pfVMHY1QLfkRcY59hjPfWrFCKUWX3RmR", - "is_slashed": false, - "stake": "184162578269044826045352223479", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "bitcat.pool.f863973.m0", - "public_key": "ed25519:9mtnwPQyyap1QNH9ag6r4the7Jkkpdyt9HUF5G1dWxKx", - "is_slashed": false, - "stake": "135215509376418353124295451543", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "blazenet.pool.f863973.m0", - "public_key": "ed25519:DiogP36wBXKFpFeqirrxN8G2Mq9vnakgBvgnHdL9CcN3", - "is_slashed": false, - "stake": "137364229255641651855065314186", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "certusone.pool.f863973.m0", - "public_key": "ed25519:CKW7f41Kn8YCDPzaGLs1MrPb9h3BjQmHhbei6Ff6nRRF", - "is_slashed": false, - "stake": "176644821310043228577017742667", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "chorus-one.pool.f863973.m0", - "public_key": "ed25519:6LFwyEEsqhuDxorWfsKcPPs324zLWTaoqk4o6RDXN7Qc", - "is_slashed": false, - "stake": "110397600457815316527526651811", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 213 - }, - { - "account_id": "cloudpost.pool.f863973.m0", - "public_key": "ed25519:AVVLmJDG8z6UgmW9fmJGVFTdYxxfnqXH6c7FVQmhE6dp", - "is_slashed": false, - "stake": "136597929514591130855076834167", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "dokia.pool.f863973.m0", - "public_key": "ed25519:935JMz1vLcJxFApG3TY4MA4RHhvResvoGwCrQoJxHPn9", - "is_slashed": false, - "stake": "220445043066799898276306006919", - "shards": [0], - "num_produced_blocks": 426, - "num_expected_blocks": 426 - }, - { - "account_id": "dsrvlabs.pool.f863973.m0", - "public_key": "ed25519:61ei2efmmLkeDR1CG6JDEC2U3oZCUuC2K1X16Vmxrud9", - "is_slashed": false, - "stake": "161508967845718247649113721019", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "fresh_lockup.pool.f863973.m0", - "public_key": "ed25519:7CMFLtEohojtxBkmj9Jb6AGgbphb1zvxymHzpzuyCjfG", - "is_slashed": false, - "stake": "193574159400241036715020269158", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "inotel.pool.f863973.m0", - "public_key": "ed25519:C55jH1MCHYGa3tzUyZZdGrJmmCLP22Aa4v88KYpn2xwZ", - "is_slashed": false, - "stake": "178598870951670469578754984993", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "jazza.pool.f863973.m0", - "public_key": "ed25519:85cPMNVrqUz8N7oWbbvWbUuamHcJNe49uRbaSzftLCz9", - "is_slashed": false, - "stake": "155762349362951827286303475797", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "joe1.pool.f863973.m0", - "public_key": "ed25519:G3SxwzmiEZSm3bHnTLtxJvm3NvT1TLQcWuV1iod6i6NJ", - "is_slashed": false, - "stake": "129230772267511696840933436174", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "kronos.pool.f863973.m0", - "public_key": "ed25519:3i2pertqzF8xqkJ4BrE4t4r67YiYYrUKCktbqvDgjzuQ", - "is_slashed": false, - "stake": "144544279093485390569527924033", - "shards": [0], - "num_produced_blocks": 202, - "num_expected_blocks": 213 - }, - { - "account_id": "kytzu.pool.f863973.m0", - "public_key": "ed25519:61tgPZpy8tqFeAwG4vtf2ZKCRoENiP2A1TJVWEwnbxZU", - "is_slashed": false, - "stake": "113758432843198726378418342568", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "lowfeevalidation.pool.f863973.m0", - "public_key": "ed25519:EXyjSMGSnk5uGphF3gVV1jCudaAudbW8imoEccYEJg3V", - "is_slashed": false, - "stake": "113685537557977098595863252617", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "lunanova.pool.f863973.m0", - "public_key": "ed25519:2fZ59qfo9QHNLijoht9cwUb9enSNcnRmXbQn1gKZxvkw", - "is_slashed": false, - "stake": "172903039219549397267702571804", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "moonlet.pool.f863973.m0", - "public_key": "ed25519:3e1nVCVGNS3yr6CcUvpDAs3BhiWtyM9uTBWkyVR5Xn3K", - "is_slashed": false, - "stake": "140599784944681716744261599779", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "node0", - "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX", - "is_slashed": false, - "stake": "1907234923845608896091985071588", - "shards": [0], - "num_produced_blocks": 3614, - "num_expected_blocks": 3616 - }, - { - "account_id": "node1", - "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e", - "is_slashed": false, - "stake": "1906065501889463342906704128820", - "shards": [0], - "num_produced_blocks": 3613, - "num_expected_blocks": 3614 - }, - { - "account_id": "node2", - "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", - "is_slashed": false, - "stake": "1840271519773089248112279578450", - "shards": [0], - "num_produced_blocks": 3615, - "num_expected_blocks": 3615 - }, - { - "account_id": "node3", - "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su", - "is_slashed": false, - "stake": "1247270566437910246525604113433", - "shards": [0], - "num_produced_blocks": 2335, - "num_expected_blocks": 2342 - }, - { - "account_id": "nodeasy.pool.f863973.m0", - "public_key": "ed25519:25Dhg8NBvQhsVTuugav3t1To1X1zKiomDmnh8yN9hHMb", - "is_slashed": false, - "stake": "131652957125263756523827257067", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "northernlights.stakingpool", - "public_key": "ed25519:CsMecqKCfagnebMB3ha1uRubay5Z4V85req23bNAJSG3", - "is_slashed": false, - "stake": "159669819380982417675619400525", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "orangeclub.pool.f863973.m0", - "public_key": "ed25519:HezFeSzcwuR5wvkqccgMCMnpf1eQkVCfk52tXZEdKZHz", - "is_slashed": false, - "stake": "143971234567521206686862639104", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "pathrock.pool.f863973.m0", - "public_key": "ed25519:G138GdQsU7PdFLD6X88NmTLAEDR7agPcq9HLZqGpegkm", - "is_slashed": false, - "stake": "125204431569306697735287326827", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "pool_easy2stake.pool.f863973.m0", - "public_key": "ed25519:8nzKxvmyeauQRehWkby8GfWNLgqPiF5FCRFSD75M1Rwh", - "is_slashed": false, - "stake": "176893731686620703671521068552", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "sl1sub.pool.f863973.m0", - "public_key": "ed25519:3URBpNUjNAMzugQH1rdSKMtwFM8AwHaJgZk5Z6YtnfFL", - "is_slashed": false, - "stake": "155741680601335529540438949153", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 213 - }, - { - "account_id": "staked.pool.6fb1358", - "public_key": "ed25519:684rMbuVYYgL2CkmYgC1weLh3erd2bwrmtQtJJhWzPwj", - "is_slashed": false, - "stake": "126911347639167461321544980789", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "staked.pool.f863973.m0", - "public_key": "ed25519:D2afKYVaKQ1LGiWbMAZRfkKLgqimTR74wvtESvjx5Ft2", - "is_slashed": false, - "stake": "140558085958535444819294942478", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "stakin.pool.f863973.m0", - "public_key": "ed25519:GvddxjaxBCqGGB4kMNWNFtvozU1EEZ2jrnggKZW8LaU4", - "is_slashed": false, - "stake": "122221693837484004905170552626", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "staking-power.pool.f863973.m0", - "public_key": "ed25519:4s79F6Fdjgb3rHXPLwaXZG4Hq7Za8nogUu3vXEamRBQo", - "is_slashed": false, - "stake": "113293334165305165414435157738", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "syncnode.pool.f863973.m0", - "public_key": "ed25519:FUAVDkmLhuTbKYv4GWuWv9ogjKzRatLd5ZBMKXRy7WqE", - "is_slashed": false, - "stake": "133414422809248011010747790387", - "shards": [0], - "num_produced_blocks": 212, - "num_expected_blocks": 212 - }, - { - "account_id": "thepassivetrust.pool.f863973.m0", - "public_key": "ed25519:4NccD2DNJpBkDmWeJ2GbqPoivQ93qcKiR4PHALJKCTod", - "is_slashed": false, - "stake": "162714097201953456968339272308", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "top.pool.f863973.m0", - "public_key": "ed25519:FR5qxAsP8GgXDN96pappLtWMywiqWsPVqT3HLE3YaUx", - "is_slashed": false, - "stake": "164760602493727447176131601464", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "valeraverim.pool.f863973.m0", - "public_key": "ed25519:3686ABqNUZc1qhLWLHg5xZpBzrWPiUCMNZxcCNmg3e2s", - "is_slashed": false, - "stake": "191733144511459134091274432419", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "zainy.pool.f863973.m0", - "public_key": "ed25519:37KfhBNYjqpaUVh3ft5kPcFn3xK1eVvtDZJCQQVCGnzQ", - "is_slashed": false, - "stake": "113441017844444454951489924484", - "shards": [0], - "num_produced_blocks": 213, - "num_expected_blocks": 213 - }, - { - "account_id": "zpool.pool.f863973.m0", - "public_key": "ed25519:ETFRFNHfvd6fpj74MGYYQp3diY8WB4bFmWMxjTB2yY4V", - "is_slashed": false, - "stake": "140932616764414290525265048028", - "shards": [0], - "num_produced_blocks": 120, - "num_expected_blocks": 212 - } - ], - "next_validators": [ - { - "account_id": "01node.pool.f863973.m0", - "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL", - "stake": "177341160716540400974121040893", - "shards": [0] - }, - { - "account_id": "alexandruast.pool.f863973.m0", - "public_key": "ed25519:A3XJ3uVGxSi9o2gnG2r8Ra3fqqodRpL4iuLTc6fNdGUj", - "stake": "152212670433756011274558210225", - "shards": [0] - }, - { - "account_id": "aquarius.pool.f863973.m0", - "public_key": "ed25519:8NfEarjStDYjJTwKUgQGy7Z7UTGsZaPhTUsExheQN3r1", - "stake": "131041030638338742265060835987", - "shards": [0] - }, - { - "account_id": "bazilik.pool.f863973.m0", - "public_key": "ed25519:3pDJwDQ6Y5B9QeW1jz8KunhZH4D4GQG86reTmrRfdD7c", - "stake": "169886556654364796730036727847", - "shards": [0] - }, - { - "account_id": "bisontrails.pool.f863973.m0", - "public_key": "ed25519:8g4P5EXyp2b2pfVMHY1QLfkRcY59hjPfWrFCKUWX3RmR", - "stake": "185113946165399113822995097304", - "shards": [0] - }, - { - "account_id": "bitcat.pool.f863973.m0", - "public_key": "ed25519:9mtnwPQyyap1QNH9ag6r4the7Jkkpdyt9HUF5G1dWxKx", - "stake": "135914020962862866419944507506", - "shards": [0] - }, - { - "account_id": "blazenet.pool.f863973.m0", - "public_key": "ed25519:DiogP36wBXKFpFeqirrxN8G2Mq9vnakgBvgnHdL9CcN3", - "stake": "138073840925159254185212483041", - "shards": [0] - }, - { - "account_id": "certusone.pool.f863973.m0", - "public_key": "ed25519:CKW7f41Kn8YCDPzaGLs1MrPb9h3BjQmHhbei6Ff6nRRF", - "stake": "177557353126393581856047095474", - "shards": [0] - }, - { - "account_id": "chorus-one.pool.f863973.m0", - "public_key": "ed25519:6LFwyEEsqhuDxorWfsKcPPs324zLWTaoqk4o6RDXN7Qc", - "stake": "110967904880664326100649881128", - "shards": [0] - }, - { - "account_id": "cloudpost.pool.f863973.m0", - "public_key": "ed25519:AVVLmJDG8z6UgmW9fmJGVFTdYxxfnqXH6c7FVQmhE6dp", - "stake": "137303582563490110045159846741", - "shards": [0] - }, - { - "account_id": "dokia.pool.f863973.m0", - "public_key": "ed25519:935JMz1vLcJxFApG3TY4MA4RHhvResvoGwCrQoJxHPn9", - "stake": "221583843027440134728813179120", - "shards": [0] - }, - { - "account_id": "dsrvlabs.pool.f863973.m0", - "public_key": "ed25519:61ei2efmmLkeDR1CG6JDEC2U3oZCUuC2K1X16Vmxrud9", - "stake": "162343309156672629963246208215", - "shards": [0] - }, - { - "account_id": "fresh_lockup.pool.f863973.m0", - "public_key": "ed25519:7CMFLtEohojtxBkmj9Jb6AGgbphb1zvxymHzpzuyCjfG", - "stake": "194574146707912827852030100603", - "shards": [0] - }, - { - "account_id": "inotel.pool.f863973.m0", - "public_key": "ed25519:C55jH1MCHYGa3tzUyZZdGrJmmCLP22Aa4v88KYpn2xwZ", - "stake": "179521497218882663562358374377", - "shards": [0] - }, - { - "account_id": "jazza.pool.f863973.m0", - "public_key": "ed25519:85cPMNVrqUz8N7oWbbvWbUuamHcJNe49uRbaSzftLCz9", - "stake": "156567004141558073310769195719", - "shards": [0] - }, - { - "account_id": "joe1.pool.f863973.m0", - "public_key": "ed25519:G3SxwzmiEZSm3bHnTLtxJvm3NvT1TLQcWuV1iod6i6NJ", - "stake": "129898367221448376460128575495", - "shards": [0] - }, - { - "account_id": "kronos.pool.f863973.m0", - "public_key": "ed25519:3i2pertqzF8xqkJ4BrE4t4r67YiYYrUKCktbqvDgjzuQ", - "stake": "145291600307308103830278523851", - "shards": [0] - }, - { - "account_id": "kytzu.pool.f863973.m0", - "public_key": "ed25519:61tgPZpy8tqFeAwG4vtf2ZKCRoENiP2A1TJVWEwnbxZU", - "stake": "114346099616381729581424582943", - "shards": [0] - }, - { - "account_id": "lowfeevalidation.pool.f863973.m0", - "public_key": "ed25519:EXyjSMGSnk5uGphF3gVV1jCudaAudbW8imoEccYEJg3V", - "stake": "114272827178534171015566175242", - "shards": [0] - }, - { - "account_id": "lunanova.pool.f863973.m0", - "public_key": "ed25519:2fZ59qfo9QHNLijoht9cwUb9enSNcnRmXbQn1gKZxvkw", - "stake": "173796241314359640924313305613", - "shards": [0] - }, - { - "account_id": "moonlet.pool.f863973.m0", - "public_key": "ed25519:3e1nVCVGNS3yr6CcUvpDAs3BhiWtyM9uTBWkyVR5Xn3K", - "stake": "141326111231422084384405939935", - "shards": [0] - }, - { - "account_id": "node0", - "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX", - "stake": "1917087533938315356792420553580", - "shards": [0] - }, - { - "account_id": "node1", - "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e", - "stake": "1915912070849706566898523265362", - "shards": [0] - }, - { - "account_id": "node2", - "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", - "stake": "1849778202731933988446605407109", - "shards": [0] - }, - { - "account_id": "node3", - "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su", - "stake": "1253713857932062021626652303305", - "shards": [0] - }, - { - "account_id": "nodeasy.pool.f863973.m0", - "public_key": "ed25519:25Dhg8NBvQhsVTuugav3t1To1X1zKiomDmnh8yN9hHMb", - "stake": "132333065508677559475570461579", - "shards": [0] - }, - { - "account_id": "northernlights.stakingpool", - "public_key": "ed25519:CsMecqKCfagnebMB3ha1uRubay5Z4V85req23bNAJSG3", - "stake": "160494659810582810750858869593", - "shards": [0] - }, - { - "account_id": "orangeclub.pool.f863973.m0", - "public_key": "ed25519:HezFeSzcwuR5wvkqccgMCMnpf1eQkVCfk52tXZEdKZHz", - "stake": "144714977470413958038055754809", - "shards": [0] - }, - { - "account_id": "pathrock.pool.f863973.m0", - "public_key": "ed25519:G138GdQsU7PdFLD6X88NmTLAEDR7agPcq9HLZqGpegkm", - "stake": "125851226796631921571804668732", - "shards": [0] - }, - { - "account_id": "pool_easy2stake.pool.f863973.m0", - "public_key": "ed25519:8nzKxvmyeauQRehWkby8GfWNLgqPiF5FCRFSD75M1Rwh", - "stake": "177807549352374182247265978294", - "shards": [0] - }, - { - "account_id": "sl1sub.pool.f863973.m0", - "public_key": "ed25519:3URBpNUjNAMzugQH1rdSKMtwFM8AwHaJgZk5Z6YtnfFL", - "stake": "156546228606913052982706314599", - "shards": [0] - }, - { - "account_id": "staked.pool.6fb1358", - "public_key": "ed25519:684rMbuVYYgL2CkmYgC1weLh3erd2bwrmtQtJJhWzPwj", - "stake": "127566960646771620637977634520", - "shards": [0] - }, - { - "account_id": "staked.pool.f863973.m0", - "public_key": "ed25519:D2afKYVaKQ1LGiWbMAZRfkKLgqimTR74wvtESvjx5Ft2", - "stake": "141284196855966747583242721111", - "shards": [0] - }, - { - "account_id": "stakin.pool.f863973.m0", - "public_key": "ed25519:GvddxjaxBCqGGB4kMNWNFtvozU1EEZ2jrnggKZW8LaU4", - "stake": "122853080560791799567241762038", - "shards": [0] - }, - { - "account_id": "staking-power.pool.f863973.m0", - "public_key": "ed25519:4s79F6Fdjgb3rHXPLwaXZG4Hq7Za8nogUu3vXEamRBQo", - "stake": "113878597697173990840757447344", - "shards": [0] - }, - { - "account_id": "syncnode.pool.f863973.m0", - "public_key": "ed25519:FUAVDkmLhuTbKYv4GWuWv9ogjKzRatLd5ZBMKXRy7WqE", - "stake": "134103630138795323490241660174", - "shards": [0] - }, - { - "account_id": "thepassivetrust.pool.f863973.m0", - "public_key": "ed25519:4NccD2DNJpBkDmWeJ2GbqPoivQ93qcKiR4PHALJKCTod", - "stake": "163554668234785516757420218799", - "shards": [0] - }, - { - "account_id": "top.pool.f863973.m0", - "public_key": "ed25519:FR5qxAsP8GgXDN96pappLtWMywiqWsPVqT3HLE3YaUx", - "stake": "165611741467072665024638629174", - "shards": [0] - }, - { - "account_id": "valeraverim.pool.f863973.m0", - "public_key": "ed25519:3686ABqNUZc1qhLWLHg5xZpBzrWPiUCMNZxcCNmg3e2s", - "stake": "192723621295992295990275575014", - "shards": [0] - }, - { - "account_id": "zainy.pool.f863973.m0", - "public_key": "ed25519:37KfhBNYjqpaUVh3ft5kPcFn3xK1eVvtDZJCQQVCGnzQ", - "stake": "114027175849273464802110072969", - "shards": [0] - }, - { - "account_id": "zpool.pool.f863973.m0", - "public_key": "ed25519:ETFRFNHfvd6fpj74MGYYQp3diY8WB4bFmWMxjTB2yY4V", - "stake": "141660662431449802378487016195", - "shards": [0] - } - ], - "current_fishermen": [ - { - "account_id": "staked.stakingpool", - "public_key": "ed25519:5VmCXxWepj22uFoKmrxk6DTiFa3fuTzDcwGxM8uUErpr", - "stake": "5957256918881889179239884296" - }, - { - "account_id": "bisontrails.stakingpool", - "public_key": "ed25519:ED2v5KtScbk6aNjGcTn1YMDUu3EXfD5HPt1x6RiYBypk", - "stake": "7679439354334034871130713908" - }, - { - "account_id": "cryptium.stakingpool", - "public_key": "ed25519:2usUkjmKWxQw7QUeFfELHCEqS2UxjwsRqnCkA5oQ6A2B", - "stake": "6484546971716985483357166277" - }, - { - "account_id": "buildlinks3.pool.f863973.m0", - "public_key": "ed25519:Cfy8xjSsvVquSqo7W4A2bRX1vkLPycLgyCvFNs3Rz6bb", - "stake": "81221864655530313350540629757" - }, - { - "account_id": "mmm.pool.f863973.m0", - "public_key": "ed25519:3jEqDDKaJEg1r8UGu2x2dC55BXE7i26yNFQzvfJkkHkf", - "stake": "80030001196381772535600000000" - } - ], - "next_fishermen": [ - { - "account_id": "staked.stakingpool", - "public_key": "ed25519:5VmCXxWepj22uFoKmrxk6DTiFa3fuTzDcwGxM8uUErpr", - "stake": "5957256918881889179239884296" - }, - { - "account_id": "bisontrails.stakingpool", - "public_key": "ed25519:ED2v5KtScbk6aNjGcTn1YMDUu3EXfD5HPt1x6RiYBypk", - "stake": "7679439354334034871130713908" - }, - { - "account_id": "cryptium.stakingpool", - "public_key": "ed25519:2usUkjmKWxQw7QUeFfELHCEqS2UxjwsRqnCkA5oQ6A2B", - "stake": "6484546971716985483357166277" - }, - { - "account_id": "buildlinks3.pool.f863973.m0", - "public_key": "ed25519:Cfy8xjSsvVquSqo7W4A2bRX1vkLPycLgyCvFNs3Rz6bb", - "stake": "81221864655530313350540629757" - }, - { - "account_id": "mmm.pool.f863973.m0", - "public_key": "ed25519:3jEqDDKaJEg1r8UGu2x2dC55BXE7i26yNFQzvfJkkHkf", - "stake": "80030001196381772535600000000" - } - ], - "current_proposals": [ - { - "account_id": "kytzu.pool.f863973.m0", - "public_key": "ed25519:61tgPZpy8tqFeAwG4vtf2ZKCRoENiP2A1TJVWEwnbxZU", - "stake": "114346100195275968419224582943" - }, - { - "account_id": "nodeasy.pool.f863973.m0", - "public_key": "ed25519:25Dhg8NBvQhsVTuugav3t1To1X1zKiomDmnh8yN9hHMb", - "stake": "132333066144809013154670461579" - }, - { - "account_id": "thepassivetrust.pool.f863973.m0", - "public_key": "ed25519:4NccD2DNJpBkDmWeJ2GbqPoivQ93qcKiR4PHALJKCTod", - "stake": "163554672455685458970920218837" - } - ], - "prev_epoch_kickout": [], - "epoch_start_height": 17754191, - "epoch_height": 321 - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-2} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `validators` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_EPOCH200An epoch for the provided block can't be found in a database -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
  • Check that the requested block is the last block of some epoch
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/network/network-info/error-schema-table.mdx b/docs/5.api/rpc/network/network-info/error-schema-table.mdx new file mode 100644 index 00000000000..1101871ef84 --- /dev/null +++ b/docs/5.api/rpc/network/network-info/error-schema-table.mdx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/network/network-info/index.mdx b/docs/5.api/rpc/network/network-info/index.mdx new file mode 100644 index 00000000000..1916e5a4013 --- /dev/null +++ b/docs/5.api/rpc/network/network-info/index.mdx @@ -0,0 +1,43 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Network Info {#network-info} + +> Returns the current state of node network connections (active peers, transmitted data, etc.) + +- method: `network_info` +- params: _none_ + +Example: + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-1} + + + +Here is the exhaustive list of the error variants that can be returned by `network_info` method: + + diff --git a/docs/5.api/rpc/network/network-info/request-bash.mdx b/docs/5.api/rpc/network/network-info/request-bash.mdx new file mode 100644 index 00000000000..852f01f4626 --- /dev/null +++ b/docs/5.api/rpc/network/network-info/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=network_info \ + params:='[]' +``` diff --git a/docs/5.api/rpc/network/network-info/request-json.mdx b/docs/5.api/rpc/network/network-info/request-json.mdx new file mode 100644 index 00000000000..097d4a50934 --- /dev/null +++ b/docs/5.api/rpc/network/network-info/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "network_info", + "params": [] +} +``` diff --git a/docs/5.api/rpc/network/network-info/response-json.mdx b/docs/5.api/rpc/network/network-info/response-json.mdx new file mode 100644 index 00000000000..3690e4008aa --- /dev/null +++ b/docs/5.api/rpc/network/network-info/response-json.mdx @@ -0,0 +1,26 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "active_peers": [ + { + "id": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", + "addr": "35.193.24.121:24567", + "account_id": null + } + ], + "num_active_peers": 34, + "peer_max_count": 40, + "sent_bytes_per_sec": 17754754, + "received_bytes_per_sec": 492116, + "known_producers": [ + { + "account_id": "node0", + "addr": null, + "peer_id": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/network/node-status/error-schema-table.mdx b/docs/5.api/rpc/network/node-status/error-schema-table.mdx new file mode 100644 index 00000000000..1101871ef84 --- /dev/null +++ b/docs/5.api/rpc/network/node-status/error-schema-table.mdx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/network/node-status/index.mdx b/docs/5.api/rpc/network/node-status/index.mdx new file mode 100644 index 00000000000..d4756f67a14 --- /dev/null +++ b/docs/5.api/rpc/network/node-status/index.mdx @@ -0,0 +1,48 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Node Status {#node-status} + +> Returns general status of a given node (sync status, nearcore node version, +> protocol version, etc.), and the current set of validators. + +- method: `status` +- params: `[]` + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `status` method: + + diff --git a/docs/5.api/rpc/network/node-status/request-bash.mdx b/docs/5.api/rpc/network/node-status/request-bash.mdx new file mode 100644 index 00000000000..ecbba7b6f98 --- /dev/null +++ b/docs/5.api/rpc/network/node-status/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=status \ + params:='[]' +``` diff --git a/docs/5.api/rpc/network/node-status/request-js.mdx b/docs/5.api/rpc/network/node-status/request-js.mdx new file mode 100644 index 00000000000..21a6d39183a --- /dev/null +++ b/docs/5.api/rpc/network/node-status/request-js.mdx @@ -0,0 +1,3 @@ +```js +const response = await near.connection.provider.status(); +``` diff --git a/docs/5.api/rpc/network/node-status/request-json.mdx b/docs/5.api/rpc/network/node-status/request-json.mdx new file mode 100644 index 00000000000..45e8fa80a60 --- /dev/null +++ b/docs/5.api/rpc/network/node-status/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "status", + "params": [] +} +``` diff --git a/docs/5.api/rpc/network/node-status/response-json.mdx b/docs/5.api/rpc/network/node-status/response-json.mdx new file mode 100644 index 00000000000..b387d4519d9 --- /dev/null +++ b/docs/5.api/rpc/network/node-status/response-json.mdx @@ -0,0 +1,117 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "chain_id": "testnet", + "genesis_hash": "FWJ9kR6KFWoyMoNjpLXXGHeuiy7tEY6GmoFeCA5yuc6b", + "latest_protocol_version": 73, + "node_key": null, + "node_public_key": "ed25519:DC7DbfZq4dkPqUKaKpWNimgtRBxnD9rja2KcZRs4e3DL", + "protocol_version": 73, + "rpc_addr": "0.0.0.0:3030", + "sync_info": { + "earliest_block_hash": "uz2gwgYxpx8dHsjgiPQefbwAhWk41CCvEmHU7ktYE2C", + "earliest_block_height": 187251995, + "earliest_block_time": "2025-02-10T13:54:22.616904144Z", + "epoch_id": "94jeudySZcxGBSVgKXn3xPT3P5iFF6YcnxC43F15QtkQ", + "epoch_start_height": 187443633, + "latest_block_hash": "EfL8Rc1EH13UxgbJB4skt8xSF8vojNQPcAX1opf6RFab", + "latest_block_height": 187456272, + "latest_block_time": "2025-02-12T22:10:10.530341781Z", + "latest_state_root": "3Vpebx4DuKAYmMjL96XMmLqWYUfuS2raZWoAbxFxeqBm", + "syncing": false + }, + "uptime_sec": 6020117, + "validator_account_id": null, + "validator_public_key": null, + "validators": [ + { + "account_id": "kiln.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "node2", + "is_slashed": false + }, + { + "account_id": "node3", + "is_slashed": false + }, + { + "account_id": "node0", + "is_slashed": false + }, + { + "account_id": "node1", + "is_slashed": false + }, + { + "account_id": "legends.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "aurora.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "01node.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "stakely_v2.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "chorusone.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "ni.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "foundryusa.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "chorus-one.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "lunanova2.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "everstake.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "fastnear.testnet", + "is_slashed": false + }, + { + "account_id": "pionear-0.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "stakesstone.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "stakeway.pool.f863973.m0", + "is_slashed": false + }, + { + "account_id": "bisontrails.pool.f863973.m0", + "is_slashed": false + } + ], + "version": { + "build": "2.4.0-rc.1", + "rustc_version": "1.82.0", + "version": "2.4.0-rc.1" + } + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/network/validation-status/epoch-hash/request-bash.mdx b/docs/5.api/rpc/network/validation-status/epoch-hash/request-bash.mdx new file mode 100644 index 00000000000..6077495045c --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/epoch-hash/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=validators \ + params:='{ + "epoch_id": "94jeudySZcxGBSVgKXn3xPT3P5iFF6YcnxC43F15QtkQ" + }' +``` diff --git a/docs/5.api/rpc/network/validation-status/epoch-hash/request-json.mdx b/docs/5.api/rpc/network/validation-status/epoch-hash/request-json.mdx new file mode 100644 index 00000000000..2b51a8e1702 --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/epoch-hash/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "validators", + "params": { + "epoch_id": "94jeudySZcxGBSVgKXn3xPT3P5iFF6YcnxC43F15QtkQ" + } +} +``` diff --git a/docs/5.api/rpc/network/validation-status/error-schema-table.mdx b/docs/5.api/rpc/network/validation-status/error-schema-table.mdx new file mode 100644 index 00000000000..566934c573f --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/error-schema-table.mdx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_EPOCH200An epoch for the provided block can't be found in a database +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to an archival node +
  • +
  • + Check that the requested block is the last block of some epoch +
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/network/validation-status/index.mdx b/docs/5.api/rpc/network/validation-status/index.mdx new file mode 100644 index 00000000000..9c14e9d0805 --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/index.mdx @@ -0,0 +1,67 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import EpochHashRequestJson from "./epoch-hash/request-json.mdx"; +import EpochHashRequestBash from "./epoch-hash/request-bash.mdx"; +import LatestRequestJson from "./latest/request-json.mdx"; +import LatestRequestBash from "./latest/request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Validation Status {#validation-status} + +> Queries active validators on the network returning details and the state of +> validation on the blockchain. + +- method: `validators` +- params: + - `epoch_id` _OR_ `[null]` + +**Note:** +You can obtain the `epoch_id` from a block that belongs to a specific epoch.
+If you want to retrieve the current list of validators, pass `null` as the parameter.
+Additionally, you can query validators for past epochs by providing the `epoch_id` +of the desired past epoch. + +`null` example: + + + + + + + + + }> + + + + +`epoch_id` example: + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-2} + + + +Here is the exhaustive list of the error variants that can be returned by `validators` method: + + diff --git a/docs/5.api/rpc/network/validation-status/latest/request-bash.mdx b/docs/5.api/rpc/network/validation-status/latest/request-bash.mdx new file mode 100644 index 00000000000..20bc81dab9d --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/latest/request-bash.mdx @@ -0,0 +1,7 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=validators \ + params:='[null]' +``` diff --git a/docs/5.api/rpc/network/validation-status/latest/request-json.mdx b/docs/5.api/rpc/network/validation-status/latest/request-json.mdx new file mode 100644 index 00000000000..2584dcacb27 --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/latest/request-json.mdx @@ -0,0 +1,8 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "validators", + "params": [null] +} +``` diff --git a/docs/5.api/rpc/network/validation-status/response-json.mdx b/docs/5.api/rpc/network/validation-status/response-json.mdx new file mode 100644 index 00000000000..5405c2e5f3d --- /dev/null +++ b/docs/5.api/rpc/network/validation-status/response-json.mdx @@ -0,0 +1,706 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "current_fishermen": [], + "current_proposals": [ + { + "account_id": "01node.pool.f863973.m0", + "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL", + "stake": "14508308808748255650142126217547", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "aurora.pool.f863973.m0", + "public_key": "ed25519:9c7mczZpNzJz98V1sDeGybfD4gMybP4JKHotH8RrrHTm", + "stake": "17826847625047324847852411794769", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "bee1stake.pool.f863973.m0", + "public_key": "ed25519:B7Mwy3sCCJ6GZzEojsKFXMjLQfVXPDC4Q1LjuHoZcyM6", + "stake": "471694761517302606589435816113", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "bg-1.pool.f863973.m0", + "public_key": "ed25519:BWaBJ1hYmZsarajYwt8VdKineUWza5fSd2mnoMdMSZAP", + "stake": "193323957787516169318606113781", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "bisontrails.pool.f863973.m0", + "public_key": "ed25519:8g4P5EXyp2b2pfVMHY1QLfkRcY59hjPfWrFCKUWX3RmR", + "stake": "865214562736652423187753081175", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "colossus.pool.f863973.m0", + "public_key": "ed25519:FFoMFmpBb7Z4jJE6xivyBRRFP3CDmkWeMrQ7W3jqVBAJ", + "stake": "131506697068344803997879646937", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "everstake.pool.f863973.m0", + "public_key": "ed25519:4LDN8tZUTRRc4siGmYCPA67tRyxStACDchdGDZYKdFsw", + "stake": "3162752192329673966382166073862", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "lavenderfive.pool.f863973.m0", + "public_key": "ed25519:AzwAiLDqprZKpDjhsH7dfyvFdfSasmPTjuJUAHfX1Pg4", + "stake": "31016698022520444934810183598", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "pionear-0.pool.f863973.m0", + "public_key": "ed25519:315y78D1DURpek1qZgp2vZSEkvWaLpgCmNj3YyVRBupW", + "stake": "2458138661861406384369486851832", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "pool01b.carlo01.testnet", + "public_key": "ed25519:GNiQR9xKfwqQLckbfuHo2yRnMnbdCapxK74LTBQxB3DP", + "stake": "5625085084130210554951106454", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "stakely_v2.pool.f863973.m0", + "public_key": "ed25519:7BanKZKGvFjK5Yy83gfJ71vPhqRwsDDyVHrV2FMJCUWr", + "stake": "12258015381474151302438412883474", + "validator_stake_struct_version": "V1" + }, + { + "account_id": "stakeway.pool.f863973.m0", + "public_key": "ed25519:CUzUvC55STwBYCM9rCjPXVC9P9n771QsexigcaV9FzQE", + "stake": "2323231977216618436691170859463", + "validator_stake_struct_version": "V1" + } + ], + "current_validators": [ + { + "account_id": "kiln.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 2622, + "num_expected_chunks": 9298, + "num_expected_chunks_per_shard": [9298], + "num_expected_endorsements": 79788, + "num_expected_endorsements_per_shard": [13298], + "num_produced_blocks": 2622, + "num_produced_chunks": 9288, + "num_produced_chunks_per_shard": [9288], + "num_produced_endorsements": 79625, + "num_produced_endorsements_per_shard": [13274], + "public_key": "ed25519:Bq8fe1eUgDRexX2CYDMhMMQBiN13j8vTAVFyTNhEfh1W", + "shards": [0], + "stake": "92891729926051855086331836750992" + }, + { + "account_id": "node2", + "is_slashed": false, + "num_expected_blocks": 2043, + "num_expected_chunks": 12205, + "num_expected_chunks_per_shard": [12205], + "num_expected_endorsements": 79788, + "num_expected_endorsements_per_shard": [13298], + "num_produced_blocks": 2043, + "num_produced_chunks": 12201, + "num_produced_chunks_per_shard": [12201], + "num_produced_endorsements": 79726, + "num_produced_endorsements_per_shard": [13292], + "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", + "shards": [2], + "stake": "70078722808826224703158216890648" + }, + { + "account_id": "node3", + "is_slashed": false, + "num_expected_blocks": 2021, + "num_expected_chunks": 6701, + "num_expected_chunks_per_shard": [6701], + "num_expected_endorsements": 79786, + "num_expected_endorsements_per_shard": [13298], + "num_produced_blocks": 2021, + "num_produced_chunks": 6699, + "num_produced_chunks_per_shard": [6699], + "num_produced_endorsements": 79694, + "num_produced_endorsements_per_shard": [13291], + "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su", + "shards": [3], + "stake": "69920729382306083222333791762346" + }, + { + "account_id": "node0", + "is_slashed": false, + "num_expected_blocks": 1865, + "num_expected_chunks": 6227, + "num_expected_chunks_per_shard": [6227], + "num_expected_endorsements": 79787, + "num_expected_endorsements_per_shard": [13298], + "num_produced_blocks": 1865, + "num_produced_chunks": 6226, + "num_produced_chunks_per_shard": [6226], + "num_produced_endorsements": 79704, + "num_produced_endorsements_per_shard": [13292], + "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX", + "shards": [3], + "stake": "65137754608752835889247541026299" + }, + { + "account_id": "node1", + "is_slashed": false, + "num_expected_blocks": 1815, + "num_expected_chunks": 11080, + "num_expected_chunks_per_shard": [11080], + "num_expected_endorsements": 79788, + "num_expected_endorsements_per_shard": [13298], + "num_produced_blocks": 1815, + "num_produced_chunks": 11075, + "num_produced_chunks_per_shard": [11075], + "num_produced_endorsements": 79730, + "num_produced_endorsements_per_shard": [13291], + "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e", + "shards": [1], + "stake": "63263814354522829877199449732381" + }, + { + "account_id": "legends.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 658, + "num_expected_chunks": 2226, + "num_expected_chunks_per_shard": [2226], + "num_expected_endorsements": 77942, + "num_expected_endorsements_per_shard": [12991], + "num_produced_blocks": 658, + "num_produced_chunks": 2224, + "num_produced_chunks_per_shard": [2224], + "num_produced_endorsements": 77796, + "num_produced_endorsements_per_shard": [12963], + "public_key": "ed25519:AhQ6sUifJYgjqarXSAzdDZU9ZixpUesP9JEH1Vr7NbaF", + "shards": [0], + "stake": "21699960146196584008369593130963" + }, + { + "account_id": "aurora.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 526, + "num_expected_chunks": 7605, + "num_expected_chunks_per_shard": [7605], + "num_expected_endorsements": 76454, + "num_expected_endorsements_per_shard": [12737], + "num_produced_blocks": 526, + "num_produced_chunks": 7603, + "num_produced_chunks_per_shard": [7603], + "num_produced_endorsements": 76389, + "num_produced_endorsements_per_shard": [12728], + "public_key": "ed25519:9c7mczZpNzJz98V1sDeGybfD4gMybP4JKHotH8RrrHTm", + "shards": [4], + "stake": "17821019225873468551948241890887" + }, + { + "account_id": "01node.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 423, + "num_expected_chunks": 1503, + "num_expected_chunks_per_shard": [1503], + "num_expected_endorsements": 73729, + "num_expected_endorsements_per_shard": [12329], + "num_produced_blocks": 423, + "num_produced_chunks": 1502, + "num_produced_chunks_per_shard": [1502], + "num_produced_endorsements": 73577, + "num_produced_endorsements_per_shard": [12301], + "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL", + "shards": [0], + "stake": "14503585729080627951824567828719" + }, + { + "account_id": "stakely_v2.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 334, + "num_expected_chunks": 5337, + "num_expected_chunks_per_shard": [5337], + "num_expected_endorsements": 70936, + "num_expected_endorsements_per_shard": [11814], + "num_produced_blocks": 334, + "num_produced_chunks": 5331, + "num_produced_chunks_per_shard": [5331], + "num_produced_endorsements": 70854, + "num_produced_endorsements_per_shard": [11797], + "public_key": "ed25519:7BanKZKGvFjK5Yy83gfJ71vPhqRwsDDyVHrV2FMJCUWr", + "shards": [4], + "stake": "12254024869278462134131091911403" + }, + { + "account_id": "chorusone.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 164, + "num_expected_chunks": 871, + "num_expected_chunks_per_shard": [871], + "num_expected_endorsements": 47978, + "num_expected_endorsements_per_shard": [7926], + "num_produced_blocks": 164, + "num_produced_chunks": 871, + "num_produced_chunks_per_shard": [871], + "num_produced_endorsements": 47915, + "num_produced_endorsements_per_shard": [7913], + "public_key": "ed25519:3TkUuDpzrq75KtJhkuLfNNJBPHR5QEWpDxrter3znwto", + "shards": [1], + "stake": "5021605065953771080058901060214" + }, + { + "account_id": "ni.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 130, + "num_expected_chunks": 700, + "num_expected_chunks_per_shard": [700], + "num_expected_endorsements": 41432, + "num_expected_endorsements_per_shard": [6864], + "num_produced_blocks": 130, + "num_produced_chunks": 700, + "num_produced_chunks_per_shard": [700], + "num_produced_endorsements": 41317, + "num_produced_endorsements_per_shard": [6843], + "public_key": "ed25519:GfCfFkLk2twbAWdsS3tr7C2eaiHN3znSfbshS5e8NqBS", + "shards": [2], + "stake": "4171300662937553143029051488796" + }, + { + "account_id": "foundryusa.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 129, + "num_expected_chunks": 727, + "num_expected_chunks_per_shard": [727], + "num_expected_endorsements": 41314, + "num_expected_endorsements_per_shard": [6832], + "num_produced_blocks": 129, + "num_produced_chunks": 727, + "num_produced_chunks_per_shard": [727], + "num_produced_endorsements": 38980, + "num_produced_endorsements_per_shard": [6705], + "public_key": "ed25519:ABGnMW8c87ZKWxvZLLWgvrNe72HN7UoSf4cTBxCHbEE5", + "shards": [1], + "stake": "4002828237905742589189924266507" + }, + { + "account_id": "chorus-one.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 99, + "num_expected_chunks": 370, + "num_expected_chunks_per_shard": [370], + "num_expected_endorsements": 41252, + "num_expected_endorsements_per_shard": [6869], + "num_produced_blocks": 99, + "num_produced_chunks": 370, + "num_produced_chunks_per_shard": [370], + "num_produced_endorsements": 41189, + "num_produced_endorsements_per_shard": [6858], + "public_key": "ed25519:6LFwyEEsqhuDxorWfsKcPPs324zLWTaoqk4o6RDXN7Qc", + "shards": [3], + "stake": "3540207403371800913697591351067" + }, + { + "account_id": "lunanova2.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 88, + "num_expected_chunks": 620, + "num_expected_chunks_per_shard": [620], + "num_expected_endorsements": 41311, + "num_expected_endorsements_per_shard": [6932], + "num_produced_blocks": 88, + "num_produced_chunks": 620, + "num_produced_chunks_per_shard": [620], + "num_produced_endorsements": 41267, + "num_produced_endorsements_per_shard": [6926], + "public_key": "ed25519:9Jv6e9Kye4wM9EL1XJvXY8CYsLi1HLdRKnTzXBQY44w9", + "shards": [1], + "stake": "3482601242374916990980148061500" + }, + { + "account_id": "everstake.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 86, + "num_expected_chunks": 5154, + "num_expected_chunks_per_shard": [5154], + "num_expected_endorsements": 33613, + "num_expected_endorsements_per_shard": [5662], + "num_produced_blocks": 86, + "num_produced_chunks": 5152, + "num_produced_chunks_per_shard": [5152], + "num_produced_endorsements": 33576, + "num_produced_endorsements_per_shard": [5652], + "public_key": "ed25519:4LDN8tZUTRRc4siGmYCPA67tRyxStACDchdGDZYKdFsw", + "shards": [5], + "stake": "3161722580047357404436371465448" + }, + { + "account_id": "fastnear.testnet", + "is_slashed": false, + "num_expected_blocks": 69, + "num_expected_chunks": 4219, + "num_expected_chunks_per_shard": [4219], + "num_expected_endorsements": 33662, + "num_expected_endorsements_per_shard": [5583], + "num_produced_blocks": 69, + "num_produced_chunks": 4216, + "num_produced_chunks_per_shard": [4216], + "num_produced_endorsements": 33275, + "num_produced_endorsements_per_shard": [5534], + "public_key": "ed25519:FUSbEhRG22AiQEUr8PgRJJjdYqnsBbzTmquLchZ3EuaJ", + "shards": [5], + "stake": "2537831618716734010878317070489" + }, + { + "account_id": "pionear-0.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 64, + "num_expected_chunks": 271, + "num_expected_chunks_per_shard": [271], + "num_expected_endorsements": 33604, + "num_expected_endorsements_per_shard": [5575], + "num_produced_blocks": 64, + "num_produced_chunks": 271, + "num_produced_chunks_per_shard": [271], + "num_produced_endorsements": 33552, + "num_produced_endorsements_per_shard": [5567], + "public_key": "ed25519:315y78D1DURpek1qZgp2vZSEkvWaLpgCmNj3YyVRBupW", + "shards": [0], + "stake": "2457338431580190425147558948590" + }, + { + "account_id": "stakesstone.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 67, + "num_expected_chunks": 3925, + "num_expected_chunks_per_shard": [3925], + "num_expected_endorsements": 33622, + "num_expected_endorsements_per_shard": [5604], + "num_produced_blocks": 67, + "num_produced_chunks": 3924, + "num_produced_chunks_per_shard": [3924], + "num_produced_endorsements": 33575, + "num_produced_endorsements_per_shard": [5595], + "public_key": "ed25519:3aAdsKUuzZbjW9hHnmLWFRKwXjmcxsnLNLfNL4gP1wJ8", + "shards": [5], + "stake": "2392729489880088390499500312797" + }, + { + "account_id": "stakeway.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 72, + "num_expected_chunks": 393, + "num_expected_chunks_per_shard": [393], + "num_expected_endorsements": 33705, + "num_expected_endorsements_per_shard": [5701], + "num_produced_blocks": 72, + "num_produced_chunks": 393, + "num_produced_chunks_per_shard": [393], + "num_produced_endorsements": 32290, + "num_produced_endorsements_per_shard": [5686], + "public_key": "ed25519:CUzUvC55STwBYCM9rCjPXVC9P9n771QsexigcaV9FzQE", + "shards": [2], + "stake": "2322475664929977341656713227424" + }, + { + "account_id": "bisontrails.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 23, + "num_expected_chunks": 356, + "num_expected_chunks_per_shard": [356], + "num_expected_endorsements": 13298, + "num_expected_endorsements_per_shard": [2206], + "num_produced_blocks": 23, + "num_produced_chunks": 356, + "num_produced_chunks_per_shard": [356], + "num_produced_endorsements": 12619, + "num_produced_endorsements_per_shard": [2177], + "public_key": "ed25519:8g4P5EXyp2b2pfVMHY1QLfkRcY59hjPfWrFCKUWX3RmR", + "shards": [4], + "stake": "864932897923367748455848113029" + }, + { + "account_id": "bee1stake.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "num_produced_endorsements": 12590, + "public_key": "ed25519:B7Mwy3sCCJ6GZzEojsKFXMjLQfVXPDC4Q1LjuHoZcyM6", + "shards": [], + "stake": "471541204349192086717416391804" + }, + { + "account_id": "bg-1.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "num_produced_endorsements": 13059, + "public_key": "ed25519:BWaBJ1hYmZsarajYwt8VdKineUWza5fSd2mnoMdMSZAP", + "shards": [], + "stake": "193261022264150168446871422383" + }, + { + "account_id": "bdcnear.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "num_produced_endorsements": 11657, + "public_key": "ed25519:38XzZgGzXkVU1WGPmAebVgKUS7TNoTQ4BbwYmSaJtB5E", + "shards": [], + "stake": "152253956367503132443302137897" + }, + { + "account_id": "colossus.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "num_produced_endorsements": 12525, + "public_key": "ed25519:FFoMFmpBb7Z4jJE6xivyBRRFP3CDmkWeMrQ7W3jqVBAJ", + "shards": [], + "stake": "131463885701606478224024595560" + }, + { + "account_id": "do0k13.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "public_key": "ed25519:BNZEVQLfRVQ6kRDtSiehn5VCdsDfvnmPP6PFEfEF4Kyc", + "shards": [], + "stake": "20052755347209554047688885272" + }, + { + "account_id": "m340i.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "num_produced_endorsements": 12171, + "public_key": "ed25519:AAmV17bBMV1AwigkfRXJjZeW45bncxg6Mh3wDD312CxS", + "shards": [], + "stake": "12791380004559238408090666856" + }, + { + "account_id": "smcvalidator.pool.f863973.m0", + "is_slashed": false, + "num_expected_blocks": 0, + "num_expected_chunks": 0, + "num_expected_chunks_per_shard": [], + "num_expected_endorsements": 13298, + "num_produced_blocks": 0, + "num_produced_chunks": 0, + "num_produced_chunks_per_shard": [], + "public_key": "ed25519:pG4LYsyoAa8yWYG9nsTQ5yBcwke51i3VqeRcMVbE9Q7", + "shards": [], + "stake": "11572234249650586892415305619" + } + ], + "epoch_height": 3358, + "epoch_start_height": 187443633, + "next_fishermen": [], + "next_validators": [ + { + "account_id": "kiln.pool.f863973.m0", + "public_key": "ed25519:Bq8fe1eUgDRexX2CYDMhMMQBiN13j8vTAVFyTNhEfh1W", + "shards": [0], + "stake": "92921980033422214461941381687070" + }, + { + "account_id": "node2", + "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", + "shards": [2], + "stake": "70101543880843059439753643153179" + }, + { + "account_id": "node3", + "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su", + "shards": [3], + "stake": "69943499004029400432138935046376" + }, + { + "account_id": "node0", + "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX", + "shards": [3], + "stake": "65158966659105429729981574314821" + }, + { + "account_id": "node1", + "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e", + "shards": [1], + "stake": "63284416157941533583511983074616" + }, + { + "account_id": "legends.pool.f863973.m0", + "public_key": "ed25519:AhQ6sUifJYgjqarXSAzdDZU9ZixpUesP9JEH1Vr7NbaF", + "shards": [0], + "stake": "21707026718417797003552971028171" + }, + { + "account_id": "aurora.pool.f863973.m0", + "public_key": "ed25519:9c7mczZpNzJz98V1sDeGybfD4gMybP4JKHotH8RrrHTm", + "shards": [4], + "stake": "17826847624645549774838011794769" + }, + { + "account_id": "01node.pool.f863973.m0", + "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL", + "shards": [0], + "stake": "14508308808643776172456926217547" + }, + { + "account_id": "stakely_v2.pool.f863973.m0", + "public_key": "ed25519:7BanKZKGvFjK5Yy83gfJ71vPhqRwsDDyVHrV2FMJCUWr", + "shards": [4], + "stake": "12258015381384133457889212883474" + }, + { + "account_id": "chorusone.pool.f863973.m0", + "public_key": "ed25519:3TkUuDpzrq75KtJhkuLfNNJBPHR5QEWpDxrter3znwto", + "shards": [1], + "stake": "5023240357275531194839534425974" + }, + { + "account_id": "ni.pool.f863973.m0", + "public_key": "ed25519:GfCfFkLk2twbAWdsS3tr7C2eaiHN3znSfbshS5e8NqBS", + "shards": [2], + "stake": "4172659043272273212430060733803" + }, + { + "account_id": "foundryusa.pool.f863973.m0", + "public_key": "ed25519:ABGnMW8c87ZKWxvZLLWgvrNe72HN7UoSf4cTBxCHbEE5", + "shards": [1], + "stake": "4004136212576286646267651480193" + }, + { + "account_id": "chorus-one.pool.f863973.m0", + "public_key": "ed25519:6LFwyEEsqhuDxorWfsKcPPs324zLWTaoqk4o6RDXN7Qc", + "shards": [3], + "stake": "3541360268682365851956864933197" + }, + { + "account_id": "lunanova2.pool.f863973.m0", + "public_key": "ed25519:9Jv6e9Kye4wM9EL1XJvXY8CYsLi1HLdRKnTzXBQY44w9", + "shards": [1], + "stake": "3483735348291753982514724379044" + }, + { + "account_id": "everstake.pool.f863973.m0", + "public_key": "ed25519:4LDN8tZUTRRc4siGmYCPA67tRyxStACDchdGDZYKdFsw", + "shards": [5], + "stake": "3162752192225120518455066073862" + }, + { + "account_id": "fastnear.testnet", + "public_key": "ed25519:FUSbEhRG22AiQEUr8PgRJJjdYqnsBbzTmquLchZ3EuaJ", + "shards": [5], + "stake": "2538658061267693395333896919744" + }, + { + "account_id": "pionear-0.pool.f863973.m0", + "public_key": "ed25519:315y78D1DURpek1qZgp2vZSEkvWaLpgCmNj3YyVRBupW", + "shards": [0], + "stake": "2458138661730825288726186851832" + }, + { + "account_id": "stakesstone.pool.f863973.m0", + "public_key": "ed25519:3aAdsKUuzZbjW9hHnmLWFRKwXjmcxsnLNLfNL4gP1wJ8", + "shards": [5], + "stake": "2393508680167151178654927962933" + }, + { + "account_id": "stakeway.pool.f863973.m0", + "public_key": "ed25519:CUzUvC55STwBYCM9rCjPXVC9P9n771QsexigcaV9FzQE", + "shards": [2], + "stake": "2323231977126165123038870859463" + }, + { + "account_id": "bisontrails.pool.f863973.m0", + "public_key": "ed25519:8g4P5EXyp2b2pfVMHY1QLfkRcY59hjPfWrFCKUWX3RmR", + "shards": [4], + "stake": "865214562646576811861753081175" + }, + { + "account_id": "bee1stake.pool.f863973.m0", + "public_key": "ed25519:B7Mwy3sCCJ6GZzEojsKFXMjLQfVXPDC4Q1LjuHoZcyM6", + "shards": [], + "stake": "471694761414887680568035816113" + }, + { + "account_id": "bg-1.pool.f863973.m0", + "public_key": "ed25519:BWaBJ1hYmZsarajYwt8VdKineUWza5fSd2mnoMdMSZAP", + "shards": [], + "stake": "193323957663594316022106113781" + }, + { + "account_id": "bdcnear.pool.f863973.m0", + "public_key": "ed25519:38XzZgGzXkVU1WGPmAebVgKUS7TNoTQ4BbwYmSaJtB5E", + "shards": [], + "stake": "152303537729468030960543152051" + }, + { + "account_id": "colossus.pool.f863973.m0", + "public_key": "ed25519:FFoMFmpBb7Z4jJE6xivyBRRFP3CDmkWeMrQ7W3jqVBAJ", + "shards": [], + "stake": "131506696932997797323679646937" + }, + { + "account_id": "lavenderfive.pool.f863973.m0", + "public_key": "ed25519:AzwAiLDqprZKpDjhsH7dfyvFdfSasmPTjuJUAHfX1Pg4", + "shards": [], + "stake": "31016697830847968307510183598" + }, + { + "account_id": "do0k13.pool.f863973.m0", + "public_key": "ed25519:BNZEVQLfRVQ6kRDtSiehn5VCdsDfvnmPP6PFEfEF4Kyc", + "shards": [], + "stake": "20052755432372793140688885272" + }, + { + "account_id": "m340i.pool.f863973.m0", + "public_key": "ed25519:AAmV17bBMV1AwigkfRXJjZeW45bncxg6Mh3wDD312CxS", + "shards": [], + "stake": "12795545505786070882425535528" + } + ], + "prev_epoch_kickout": [ + { + "account_id": "smcvalidator.pool.f863973.m0", + "reason": { + "NotEnoughChunkEndorsements": { + "expected": 43196, + "produced": 0 + } + } + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/protocol.md b/docs/5.api/rpc/protocol.md index 24d883d9377..bb2b8f13814 100644 --- a/docs/5.api/rpc/protocol.md +++ b/docs/5.api/rpc/protocol.md @@ -3,670 +3,13 @@ id: protocol title: Protocol --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - +import GenesisConfig from './protocol/genesis-config/index.mdx'; +import ProtocolConfig from './protocol/protocol-config/index.mdx'; The RPC API enables you to retrieve the current genesis and protocol configuration. --- - -## Genesis Config {#genesis-config} - -> Returns current genesis configuration. - -- method: `EXPERIMENTAL_genesis_config` -- params: _none_ - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_genesis_config" -} -``` - - - - -```js -const response = await near.connection.provider.experimental_genesisConfig(); -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_genesis_config -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "protocol_version": 29, - "genesis_time": "2020-07-31T03:39:42.911378Z", - "chain_id": "testnet", - "genesis_height": 10885359, - "num_block_producer_seats": 100, - "num_block_producer_seats_per_shard": [100], - "avg_hidden_validator_seats_per_shard": [0], - "dynamic_resharding": false, - "protocol_upgrade_stake_threshold": [4, 5], - "protocol_upgrade_num_epochs": 2, - "epoch_length": 43200, - "gas_limit": 1000000000000000, - "min_gas_price": "5000", - "max_gas_price": "10000000000000000000000", - "block_producer_kickout_threshold": 80, - "chunk_producer_kickout_threshold": 90, - "online_min_threshold": [90, 100], - "online_max_threshold": [99, 100], - "gas_price_adjustment_rate": [1, 100], - "runtime_config": { - "storage_amount_per_byte": "90949470177292823791", - "transaction_costs": { - "action_receipt_creation_config": { - "send_sir": 108059500000, - "send_not_sir": 108059500000, - "execution": 108059500000 - }, - "data_receipt_creation_config": { - "base_cost": { - "send_sir": 4697339419375, - "send_not_sir": 4697339419375, - "execution": 4697339419375 - }, - "cost_per_byte": { - "send_sir": 59357464, - "send_not_sir": 59357464, - "execution": 59357464 - } - }, - "action_creation_config": { - "create_account_cost": { - "send_sir": 99607375000, - "send_not_sir": 99607375000, - "execution": 99607375000 - }, - "deploy_contract_cost": { - "send_sir": 184765750000, - "send_not_sir": 184765750000, - "execution": 184765750000 - }, - "deploy_contract_cost_per_byte": { - "send_sir": 6812999, - "send_not_sir": 6812999, - "execution": 6812999 - }, - "function_call_cost": { - "send_sir": 2319861500000, - "send_not_sir": 2319861500000, - "execution": 2319861500000 - }, - "function_call_cost_per_byte": { - "send_sir": 2235934, - "send_not_sir": 2235934, - "execution": 2235934 - }, - "transfer_cost": { - "send_sir": 115123062500, - "send_not_sir": 115123062500, - "execution": 115123062500 - }, - "stake_cost": { - "send_sir": 141715687500, - "send_not_sir": 141715687500, - "execution": 102217625000 - }, - "add_key_cost": { - "full_access_cost": { - "send_sir": 101765125000, - "send_not_sir": 101765125000, - "execution": 101765125000 - }, - "function_call_cost": { - "send_sir": 102217625000, - "send_not_sir": 102217625000, - "execution": 102217625000 - }, - "function_call_cost_per_byte": { - "send_sir": 1925331, - "send_not_sir": 1925331, - "execution": 1925331 - } - }, - "delete_key_cost": { - "send_sir": 94946625000, - "send_not_sir": 94946625000, - "execution": 94946625000 - }, - "delete_account_cost": { - "send_sir": 147489000000, - "send_not_sir": 147489000000, - "execution": 147489000000 - } - }, - "storage_usage_config": { - "num_bytes_account": 100, - "num_extra_bytes_record": 40 - }, - "burnt_gas_reward": [3, 10], - "pessimistic_gas_price_inflation_ratio": [103, 100] - }, - "wasm_config": { - "ext_costs": { - "base": 264768111, - "contract_compile_base": 35445963, - "contract_compile_bytes": 216750, - "read_memory_base": 2609863200, - "read_memory_byte": 3801333, - "write_memory_base": 2803794861, - "write_memory_byte": 2723772, - "read_register_base": 2517165186, - "read_register_byte": 98562, - "write_register_base": 2865522486, - "write_register_byte": 3801564, - "utf8_decoding_base": 3111779061, - "utf8_decoding_byte": 291580479, - "utf16_decoding_base": 3543313050, - "utf16_decoding_byte": 163577493, - "sha256_base": 4540970250, - "sha256_byte": 24117351, - "keccak256_base": 5879491275, - "keccak256_byte": 21471105, - "keccak512_base": 5811388236, - "keccak512_byte": 36649701, - "log_base": 3543313050, - "log_byte": 13198791, - "storage_write_base": 64196736000, - "storage_write_key_byte": 70482867, - "storage_write_value_byte": 31018539, - "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, - "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, - "storage_remove_base": 53473030500, - "storage_remove_key_byte": 38220384, - "storage_remove_ret_value_byte": 11531556, - "storage_has_key_base": 54039896625, - "storage_has_key_byte": 30790845, - "storage_iter_create_prefix_base": 0, - "storage_iter_create_prefix_byte": 0, - "storage_iter_create_range_base": 0, - "storage_iter_create_from_byte": 0, - "storage_iter_create_to_byte": 0, - "storage_iter_next_base": 0, - "storage_iter_next_key_byte": 0, - "storage_iter_next_value_byte": 0, - "touching_trie_node": 16101955926, - "promise_and_base": 1465013400, - "promise_and_per_promise": 5452176, - "promise_return": 560152386, - "validator_stake_base": 911834726400, - "validator_total_stake_base": 911834726400 - }, - "grow_mem_cost": 1, - "regular_op_cost": 3856371, - "limit_config": { - "max_gas_burnt": 200000000000000, - "max_gas_burnt_view": 200000000000000, - "max_stack_height": 16384, - "initial_memory_pages": 1024, - "max_memory_pages": 2048, - "registers_memory_limit": 1073741824, - "max_register_size": 104857600, - "max_number_registers": 100, - "max_number_logs": 100, - "max_total_log_length": 16384, - "max_total_prepaid_gas": 300000000000000, - "max_actions_per_receipt": 100, - "max_number_bytes_method_names": 2000, - "max_length_method_name": 256, - "max_arguments_length": 4194304, - "max_length_returned_data": 4194304, - "max_contract_size": 4194304, - "max_length_storage_key": 4194304, - "max_length_storage_value": 4194304, - "max_promises_per_function_call_action": 1024, - "max_number_input_data_dependencies": 128 - } - }, - "account_creation_config": { - "min_allowed_top_level_account_length": 0, - "registrar_account_id": "registrar" - } - }, - "validators": [ - { - "account_id": "node0", - "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX", - "amount": "1000000000000000000000000000000" - }, - { - "account_id": "node1", - "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e", - "amount": "1000000000000000000000000000000" - }, - { - "account_id": "node2", - "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5", - "amount": "1000000000000000000000000000000" - }, - { - "account_id": "node3", - "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su", - "amount": "1000000000000000000000000000000" - } - ], - "transaction_validity_period": 86400, - "protocol_reward_rate": [1, 10], - "max_inflation_rate": [1, 20], - "total_supply": "1031467299046044096035532756810080", - "num_blocks_per_year": 31536000, - "protocol_treasury_account": "near", - "fishermen_threshold": "10000000000000000000", - "minimum_stake_divisor": 10 - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_genesis_config` method: - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Protocol Config {#protocol-config} - -> Returns most recent protocol configuration or a specific queried block. Useful for finding current storage and transaction costs. - -- method: `EXPERIMENTAL_protocol_config` -- params: - - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_protocol_config", - "params": { - "finality": "final" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=EXPERIMENTAL_protocol_config \ - params:='{ - "finality": "final" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "protocol_version": 45, - "genesis_time": "2020-07-31T03:39:42.911378Z", - "chain_id": "testnet", - "genesis_height": 42376888, - "num_block_producer_seats": 200, - "num_block_producer_seats_per_shard": [200], - "avg_hidden_validator_seats_per_shard": [0], - "dynamic_resharding": false, - "protocol_upgrade_stake_threshold": [4, 5], - "epoch_length": 43200, - "gas_limit": 1000000000000000, - "min_gas_price": "5000", - "max_gas_price": "10000000000000000000000", - "block_producer_kickout_threshold": 80, - "chunk_producer_kickout_threshold": 90, - "online_min_threshold": [90, 100], - "online_max_threshold": [99, 100], - "gas_price_adjustment_rate": [1, 100], - "runtime_config": { - "storage_amount_per_byte": "10000000000000000000", - "transaction_costs": { - "action_receipt_creation_config": { - "send_sir": 108059500000, - "send_not_sir": 108059500000, - "execution": 108059500000 - }, - "data_receipt_creation_config": { - "base_cost": { - "send_sir": 4697339419375, - "send_not_sir": 4697339419375, - "execution": 4697339419375 - }, - "cost_per_byte": { - "send_sir": 59357464, - "send_not_sir": 59357464, - "execution": 59357464 - } - }, - "action_creation_config": { - "create_account_cost": { - "send_sir": 99607375000, - "send_not_sir": 99607375000, - "execution": 99607375000 - }, - "deploy_contract_cost": { - "send_sir": 184765750000, - "send_not_sir": 184765750000, - "execution": 184765750000 - }, - "deploy_contract_cost_per_byte": { - "send_sir": 6812999, - "send_not_sir": 6812999, - "execution": 6812999 - }, - "function_call_cost": { - "send_sir": 2319861500000, - "send_not_sir": 2319861500000, - "execution": 2319861500000 - }, - "function_call_cost_per_byte": { - "send_sir": 2235934, - "send_not_sir": 2235934, - "execution": 2235934 - }, - "transfer_cost": { - "send_sir": 115123062500, - "send_not_sir": 115123062500, - "execution": 115123062500 - }, - "stake_cost": { - "send_sir": 141715687500, - "send_not_sir": 141715687500, - "execution": 102217625000 - }, - "add_key_cost": { - "full_access_cost": { - "send_sir": 101765125000, - "send_not_sir": 101765125000, - "execution": 101765125000 - }, - "function_call_cost": { - "send_sir": 102217625000, - "send_not_sir": 102217625000, - "execution": 102217625000 - }, - "function_call_cost_per_byte": { - "send_sir": 1925331, - "send_not_sir": 1925331, - "execution": 1925331 - } - }, - "delete_key_cost": { - "send_sir": 94946625000, - "send_not_sir": 94946625000, - "execution": 94946625000 - }, - "delete_account_cost": { - "send_sir": 147489000000, - "send_not_sir": 147489000000, - "execution": 147489000000 - } - }, - "storage_usage_config": { - "num_bytes_account": 100, - "num_extra_bytes_record": 40 - }, - "burnt_gas_reward": [3, 10], - "pessimistic_gas_price_inflation_ratio": [103, 100] - }, - "wasm_config": { - "ext_costs": { - "base": 264768111, - "contract_compile_base": 35445963, - "contract_compile_bytes": 216750, - "read_memory_base": 2609863200, - "read_memory_byte": 3801333, - "write_memory_base": 2803794861, - "write_memory_byte": 2723772, - "read_register_base": 2517165186, - "read_register_byte": 98562, - "write_register_base": 2865522486, - "write_register_byte": 3801564, - "utf8_decoding_base": 3111779061, - "utf8_decoding_byte": 291580479, - "utf16_decoding_base": 3543313050, - "utf16_decoding_byte": 163577493, - "sha256_base": 4540970250, - "sha256_byte": 24117351, - "keccak256_base": 5879491275, - "keccak256_byte": 21471105, - "keccak512_base": 5811388236, - "keccak512_byte": 36649701, - "log_base": 3543313050, - "log_byte": 13198791, - "storage_write_base": 64196736000, - "storage_write_key_byte": 70482867, - "storage_write_value_byte": 31018539, - "storage_write_evicted_byte": 32117307, - "storage_read_base": 56356845750, - "storage_read_key_byte": 30952533, - "storage_read_value_byte": 5611005, - "storage_remove_base": 53473030500, - "storage_remove_key_byte": 38220384, - "storage_remove_ret_value_byte": 11531556, - "storage_has_key_base": 54039896625, - "storage_has_key_byte": 30790845, - "storage_iter_create_prefix_base": 0, - "storage_iter_create_prefix_byte": 0, - "storage_iter_create_range_base": 0, - "storage_iter_create_from_byte": 0, - "storage_iter_create_to_byte": 0, - "storage_iter_next_base": 0, - "storage_iter_next_key_byte": 0, - "storage_iter_next_value_byte": 0, - "touching_trie_node": 16101955926, - "promise_and_base": 1465013400, - "promise_and_per_promise": 5452176, - "promise_return": 560152386, - "validator_stake_base": 911834726400, - "validator_total_stake_base": 911834726400 - }, - "grow_mem_cost": 1, - "regular_op_cost": 3856371, - "limit_config": { - "max_gas_burnt": 200000000000000, - "max_gas_burnt_view": 200000000000000, - "max_stack_height": 16384, - "initial_memory_pages": 1024, - "max_memory_pages": 2048, - "registers_memory_limit": 1073741824, - "max_register_size": 104857600, - "max_number_registers": 100, - "max_number_logs": 100, - "max_total_log_length": 16384, - "max_total_prepaid_gas": 300000000000000, - "max_actions_per_receipt": 100, - "max_number_bytes_method_names": 2000, - "max_length_method_name": 256, - "max_arguments_length": 4194304, - "max_length_returned_data": 4194304, - "max_contract_size": 4194304, - "max_length_storage_key": 4194304, - "max_length_storage_value": 4194304, - "max_promises_per_function_call_action": 1024, - "max_number_input_data_dependencies": 128 - } - }, - "account_creation_config": { - "min_allowed_top_level_account_length": 0, - "registrar_account_id": "registrar" - } - }, - "transaction_validity_period": 86400, - "protocol_reward_rate": [1, 10], - "max_inflation_rate": [1, 20], - "num_blocks_per_year": 31536000, - "protocol_treasury_account": "near", - "fishermen_threshold": "340282366920938463463374607431768211455", - "minimum_stake_divisor": 10 - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-1} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_protocol_config` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200The requested block has not been produced yet or it has been garbage-collected (cleaned up to save space on the RPC node) -
    -
  • Check that the requested block is legit
  • -
  • If the block had been produced more than 5 epochs ago, try to send your request to an archival node
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/protocol/genesis-config/error-schema-table.mdx b/docs/5.api/rpc/protocol/genesis-config/error-schema-table.mdx new file mode 100644 index 00000000000..1101871ef84 --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/error-schema-table.mdx @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/protocol/genesis-config/index.mdx b/docs/5.api/rpc/protocol/genesis-config/index.mdx new file mode 100644 index 00000000000..0c7a7b79c41 --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/index.mdx @@ -0,0 +1,47 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Genesis Config {#genesis-config} + +> Returns current genesis configuration. + +- method: `EXPERIMENTAL_genesis_config` +- params: _none_ + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_genesis_config` method: + + diff --git a/docs/5.api/rpc/protocol/genesis-config/request-bash.mdx b/docs/5.api/rpc/protocol/genesis-config/request-bash.mdx new file mode 100644 index 00000000000..80975325591 --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/request-bash.mdx @@ -0,0 +1,6 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_genesis_config +``` diff --git a/docs/5.api/rpc/protocol/genesis-config/request-js.mdx b/docs/5.api/rpc/protocol/genesis-config/request-js.mdx new file mode 100644 index 00000000000..cce2ed769c2 --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.experimental_protocolConfig({ + sync_checkpoint: "genesis", +}); +``` diff --git a/docs/5.api/rpc/protocol/genesis-config/request-json.mdx b/docs/5.api/rpc/protocol/genesis-config/request-json.mdx new file mode 100644 index 00000000000..9565711bd17 --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/request-json.mdx @@ -0,0 +1,7 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_genesis_config" +} +``` diff --git a/docs/5.api/rpc/protocol/genesis-config/response-json.mdx b/docs/5.api/rpc/protocol/genesis-config/response-json.mdx new file mode 100644 index 00000000000..e2b75da647c --- /dev/null +++ b/docs/5.api/rpc/protocol/genesis-config/response-json.mdx @@ -0,0 +1,158 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "avg_hidden_validator_seats_per_shard": [0], + "block_producer_kickout_threshold": 80, + "chain_id": "testnet", + "chunk_producer_assignment_changes_limit": 5, + "chunk_producer_kickout_threshold": 90, + "chunk_validator_only_kickout_threshold": 80, + "dynamic_resharding": false, + "epoch_length": 43200, + "fishermen_threshold": "340282366920938463463374607431768211455", + "gas_limit": 1000000000000000, + "gas_price_adjustment_rate": [1, 100], + "genesis_height": 42376888, + "genesis_time": "2020-07-31T03:39:42.911378Z", + "max_gas_price": "10000000000000000000000", + "max_inflation_rate": [1, 20], + "max_kickout_stake_perc": 100, + "min_gas_price": "5000", + "minimum_stake_divisor": 10, + "minimum_stake_ratio": [1, 6250], + "minimum_validators_per_shard": 1, + "num_block_producer_seats": 200, + "num_block_producer_seats_per_shard": [200], + "num_blocks_per_year": 31536000, + "num_chunk_only_producer_seats": 300, + "num_chunk_producer_seats": 100, + "num_chunk_validator_seats": 300, + "online_max_threshold": [99, 100], + "online_min_threshold": [90, 100], + "protocol_reward_rate": [1, 10], + "protocol_treasury_account": "near", + "protocol_upgrade_stake_threshold": [4, 5], + "protocol_version": 29, + "shard_layout": { + "V0": { + "num_shards": 1, + "version": 0 + } + }, + "shuffle_shard_assignment_for_chunk_producers": false, + "target_validator_mandates_per_shard": 68, + "total_supply": "2089646653180081825096998107194444", + "transaction_validity_period": 86400, + "use_production_config": false, + "validators": [ + { + "account_id": "masternode24.pool.f863973.m0", + "amount": "2096547887468158804726149840014", + "public_key": "ed25519:9E3JvrQN6VGDGg1WJ3TjBsNyfmrU6kncBcDvvJLj6qHr" + }, + { + "account_id": "lunanova.pool.f863973.m0", + "amount": "6023592217250515747116857534108", + "public_key": "ed25519:2fZ59qfo9QHNLijoht9cwUb9enSNcnRmXbQn1gKZxvkw" + }, + { + "account_id": "node0", + "amount": "7017386808510582905904716139001", + "public_key": "ed25519:7PGseFbWxvYVgZ89K1uTJKYoKetWs7BJtbyXDzfbAcqX" + }, + { + "account_id": "node1", + "amount": "7021733510638228632380895173752", + "public_key": "ed25519:6DSjZ8mvsRZDvFqFxo8tCKePG96omXW7eVYVSySmDk8e" + }, + { + "account_id": "nodeasy.pool.f863973.m0", + "amount": "350028003459257633077889642325", + "public_key": "ed25519:25Dhg8NBvQhsVTuugav3t1To1X1zKiomDmnh8yN9hHMb" + }, + { + "account_id": "valeraverim.pool.f863973.m0", + "amount": "2460437541222457077732687804254", + "public_key": "ed25519:3686ABqNUZc1qhLWLHg5xZpBzrWPiUCMNZxcCNmg3e2s" + }, + { + "account_id": "node2", + "amount": "7022280566885326956797181813724", + "public_key": "ed25519:GkDv7nSMS3xcqA45cpMvFmfV1o4fRF6zYo1JRR6mNqg5" + }, + { + "account_id": "orangeclub.pool.f863973.m0", + "amount": "3073208665436498671483798256985", + "public_key": "ed25519:HezFeSzcwuR5wvkqccgMCMnpf1eQkVCfk52tXZEdKZHz" + }, + { + "account_id": "tribe-pool.pool.f863973.m0", + "amount": "502021509894008520748060961431", + "public_key": "ed25519:CRS4HTSAeiP8FKD3c3ZrCL5pC92Mu1LQaWj22keThwFY" + }, + { + "account_id": "staked.pool.f863973.m0", + "amount": "1835541810883701332840668361355", + "public_key": "ed25519:D2afKYVaKQ1LGiWbMAZRfkKLgqimTR74wvtESvjx5Ft2" + }, + { + "account_id": "node3", + "amount": "7025309465335462891886410729905", + "public_key": "ed25519:ydgzeXHJ5Xyt7M1gXLxqLBW1Ejx6scNV5Nx2pxFM8su" + }, + { + "account_id": "moonlet.pool.f863973.m0", + "amount": "396044187712024170314465720781", + "public_key": "ed25519:3e1nVCVGNS3yr6CcUvpDAs3BhiWtyM9uTBWkyVR5Xn3K" + }, + { + "account_id": "sweden.pool.f863973.m0", + "amount": "385869819054217573549654420144", + "public_key": "ed25519:2RVUnsMEZhGCj1A3vLZBGjj3i9SQ2L46Z1Z41aEgBzXg" + }, + { + "account_id": "shawnpool.pool.f863973.m0", + "amount": "326196336737920044305254508558", + "public_key": "ed25519:6dfAfW3oy1kp4u9ePuticHy3Y2WDcHwx8yKSdyLNMPSr" + }, + { + "account_id": "chorus-one.pool.f863973.m0", + "amount": "1318859742119402879751178031888", + "public_key": "ed25519:6LFwyEEsqhuDxorWfsKcPPs324zLWTaoqk4o6RDXN7Qc" + }, + { + "account_id": "inotel.pool.f863973.m0", + "amount": "4945759122706953812641339874642", + "public_key": "ed25519:C55jH1MCHYGa3tzUyZZdGrJmmCLP22Aa4v88KYpn2xwZ" + }, + { + "account_id": "p2p.pool.f863973.m0", + "amount": "991547852404615467434919132596", + "public_key": "ed25519:4ie5979JdSR4f7MRAG58eghRxndVoKnAYAKa1PLoMYSS" + }, + { + "account_id": "dokia.pool.f863973.m0", + "amount": "4004628852742744225484204285260", + "public_key": "ed25519:935JMz1vLcJxFApG3TY4MA4RHhvResvoGwCrQoJxHPn9" + }, + { + "account_id": "01node.pool.f863973.m0", + "amount": "1416856356232757387343764992394", + "public_key": "ed25519:3iNqnvBgxJPXCxu6hNdvJso1PEAc1miAD35KQMBCA3aL" + }, + { + "account_id": "legends.pool.f863973.m0", + "amount": "303006135607766172564337480878", + "public_key": "ed25519:AhQ6sUifJYgjqarXSAzdDZU9ZixpUesP9JEH1Vr7NbaF" + }, + { + "account_id": "blazenet.pool.f863973.m0", + "amount": "1892937440977093265954787297596", + "public_key": "ed25519:DiogP36wBXKFpFeqirrxN8G2Mq9vnakgBvgnHdL9CcN3" + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/protocol/protocol-config/error-schema-table.mdx b/docs/5.api/rpc/protocol/protocol-config/error-schema-table.mdx new file mode 100644 index 00000000000..f676b8a2c17 --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/error-schema-table.mdx @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_BLOCK200 + The requested block has not been produced yet or it has been + garbage-collected (cleaned up to save space on the RPC node) + +
    +
  • Check that the requested block is legit
  • +
  • + If the block had been produced more than 5 epochs ago, try to send + your request to{" "} + + an archival node + +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/protocol/protocol-config/index.mdx b/docs/5.api/rpc/protocol/protocol-config/index.mdx new file mode 100644 index 00000000000..b1e9f2e3701 --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/index.mdx @@ -0,0 +1,49 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Protocol Config {#protocol-config} + +> Returns most recent protocol configuration or a specific queried block. +Useful for finding current storage and transaction costs. + +- method: `EXPERIMENTAL_protocol_config` +- params: + - [`finality`](/api/rpc/setup#using-finality-param) _OR_ [`block_id`](/api/rpc/setup#using-block_id-param) + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-1} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_protocol_config` method: + + diff --git a/docs/5.api/rpc/protocol/protocol-config/request-bash.mdx b/docs/5.api/rpc/protocol/protocol-config/request-bash.mdx new file mode 100644 index 00000000000..0bf2b34aac4 --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_protocol_config \ + params:='{ + "finality": "final" + }' +``` diff --git a/docs/5.api/rpc/protocol/protocol-config/request-js.mdx b/docs/5.api/rpc/protocol/protocol-config/request-js.mdx new file mode 100644 index 00000000000..8aaaf3c4cdc --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/request-js.mdx @@ -0,0 +1,5 @@ +```js +const response = await near.connection.provider.experimental_protocolConfig({ + finality: "final", +}); +``` diff --git a/docs/5.api/rpc/protocol/protocol-config/request-json.mdx b/docs/5.api/rpc/protocol/protocol-config/request-json.mdx new file mode 100644 index 00000000000..72566ebe03e --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_protocol_config", + "params": { + "finality": "final" + } +} +``` diff --git a/docs/5.api/rpc/protocol/protocol-config/response-json.mdx b/docs/5.api/rpc/protocol/protocol-config/response-json.mdx new file mode 100644 index 00000000000..8d0acb9f1de --- /dev/null +++ b/docs/5.api/rpc/protocol/protocol-config/response-json.mdx @@ -0,0 +1,311 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "avg_hidden_validator_seats_per_shard": [0, 0, 0, 0, 0, 0], + "block_producer_kickout_threshold": 80, + "chain_id": "testnet", + "chunk_producer_kickout_threshold": 80, + "chunk_validator_only_kickout_threshold": 70, + "dynamic_resharding": false, + "epoch_length": 43200, + "fishermen_threshold": "340282366920938463463374607431768211455", + "gas_limit": 1000000000000000, + "gas_price_adjustment_rate": [1, 100], + "genesis_height": 42376888, + "genesis_time": "2020-07-31T03:39:42.911378Z", + "max_gas_price": "10000000000000000000000", + "max_inflation_rate": [1, 20], + "max_kickout_stake_perc": 30, + "min_gas_price": "5000", + "minimum_stake_divisor": 10, + "minimum_stake_ratio": [1, 62500], + "minimum_validators_per_shard": 1, + "num_block_producer_seats": 20, + "num_block_producer_seats_per_shard": [20, 20, 20, 20, 20, 20], + "num_blocks_per_year": 31536000, + "num_chunk_only_producer_seats": 0, + "online_max_threshold": [99, 100], + "online_min_threshold": [90, 100], + "protocol_reward_rate": [1, 10], + "protocol_treasury_account": "near", + "protocol_upgrade_stake_threshold": [4, 5], + "protocol_version": 73, + "runtime_config": { + "account_creation_config": { + "min_allowed_top_level_account_length": 65, + "registrar_account_id": "registrar" + }, + "congestion_control_config": { + "allowed_shard_outgoing_gas": 1000000000000000, + "max_congestion_incoming_gas": 400000000000000000, + "max_congestion_memory_consumption": 1000000000, + "max_congestion_missed_chunks": 5, + "max_congestion_outgoing_gas": 10000000000000000, + "max_outgoing_gas": 300000000000000000, + "max_tx_gas": 500000000000000, + "min_outgoing_gas": 1000000000000000, + "min_tx_gas": 20000000000000, + "outgoing_receipts_big_size_limit": 4718592, + "outgoing_receipts_usual_size_limit": 102400, + "reject_tx_congestion_threshold": 0.8 + }, + "storage_amount_per_byte": "10000000000000000000", + "transaction_costs": { + "action_creation_config": { + "add_key_cost": { + "full_access_cost": { + "execution": 101765125000, + "send_not_sir": 101765125000, + "send_sir": 101765125000 + }, + "function_call_cost": { + "execution": 102217625000, + "send_not_sir": 102217625000, + "send_sir": 102217625000 + }, + "function_call_cost_per_byte": { + "execution": 1925331, + "send_not_sir": 47683715, + "send_sir": 1925331 + } + }, + "create_account_cost": { + "execution": 3850000000000, + "send_not_sir": 3850000000000, + "send_sir": 3850000000000 + }, + "delegate_cost": { + "execution": 200000000000, + "send_not_sir": 200000000000, + "send_sir": 200000000000 + }, + "delete_account_cost": { + "execution": 147489000000, + "send_not_sir": 147489000000, + "send_sir": 147489000000 + }, + "delete_key_cost": { + "execution": 94946625000, + "send_not_sir": 94946625000, + "send_sir": 94946625000 + }, + "deploy_contract_cost": { + "execution": 184765750000, + "send_not_sir": 184765750000, + "send_sir": 184765750000 + }, + "deploy_contract_cost_per_byte": { + "execution": 64572944, + "send_not_sir": 47683715, + "send_sir": 6812999 + }, + "function_call_cost": { + "execution": 780000000000, + "send_not_sir": 200000000000, + "send_sir": 200000000000 + }, + "function_call_cost_per_byte": { + "execution": 2235934, + "send_not_sir": 47683715, + "send_sir": 2235934 + }, + "stake_cost": { + "execution": 102217625000, + "send_not_sir": 141715687500, + "send_sir": 141715687500 + }, + "transfer_cost": { + "execution": 115123062500, + "send_not_sir": 115123062500, + "send_sir": 115123062500 + } + }, + "action_receipt_creation_config": { + "execution": 108059500000, + "send_not_sir": 108059500000, + "send_sir": 108059500000 + }, + "burnt_gas_reward": [3, 10], + "data_receipt_creation_config": { + "base_cost": { + "execution": 36486732312, + "send_not_sir": 36486732312, + "send_sir": 36486732312 + }, + "cost_per_byte": { + "execution": 17212011, + "send_not_sir": 47683715, + "send_sir": 17212011 + } + }, + "pessimistic_gas_price_inflation_ratio": [103, 100], + "storage_usage_config": { + "num_bytes_account": 100, + "num_extra_bytes_record": 40 + } + }, + "wasm_config": { + "alt_bn128": true, + "disable_9393_fix": false, + "discard_custom_sections": true, + "ed25519_verify": true, + "eth_implicit_accounts": true, + "ext_costs": { + "alt_bn128_g1_multiexp_base": 713000000000, + "alt_bn128_g1_multiexp_element": 320000000000, + "alt_bn128_g1_sum_base": 3000000000, + "alt_bn128_g1_sum_element": 5000000000, + "alt_bn128_pairing_check_base": 9686000000000, + "alt_bn128_pairing_check_element": 5102000000000, + "base": 264768111, + "bls12381_g1_multiexp_base": 16500000000, + "bls12381_g1_multiexp_element": 930000000000, + "bls12381_g2_multiexp_base": 18600000000, + "bls12381_g2_multiexp_element": 1995000000000, + "bls12381_map_fp2_to_g2_base": 1500000000, + "bls12381_map_fp2_to_g2_element": 900000000000, + "bls12381_map_fp_to_g1_base": 1500000000, + "bls12381_map_fp_to_g1_element": 252000000000, + "bls12381_p1_decompress_base": 15000000000, + "bls12381_p1_decompress_element": 81000000000, + "bls12381_p1_sum_base": 16500000000, + "bls12381_p1_sum_element": 6000000000, + "bls12381_p2_decompress_base": 15000000000, + "bls12381_p2_decompress_element": 165000000000, + "bls12381_p2_sum_base": 18600000000, + "bls12381_p2_sum_element": 15000000000, + "bls12381_pairing_base": 2130000000000, + "bls12381_pairing_element": 2130000000000, + "contract_compile_base": 0, + "contract_compile_bytes": 0, + "contract_loading_base": 35445963, + "contract_loading_bytes": 1089295, + "ecrecover_base": 278821988457, + "ed25519_verify_base": 210000000000, + "ed25519_verify_byte": 9000000, + "keccak256_base": 5879491275, + "keccak256_byte": 21471105, + "keccak512_base": 5811388236, + "keccak512_byte": 36649701, + "log_base": 3543313050, + "log_byte": 13198791, + "promise_and_base": 1465013400, + "promise_and_per_promise": 5452176, + "promise_return": 560152386, + "read_cached_trie_node": 2280000000, + "read_memory_base": 2609863200, + "read_memory_byte": 3801333, + "read_register_base": 2517165186, + "read_register_byte": 98562, + "ripemd160_base": 853675086, + "ripemd160_block": 680107584, + "sha256_base": 4540970250, + "sha256_byte": 24117351, + "storage_has_key_base": 54039896625, + "storage_has_key_byte": 30790845, + "storage_iter_create_from_byte": 0, + "storage_iter_create_prefix_base": 0, + "storage_iter_create_prefix_byte": 0, + "storage_iter_create_range_base": 0, + "storage_iter_create_to_byte": 0, + "storage_iter_next_base": 0, + "storage_iter_next_key_byte": 0, + "storage_iter_next_value_byte": 0, + "storage_large_read_overhead_base": 1, + "storage_large_read_overhead_byte": 1, + "storage_read_base": 56356845749, + "storage_read_key_byte": 30952533, + "storage_read_value_byte": 5611004, + "storage_remove_base": 53473030500, + "storage_remove_key_byte": 38220384, + "storage_remove_ret_value_byte": 11531556, + "storage_write_base": 64196736000, + "storage_write_evicted_byte": 32117307, + "storage_write_key_byte": 70482867, + "storage_write_value_byte": 31018539, + "touching_trie_node": 16101955926, + "utf16_decoding_base": 3543313050, + "utf16_decoding_byte": 163577493, + "utf8_decoding_base": 3111779061, + "utf8_decoding_byte": 291580479, + "validator_stake_base": 911834726400, + "validator_total_stake_base": 911834726400, + "write_memory_base": 2803794861, + "write_memory_byte": 2723772, + "write_register_base": 2865522486, + "write_register_byte": 3801564, + "yield_create_base": 153411779276, + "yield_create_byte": 15643988, + "yield_resume_base": 1195627285210, + "yield_resume_byte": 47683715 + }, + "fix_contract_loading_cost": false, + "function_call_weight": true, + "grow_mem_cost": 1, + "implicit_account_creation": true, + "limit_config": { + "account_id_validity_rules_version": 1, + "contract_prepare_version": 2, + "initial_memory_pages": 1024, + "max_actions_per_receipt": 100, + "max_arguments_length": 4194304, + "max_contract_size": 4194304, + "max_functions_number_per_contract": 10000, + "max_gas_burnt": 300000000000000, + "max_length_method_name": 256, + "max_length_returned_data": 4194304, + "max_length_storage_key": 2048, + "max_length_storage_value": 4194304, + "max_locals_per_contract": 1000000, + "max_memory_pages": 2048, + "max_number_bytes_method_names": 2000, + "max_number_input_data_dependencies": 128, + "max_number_logs": 100, + "max_number_registers": 100, + "max_promises_per_function_call_action": 1024, + "max_receipt_size": 4194304, + "max_register_size": 104857600, + "max_stack_height": 262144, + "max_total_log_length": 16384, + "max_total_prepaid_gas": 300000000000000, + "max_transaction_size": 1572864, + "max_yield_payload_size": 1024, + "per_receipt_storage_proof_size_limit": 4000000, + "registers_memory_limit": 1073741824, + "wasmer2_stack_limit": 204800, + "yield_timeout_length_in_blocks": 200 + }, + "math_extension": true, + "regular_op_cost": 822756, + "storage_get_mode": "FlatStorage", + "vm_kind": "NearVm", + "yield_resume_host_functions": true + }, + "witness_config": { + "combined_transactions_size_limit": 4194304, + "main_storage_proof_size_soft_limit": 4000000, + "new_transactions_validation_state_size_soft_limit": 572864 + } + }, + "shard_layout": { + "V1": { + "boundary_accounts": [ + "aurora", + "aurora-0", + "game.hot.tg", + "kkuuue2akv_1630967379.near", + "tge-lockup.sweat" + ], + "shards_split_map": [[0], [1], [2, 3], [4], [5]], + "to_parent_shard_map": [0, 1, 2, 2, 3, 4], + "version": 3 + } + }, + "shuffle_shard_assignment_for_chunk_producers": false, + "target_validator_mandates_per_shard": 68, + "transaction_validity_period": 86400 + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions.md b/docs/5.api/rpc/transactions.md index d0f509b2557..50e27890910 100644 --- a/docs/5.api/rpc/transactions.md +++ b/docs/5.api/rpc/transactions.md @@ -4,1385 +4,31 @@ title: RPC Endpoints sidebar_label: Transactions --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import SendTx from './transactions/send-tx/index.mdx'; +import TransactionStatus from './transactions/transaction-status/index.mdx'; +import TransactionStatusWithReceipts from './transactions/transaction-status-with-receipts/index.mdx'; +import ReceiptById from './transactions/receipt-by-id/index.mdx'; +import TxStatusResult from './transactions/tx-status-result/index.mdx'; +import SendTransactionAsync from './transactions/send-transaction-async/index.mdx'; +import SendTransactionAwait from './transactions/send-transaction-await/index.mdx'; The RPC API enables you to send transactions and query their status. --- - -## Send transaction {#send-tx} - -> Sends transaction. -> Returns the guaranteed execution status and the results the blockchain can provide at the moment. - -- method: `send_tx` -- params: - - `signed_tx_base64`: SignedTransaction encoded in base64 - - [Optional] `wait_until`: the required minimal execution level. [Read more here](#tx-status-result). The default value is `EXECUTED_OPTIMISTIC`. - -Using `send_tx` with `wait_until = NONE` is equal to legacy `broadcast_tx_async` method. -Using `send_tx` with finality `wait_until = EXECUTED_OPTIMISTIC` is equal to legacy `broadcast_tx_commit` method. - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "send_tx", - "params": { - "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=", - "wait_until": "INCLUDED_FINAL" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=send_tx \ - params:='{ - "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=", - "wait_until": "EXECUTED" - }' -``` - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=send_tx \ - params:='{ - "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=" - }' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "final_execution_status": "FINAL", - "status": { - "SuccessValue": "" - }, - "transaction": { - "signer_id": "sender.testnet", - "public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6", - "nonce": 13, - "receiver_id": "receiver.testnet", - "actions": [ - { - "Transfer": { - "deposit": "1000000000000000000000000" - } - } - ], - "signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH", - "hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR" - }, - "transaction_outcome": { - "proof": [], - "block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe", - "id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR", - "outcome": { - "logs": [], - "receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "sender.testnet", - "status": { - "SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh" - } - } - }, - "receipts_outcome": [ - { - "proof": [], - "block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a", - "id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh", - "outcome": { - "logs": [], - "receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "receiver.testnet", - "status": { - "SuccessValue": "" - } - } - }, - { - "proof": [], - "block_hash": "CbwEqMpPcu6KwqVpBM3Ry83k6M4H1FrJjES9kBXThcRd", - "id": "3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR", - "outcome": { - "logs": [], - "receipt_ids": [], - "gas_burnt": 0, - "tokens_burnt": "0", - "executor_id": "sender.testnet", - "status": { - "SuccessValue": "" - } - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-send-tx} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_commit` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution -
    -
  • See error.cause.info for details, likely a field in the transaction was invalid
  • -
  • If error.cause.info is ShardCongested, resubmit the identical transaction after a delay. (Consider adding a priority fee once [NEP-541](https://github.com/near/NEPs/pull/541) is released.)
  • -
  • If error.cause.info is ShardStuck, you may also resubmit the identical transaction after a delay
  • -
-
TIMEOUT_ERROR408Transaction was routed, but has not been recorded on chain in 10 seconds. -
    -
  • Resubmit the request with the identical transaction (in NEAR Protocol unique transactions apply exactly once, so if the previously sent transaction gets applied, this request will just return the known result, otherwise, it will route the transaction to the chain once again)
  • -
  • Check that your transaction is valid
  • -
  • Check that the signer account id has enough tokens to cover the transaction fees (keep in mind that some tokens on each account are locked to cover the storage cost)
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Transaction Status {#transaction-status} - -> Queries status of a transaction by hash and returns the final transaction result. - -- method: `tx` -- params: - - `tx_hash` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid transaction hash)_ - - `sender_account_id` _(used to determine which shard to query for transaction)_ - - [Optional] `wait_until`: the required minimal execution level. Read more [here](/api/rpc/transactions#tx-status-result). The default value is `EXECUTED_OPTIMISTIC`. - -A Transaction status request with `wait_until != NONE` will wait until the transaction appears on the blockchain. -If the transaction does not exist, the method will wait until the timeout is reached. -If you only need to check whether the transaction exists, use `wait_until = NONE`, it will return the response immediately. - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "tx", - "params": { - "tx_hash": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm", - "sender_account_id": "sender.testnet", - "wait_until": "EXECUTED" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=tx \ - params:='{"tx_hash": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm", "sender_account_id": "sender.testnet"}' -``` - - - - -
-Example Result: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "final_execution_status": "FINAL", - "status": { - "SuccessValue": "" - }, - "transaction": { - "signer_id": "sender.testnet", - "public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6", - "nonce": 15, - "receiver_id": "receiver.testnet", - "actions": [ - { - "Transfer": { - "deposit": "1000000000000000000000000" - } - } - ], - "signature": "ed25519:3168QMdTpcwHvM1dmMYBc8hg9J3Wn8n7MWBSE9WrEpns6P5CaY87RM6k4uzyBkQuML38CZhU18HzmQEevPG1zCvk", - "hash": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm" - }, - "transaction_outcome": { - "proof": [ - { - "hash": "F7mL76CMdfbdZ3xCehVGNh1fCyaR37gr3MeGX3EZkiVf", - "direction": "Right" - } - ], - "block_hash": "ADTMLVtkhsvzUxuf6m87Pt1dnF5vi1yY7ftxmNpFx7y", - "id": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm", - "outcome": { - "logs": [], - "receipt_ids": ["3dMfwczW5GQqXbD9GMTnmf8jy5uACxG6FC5dWxm3KcXT"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "sender.testnet", - "status": { - "SuccessReceiptId": "3dMfwczW5GQqXbD9GMTnmf8jy5uACxG6FC5dWxm3KcXT" - } - } - }, - "receipts_outcome": [ - { - "proof": [ - { - "hash": "6h95oEd7ih62KXfyPT4zsZYont4qy9sWEXc5VQVDhqtG", - "direction": "Right" - }, - { - "hash": "6DnibgZk1T669ZprcehUy1GpCSPw1kjzXRGu69nSaUNn", - "direction": "Right" - } - ], - "block_hash": "GgFTVr33r4MrpAiHc9mr8TZqLnpZAX1BaZTNvhBnciy2", - "id": "3dMfwczW5GQqXbD9GMTnmf8jy5uACxG6FC5dWxm3KcXT", - "outcome": { - "logs": [], - "receipt_ids": ["46KYgN8ddxs4Qy8C7BDQH49XUfcYZsaQmAvdU1nfcL9V"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "receiver.testnet", - "status": { - "SuccessValue": "" - } - } - }, - { - "proof": [ - { - "hash": "CD9Y7Bw3MSFgaPZzpc1yP51ajhGDCAsR61qXcMNcRoHf", - "direction": "Left" - } - ], - "block_hash": "EGAgKuW6Bd6QKYSaxAkx2pPGmnjrjAcq4UpoUiqMXvPH", - "id": "46KYgN8ddxs4Qy8C7BDQH49XUfcYZsaQmAvdU1nfcL9V", - "outcome": { - "logs": [], - "receipt_ids": [], - "gas_burnt": 0, - "tokens_burnt": "0", - "executor_id": "sender.testnet", - "status": { - "SuccessValue": "" - } - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-2} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `tx` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution -
    -
  • See error.cause.info for details
  • -
-
UNKNOWN_TRANSACTION200The requested transaction is not available on the node since it might have not been recorded on the chain yet or has been garbage-collected -
    -
  • Try again later
  • -
  • If the transaction had been submitted more than 5 epochs ago, try to send your request to an archival node
  • -
  • Check the transaction hash
  • -
-
TIMEOUT_ERROR408It was unable to wait for the transaction status for reasonable time -
    -
  • Send a request to a different node
  • -
  • Try again later
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## Transaction Status with Receipts {#transaction-status-with-receipts} - -> Queries status of a transaction by hash, returning the final transaction result _and_ details of all receipts. - -- method: `EXPERIMENTAL_tx_status` -- params: - - `tx_hash` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid transaction hash)_ - - `sender_account_id` _(used to determine which shard to query for transaction)_ - - [Optional] `wait_until`: the required minimal execution level. Read more [here](/api/rpc/transactions#tx-status-result). The default value is `EXECUTED_OPTIMISTIC`. - -A Transaction status request with `wait_until != NONE` will wait until the transaction appears on the blockchain. -If the transaction does not exist, the method will wait until the timeout is reached. -If you only need to check whether the transaction exists, use `wait_until = NONE`, it will return the response immediately. - - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_tx_status", - "params": { - "tx_hash": "HEgnVQZfs9uJzrqTob4g2Xmebqodq9waZvApSkrbcAhd", - "sender_account_id": "bowen", - "wait_until": "EXECUTED" - } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=EXPERIMENTAL_tx_status params:='{"tx_hash": "HEgnVQZfs9uJzrqTob4g2Xmebqodq9waZvApSkrbcAhd", "sender_account_id": "bowen"}' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "id": "123", - "jsonrpc": "2.0", - "result": { - "final_execution_status": "FINAL", - "receipts": [ - { - "predecessor_id": "bowen", - "receipt": { - "Action": { - "actions": [ - { - "FunctionCall": { - "args": "eyJhbW91bnQiOiIxMDAwIiwicmVjZWl2ZXJfaWQiOiJib3dlbiJ9", - "deposit": "0", - "gas": 100000000000000, - "method_name": "transfer" - } - } - ], - "gas_price": "186029458", - "input_data_ids": [], - "output_data_receivers": [], - "signer_id": "bowen", - "signer_public_key": "ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK" - } - }, - "receipt_id": "FXMVxdhSUZaZftbmPJWaoqhEB9GrKB2oqg9Wgvuyvom8", - "receiver_id": "evgeny.lockup.m0" - }, - { - "predecessor_id": "evgeny.lockup.m0", - "receipt": { - "Action": { - "actions": [ - { - "Transfer": { - "deposit": "1000" - } - } - ], - "gas_price": "186029458", - "input_data_ids": [], - "output_data_receivers": [], - "signer_id": "bowen", - "signer_public_key": "ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK" - } - }, - "receipt_id": "3Ad7pUygUegMUWUb1rEazfjnTaHfptXCABqKQ6WNq6Wa", - "receiver_id": "bowen" - }, - { - "predecessor_id": "system", - "receipt": { - "Action": { - "actions": [ - { - "Transfer": { - "deposit": "19200274886926125000" - } - } - ], - "gas_price": "0", - "input_data_ids": [], - "output_data_receivers": [], - "signer_id": "bowen", - "signer_public_key": "ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK" - } - }, - "receipt_id": "5DdQg9pfoJMX1q6bvhsjyyRihzA3sb9Uq5K1J7vK43Ze", - "receiver_id": "bowen" - }, - { - "predecessor_id": "system", - "receipt": { - "Action": { - "actions": [ - { - "Transfer": { - "deposit": "18663792669276228632284" - } - } - ], - "gas_price": "0", - "input_data_ids": [], - "output_data_receivers": [], - "signer_id": "bowen", - "signer_public_key": "ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK" - } - }, - "receipt_id": "FDp8ovTf5uJYDFemW5op6ebjCT2n4CPExHYie3S1h4qp", - "receiver_id": "bowen" - } - ], - "receipts_outcome": [ - { - "block_hash": "HuqYrYsC7h2VERFMgFkqaNqSiFuTH9CA3uJr3BkyNxhF", - "id": "FXMVxdhSUZaZftbmPJWaoqhEB9GrKB2oqg9Wgvuyvom8", - "outcome": { - "executor_id": "evgeny.lockup.m0", - "gas_burnt": 3493189769144, - "logs": ["Transferring 1000 to account @bowen"], - "receipt_ids": [ - "3Ad7pUygUegMUWUb1rEazfjnTaHfptXCABqKQ6WNq6Wa", - "FDp8ovTf5uJYDFemW5op6ebjCT2n4CPExHYie3S1h4qp" - ], - "status": { - "SuccessReceiptId": "3Ad7pUygUegMUWUb1rEazfjnTaHfptXCABqKQ6WNq6Wa" - }, - "tokens_burnt": "349318976914400000000" - }, - "proof": [ - { - "direction": "Right", - "hash": "5WwHEszBcpfrHnt2VTvVDVnEEACNq5EpQdjz1aW9gTAa" - } - ] - }, - { - "block_hash": "DJ6oK5FtPPSwksS6pKdEjFvHWAaSVocnVNLoyi8aYk1k", - "id": "3Ad7pUygUegMUWUb1rEazfjnTaHfptXCABqKQ6WNq6Wa", - "outcome": { - "executor_id": "bowen", - "gas_burnt": 223182562500, - "logs": [], - "receipt_ids": ["5DdQg9pfoJMX1q6bvhsjyyRihzA3sb9Uq5K1J7vK43Ze"], - "status": { - "SuccessValue": "" - }, - "tokens_burnt": "22318256250000000000" - }, - "proof": [ - { - "direction": "Right", - "hash": "CXSXmKpDU8R3UUrBAsffWMeGfKanKqEHCQrHeZkR3RKT" - }, - { - "direction": "Right", - "hash": "2dNo7A1VHKBmMA86m1k3Z9DVXwWgQJGkKGRg8wUR3co9" - } - ] - }, - { - "block_hash": "9cjUoqAksMbs7ZJ4CXiuwm8vppz9QctTwGmgwZ5mDmUA", - "id": "5DdQg9pfoJMX1q6bvhsjyyRihzA3sb9Uq5K1J7vK43Ze", - "outcome": { - "executor_id": "bowen", - "gas_burnt": 0, - "logs": [], - "receipt_ids": [], - "status": { - "SuccessValue": "" - }, - "tokens_burnt": "0" - }, - "proof": [] - }, - { - "block_hash": "DJ6oK5FtPPSwksS6pKdEjFvHWAaSVocnVNLoyi8aYk1k", - "id": "FDp8ovTf5uJYDFemW5op6ebjCT2n4CPExHYie3S1h4qp", - "outcome": { - "executor_id": "bowen", - "gas_burnt": 0, - "logs": [], - "receipt_ids": [], - "status": { - "SuccessValue": "" - }, - "tokens_burnt": "0" - }, - "proof": [ - { - "direction": "Left", - "hash": "A2Ry6NCeuK8WhRCWc41hy6uddadc5nLJ1NBX5wVYo3Yb" - }, - { - "direction": "Right", - "hash": "2dNo7A1VHKBmMA86m1k3Z9DVXwWgQJGkKGRg8wUR3co9" - } - ] - } - ], - "status": { - "SuccessValue": "" - }, - "transaction": { - "actions": [ - { - "FunctionCall": { - "args": "eyJhbW91bnQiOiIxMDAwIiwicmVjZWl2ZXJfaWQiOiJib3dlbiJ9", - "deposit": "0", - "gas": 100000000000000, - "method_name": "transfer" - } - } - ], - "hash": "HEgnVQZfs9uJzrqTob4g2Xmebqodq9waZvApSkrbcAhd", - "nonce": 77, - "public_key": "ed25519:2f9Zv5kuyuPM5DCyEP5pSqg58NQ8Ct9uSRerZXnCS9fK", - "receiver_id": "evgeny.lockup.m0", - "signature": "ed25519:5v1hJuw5RppKGezJHBFU6z3hwmmdferETud9rUbwxVf6xSBAWyiod93Lezaq4Zdcp4zbukDusQY9PjhV47JVCgBx", - "signer_id": "bowen" - }, - "transaction_outcome": { - "block_hash": "9RX2pefXKw8M4EYjLznDF3AMvbkf9asAjN8ACK7gxKsa", - "id": "HEgnVQZfs9uJzrqTob4g2Xmebqodq9waZvApSkrbcAhd", - "outcome": { - "executor_id": "bowen", - "gas_burnt": 2428026088898, - "logs": [], - "receipt_ids": ["FXMVxdhSUZaZftbmPJWaoqhEB9GrKB2oqg9Wgvuyvom8"], - "status": { - "SuccessReceiptId": "FXMVxdhSUZaZftbmPJWaoqhEB9GrKB2oqg9Wgvuyvom8" - }, - "tokens_burnt": "242802608889800000000" - }, - "proof": [ - { - "direction": "Right", - "hash": "DXf4XVmAF5jnjZhcxi1CYxGPuuQrcAmayq9X5inSAYvJ" - } - ] - } - } -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-3} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_tx_status` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution -
    -
  • See error.cause.info for details
  • -
-
UNKNOWN_TRANSACTION200The requested transaction is not available on the node since it might have not been recorded on the chain yet or has been garbage-collected -
    -
  • Try again later
  • -
  • If the transaction had been submitted more than 5 epochs ago, try to send your request to an archival node
  • -
  • Check the transaction hash
  • -
-
TIMEOUT_ERROR408It was unable to wait for the transaction status for reasonable time -
    -
  • Send a request to a different node
  • -
  • Try again later
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -### Receipt by ID {#receipt-by-id} - -> Fetches a receipt by its ID (as is, without a status or execution outcome) - -- method: `EXPERIMENTAL_receipt` -- params: - - `receipt_id` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid receipt id)_ - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "EXPERIMENTAL_receipt", - "params": { "receipt_id": "2EbembRPJhREPtmHCrGv3Xtdm3xoc5BMVYHm3b2kjvMY" } -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 method=EXPERIMENTAL_receipt params:='{"receipt_id": "2EbembRPJhREPtmHCrGv3Xtdm3xoc5BMVYHm3b2kjvMY"}' id=dontcare -``` - - - - -
-Example response: -

- -```json -{ - "id": "dontcare", - "jsonrpc": "2.0", - "result": { - "predecessor_id": "bohdan.testnet", - "receipt": { - "Action": { - "actions": [ - { - "Transfer": { - "deposit": "1000000000000000000000000" - } - } - ], - "gas_price": "103000000", - "input_data_ids": [], - "output_data_receivers": [], - "signer_id": "bohdan.testnet", - "signer_public_key": "ed25519:DhC7rPNTBwWJtmVXs1U1SqJztkn9AWbj6jCmQtkrg3TA" - } - }, - "receipt_id": "2EbembRPJhREPtmHCrGv3Xtdm3xoc5BMVYHm3b2kjvMY", - "receiver_id": "frol.testnet" - } -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-4} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_receipt` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_RECEIPT200The receipt with the given receipt_id was never observed on the node -
    -
  • Check the provided receipt_id is correct
  • -
  • Send a request on a different node
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- -## Transaction Execution Levels {#tx-status-result} - -All the methods listed above have `wait_until` request parameter, and `final_execution_status` response value. -They correspond to the same enum `TxExecutionStatus`. -See the detailed explanation for all the options: - -```rust -#[serde(rename_all = "SCREAMING_SNAKE_CASE")] -pub enum TxExecutionStatus { - /// Transaction is waiting to be included into the block - None, - /// Transaction is included into the block. The block may be not finalized yet - Included, - /// Transaction is included into the block + - /// All non-refund transaction receipts finished their execution. - /// The corresponding blocks for tx and each receipt may be not finalized yet - #[default] - ExecutedOptimistic, - /// Transaction is included into finalized block - IncludedFinal, - /// Transaction is included into finalized block + - /// All non-refund transaction receipts finished their execution. - /// The corresponding blocks for each receipt may be not finalized yet - Executed, - /// Transaction is included into finalized block + - /// Execution of all transaction receipts is finalized, including refund receipts - Final, -} -``` - + +--- + --- # Deprecated methods {#deprecated} -## [deprecated] Send transaction (async) {#send-transaction-async} - -> Consider using [`send_tx`](/api/rpc/transactions#send-tx) instead - -> Sends a transaction and immediately returns transaction hash. - -- method: `broadcast_tx_async` -- params: [SignedTransaction encoded in base64] - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "broadcast_tx_async", - "params": [ - "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=" - ] -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=broadcast_tx_async \ - params:='[ - "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=" - ]' -``` - - - - -Example response: - -```json -{ - "jsonrpc": "2.0", - "result": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm", - "id": "dontcare" -} -``` - -Final transaction results can be queried using [Transaction Status](#transaction-status) -or [NearBlocks Explorer](https://testnet.nearblocks.io/) using the above `result` hash returning a result similar to the example below. - -![NEAR-Explorer-transactionHash](/docs/assets/NEAR-Explorer-transactionHash.png) - -#### What could go wrong? {#what-could-go-wrong} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_async` method: - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
- + --- - -## [deprecated] Send transaction (await) {#send-transaction-await} - -> Consider using [`send_tx`](/api/rpc/transactions#send-tx) instead - -> Sends a transaction and waits until transaction is fully complete. _(Has a 10 second timeout)_ - -- method: `broadcast_tx_commit` -- params: `[SignedTransaction encoded in base64]` - -Example: - - - - -```json -{ - "jsonrpc": "2.0", - "id": "dontcare", - "method": "broadcast_tx_commit", - "params": [ - "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDQAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldIODI4YfV/QS++blXpQYT+bOsRblTRW4f547y/LkvMQ9AQAAAAMAAACh7czOG8LTAAAAAAAAAAXcaTJzu9GviPT7AD4mNJGY79jxTrjFLoyPBiLGHgBi8JK1AnhK8QknJ1ourxlvOYJA2xEZE8UR24THmSJcLQw=" - ] -} -``` - - - - -```bash -http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=broadcast_tx_commit \ - params:='[ - "DwAAAG5lYXJrYXQudGVzdG5ldABuTi5L1rwnlb35hc9tn5WELkxfiGfGh1Q5aeGNQDejo0QAAAAAAAAAEAAAAGpvc2hmb3JkLnRlc3RuZXSiWAc6W9KlqXS5fK+vjFRDV5pAxHRKU0srKX/cmdRTBgEAAAADAAAAoe3MzhvC0wAAAAAAAAB9rOE9zc5zQYLL1j6VTh3I4fQbERs6I07gJfrAC6jo8DB4HolR9Xps3v4qrZxkgZjwv6wB0QOROM4UEbeOaBoB" - ]' -``` - - - - -
-Example response: -

- -```json -{ - "jsonrpc": "2.0", - "result": { - "final_execution_status": "FINAL", - "status": { - "SuccessValue": "" - }, - "transaction": { - "signer_id": "sender.testnet", - "public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6", - "nonce": 13, - "receiver_id": "receiver.testnet", - "actions": [ - { - "Transfer": { - "deposit": "1000000000000000000000000" - } - } - ], - "signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH", - "hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR" - }, - "transaction_outcome": { - "proof": [], - "block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe", - "id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR", - "outcome": { - "logs": [], - "receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "sender.testnet", - "status": { - "SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh" - } - } - }, - "receipts_outcome": [ - { - "proof": [], - "block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a", - "id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh", - "outcome": { - "logs": [], - "receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"], - "gas_burnt": 223182562500, - "tokens_burnt": "22318256250000000000", - "executor_id": "receiver.testnet", - "status": { - "SuccessValue": "" - } - } - }, - { - "proof": [], - "block_hash": "CbwEqMpPcu6KwqVpBM3Ry83k6M4H1FrJjES9kBXThcRd", - "id": "3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR", - "outcome": { - "logs": [], - "receipt_ids": [], - "gas_burnt": 0, - "tokens_burnt": "0", - "executor_id": "sender.testnet", - "status": { - "SuccessValue": "" - } - } - } - ] - }, - "id": "dontcare" -} -``` - -

-
- -#### What could go wrong? {#what-could-go-wrong-1} - -When API request fails, RPC server returns a structured error response with a limited number of well-defined error variants, so client code can exhaustively handle all the possible error cases. Our JSON-RPC errors follow [verror](https://github.com/joyent/node-verror) convention for structuring the error response: - - -```json -{ - "error": { - "name": , - "cause": { - "info": {..}, - "name": - }, - "code": -32000, - "data": String, - "message": "Server error", - }, - "id": "dontcare", - "jsonrpc": "2.0" -} -``` - -> **Heads up** -> -> The fields `code`, `data`, and `message` in the structure above are considered legacy ones and might be deprecated in the future. Please, don't rely on them. - -Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_commit` method: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ERROR_TYPE
- error.name -
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution -
    -
  • See error.cause.info for details, likely a field in the transaction was invalid
  • -
  • If error.cause.info is ShardCongested, resubmit the identical transaction after a delay. (Consider adding a priority fee once [NEP-541](https://github.com/near/NEPs/pull/541) is released.)
  • -
  • If error.cause.info is ShardStuck, you may also resubmit the identical transaction after a delay
  • -
-
TIMEOUT_ERROR408Transaction was routed, but has not been recorded on chain in 10 seconds. -
    -
  • Resubmit the request with the identical transaction (in NEAR Protocol unique transactions apply exactly once, so if the previously sent transaction gets applied, this request will just return the known result, otherwise, it will route the transaction to the chain once again)
  • -
  • Check that your transaction is valid
  • -
  • Check that the signer account id has enough tokens to cover the transaction fees (keep in mind that some tokens on each account are locked to cover the storage cost)
  • -
-
REQUEST_VALIDATION_ERRORPARSE_ERROR400Passed arguments can't be parsed by JSON RPC server (missing arguments, wrong format, etc.) -
    -
  • Check the arguments passed and pass the correct ones
  • -
  • Check error.cause.info for more details
  • -
-
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded -
    -
  • Try again later
  • -
  • Send a request to a different node
  • -
  • Check error.cause.info for more details
  • -
-
- + --- diff --git a/docs/5.api/rpc/transactions/receipt-by-id/error-schema-table.mdx b/docs/5.api/rpc/transactions/receipt-by-id/error-schema-table.mdx new file mode 100644 index 00000000000..843f411f959 --- /dev/null +++ b/docs/5.api/rpc/transactions/receipt-by-id/error-schema-table.mdx @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORUNKNOWN_RECEIPT200 + The receipt with the given receipt_id was never observed on + the node + +
    +
  • + Check the provided receipt_id is correct +
  • +
  • Send a request on a different node
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/receipt-by-id/index.mdx b/docs/5.api/rpc/transactions/receipt-by-id/index.mdx new file mode 100644 index 00000000000..0bdc67089e1 --- /dev/null +++ b/docs/5.api/rpc/transactions/receipt-by-id/index.mdx @@ -0,0 +1,44 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; + +## Receipt by ID {#receipt-by-id} + +> Fetches a receipt by its ID (as is, without a status or execution outcome) + +- method: `EXPERIMENTAL_receipt` +- params: + - `receipt_id` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid receipt id)_ + +Example: + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-4} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_receipt` method: + + diff --git a/docs/5.api/rpc/transactions/receipt-by-id/request-bash.mdx b/docs/5.api/rpc/transactions/receipt-by-id/request-bash.mdx new file mode 100644 index 00000000000..2d8e92a28ec --- /dev/null +++ b/docs/5.api/rpc/transactions/receipt-by-id/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_receipt \ + params:='{ + "receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE" + }' +``` diff --git a/docs/5.api/rpc/transactions/receipt-by-id/request-json.mdx b/docs/5.api/rpc/transactions/receipt-by-id/request-json.mdx new file mode 100644 index 00000000000..d256d821e04 --- /dev/null +++ b/docs/5.api/rpc/transactions/receipt-by-id/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_receipt", + "params": { + "receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE" + } +} +``` diff --git a/docs/5.api/rpc/transactions/receipt-by-id/response-json.mdx b/docs/5.api/rpc/transactions/receipt-by-id/response-json.mdx new file mode 100644 index 00000000000..e2d0ccec21f --- /dev/null +++ b/docs/5.api/rpc/transactions/receipt-by-id/response-json.mdx @@ -0,0 +1,39 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "predecessor_id": "rpc-examples.testnet", + "priority": 0, + "receipt": { + "Action": { + "actions": [ + "CreateAccount", + { + "Transfer": { + "deposit": "5000000000000000000000000" + } + }, + { + "AddKey": { + "access_key": { + "nonce": 0, + "permission": "FullAccess" + }, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + } + ], + "gas_price": "103000000", + "input_data_ids": [], + "is_promise_yield": false, + "output_data_receivers": [], + "signer_id": "rpc-examples.testnet", + "signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + }, + "receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE", + "receiver_id": "contract.rpc-examples.testnet" + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-async/error-schema-table.mdx b/docs/5.api/rpc/transactions/send-transaction-async/error-schema-table.mdx new file mode 100644 index 00000000000..ae3043fe93e --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-async/error-schema-table.mdx @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/send-transaction-async/index.mdx b/docs/5.api/rpc/transactions/send-transaction-async/index.mdx new file mode 100644 index 00000000000..fb27f962bde --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-async/index.mdx @@ -0,0 +1,46 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## [deprecated] Send transaction (async) {#send-transaction-async} + +> Consider using [`send_tx`](/api/rpc/transactions#send-tx) instead + +> Sends a transaction and immediately returns transaction hash. + +- method: `broadcast_tx_async` +- params: [SignedTransaction encoded in base64] + +Example: + + + + + + + + + + +
+ Example response: + +
+ +Final transaction results can be queried using [Transaction Status](#transaction-status) +or [NearBlocks Explorer](https://testnet.nearblocks.io/) using the above +`result` hash returning a result similar to the example below. + +![NEAR-Explorer-transactionHash](/docs/assets/NEAR-Explorer-transactionHash.png) + +#### What could go wrong? {#what-could-go-wrong} + + + +Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_async` method: + + diff --git a/docs/5.api/rpc/transactions/send-transaction-async/request-bash.mdx b/docs/5.api/rpc/transactions/send-transaction-async/request-bash.mdx new file mode 100644 index 00000000000..6f0299f481d --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-async/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=broadcast_tx_async \ + params:='[ + "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=" + ]' +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-async/request-json.mdx b/docs/5.api/rpc/transactions/send-transaction-async/request-json.mdx new file mode 100644 index 00000000000..87bfecd4984 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-async/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "broadcast_tx_async", + "params": [ + "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=" + ] +} +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-async/response-json.mdx b/docs/5.api/rpc/transactions/send-transaction-async/response-json.mdx new file mode 100644 index 00000000000..e5522800295 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-async/response-json.mdx @@ -0,0 +1,7 @@ +```json +{ + "jsonrpc": "2.0", + "result": "6zgh2u9DqHHiXzdy9ouTP7oGky2T4nugqzqt9wJZwNFm", + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-await/error-schema-table.mdx b/docs/5.api/rpc/transactions/send-transaction-await/error-schema-table.mdx new file mode 100644 index 00000000000..2be27640df9 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-await/error-schema-table.mdx @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution +
    +
  • + See error.cause.info for details, likely a field in the + transaction was invalid +
  • +
  • + If error.cause.info is ShardCongested, + resubmit the identical transaction after a delay. (Consider adding a + priority fee once [NEP-541](https://github.com/near/NEPs/pull/541) + is released.) +
  • +
  • + If error.cause.info is ShardStuck, you may + also resubmit the identical transaction after a delay +
  • +
+
TIMEOUT_ERROR408 + Transaction was routed, but has not been recorded on chain in 10 + seconds. + +
    +
  • + {" "} + Resubmit the request with the identical transaction (in NEAR + Protocol unique transactions apply exactly once, so if the + previously sent transaction gets applied, this request will just + return the known result, otherwise, it will route the transaction to + the chain once again) +
  • +
  • Check that your transaction is valid
  • +
  • + Check that the signer account id has enough tokens to cover the + transaction fees (keep in mind that some tokens on each account are + locked to cover the storage cost) +
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/send-transaction-await/index.mdx b/docs/5.api/rpc/transactions/send-transaction-await/index.mdx new file mode 100644 index 00000000000..a2a310dbce1 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-await/index.mdx @@ -0,0 +1,40 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## [deprecated] Send transaction (await) {#send-transaction-await} + +> Consider using [`send_tx`](/api/rpc/transactions#send-tx) instead + +> Sends a transaction and waits until transaction is fully complete. _(Has a 10 second timeout)_ + +- method: `broadcast_tx_commit` +- params: `[SignedTransaction encoded in base64]` + +Example: + + + + + + + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-1} + + + +Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_commit` method: + + diff --git a/docs/5.api/rpc/transactions/send-transaction-await/request-bash.mdx b/docs/5.api/rpc/transactions/send-transaction-await/request-bash.mdx new file mode 100644 index 00000000000..aa694dd24b3 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-await/request-bash.mdx @@ -0,0 +1,9 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=broadcast_tx_commit \ + params:='[ + "DwAAAG5lYXJrYXQudGVzdG5ldABuTi5L1rwnlb35hc9tn5WELkxfiGfGh1Q5aeGNQDejo0QAAAAAAAAAEAAAAGpvc2hmb3JkLnRlc3RuZXSiWAc6W9KlqXS5fK+vjFRDV5pAxHRKU0srKX/cmdRTBgEAAAADAAAAoe3MzhvC0wAAAAAAAAB9rOE9zc5zQYLL1j6VTh3I4fQbERs6I07gJfrAC6jo8DB4HolR9Xps3v4qrZxkgZjwv6wB0QOROM4UEbeOaBoB" + ]' +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-await/request-json.mdx b/docs/5.api/rpc/transactions/send-transaction-await/request-json.mdx new file mode 100644 index 00000000000..f3da83a5581 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-await/request-json.mdx @@ -0,0 +1,10 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "broadcast_tx_commit", + "params": [ + "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDQAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldIODI4YfV/QS++blXpQYT+bOsRblTRW4f547y/LkvMQ9AQAAAAMAAACh7czOG8LTAAAAAAAAAAXcaTJzu9GviPT7AD4mNJGY79jxTrjFLoyPBiLGHgBi8JK1AnhK8QknJ1ourxlvOYJA2xEZE8UR24THmSJcLQw=" + ] +} +``` diff --git a/docs/5.api/rpc/transactions/send-transaction-await/response-json.mdx b/docs/5.api/rpc/transactions/send-transaction-await/response-json.mdx new file mode 100644 index 00000000000..f1d05413226 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-transaction-await/response-json.mdx @@ -0,0 +1,74 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "final_execution_status": "FINAL", + "status": { + "SuccessValue": "" + }, + "transaction": { + "signer_id": "sender.testnet", + "public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6", + "nonce": 13, + "receiver_id": "receiver.testnet", + "actions": [ + { + "Transfer": { + "deposit": "1000000000000000000000000" + } + } + ], + "signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH", + "hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR" + }, + "transaction_outcome": { + "proof": [], + "block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe", + "id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR", + "outcome": { + "logs": [], + "receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"], + "gas_burnt": 223182562500, + "tokens_burnt": "22318256250000000000", + "executor_id": "sender.testnet", + "status": { + "SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh" + } + } + }, + "receipts_outcome": [ + { + "proof": [], + "block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a", + "id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh", + "outcome": { + "logs": [], + "receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"], + "gas_burnt": 223182562500, + "tokens_burnt": "22318256250000000000", + "executor_id": "receiver.testnet", + "status": { + "SuccessValue": "" + } + } + }, + { + "proof": [], + "block_hash": "CbwEqMpPcu6KwqVpBM3Ry83k6M4H1FrJjES9kBXThcRd", + "id": "3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR", + "outcome": { + "logs": [], + "receipt_ids": [], + "gas_burnt": 0, + "tokens_burnt": "0", + "executor_id": "sender.testnet", + "status": { + "SuccessValue": "" + } + } + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/send-tx/error-schema-table.mdx b/docs/5.api/rpc/transactions/send-tx/error-schema-table.mdx new file mode 100644 index 00000000000..a6f2dc0eeda --- /dev/null +++ b/docs/5.api/rpc/transactions/send-tx/error-schema-table.mdx @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution +
    +
  • + See error.cause.info for details, likely a field in the + transaction was invalid +
  • +
  • + If error.cause.info is ShardCongested, + resubmit the identical transaction after a delay. (Consider adding a + priority fee once [NEP-541](https://github.com/near/NEPs/pull/541) + is released.) +
  • +
  • + If error.cause.info is ShardStuck, you may + also resubmit the identical transaction after a delay +
  • +
+
TIMEOUT_ERROR408 + Transaction was routed, but has not been recorded on chain in 10 + seconds. + +
    +
  • + {" "} + Resubmit the request with the identical transaction (in NEAR + Protocol unique transactions apply exactly once, so if the + previously sent transaction gets applied, this request will just + return the known result, otherwise, it will route the transaction to + the chain once again) +
  • +
  • Check that your transaction is valid
  • +
  • + Check that the signer account id has enough tokens to cover the + transaction fees (keep in mind that some tokens on each account are + locked to cover the storage cost) +
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/send-tx/index.mdx b/docs/5.api/rpc/transactions/send-tx/index.mdx new file mode 100644 index 00000000000..bb0b6625de0 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-tx/index.mdx @@ -0,0 +1,46 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import RequestJson from "./request-json.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Send transaction {#send-tx} + +> Sends transaction. +> Returns the guaranteed execution status and the results the blockchain can provide at the moment. + +- method: `send_tx` +- params: + - `signed_tx_base64`: SignedTransaction encoded in base64 + - [Optional] `wait_until`: the required minimal execution level. + The default value is `EXECUTED_OPTIMISTIC`. + [Read more here](#tx-status-result). + +Using `send_tx` with `wait_until = NONE` is equal to legacy `broadcast_tx_async` method.
+Using `send_tx` with finality `wait_until = EXECUTED_OPTIMISTIC` is equal to legacy `broadcast_tx_commit` method. + +Example: + + + + + + + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-send-tx} + + + +Here is the exhaustive list of the error variants that can be returned by `broadcast_tx_commit` method: + + diff --git a/docs/5.api/rpc/transactions/send-tx/request-bash.mdx b/docs/5.api/rpc/transactions/send-tx/request-bash.mdx new file mode 100644 index 00000000000..d3e96055dfe --- /dev/null +++ b/docs/5.api/rpc/transactions/send-tx/request-bash.mdx @@ -0,0 +1,10 @@ +```bash +http POST https://rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=send_tx \ + params:='{ + "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=", + "wait_until": "EXECUTED" + }' +``` diff --git a/docs/5.api/rpc/transactions/send-tx/request-json.mdx b/docs/5.api/rpc/transactions/send-tx/request-json.mdx new file mode 100644 index 00000000000..04b9849c25b --- /dev/null +++ b/docs/5.api/rpc/transactions/send-tx/request-json.mdx @@ -0,0 +1,11 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "send_tx", + "params": { + "signed_tx_base64": "DgAAAHNlbmRlci50ZXN0bmV0AOrmAai64SZOv9e/naX4W15pJx0GAap35wTT1T/DwcbbDwAAAAAAAAAQAAAAcmVjZWl2ZXIudGVzdG5ldNMnL7URB1cxPOu3G8jTqlEwlcasagIbKlAJlF5ywVFLAQAAAAMAAACh7czOG8LTAAAAAAAAAGQcOG03xVSFQFjoagOb4NBBqWhERnnz45LY4+52JgZhm1iQKz7qAdPByrGFDQhQ2Mfga8RlbysuQ8D8LlA6bQE=", + "wait_until": "INCLUDED_FINAL" + } +} +``` diff --git a/docs/5.api/rpc/transactions/send-tx/response-json.mdx b/docs/5.api/rpc/transactions/send-tx/response-json.mdx new file mode 100644 index 00000000000..f1d05413226 --- /dev/null +++ b/docs/5.api/rpc/transactions/send-tx/response-json.mdx @@ -0,0 +1,74 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "final_execution_status": "FINAL", + "status": { + "SuccessValue": "" + }, + "transaction": { + "signer_id": "sender.testnet", + "public_key": "ed25519:Gowpa4kXNyTMRKgt5W7147pmcc2PxiFic8UHW9rsNvJ6", + "nonce": 13, + "receiver_id": "receiver.testnet", + "actions": [ + { + "Transfer": { + "deposit": "1000000000000000000000000" + } + } + ], + "signature": "ed25519:7oCBMfSHrZkT7tzPDBxxCd3tWFhTES38eks3MCZMpYPJRfPWKxJsvmwQiVBBxRLoxPTnXVaMU2jPV3MdFKZTobH", + "hash": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR" + }, + "transaction_outcome": { + "proof": [], + "block_hash": "9MzuZrRPW1BGpFnZJUJg6SzCrixPpJDfjsNeUobRXsLe", + "id": "ASS7oYwGiem9HaNwJe6vS2kznx2CxueKDvU9BAYJRjNR", + "outcome": { + "logs": [], + "receipt_ids": ["BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh"], + "gas_burnt": 223182562500, + "tokens_burnt": "22318256250000000000", + "executor_id": "sender.testnet", + "status": { + "SuccessReceiptId": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh" + } + } + }, + "receipts_outcome": [ + { + "proof": [], + "block_hash": "5Hpj1PeCi32ZkNXgiD1DrW4wvW4Xtic74DJKfyJ9XL3a", + "id": "BLV2q6p8DX7pVgXRtGtBkyUNrnqkNyU7iSksXG7BjVZh", + "outcome": { + "logs": [], + "receipt_ids": ["3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR"], + "gas_burnt": 223182562500, + "tokens_burnt": "22318256250000000000", + "executor_id": "receiver.testnet", + "status": { + "SuccessValue": "" + } + } + }, + { + "proof": [], + "block_hash": "CbwEqMpPcu6KwqVpBM3Ry83k6M4H1FrJjES9kBXThcRd", + "id": "3sawynPNP8UkeCviGqJGwiwEacfPyxDKRxsEWPpaUqtR", + "outcome": { + "logs": [], + "receipt_ids": [], + "gas_burnt": 0, + "tokens_burnt": "0", + "executor_id": "sender.testnet", + "status": { + "SuccessValue": "" + } + } + } + ] + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/error-schema-table.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/error-schema-table.mdx new file mode 100644 index 00000000000..23dccca4807 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/error-schema-table.mdx @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution +
    +
  • + See error.cause.info for details +
  • +
+
UNKNOWN_TRANSACTION200 + The requested transaction is not available on the node since it might + have not been recorded on the chain yet or has been garbage-collected + +
    +
  • Try again later
  • +
  • + If the transaction had been submitted more than 5 epochs ago, try to + send your request to{" "} + + an archival node + +
  • +
  • Check the transaction hash
  • +
+
TIMEOUT_ERROR408 + It was unable to wait for the transaction status for reasonable time + +
    +
  • Send a request to a different node
  • +
  • Try again later
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/index.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/index.mdx new file mode 100644 index 00000000000..4b24c3f5cc9 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/index.mdx @@ -0,0 +1,58 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Transaction Status with Receipts {#transaction-status-with-receipts} + +> Queries status of a transaction by hash, returning the final transaction +> result _and_ details of all receipts. + +- method: `EXPERIMENTAL_tx_status` +- params: + - `tx_hash` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid transaction hash)_ + - `sender_account_id` _(used to determine which shard to query for transaction)_ + - [Optional] `wait_until`: the required minimal execution level. + The default value is `EXECUTED_OPTIMISTIC`. + Read more [here](/api/rpc/transactions#tx-status-result). + +A Transaction status request with `wait_until != NONE` will wait until the +transaction appears on the blockchain. If the transaction does not exist, +the method will wait until the timeout is reached. If you only need to check +whether the transaction exists, use `wait_until = NONE`, it will return the response immediately. + +Example: + + + + + + + + + + + + }> + + + + +
+ Example response: + +
+ +#### What could go wrong? {#what-could-go-wrong-3} + + + +Here is the exhaustive list of the error variants that can be returned by `EXPERIMENTAL_tx_status` method: + + diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-bash.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-bash.mdx new file mode 100644 index 00000000000..603df657ecd --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=EXPERIMENTAL_tx_status \ + params:='{ + "tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "sender_account_id": "rpc-examples.testnet", + "wait_until": "FINAL" + }' +``` diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-js.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-js.mdx new file mode 100644 index 00000000000..a6d727a4877 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-js.mdx @@ -0,0 +1,7 @@ +```js +const response = await near.connection.provider.txStatusReceipts( + "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "rpc-examples.testnet", + "FINAL", +); +``` diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-json.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-json.mdx new file mode 100644 index 00000000000..336beac2c43 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "EXPERIMENTAL_tx_status", + "params": { + "tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "sender_account_id": "rpc-examples.testnet", + "wait_until": "FINAL" + } +} +``` diff --git a/docs/5.api/rpc/transactions/transaction-status-with-receipts/response-json.mdx b/docs/5.api/rpc/transactions/transaction-status-with-receipts/response-json.mdx new file mode 100644 index 00000000000..19bb2a56f71 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status-with-receipts/response-json.mdx @@ -0,0 +1,182 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "final_execution_status": "FINAL", + "receipts": [ + { + "predecessor_id": "rpc-examples.testnet", + "priority": 0, + "receipt": { + "Action": { + "actions": [ + "CreateAccount", + { + "Transfer": { + "deposit": "5000000000000000000000000" + } + }, + { + "AddKey": { + "access_key": { + "nonce": 0, + "permission": "FullAccess" + }, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + } + ], + "gas_price": "103000000", + "input_data_ids": [], + "is_promise_yield": false, + "output_data_receivers": [], + "signer_id": "rpc-examples.testnet", + "signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + }, + "receipt_id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE", + "receiver_id": "contract.rpc-examples.testnet" + }, + { + "predecessor_id": "system", + "priority": 0, + "receipt": { + "Action": { + "actions": [ + { + "Transfer": { + "deposit": "12524843062500000000" + } + } + ], + "gas_price": "0", + "input_data_ids": [], + "is_promise_yield": false, + "output_data_receivers": [], + "signer_id": "rpc-examples.testnet", + "signer_public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + }, + "receipt_id": "AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4", + "receiver_id": "rpc-examples.testnet" + } + ], + "receipts_outcome": [ + { + "block_hash": "ApNYvBCU3Nnn8TeESvJ7Anfw8vfbmwcXmavypAWtKv6p", + "id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE", + "outcome": { + "executor_id": "contract.rpc-examples.testnet", + "gas_burnt": 4174947687500, + "logs": [], + "metadata": { + "gas_profile": [], + "version": 3 + }, + "receipt_ids": ["AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4"], + "status": { + "SuccessValue": "" + }, + "tokens_burnt": "417494768750000000000" + }, + "proof": [ + { + "direction": "Left", + "hash": "CuLK7PnND8x1XooFysdUbG9VqG2yzKKjPSFXSGsuKzn4" + } + ] + }, + { + "block_hash": "4C1384HReTY7NR7jVk2aMDyccCNVM5zeQDQ6z84cj1N4", + "id": "AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4", + "outcome": { + "executor_id": "rpc-examples.testnet", + "gas_burnt": 223182562500, + "logs": [], + "metadata": { + "gas_profile": [], + "version": 3 + }, + "receipt_ids": [], + "status": { + "SuccessValue": "" + }, + "tokens_burnt": "0" + }, + "proof": [ + { + "direction": "Left", + "hash": "7agjDTstRCDmAn4LvPnHDu8yxhbSWCD7VNhzr7nLq37N" + }, + { + "direction": "Left", + "hash": "54QAYN39nMUp6uz6vhNbDNRbvAmk16mw7R1WvxnmG1Xr" + } + ] + } + ], + "status": { + "SuccessValue": "" + }, + "transaction": { + "actions": [ + "CreateAccount", + { + "Transfer": { + "deposit": "5000000000000000000000000" + } + }, + { + "AddKey": { + "access_key": { + "nonce": 0, + "permission": "FullAccess" + }, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + } + ], + "hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "nonce": 187307146000001, + "priority_fee": 0, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M", + "receiver_id": "contract.rpc-examples.testnet", + "signature": "ed25519:34NgQAukvyKajXFDB6XzKpfd2YDUo3QyTdkUeCgwm24J3dkju7Ejm71VRkRsJwdpKwH1HQWqSV2frnF26yQYEZpJ", + "signer_id": "rpc-examples.testnet" + }, + "transaction_outcome": { + "block_hash": "G1xSnhtrDiaEZNef41kiY8ePQCAwsF2gyVcRNa7B6xaP", + "id": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "outcome": { + "executor_id": "rpc-examples.testnet", + "gas_burnt": 4174947687500, + "logs": [], + "metadata": { + "gas_profile": null, + "version": 1 + }, + "receipt_ids": ["23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"], + "status": { + "SuccessReceiptId": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE" + }, + "tokens_burnt": "417494768750000000000" + }, + "proof": [ + { + "direction": "Left", + "hash": "Ft2GVFu6zuQGbUU7DB7opgshYLPvuvfNnGqMAny1kgPj" + }, + { + "direction": "Left", + "hash": "39hCSJBs64y18wcM8qtasQQnkfXYBhvHau3bEbULgV3E" + }, + { + "direction": "Right", + "hash": "GkZCCuNqu2qpwd5Xwo2g4qwRvXXmgV2k71YM7EYhg5HK" + } + ] + } + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/transaction-status/error-schema-table.mdx b/docs/5.api/rpc/transactions/transaction-status/error-schema-table.mdx new file mode 100644 index 00000000000..23dccca4807 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/error-schema-table.mdx @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ERROR_TYPE
error.name
ERROR_CAUSE
error.cause.name
Status CodeReasonSolution
HANDLER_ERRORINVALID_TRANSACTION200An error happened during transaction execution +
    +
  • + See error.cause.info for details +
  • +
+
UNKNOWN_TRANSACTION200 + The requested transaction is not available on the node since it might + have not been recorded on the chain yet or has been garbage-collected + +
    +
  • Try again later
  • +
  • + If the transaction had been submitted more than 5 epochs ago, try to + send your request to{" "} + + an archival node + +
  • +
  • Check the transaction hash
  • +
+
TIMEOUT_ERROR408 + It was unable to wait for the transaction status for reasonable time + +
    +
  • Send a request to a different node
  • +
  • Try again later
  • +
+
REQUEST_VALIDATION_ERRORPARSE_ERROR400 + Passed arguments can't be parsed by JSON RPC server (missing arguments, + wrong format, etc.) + +
    +
  • Check the arguments passed and pass the correct ones
  • +
  • + Check error.cause.info for more details +
  • +
+
INTERNAL_ERRORINTERNAL_ERROR500Something went wrong with the node itself or overloaded +
    +
  • Try again later
  • +
  • Send a request to a different node
  • +
  • + Check error.cause.info for more details +
  • +
+
diff --git a/docs/5.api/rpc/transactions/transaction-status/index.mdx b/docs/5.api/rpc/transactions/transaction-status/index.mdx new file mode 100644 index 00000000000..866ec7f1377 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/index.mdx @@ -0,0 +1,58 @@ +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import { LantstoolLabel } from "@site/src/components/lantstool/LantstoolLabel/LantstoolLabel"; +import { TryOutOnLantstool } from "@site/src/components/lantstool/TryOutOnLantstool"; +import RequestJson from "./request-json.mdx"; +import RequestJs from "./request-js.mdx"; +import RequestBash from "./request-bash.mdx"; +import ResponseJson from "./response-json.mdx"; +import ErrorSchemaTable from "./error-schema-table.mdx"; +import ErrorSchemaDescription from "../../general/error-schema-description.mdx"; + +## Transaction Status {#transaction-status} + +> Queries status of a transaction by hash and returns the final transaction result. + +- method: `tx` +- params: + - `tx_hash` _(see [NearBlocks Explorer](https://testnet.nearblocks.io) for a valid transaction hash)_ + - `sender_account_id` _(used to determine which shard to query for transaction)_ + - [Optional] `wait_until`: the required minimal execution level. + The default value is `EXECUTED_OPTIMISTIC`. + Read more [here](/api/rpc/transactions#tx-status-result). + +A Transaction status request with `wait_until != NONE` will wait until the +transaction appears on the blockchain. If the transaction does not exist, +the method will wait until the timeout is reached. If you only need to check +whether the transaction exists, use `wait_until = NONE`, it will return +the response immediately. + +Example: + + + + + + + + + + + + }> + + + + +
+ Example Result: + +
+ +#### What could go wrong? {#what-could-go-wrong-2} + + + +Here is the exhaustive list of the error variants that can be returned by `tx` method: + + diff --git a/docs/5.api/rpc/transactions/transaction-status/request-bash.mdx b/docs/5.api/rpc/transactions/transaction-status/request-bash.mdx new file mode 100644 index 00000000000..3b1cc796ae9 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/request-bash.mdx @@ -0,0 +1,11 @@ +```bash +http POST https://archival-rpc.testnet.near.org \ + jsonrpc=2.0 \ + id=dontcare \ + method=tx \ + params:='{ + "tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "sender_account_id": "rpc-examples.testnet", + "wait_until": "FINAL" + }' +``` diff --git a/docs/5.api/rpc/transactions/transaction-status/request-js.mdx b/docs/5.api/rpc/transactions/transaction-status/request-js.mdx new file mode 100644 index 00000000000..f0058ee9062 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/request-js.mdx @@ -0,0 +1,7 @@ +```js +const response = await near.connection.provider.txStatus( + "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "rpc-examples.testnet", + "FINAL", +); +``` diff --git a/docs/5.api/rpc/transactions/transaction-status/request-json.mdx b/docs/5.api/rpc/transactions/transaction-status/request-json.mdx new file mode 100644 index 00000000000..05a14aef4c1 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/request-json.mdx @@ -0,0 +1,12 @@ +```json +{ + "jsonrpc": "2.0", + "id": "dontcare", + "method": "tx", + "params": { + "tx_hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "sender_account_id": "rpc-examples.testnet", + "wait_until": "FINAL" + } +} +``` diff --git a/docs/5.api/rpc/transactions/transaction-status/response-json.mdx b/docs/5.api/rpc/transactions/transaction-status/response-json.mdx new file mode 100644 index 00000000000..358975269a6 --- /dev/null +++ b/docs/5.api/rpc/transactions/transaction-status/response-json.mdx @@ -0,0 +1,124 @@ +```json +{ + "jsonrpc": "2.0", + "result": { + "final_execution_status": "FINAL", + "receipts_outcome": [ + { + "block_hash": "ApNYvBCU3Nnn8TeESvJ7Anfw8vfbmwcXmavypAWtKv6p", + "id": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE", + "outcome": { + "executor_id": "contract.rpc-examples.testnet", + "gas_burnt": 4174947687500, + "logs": [], + "metadata": { + "gas_profile": [], + "version": 3 + }, + "receipt_ids": ["AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4"], + "status": { + "SuccessValue": "" + }, + "tokens_burnt": "417494768750000000000" + }, + "proof": [ + { + "direction": "Left", + "hash": "CuLK7PnND8x1XooFysdUbG9VqG2yzKKjPSFXSGsuKzn4" + } + ] + }, + { + "block_hash": "4C1384HReTY7NR7jVk2aMDyccCNVM5zeQDQ6z84cj1N4", + "id": "AZz7tN4cSK9Ngeq7KUFWSm8yi9WLsVjqYiohNYzW8Pc4", + "outcome": { + "executor_id": "rpc-examples.testnet", + "gas_burnt": 223182562500, + "logs": [], + "metadata": { + "gas_profile": [], + "version": 3 + }, + "receipt_ids": [], + "status": { + "SuccessValue": "" + }, + "tokens_burnt": "0" + }, + "proof": [ + { + "direction": "Left", + "hash": "7agjDTstRCDmAn4LvPnHDu8yxhbSWCD7VNhzr7nLq37N" + }, + { + "direction": "Left", + "hash": "54QAYN39nMUp6uz6vhNbDNRbvAmk16mw7R1WvxnmG1Xr" + } + ] + } + ], + "status": { + "SuccessValue": "" + }, + "transaction": { + "actions": [ + "CreateAccount", + { + "Transfer": { + "deposit": "5000000000000000000000000" + } + }, + { + "AddKey": { + "access_key": { + "nonce": 0, + "permission": "FullAccess" + }, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M" + } + } + ], + "hash": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "nonce": 187307146000001, + "priority_fee": 0, + "public_key": "ed25519:vJBU18AtvePANmepMoY3rtV3wt1RHwqoktak82E4d2M", + "receiver_id": "contract.rpc-examples.testnet", + "signature": "ed25519:34NgQAukvyKajXFDB6XzKpfd2YDUo3QyTdkUeCgwm24J3dkju7Ejm71VRkRsJwdpKwH1HQWqSV2frnF26yQYEZpJ", + "signer_id": "rpc-examples.testnet" + }, + "transaction_outcome": { + "block_hash": "G1xSnhtrDiaEZNef41kiY8ePQCAwsF2gyVcRNa7B6xaP", + "id": "7AfonAhbK4ZbdBU9VPcQdrTZVZBXE25HmZAMEABs9To1", + "outcome": { + "executor_id": "rpc-examples.testnet", + "gas_burnt": 4174947687500, + "logs": [], + "metadata": { + "gas_profile": null, + "version": 1 + }, + "receipt_ids": ["23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE"], + "status": { + "SuccessReceiptId": "23r1wWsMAVtZysr9wNV6TCSdZTUyPbhBZ3McJ6zStpaE" + }, + "tokens_burnt": "417494768750000000000" + }, + "proof": [ + { + "direction": "Left", + "hash": "Ft2GVFu6zuQGbUU7DB7opgshYLPvuvfNnGqMAny1kgPj" + }, + { + "direction": "Left", + "hash": "39hCSJBs64y18wcM8qtasQQnkfXYBhvHau3bEbULgV3E" + }, + { + "direction": "Right", + "hash": "GkZCCuNqu2qpwd5Xwo2g4qwRvXXmgV2k71YM7EYhg5HK" + } + ] + } + }, + "id": "dontcare" +} +``` diff --git a/docs/5.api/rpc/transactions/tx-status-result/index.mdx b/docs/5.api/rpc/transactions/tx-status-result/index.mdx new file mode 100644 index 00000000000..fd873c1aa3a --- /dev/null +++ b/docs/5.api/rpc/transactions/tx-status-result/index.mdx @@ -0,0 +1,29 @@ +## Transaction Execution Levels {#tx-status-result} + +All the methods listed above have `wait_until` request parameter, and +`final_execution_status` response value. They correspond to the same enum +`TxExecutionStatus`. See the detailed explanation for all the options: + +```rust +#[serde(rename_all = "SCREAMING_SNAKE_CASE")] +pub enum TxExecutionStatus { + /// Transaction is waiting to be included into the block + None, + /// Transaction is included into the block. The block may be not finalized yet + Included, + /// Transaction is included into the block + + /// All non-refund transaction receipts finished their execution. + /// The corresponding blocks for tx and each receipt may be not finalized yet + #[default] + ExecutedOptimistic, + /// Transaction is included into finalized block + IncludedFinal, + /// Transaction is included into finalized block + + /// All non-refund transaction receipts finished their execution. + /// The corresponding blocks for each receipt may be not finalized yet + Executed, + /// Transaction is included into finalized block + + /// Execution of all transaction receipts is finalized, including refund receipts + Final, +} +```