Network guides

Solana: slots, blocks, and txs

Solana JSON-RPC uses different method names than EVM. Commitment levels (processed / confirmed / finalized) matter for how “fresh” data is.

solanagetSlotgetBlockgetTransaction

← All guides

Steps

  1. Create a solana mainnet endpoint in the dashboard.
  2. Read the tip with getSlot or getLatestBlockhash.
  3. Fetch a block with getBlock(slot, config) — start with transactionDetails: "signatures".
  4. Fetch a tx with getTransaction(signature, config).
  5. Use getBalance / getTokenAccountBalance for accounts.

getSlot (curl)

curl

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

getSlot (JavaScript)

fetch

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

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

getLatestBlockhash (curl)

curl

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

getLatestBlockhash (JavaScript)

fetch

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

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

getBlock (curl)

curl

curl https://holy-burned-sky-solana-mainnet.rpcnode.dev/7c9e6679-7425-40de-944b-e07fc1f90ae7 \
  -X POST \
  -H 'content-type: application/json' \
  -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlock",
  "params": [
    300000000,
    {
      "encoding": "json",
      "transactionDetails": "signatures",
      "rewards": false,
      "maxSupportedTransactionVersion": 0
    }
  ]
}'

getBlock (JavaScript)

fetch

const response = await fetch('https://holy-burned-sky-solana-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: [
      300000000,
      {
        "encoding": "json",
        "transactionDetails": "signatures",
        "rewards": false,
        "maxSupportedTransactionVersion": 0
      }
    ],
  }),
});

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

getBalance (curl)

curl

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

getBalance (JavaScript)

fetch

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

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

Tips

  • Always pass maxSupportedTransactionVersion when reading versioned transactions.
  • Old slots may be unavailable on a full node — that is expected without a long-term archive.
  • getBlock can be heavy; prefer signatures-only when listing.

Related