getBlock
Returns identity and transaction information about a confirmed block in the ledger

Parameters

  • <u64> - a slot integer denoting the target block number
  • <object> - (optional) Config object:
    • encoding: (optional) <string> - data encoding for each returned transaction
    Accepts one of the following strings: ["json" (Default), "jsonParsed", "base58" (slow), "base64"] "jsonParsed" encoding attempts to use program-specific parsers to make the transaction.message.instructions list more human-readable; if a parser cannot be found, the instruction falls back to default JSON.
    • transactionDetails: (optional) <string> - level of transaction detail to return Accepts one of the following strings: ["full" (Default), "signatures", or "none"]
    • rewards: (optional) bool - whether to populate the rewards array. true (Default)
    • commitment: (optional) Configures the commitment level of the blocks queried Accepts one of the following strings: ["finalized", "confirmed", "processed"] For more info, refer to this doc.
    • maxSupportedTransactionVersion: (optional) <number> - sets the maximum transaction version.
NOTE: For maxSupportedTransactionVersion: you cannot query blocks that contain a transaction with a higher version.

Returns

Confirmed Block
Unconfirmed Block
  • <object> - Object
    • blockhash: < base-58 encoded string> - blockhash of a given block
    • previousBlockhash:< base-58 encoded string> - the blockhash of this block's parent. If the parent block is not available due to ledger cleanup, this field will return "11111111111111111111111111111111"
    • parentSlot: <u64> - the slot index of this block's parent
    • transactions: <JSON array> - transaction details when queried with the "full" flag under transactionDetails
      • transaction: <object|[string,encoding]> - encoded transaction object
      • meta: <object> - transaction status metadata object, containing null or:
        • err: <object | null> - If transaction failed, error messaage. If transaction succeeded null
        • fee: <u64> - fee for this transaction
        • preBalances: <array of u64s> - account balances from before the transaction was processed
        • postBalances: <array of u64s> - account balances after the transaction was processed
        • innerInstructions: <array|null> - List of inner instructions null if not enabled during this transaction
        • preTokenBalances: <array|undefined> - List of token balances from before the transaction was processed or Undefined if token balance recording was not yet enabled during this transaction
        • postTokenBalances: <array|undefined> - List of token balances from after the transaction was processed Undefined if token balance recording was not yet enabled during this transaction
        • logMessages: <array|null> - array of string log messages null if log message recording was not enabled during this transaction
        • loadedAddresses: <object|undefined> - Transaction addresses loaded from address lookup tables. Undefined if maxSupportedTransactionVersion was not set in request params.
          • writable: <array[string base-58 encoded addresses]> - Ordered list addresses for writable loaded accounts
          • readonly: <array[string base-58 encoded addresses]> - Ordered list addresses for read only loaded accounts
      • version: <"legacy"|number|undefined> - Transaction version. Undefined if maxSupportedTransactionVersion is not set in request params.
    • signatures: <array of strings> - present if "signatures" are requested for transaction details corresponding to the transaction order in the block
    • rewards: <array of JSON objects> - Object present if rewards are requested
      • pubkey: <base-58 encoded string> - The public key of the account that received the reward
      • lamports: <i64>- number of reward lamports credited or debited by the account, as a i64
      • postBalance: <u64> - account balance in lamports after the reward was applied
      • rewardType: <string|undefined> - type of reward: ["fee", "rent", "voting", "staking"]
      • commission: <u8|undefined> - vote account commission when the reward was credited, only present for voting and staking rewards
    • blockTime: <i64 | null> - estimated production time, as Unix timestamp (seconds since the Unix epoch). null if not available
    • blockHeight: <u64 | null> - the number of blocks beneath this block
  • <null> - if the specified block is not confirmed

Example

Request

cURL
1
curl --location --request POST 'https://solana-mainnet.g.alchemy.com/v2/demo' \
2
--header 'Content-Type: application/json' \
3
--data-raw '{"jsonrpc": "2.0","id":1,"method":"getBlock","params":[430, {"encoding": "json","transactionDetails":"full","rewards":false}]}'
Copied!

Response

With Config Object
Without Config Object
1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"blockHeight": 428,
5
"blockTime": null,
6
"blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA",
7
"parentSlot": 429,
8
"previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B",
9
"transactions": [
10
{
11
"meta": {
12
"err": null,
13
"fee": 5000,
14
"innerInstructions": [],
15
"logMessages": [],
16
"postBalances": [499998932500, 26858640, 1, 1, 1],
17
"postTokenBalances": [],
18
"preBalances": [499998937500, 26858640, 1, 1, 1],
19
"preTokenBalances": [],
20
"status": {
21
"Ok": null
22
}
23
},
24
"transaction": {
25
"message": {
26
"accountKeys": [
27
"3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe",
28
"AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc",
29
"SysvarS1otHashes111111111111111111111111111",
30
"SysvarC1ock11111111111111111111111111111111",
31
"Vote111111111111111111111111111111111111111"
32
],
33
"header": {
34
"numReadonlySignedAccounts": 0,
35
"numReadonlyUnsignedAccounts": 3,
36
"numRequiredSignatures": 1
37
},
38
"instructions": [
39
{
40
"accounts": [1, 2, 3, 0],
41
"data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1",
42
"programIdIndex": 4
43
}
44
],
45
"recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"
46
},
47
"signatures": [
48
"2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"
49
]
50
}
51
}
52
]
53
},
54
"id": 1
55
}
Copied!
1
{
2
"jsonrpc": "2.0",
3
"result": {
4
"blockHeight": 428,
5
"blockTime": null,
6
"blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA",
7
"parentSlot": 429,
8
"previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B",
9
"rewards": [],
10
"transactions": [
11
{
12
"meta": {
13
"err": null,
14
"fee": 5000,
15
"innerInstructions": null,
16
"logMessages": null,
17
"postBalances": [499998932500, 26858640, 1, 1, 1],
18
"postTokenBalances": [],
19
"preBalances": [499998937500, 26858640, 1, 1, 1],
20
"preTokenBalances": [],
21
"status": {
22
"Ok": null
23
}
24
},
25
"transaction": [
26
"AVj7dxHlQ9IrvdYVIjuiRFs1jLaDMHixgrv+qtHBwz51L4/ImLZhszwiyEJDIp7xeBSpm/TX5B7mYzxa+fPOMw0BAAMFJMJVqLw+hJYheizSoYlLm53KzgT82cDVmazarqQKG2GQsLgiqktA+a+FDR4/7xnDX7rsusMwryYVUdixfz1B1Qan1RcZLwqvxvJl4/t3zHragsUp0L47E24tAFUgAAAABqfVFxjHdMkoVmOYaR1etoteuKObS21cc1VbIQAAAAAHYUgdNXR0u3xNdiTr072z2DVec9EQQ/wNo1OAAAAAAAtxOUhPBp2WSjUNJEgfvy70BbxI00fZyEPvFHNfxrtEAQQEAQIDADUCAAAAAQAAAAAAAACtAQAAAAAAAAdUE18R96XTJCe+YfRfUp6WP+YKCy/72ucOL8AoBFSpAA==",
27
"base64"
28
]
29
}
30
]
31
},
32
"id": 1
33
}
Copied!