get_block_template - Monero
Example code for the get_block_template JSON-RPC method. Complete guide on how to use get_block_template JSON-RPC in GetBlock Web3 documentation.
This method returns a block blob and accompanying data that miners use to construct and submit a new block. The block reward is paid to the supplied wallet address.
Parameters
wallet_address
string
Yes
Address of the wallet that will receive the coinbase reward if the block is mined
reserve_size
unsigned int
Yes
Reserve size for extra bytes in the coinbase (often used by pools for nonce space)
Request Example
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "get_block_template",
"params": {
"wallet_address": "44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns",
"reserve_size": 60
},
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "get_block_template",
"params": {
"wallet_address": "44GBHzv6ZyQdJkjqZje6KLZ3xSyN1hBSFAnLP6EAqJtCRVzMzZmeXTC2AHKDS9aEDTRKmo6a6o9r9j86pYfhCWDkKjbtcns",
"reserve_size": 60
},
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data, null, 2)))
.catch(error => console.log(error));Response Example
Response Parameters
result.blockhashing_blob
string
Hex blob to feed into the proof-of-work hash function
result.blocktemplate_blob
string
Hex blob of the full block template
result.difficulty
unsigned int
Current network difficulty
result.expected_reward
unsigned int
Expected coinbase reward in atomic units
result.height
unsigned int
Height the block would be added at
result.prev_hash
string
Hash of the previous block
result.reserved_offset
unsigned int
Byte offset within the block where the reserve bytes are placed
Use Cases
Mining pool block construction
Solo mining client integration
Testing mining software end-to-end
Error Handling
404
Not Found
Missing or invalid <ACCESS-TOKEN>
-32602
Invalid params
Request parameters are missing or malformed
429
Too Many Requests
Rate limit exceeded for your plan
SDK Integration
Last updated
Was this helpful?