From b7f1aded7ef9e4d3a42da4d28065709da4629f84 Mon Sep 17 00:00:00 2001 From: Ake <10195782+akegaviar@users.noreply.github.com> Date: Thu, 23 Jul 2026 15:31:41 +0700 Subject: [PATCH] =?UTF-8?q?docs:=20Polygon=20post-Bor=20reference=20covera?= =?UTF-8?q?ge=20=E2=80=94=20eth=5FgetProof=20note,=20bor=5F*=20+=20getProo?= =?UTF-8?q?f=20pages,=20decom=20dead=20trace=5F*=20pages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Post-cutover (Polygon Erigon->Bor migration completed 2026-07-23) follow-up to #515. Keeps callTracer as the trace_* migration target (flatCallTracer is still gated on Chainstack Polygon nodes — deferred to a separate PR once it's whitelisted). - polygon-methods.mdx: add the eth_getProof ~128-block note (prose + table annotation) - new reference pages (openapi + Try-it): eth_getProof, and bor_getAuthor / bor_getCurrentProposer / bor_getCurrentValidators / bor_getRootHash / bor_getSignersAtHash (were in the availability table with no pages); examples verified live against a Chainstack Polygon Bor node - decommission the dead trace_transaction / trace_block reference pages: delete the files, strip nav, remove their overview cards, 301 to the debug_ equivalents - new openapi group openapi/polygon_node_api/bor/ Rebuilt fresh on main (the older #542 branch was 43 commits behind); flatCallTracer switch dropped per the deployment reality. --- docs.json | 10 +- docs/polygon-methods.mdx | 4 +- .../account_info/eth_getProof.json | 141 ++++++++++++++ .../polygon_node_api/bor/bor_getAuthor.json | 86 +++++++++ .../bor/bor_getCurrentProposer.json | 81 ++++++++ .../bor/bor_getCurrentValidators.json | 98 ++++++++++ .../polygon_node_api/bor/bor_getRootHash.json | 87 +++++++++ .../bor/bor_getSignersAtHash.json | 89 +++++++++ reference/polygon-borgetauthor.mdx | 34 ++++ reference/polygon-borgetcurrentproposer.mdx | 34 ++++ reference/polygon-borgetcurrentvalidators.mdx | 38 ++++ reference/polygon-borgetroothash.mdx | 35 ++++ reference/polygon-borgetsignersathash.mdx | 34 ++++ reference/polygon-debug-trace-rpc-methods.mdx | 2 - reference/polygon-getproof.mdx | 47 +++++ reference/polygon-trace_block.mdx | 175 ------------------ reference/polygon-trace_transaction.mdx | 160 ---------------- 17 files changed, 815 insertions(+), 340 deletions(-) create mode 100644 openapi/polygon_node_api/account_info/eth_getProof.json create mode 100644 openapi/polygon_node_api/bor/bor_getAuthor.json create mode 100644 openapi/polygon_node_api/bor/bor_getCurrentProposer.json create mode 100644 openapi/polygon_node_api/bor/bor_getCurrentValidators.json create mode 100644 openapi/polygon_node_api/bor/bor_getRootHash.json create mode 100644 openapi/polygon_node_api/bor/bor_getSignersAtHash.json create mode 100644 reference/polygon-borgetauthor.mdx create mode 100644 reference/polygon-borgetcurrentproposer.mdx create mode 100644 reference/polygon-borgetcurrentvalidators.mdx create mode 100644 reference/polygon-borgetroothash.mdx create mode 100644 reference/polygon-borgetsignersathash.mdx create mode 100644 reference/polygon-getproof.mdx delete mode 100644 reference/polygon-trace_block.mdx delete mode 100644 reference/polygon-trace_transaction.mdx diff --git a/docs.json b/docs.json index 6a78b882..c34995b3 100644 --- a/docs.json +++ b/docs.json @@ -106,6 +106,8 @@ { "source": "/docs/polygon-zkevm-methods", "destination": "/docs/protocols-networks" }, { "source": "/docs/polygon-zkevm-tooling", "destination": "/docs/protocols-networks" }, { "source": "/docs/polygon-zkevm-tutorial-deploy-a-smart-contract-using-hardhat", "destination": "/docs/protocols-networks" }, + { "source": "/reference/polygon-trace_transaction", "destination": "/reference/polygon-tracetransaction" }, + { "source": "/reference/polygon-trace_block", "destination": "/reference/polygon-traceblockbynumber" }, { "source": "/docs/moonbeam-methods", "destination": "/docs/protocols-networks" }, { "source": "/docs/moonbeam-tooling", "destination": "/docs/protocols-networks" }, { "source": "/docs/moonbeam-monitoring-the-conviction-voting-contract", "destination": "/docs/protocols-networks" }, @@ -1814,11 +1816,14 @@ "reference/polygon-traceblockbynumber", "reference/polygon-tracetransaction", "reference/polygon-tracecall", - "reference/polygon-trace_transaction", - "reference/polygon-trace_block", "reference/polygon-chain-data-rpc-methods", "reference/chainid", "reference/syncing", + "reference/polygon-borgetauthor", + "reference/polygon-borgetcurrentproposer", + "reference/polygon-borgetcurrentvalidators", + "reference/polygon-borgetroothash", + "reference/polygon-borgetsignersathash", "reference/polygon-gas-data-rpc-methods", "reference/estimategas", "reference/gasprice", @@ -1827,6 +1832,7 @@ "reference/getbalance", "reference/getcode", "reference/getstorageat", + "reference/polygon-getproof", "reference/polygon-logs-rpc-methods", "reference/getlogs", "reference/newfilter", diff --git a/docs/polygon-methods.mdx b/docs/polygon-methods.mdx index 9d6ccb67..d34c594d 100644 --- a/docs/polygon-methods.mdx +++ b/docs/polygon-methods.mdx @@ -18,6 +18,8 @@ Polygon runs on the Bor client, which does not implement the Erigon-only Parity The `debug_trace*` methods return equivalent execution traces on Bor. The `erigon_*` convenience methods have no Bor equivalent — use the standard `eth_*` methods instead. +On Bor, `eth_getProof` returns state proofs only for roughly the latest 128 blocks; historical proof queries are not available. + | Method | Availability | Comment | | ---------------------------------------- | ------------ | ------- | | eth\_accounts | | | @@ -38,7 +40,7 @@ The `debug_trace*` methods return equivalent execution traces on Bor. The `erigo | eth\_getFilterChanges | | | | eth\_getFilterLogs | | | | eth\_getLogs | | | -| eth\_getProof | | | +| eth\_getProof | | Latest ~128 blocks only on Bor; no historical proofs | | eth\_getStorageAt | | | | eth\_getTransactionByBlockHashAndIndex | | | | eth\_getTransactionByBlockNumberAndIndex | | | diff --git a/openapi/polygon_node_api/account_info/eth_getProof.json b/openapi/polygon_node_api/account_info/eth_getProof.json new file mode 100644 index 00000000..cf8b6f62 --- /dev/null +++ b/openapi/polygon_node_api/account_info/eth_getProof.json @@ -0,0 +1,141 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "eth_getProof example", + "version": "1.0.0", + "description": "Get the account and storage values of the specified account including the Merkle proof." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "eth_getProof", + "operationId": "eth_getProof", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "eth_getProof" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [ + "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270", + [], + "latest" + ], + "items": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "accountProof": { + "type": "array", + "items": { + "type": "string" + } + }, + "balance": { + "type": "string" + }, + "codeHash": { + "type": "string" + }, + "nonce": { + "type": "string" + }, + "storageHash": { + "type": "string" + }, + "storageProof": { + "type": "array", + "items": { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + }, + "proof": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/openapi/polygon_node_api/bor/bor_getAuthor.json b/openapi/polygon_node_api/bor/bor_getAuthor.json new file mode 100644 index 00000000..9b5f968b --- /dev/null +++ b/openapi/polygon_node_api/bor/bor_getAuthor.json @@ -0,0 +1,86 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "bor_getAuthor example", + "version": "1.0.0", + "description": "Get the address that produced (signed) a given block." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "bor_getAuthor", + "operationId": "bor_getAuthor", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "bor_getAuthor" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [ + "0x561294b" + ], + "items": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "string" + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/openapi/polygon_node_api/bor/bor_getCurrentProposer.json b/openapi/polygon_node_api/bor/bor_getCurrentProposer.json new file mode 100644 index 00000000..a8adf2b1 --- /dev/null +++ b/openapi/polygon_node_api/bor/bor_getCurrentProposer.json @@ -0,0 +1,81 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "bor_getCurrentProposer example", + "version": "1.0.0", + "description": "Get the address of the current block proposer." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "bor_getCurrentProposer", + "operationId": "bor_getCurrentProposer", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "bor_getCurrentProposer" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "string" + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/openapi/polygon_node_api/bor/bor_getCurrentValidators.json b/openapi/polygon_node_api/bor/bor_getCurrentValidators.json new file mode 100644 index 00000000..bf0c8173 --- /dev/null +++ b/openapi/polygon_node_api/bor/bor_getCurrentValidators.json @@ -0,0 +1,98 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "bor_getCurrentValidators example", + "version": "1.0.0", + "description": "Get the current validator set as seen by the Bor consensus engine." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "bor_getCurrentValidators", + "operationId": "bor_getCurrentValidators", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "bor_getCurrentValidators" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [] + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "type": "object", + "properties": { + "ID": { + "type": "integer" + }, + "signer": { + "type": "string" + }, + "power": { + "type": "integer" + }, + "accum": { + "type": "integer" + } + } + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/openapi/polygon_node_api/bor/bor_getRootHash.json b/openapi/polygon_node_api/bor/bor_getRootHash.json new file mode 100644 index 00000000..71d0f36f --- /dev/null +++ b/openapi/polygon_node_api/bor/bor_getRootHash.json @@ -0,0 +1,87 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "bor_getRootHash example", + "version": "1.0.0", + "description": "Get the root hash for a given block range." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "bor_getRootHash", + "operationId": "bor_getRootHash", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "bor_getRootHash" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [ + 90253627, + 90253643 + ], + "items": { + "type": "integer" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "string" + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/openapi/polygon_node_api/bor/bor_getSignersAtHash.json b/openapi/polygon_node_api/bor/bor_getSignersAtHash.json new file mode 100644 index 00000000..03ce420d --- /dev/null +++ b/openapi/polygon_node_api/bor/bor_getSignersAtHash.json @@ -0,0 +1,89 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "bor_getSignersAtHash example", + "version": "1.0.0", + "description": "Get the list of authorized signers at the given block hash." + }, + "servers": [ + { + "url": "https://nd-828-700-214.p2pify.com" + } + ], + "paths": { + "/a9bca2f0f84b54086ceebe590316fff3": { + "post": { + "tags": [ + "Ethereum Operations" + ], + "summary": "bor_getSignersAtHash", + "operationId": "bor_getSignersAtHash", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "jsonrpc", + "method", + "id", + "params" + ], + "properties": { + "jsonrpc": { + "type": "string", + "default": "2.0" + }, + "method": { + "type": "string", + "default": "bor_getSignersAtHash" + }, + "id": { + "type": "integer", + "default": 1 + }, + "params": { + "type": "array", + "default": [ + "0xf125452aa7b19272f6406c3994e1fad767cd3722ab19e908e2f314528c14cfb7" + ], + "items": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "Result", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "jsonrpc": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/reference/polygon-borgetauthor.mdx b/reference/polygon-borgetauthor.mdx new file mode 100644 index 00000000..dad11523 --- /dev/null +++ b/reference/polygon-borgetauthor.mdx @@ -0,0 +1,34 @@ +--- +title: bor_getAuthor | Polygon +openapi: /openapi/polygon_node_api/bor/bor_getAuthor.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method bor_getAuthor returns the validator address that produced a given block. On Polygon via Chainstack." +--- + +Polygon API method `bor_getAuthor` returns the address of the validator that produced (signed) a given block on the Bor consensus layer. + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +* `block` — the block number in hexadecimal (for example, `0x561294b`), or a block hash. + +## Response + +* `result` — the address of the validator that authored the block. + +```json +{ "jsonrpc": "2.0", "id": 1, "result": "0x0e94b9b3fabd95338b8b23c36caae1d640e1339f" } +``` + +## Use case + +`bor_getAuthor` is used by explorers and analytics tools to attribute each block to the validator that produced it on Polygon. diff --git a/reference/polygon-borgetcurrentproposer.mdx b/reference/polygon-borgetcurrentproposer.mdx new file mode 100644 index 00000000..afe1b259 --- /dev/null +++ b/reference/polygon-borgetcurrentproposer.mdx @@ -0,0 +1,34 @@ +--- +title: bor_getCurrentProposer | Polygon +openapi: /openapi/polygon_node_api/bor/bor_getCurrentProposer.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method bor_getCurrentProposer returns the address of the current block proposer on the Bor consensus layer. On Polygon via Chainstack." +--- + +Polygon API method `bor_getCurrentProposer` returns the address of the validator that is the current block proposer on the Bor consensus layer. This method takes no parameters. + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +This method takes no parameters. + +## Response + +* `result` — the address of the current block proposer. + +```json +{ "jsonrpc": "2.0", "id": 1, "result": "0x0e94b9b3fabd95338b8b23c36caae1d640e1339f" } +``` + +## Use case + +`bor_getCurrentProposer` is used by validator dashboards and monitoring tools to track which validator is currently proposing blocks on Polygon. diff --git a/reference/polygon-borgetcurrentvalidators.mdx b/reference/polygon-borgetcurrentvalidators.mdx new file mode 100644 index 00000000..e7ebeec3 --- /dev/null +++ b/reference/polygon-borgetcurrentvalidators.mdx @@ -0,0 +1,38 @@ +--- +title: bor_getCurrentValidators | Polygon +openapi: /openapi/polygon_node_api/bor/bor_getCurrentValidators.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method bor_getCurrentValidators returns the current validator set seen by the Bor consensus engine. On Polygon via Chainstack." +--- + +Polygon API method `bor_getCurrentValidators` returns the current validator set as seen by the Bor consensus engine for the active span. This method takes no parameters. + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +This method takes no parameters. + +## Response + +* `result` — an array of validator objects: + + `ID` — the validator ID. + + `signer` — the validator's signer address. + + `power` — the validator's voting power. + + `accum` — the validator's proposer priority (accumulator) used for proposer selection. + +```json +{ "jsonrpc": "2.0", "id": 1, "result": [{ "ID": 0, "signer": "0x0e94b9b3fabd95338b8b23c36caae1d640e1339f", "power": 69637778, "accum": 0 }] } +``` + +## Use case + +`bor_getCurrentValidators` is used by staking dashboards and explorers to display the active validator set and each validator's voting power on Polygon. diff --git a/reference/polygon-borgetroothash.mdx b/reference/polygon-borgetroothash.mdx new file mode 100644 index 00000000..c4434c9d --- /dev/null +++ b/reference/polygon-borgetroothash.mdx @@ -0,0 +1,35 @@ +--- +title: bor_getRootHash | Polygon +openapi: /openapi/polygon_node_api/bor/bor_getRootHash.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method bor_getRootHash returns the root hash for a given block range, used for checkpointing to Ethereum. On Polygon via Chainstack." +--- + +Polygon API method `bor_getRootHash` returns the root hash computed over a given block range. Bor uses these range root hashes when checkpointing Polygon state to Ethereum. + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +* `from` — the start block number (integer). +* `to` — the end block number (integer). The range is capped by the node's configured limit. + +## Response + +* `result` — the root hash for the requested block range, as a hexadecimal string without the `0x` prefix. + +```json +{ "jsonrpc": "2.0", "id": 1, "result": "684c2efeba6e8b27d1fd5082424107a53dfc16f54731908ba96c0c76c598b46a" } +``` + +## Use case + +`bor_getRootHash` is used by checkpoint and bridge tooling to reconstruct or verify the block-range root hashes that Bor submits to Ethereum. diff --git a/reference/polygon-borgetsignersathash.mdx b/reference/polygon-borgetsignersathash.mdx new file mode 100644 index 00000000..4e8fdf9c --- /dev/null +++ b/reference/polygon-borgetsignersathash.mdx @@ -0,0 +1,34 @@ +--- +title: bor_getSignersAtHash | Polygon +openapi: /openapi/polygon_node_api/bor/bor_getSignersAtHash.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method bor_getSignersAtHash returns the authorized signers at a given block hash. On Polygon via Chainstack." +--- + +Polygon API method `bor_getSignersAtHash` returns the list of authorized signers at a given block hash on the Bor consensus layer. + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +* `hash` — the block hash to query. + +## Response + +* `result` — an array of signer addresses authorized at the given block. + +```json +{ "jsonrpc": "2.0", "id": 1, "result": ["0x0e94b9b3fabd95338b8b23c36caae1d640e1339f"] } +``` + +## Use case + +`bor_getSignersAtHash` is used to audit which validators were authorized to sign at a specific point in the chain's history on Polygon. diff --git a/reference/polygon-debug-trace-rpc-methods.mdx b/reference/polygon-debug-trace-rpc-methods.mdx index 9e7c726a..43de0ef5 100644 --- a/reference/polygon-debug-trace-rpc-methods.mdx +++ b/reference/polygon-debug-trace-rpc-methods.mdx @@ -20,8 +20,6 @@ Developers can access the debug and trace tools with the following methods: - - ## Pre-built native tracers diff --git a/reference/polygon-getproof.mdx b/reference/polygon-getproof.mdx new file mode 100644 index 00000000..bddb42c3 --- /dev/null +++ b/reference/polygon-getproof.mdx @@ -0,0 +1,47 @@ +--- +title: eth_getProof | Polygon +openapi: /openapi/polygon_node_api/account_info/eth_getProof.json POST /a9bca2f0f84b54086ceebe590316fff3 +description: "Polygon API method eth_getProof returns the account and storage Merkle proof for an address, letting clients verify state without the full chain. On Polygon via Chainstack." +--- + +Polygon API method `eth_getProof` returns the Merkle proof for an account and, optionally, for specific storage slots. Clients use it to verify account balances, nonces, contract code hashes, and storage values against a block's state root without holding the entire state. + + +Polygon runs on the Bor client. On Bor archive nodes (Bor with the path-based storage scheme), `eth_getProof` returns proofs only for roughly the latest 128 blocks — historical proof queries are not available. + + + +When called against a block older than the latest ~128 blocks, this method is billed as an archive request (2 RUs instead of 1 RU). See [request units](/docs/request-units#archive-state-methods). + + + + +**Get your own node endpoint today** + +[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. + +You can sign up with your GitHub, X, Google, or Microsoft account. + + + + +## Parameters + +* `address` — the address of the account to prove. +* `storageKeys` — an array of 32-byte storage slot keys to prove. Pass an empty array to prove the account only. +* `block` — the block number in hexadecimal, or one of `earliest`, `latest`, or `pending`. Defaults to `latest`. + +## Response + +* `result` — an object with the account proof and state values: + + `address` — the account address. + + `accountProof` — an array of RLP-encoded Merkle-trie nodes proving the account against the block state root. + + `balance` — the account balance, in hexadecimal wei. + + `codeHash` — the hash of the account's contract code; for a non-contract (EOA) account this is the Keccak-256 hash of empty code. + + `nonce` — the account nonce, in hexadecimal. + + `storageHash` — the root hash of the account storage trie. + + `storageProof` — an array of objects, one per requested `storageKeys` entry, each with the `key`, its `value`, and the `proof` (RLP-encoded trie nodes). + +## Use case + +`eth_getProof` is used by light clients, cross-chain bridges, and auditing tools that need cryptographic proof of an account or storage value at a specific block without syncing the full Polygon state. diff --git a/reference/polygon-trace_block.mdx b/reference/polygon-trace_block.mdx deleted file mode 100644 index e18bc833..00000000 --- a/reference/polygon-trace_block.mdx +++ /dev/null @@ -1,175 +0,0 @@ ---- -title: trace_block | Polygon -openapi: /openapi/polygon_node_api/debug_and_trace/trace_block.json POST /a9bca2f0f84b54086ceebe590316fff3 -description: "Polygon API method that returns traces for all the transactions within a specific block. Available on Polygon via Chainstack JSON-RPC nodes." ---- - -Polygon API method that returns traces for all the transactions within a specific block. Developers can use the `trace_block` method to gain insight into the behavior of smart contracts within a block, analyze gas usage and optimize their contracts accordingly. This method is only available on an Erigon instance. - - -**Not available on Polygon.** Chainstack serves Polygon on the Bor client (archive uses Bor with PBSS), which does not implement the Erigon-only `trace_*` namespace. Use [`debug_traceBlockByNumber`](/reference/polygon-traceblockbynumber) with the `callTracer`, which returns equivalent per-transaction call traces for a block on Bor. - - - - -**Get your own node endpoint today** - -[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. - -You can sign up with your GitHub, X, Google, or Microsoft account. - - - - -## Parameters - -* `quantity or tag` — the integer of a block encoded as hexadecimal or the string with: - - + `latest` — the most recent block in the blockchain and the current state of the blockchain at the most recent block - + `earliest` — the earliest available or genesis block - + `pending` — the pending state and transactions block. The current state of transactions that have been broadcast to the network but have not yet been included in a block. - - -See the [default block parameter](https://ethereum.org/en/developers/docs/apis/json-rpc/#default-block). - - - -## Response - -* `result` — an object containing the traces of all of the transactions in the block: - + `action` — an object that describes the action taken by the transaction: - - `from` — the address of the sender who initiated the transaction. - - `callType` — the type of call, `call` or `delegatecall`, two ways to invoke a function in a smart contract. `call` creates a new environment for the function to work in, so changes made in that function won't affect the environment where the function was called. `delegatecall` doesn't create a new environment. Instead, it runs the function within the environment of the caller, so changes made in that function will affect the caller's environment. - - `gas` — the units of gas included in the transaction by the sender. - - `input` — the optional input data sent with the transaction, usually used to interact with smart contracts. - - `to` — the address of the recipient of the transaction if it was a transaction to an address. For contract creation transactions, this field is null. - - `value` — the value of the native token transferred along with the transaction, in Wei. - - `blockHash` — the hash of the block in which the transaction was included. - - `blockNumber` — the number of the block in which the transaction was included. - - `error` — a string that indicates whether the transaction was successful or not. `null` if successful, `Reverted` if not. - - `result` — an object that contains additional data about the execution of the transaction: - * `gasUsed` — the total used gas by the call, encoded as hexadecimal. - * `output` — the return value of the call, encoded as a hexadecimal string. - - `subtraces` — the number of sub-traces created during execution. When a transaction is executed on the EVM, it may trigger additional sub-executions, such as when a smart contract calls another smart contract or when an external account is accessed. - - `traceAddress` — an array that indicates the position of the transaction in the trace. - - `transactionHash` — the hash of the transaction. - - `transactionPosition` — the position of the transaction in the block. - - `type` — the type of action taken by the transaction, `call` or `create`. `call` is the most common type of trace and occurs when a smart contract invokes another contract's function. `create` represents the creation of a new smart contract. This type of trace occurs when a smart contract is deployed to the blockchain. - -## `trace_block` code examples - - -```javascript ethers.js -const ethers = require('ethers'); -const NODE_URL = "CHAINSTACK_NODE_URL"; -const provider = new ethers.JsonRpcProvider(NODE_URL); - -const traceBlock = async (block) => { - const traces = await provider.send("trace_block", [block]); - console.log(traces); -}; - -traceBlock("latest") -``` - -```python web3.py -from web3 import Web3 -node_url = "CHAINSTACK_NODE_URL" -web3 = Web3.HTTPProvider(node_url) - -block = "latest" - -traces = web3.provider.make_request('trace_block', [block]) -print(traces) -``` - - - -## Use case - -A practical use case for the `trace_block` method on Polygon can be to conduct an analysis of the most recent block on the network. For example, by examining the amount of gas supplied by all the transactions and the actual amount of gas utilized, developers can gain valuable insights into the block's behavior. This can be the first step to developing a chain explorer. - -The following code is an implementation of this idea using ethers.js: - -```javascript index.js -const ethers = require("ethers"); -const NODE_URL = "CHAINSTACK_NODE_URL"; -const provider = new ethers.JsonRpcProvider(NODE_URL); - -// A function that returns an array of result and gas fields for each transaction in a block -async function traceBlock(block) { - try { - const traces = await provider.send("trace_block", [block]); - const resultFields = []; - const gasFields = []; - - for (const { result, action } of traces) { - resultFields.push(result); - gasFields.push(action.gas); - } - - return [resultFields, gasFields]; - } catch (error) { - console.error(`Error while tracing block: ${error}`); - throw error; - } -} - -// A function that calculates the total gas used by all transactions in a block -function returnGasUsed(results) { - const totalGasUsed = results.reduce((total, result) => { - if (result !== null && result.gasUsed !== undefined) { - total += Number(BigInt(result.gasUsed)); - } - return total; - }, 0); - return totalGasUsed; -} - -// A function that calculates the total gas supplied to a block -function returnTotalGas(gasArray) { - const totalGas = gasArray.reduce((total, gas) => { - if (gas !== undefined) { - total += Number(BigInt(gas)); - } - return total; - }, 0); - return totalGas; -} - -// The main function that runs the gas analysis -async function main() { - try { - const block = 'latest'; - const [results, gas] = await traceBlock(block); - - const gasUsed = returnGasUsed(results); - const totalGas = returnTotalGas(gas); - console.log('===== Gas analysis ====='); - console.log(`Total gas supplied: ${totalGas}`); - console.log(`Gas used: ${gasUsed}`); - console.log(`Unused gas: ${totalGas - gasUsed}`); - - const gasUsedPercentage = (gasUsed / totalGas) * 100; - console.log(`Percentage of gas used: ${gasUsedPercentage.toFixed(2)} %`); - } catch (error) { - console.error(`Error while running gas analysis: ${error}`); - } -} - -// Call the main function to start the program -main(); -``` - - -The `traceBlock` function takes a block number or tag as an input parameter and returns an array of two elements. The first element is an array of the results of each transaction in the block, which contains the `gasUsed` field, and the second element is an array of the `gas` field used by each call. - -The `returnGasUsed` function calculates the total gas used by all transactions in a block by iterating over the results array and summing up the `gasUsed` fields of each non-null element. - -The `returnTotalGas` function calculates the total gas supplied to a block by iterating over the `gasArray` array and summing up the non-undefined elements. - -The main function calls the `traceBlock` function with the block number or tag calculates the gas used and total gas supplied using the `returnGasUsed` and `returnTotalGas` functions, and outputs the results to the console. - -The `main` function is wrapped in a `try-catch` block to handle any errors that may occur during execution. - -Finally, the `main` function is called at the end of the script to run the gas analysis. diff --git a/reference/polygon-trace_transaction.mdx b/reference/polygon-trace_transaction.mdx deleted file mode 100644 index 0e88662f..00000000 --- a/reference/polygon-trace_transaction.mdx +++ /dev/null @@ -1,160 +0,0 @@ ---- -title: trace_transaction | Polygon -openapi: /openapi/polygon_node_api/debug_and_trace/trace_transaction.json POST /a9bca2f0f84b54086ceebe590316fff3 -description: "Polygon API method that traces a specific transaction. trace_transaction JSON-RPC method available on the Polygon blockchain via Chainstack." ---- - -Polygon API method that traces a specific transaction. It provides a detailed record of all the steps taken by the Ethereum Virtual Machine (EVM) during the execution, including all the operations performed and the changes made to the blockchain state. This method is available on Erigon only. - - -**Not available on Polygon.** Chainstack serves Polygon on the Bor client (archive uses Bor with PBSS), which does not implement the Erigon-only `trace_*` namespace. Use [`debug_traceTransaction`](/reference/polygon-tracetransaction) with the `callTracer`, which returns an equivalent call trace on Bor. - - - - -**Get your own node endpoint today** - -[Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required. - -You can sign up with your GitHub, X, Google, or Microsoft account. - - - - -## Parameters - -* `hash` — the hash identifying a transaction - -## Response - -* `action` — an object that describes the action taken by the transaction: - + `from` — the address of the sender who initiated the transaction. - + `callType` — the type of call, `call` or `delegatecall`, two ways to invoke a function in a smart contract. `call` creates a new environment for the function to work in, so changes made in that function won't affect the environment where the function was called. `delegatecall` doesn't create a new environment. Instead, it runs the function within the environment of the caller, so changes made in that function will affect the caller's environment. - + `gas` — the units of gas included in the transaction by the sender. - + `input` — the optional input data sent with the transaction, usually used to interact with smart contracts. - + `to` — the address of the recipient of the transaction if it was a transaction to an address. For contract creation transactions, this field is null. - + `value` — the value of the native token transferred along with the transaction, in Wei. - + `blockHash` — the hash of the block in which the transaction was included. - + `blockNumber` — the number of the block in which the transaction was included. - + `error` — a string that indicates whether the transaction was successful or not. `null` if successful, `Reverted` if not. - + `result` — an object that contains additional data about the execution of the transaction: - - `gasUsed` — the total used gas by the call, encoded as hexadecimal. - - `output` — the return value of the call, encoded as a hexadecimal string. - + `subtraces` — the number of sub-traces created during execution. When a transaction is executed on the EVM, it may trigger additional sub-executions, such as when a smart contract calls another smart contract or when an external account is accessed. - + `traceAddress` — an array that indicates the position of the transaction in the trace. - + `transactionHash` — the hash of the transaction. - + `transactionPosition` — the position of the transaction in the block. - + `type` — the type of action taken by the transaction, `call` or `create`. `call` is the most common type of trace and occurs when a smart contract invokes another contract's function. `create` represents the creation of a new smart contract. This type of trace occurs when a smart contract is deployed to the blockchain. - -## `trace_transaction` code examples - - -```javascript ethers.js -const ethers = require('ethers'); -const NODE_URL = "CHAINSTACK_NODE_URL"; -const provider = new ethers.JsonRpcProvider(NODE_URL); - -const traceTransaction = async (txHash) => { - const traces = await provider.send("trace_transaction", [txHash]); - console.log(traces); -}; - -traceTransaction("0x9c43baea5c33916b282707506db6d4e79e9e13d96fec1028493bd2ec2da66fd0") -``` - -```python web3.py -from web3 import Web3 -node_url = "CHAINSTACK_NODE_URL" -web3 = Web3.HTTPProvider(node_url) - -tx_hash = "0x9c43baea5c33916b282707506db6d4e79e9e13d96fec1028493bd2ec2da66fd0" - -traces = web3.provider.make_request('trace_transaction', [tx_hash]) -print(traces) -``` - - - -## Use case - -A practical use case of the `trace_transaction` method can be in inspecting NFT transfers, allowing you to identify internal transactions, the sender and receiver, and the amounts transferred. This can be especially useful when analyzing an ERC-721 token purchase on a marketplace like Opensea, where the transfer of funds is not always straightforward due to multiple internal calls for transferring funds to the NFT owner, paying royalties to the creator, and other factors. By using `trace_transaction`, you can gain a more comprehensive understanding of the transaction flow. - -The following is an implementation of the logic using ethers.js inspecting an [ERC-721 transfer from Opensea on Polygon](https://polygonscan.com/tx/0xe2eb8be0ea71220bc298e48ba58034d49efb2d311ca45dfe228cb564cd8a3fb5): - -```javascript index.js -const ethers = require("ethers"); -const NODE_URL = "CHAINSTACK_NODE_URL"; -const provider = new ethers.JsonRpcProvider(NODE_URL); - -// Trace a transaction using the trace_transaction RPC method -async function traceTransaction(txHash) { - const result = await provider.send("trace_transaction", [txHash]); - return result.map(({ action }) => action); -} - -// Parse a value in wei to ether -function parseValue(wei) { - const etherValue = ethers.formatEther(wei); - return etherValue; -} - -// Main function to run the program -async function main() { - const txHash = "0xe2eb8be0ea71220bc298e48ba58034d49efb2d311ca45dfe228cb564cd8a3fb5"; - const transactionTraces = await traceTransaction(txHash); // Trace the specified transaction - const extractedData = transactionTraces.map(({ from, to, value }) => ({ from, to, value })); // Extract relevant data from the transaction trace - - // Loop through each extracted data object and print relevant information - for (const { from, to, value } of extractedData) { - const parsedValue = parseValue(value); // Parse the value to ether - - // Print information about non-zero value transfers - if (parsedValue !== '0') { - console.log('===== Call ====='); - console.log(`From address: ${from}`); - console.log(`To address: ${to}`); - console.log(`Value of ${parsedValue} MATIC\n`); - } - } -} - -main(); // Call the main function to start the program -``` - - -A custom method called `traceTransaction` is defined using the `extend` method in web3.js. This method is used to trace the execution of a Polygon transaction and returns an array of actions that occurred during its execution. - -The `parseValue` function is defined to convert the value from Wei (the smallest denomination of ether) to its equivalent ether value. - -Finally, the main function is defined, which traces the specified Polygon transaction using the `traceTransaction` method extracts relevant data from the transaction trace, parses the transaction value to ether using the `parseValue` function, and prints information about non-zero value transfers that occurred during the transaction execution. - -In this case, the program extracts the `sender`, `receiver`, and `value` of each call. This allows to understand that the first two transfers are some kind of royalty fee, and the last transfer is the seller of the NFT receiving the amount. - -```shell Shell -===== Call ===== -From address: 0xb848a33cd484b9fbdca4593c3bc03ae6015c5b94 -To address: 0x00000000006c3852cbef3e08e8df289169ede581 -Value of 20 MATIC - -===== Call ===== -From address: 0x00000000006c3852cbef3e08e8df289169ede581 -To address: 0x0000a26b00c1f0df003000390027140000faa719 -Value of 0.5 MATIC - -===== Call ===== -From address: 0x00000000006c3852cbef3e08e8df289169ede581 -To address: 0xa52944e9fe7bf9d3d515af1494738ea7d4fa2dea -Value of 0.6 MATIC - -===== Call ===== -From address: 0x00000000006c3852cbef3e08e8df289169ede581 -To address: 0x11c6fef26abb8dfee23c2df67e9e60d120a48413 -Value of 18.9 MATIC -``` - - -From this, we can see that address `0xb848a33cd484b9fbdca4593c3bc03ae6015c5b94` pays 20 MATIC to buy an NFT, fees of 0.5 and 0.6 MATIC are taken from the total amount, and the seller `0x11c6fef26abb8dfee23c2df67e9e60d120a48413` receives 18.9 MATIC. The next step could be to find out what Token ID is bought during this transaction. This information is not readily available in the `trace_transaction` response. If you dig, you can find it in the `input` field of one of the calls, but it is encoded. The best solution is to run the same transaction hash using [eth\_getTransactionReceipt](/reference/polygon-gettransactionreceipt) and decode the logs. - - -Read [Tracking some Bored Apes: The Ethereum event logs tutorial](/docs/tracking-some-bored-apes-the-ethereum-event-logs-tutorial) to learn how to read and decode event logs. -