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

getblocktemplate - Zcash

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

This method returns a template for constructing a candidate block for mining. Miners and mining pools call this to receive the current block header parameters, coinbase output structure, and the set of mempool transactions that should be included. Zcash uses the Equihash proof-of-work algorithm, so template consumers need to solve the Equihash puzzle for the provided parameters.

Parameters

Parameter
Type
Required
Description

template_request

object

No

Template request parameters (see below). Defaults to the standard template request

Template Request

Field
Type
Required
Description

mode

string

No

template (default) requests a new template; proposal submits a proposed block

capabilities

array of string

No

Client capabilities (coinbasetxn, coinbasevalue, proposal)

longpollid

string

No

Long-polling ID for waiting on updated templates

Request

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

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

console.log(response.data.result);

Response

Response Parameters

Parameter
Type
Description

version

integer

Block version to use

previousblockhash

string

Hash of the parent block

blockcommitmentshash

string

Block commitments hash to include in the header

finalsaplingroothash

string

Final Sapling root at this block height

defaultroots

object

Precomputed default root hashes for header construction

transactions

array of object

Mempool transactions selected for inclusion

coinbasetxn

object

Coinbase transaction template with reward split

target

string

Difficulty target to solve for

mintime

integer

Minimum allowed block timestamp

mutable

array of string

Fields the miner may modify

noncerange

string

Nonce range hint

sigoplimit

integer

Maximum signature operations allowed in the block

sizelimit

integer

Maximum block size in bytes

curtime

integer

Current timestamp suggested by the node

bits

string

Compact difficulty target

height

integer

Height at which this block will be included

Use Cases

  • Solo Mining: Miners request templates to construct candidate blocks for Equihash solving

  • Mining Pool Coordination: Pool servers fetch templates and distribute solving work to participant miners

  • Block Proposal Verification: Submit constructed blocks in proposal mode to check validity before broadcasting

  • Long-Poll Template Updates: Use longpollid to wait for new templates when the chain tip advances

Error Handling

Error Code
Message
Description

-8

Invalid parameter

Template request parameters are malformed

-32602

Invalid params

Template request structure is invalid

-32603

Internal error

Node failed to build the template

Was this helpful?