For the complete documentation index, see llms.txt. This page is also available as Markdown.

z_getsubtreesbyindex - Zcash

Example code for the z_getsubtreesbyindex JSON-RPC method. Сomplete guide on how to use the z_getsubtreesbyindex JSON-RPC method in GetBlock.io Web3 documentation.

This method returns note commitment subtree roots by index. Introduced with the Ironwood note commitment tree extension (post-NU6.3), subtree roots enable efficient light-client synchronization: wallets can download and verify chunks of the shielded pool without downloading every commitment. Query the Sapling or Orchard pool independently.

Parameters

Parameter
Type
Required
Description

pool

string

Yes

Shielded pool name: sapling or orchard

startIndex

integer

Yes

Zero-based index of the first subtree to return

limit

integer

No

Maximum number of subtrees to return. Default all available

Request

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "z_getsubtreesbyindex",
    "params": [
        "orchard",
        0,
        10
    ],
    "id": "getblock.io"
}'
example.js
const axios = require('axios');

const response = await axios.post('https://go.getblock.io/<ACCESS-TOKEN>/', {
    jsonrpc: '2.0',
    method: 'z_getsubtreesbyindex',
    params: [
        "orchard",
        0,
        10
    ],
    id: 'getblock.io'
}, {
    headers: { 'Content-Type': 'application/json' }
});

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

pool

string

Pool name (sapling or orchard)

startIndex

integer

Starting subtree index

subtrees

array of object

List of subtree records

subtrees[].root

string

Hex-encoded subtree root

subtrees[].end_height

integer

Block height at which this subtree was completed

Use Cases

  • Light Client Fast Sync: Wallets download subtree roots to skip commitment-by-commitment iteration during initial sync

  • Ironwood NCT Verification: Independently verify note commitment tree state via subtree Merkle roots

  • Shielded Pool Growth Analytics: Track subtree completion cadence to visualize shielded-pool activity growth

  • Zebra 3.0.0+ Feature Detection: Post-Ironwood extension — availability confirms the endpoint runs a recent-enough Zebra version

Error Handling

Error Code
Message
Description

-8

Invalid pool

Pool parameter is not sapling or orchard

-32602

Invalid params

startIndex or limit is out of range

-32603

Internal error

Node failed to retrieve subtree data

Last updated

Was this helpful?