getblocktemplate - Bitcoin
Example code for the getblocktemplate JSON-RPC method. Complete guide on how to use getblocktemplate JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "getblocktemplate",
"params": [{"rules": ["segwit"]}],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "getblocktemplate",
"params": [{"rules": ["segwit"]}],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": {
"capabilities": ["proposal"],
"version": 536870912,
"rules": ["csv", "segwit", "taproot"],
"vbavailable": {},
"vbrequired": 0,
"previousblockhash": "000000000000000000046b9302e08c16ea186950f42a5498320ddd1bd7ab3428",
"transactions": [
{
"data": "0200000001...",
"txid": "abc123...",
"hash": "def456...",
"depends": [],
"fee": 25000,
"sigops": 4,
"weight": 900
}
],
"coinbaseaux": {"flags": ""},
"coinbasevalue": 312500000,
"longpollid": "000000000000000000046b9302e08c16ea186950f42a5498320ddd1bd7ab342812345",
"target": "000000000000000000046b9302e08c16ea186950f42a5498000000000000000",
"mintime": 1700000000,
"mutable": ["time", "transactions", "prevblock"],
"noncerange": "00000000ffffffff",
"sigoplimit": 80000,
"sizelimit": 4000000,
"weightlimit": 4000000,
"curtime": 1700001000,
"bits": "170d21b9",
"height": 820001,
"default_witness_commitment": "6a24aa21a9ed..."
}
}Response Parameters
Field
Type
Description
Use Case
Error Handling
Status Code
Error Message
Cause
Integration Notes
Last updated
Was this helpful?