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

getblock - Zcash

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

This method returns block data by hash or height. Post-Ironwood activation, the verbose (verbosity 1 and 2) response includes the extended note commitment tree information: subtree roots, tree metadata, and the nTx field (per-block transaction count) added in recent Zebra releases. Verbosity 0 returns hex-encoded serialized block data; verbosity 1 returns block header + transaction hashes; verbosity 2 returns full transaction objects.

Parameters

Parameter
Type
Required
Description

blockhash_or_height

string

Yes

Block hash (hex string) or height (as a string, e.g. "2856342")

verbosity

integer

No

0 = raw hex, 1 = summary + tx hashes, 2 = full transaction objects. Default 1

Request

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

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

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

hash

string

Block hash

confirmations

integer

Number of confirmations (1 = chain tip; -1 = orphaned)

size

integer

Serialized block size in bytes

height

integer

Block height

version

integer

Block version number

merkleroot

string

Merkle root of the transactions in the block

blockcommitments

string

Block commitments hash (post-Heartwood, ZIP 244)

authdataroot

string

Authorizing data commitment root (post-NU5)

finalsaplingroot

string

Final Sapling note commitment tree state after this block

chainhistoryroot

string

Chain history commitment (post-Heartwood)

tx

array of string or object

Transaction IDs (verbosity 1) or full transaction objects (verbosity 2)

trees.sapling.size

integer

Size of the Sapling note commitment tree at this block

trees.orchard.size

integer

Size of the Orchard note commitment tree at this block

nTx

integer

Number of transactions in the block (verbose responses only)

time

integer

Unix timestamp of block production

nonce

string

Block nonce (hex)

solution

string

Equihash solution (hex)

bits

string

Compact difficulty target

difficulty

number

Difficulty of this block

previousblockhash

string

Hash of the parent block

nextblockhash

string

Hash of the next block (empty at the chain tip)

Use Cases

  • Explorer Block Detail Pages: Full block metadata for an explorer's block detail view

  • Indexer Ingestion: Verbosity 2 loads every transaction in the block in one call

  • Shielded-Pool State Snapshots: Read finalsaplingroot and trees.* to reconstruct pool state at a specific block

  • Reorg Handling: Check confirmations — a value of -1 indicates the block was orphaned

  • Transaction Count Metrics: Post-Ironwood: use nTx for cheap per-block transaction-count aggregation

Error Handling

Error Code
Message
Description

-8

Block not found

Requested hash or height doesn't exist

-32602

Invalid params

Hash or height is malformed, or verbosity is out of range

-32603

Internal error

Node failed to retrieve the block

Last updated

Was this helpful?