Network guides

Bitcoin: blocks and transactions

Bitcoin family endpoints expose classic bitcoind JSON-RPC names. Many forks in our catalog (Litecoin, Dogecoin, …) follow the same shapes — swap the network slug.

bitcoingetblockgetrawtransaction

← All guides

Steps

  1. Create a bitcoin (or fork) endpoint.
  2. Read tip: getblockcount or getbestblockhash.
  3. getblock <hash> 1 for JSON with txids; use 2 only when you need full transactions.
  4. getrawtransaction <txid> true for decoded JSON.

getblockcount (curl)

curl

curl https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getblockcount",
  "params": []
}'

getblockcount (JavaScript)

fetch

const response = await fetch('https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getblockcount',
    params: [],
  }),
});

const data = await response.json();
console.log(data);

getbestblockhash (curl)

curl

curl https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getbestblockhash",
  "params": []
}'

getbestblockhash (JavaScript)

fetch

const response = await fetch('https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getbestblockhash',
    params: [],
  }),
});

const data = await response.json();
console.log(data);

getblock verbosity 1 (curl)

curl

curl https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getblock",
  "params": [
    "0000000000000000000123456789abcdef0123456789abcdef0123456789abcd",
    1
  ]
}'

getblock verbosity 1 (JavaScript)

fetch

const response = await fetch('https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getblock',
    params: [
      "0000000000000000000123456789abcdef0123456789abcdef0123456789abcd",
      1
    ],
  }),
});

const data = await response.json();
console.log(data);

getrawtransaction verbose (curl)

curl

curl https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getrawtransaction",
  "params": [
    "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    true
  ]
}'

getrawtransaction verbose (JavaScript)

fetch

const response = await fetch('https://holy-burned-sky-bitcoin-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getrawtransaction',
    params: [
      "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
      true
    ],
  }),
});

const data = await response.json();
console.log(data);

Tips

  • Replace placeholder hashes/txids with real mainnet values.
  • Pruned full nodes may reject historical getblock / getrawtransaction — see full-node errors.
  • Wallet RPCs that spend funds are out of scope for a shared RPC gateway.

Related