> ## Documentation Index
> Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt
> Use this file to discover all available pages before exploring further.

# getBlock

> Returns identity and transaction information about a confirmed block

## Parameters

<ParamField query="slot" type="number" required>
  The slot number of the block to retrieve
</ParamField>

<ParamField query="config" type="object" optional>
  Configuration object containing the following optional fields:

  <Expandable title="config fields">
    <ParamField query="encoding" type="string" optional default="json">
      Encoding format for transaction data:

      * `json` - JSON format
      * `jsonParsed` - JSON format with parsed transaction data
      * `base58` - Base-58 encoded binary data
      * `base64` - Base-64 encoded binary data
    </ParamField>

    <ParamField query="transactionDetails" type="string" optional default="full">
      Level of transaction detail to return:

      * `full` - Full transaction data
      * `signatures` - Only transaction signatures
      * `none` - No transaction data
    </ParamField>

    <ParamField query="rewards" type="boolean" optional default={true}>
      Whether to populate the rewards array
    </ParamField>

    <ParamField query="commitment" type="string" optional>
      Bank state to query:

      * `processed` - Latest block (unconfirmed)
      * `confirmed` - Confirmed by supermajority
      * `finalized` - Finalized by supermajority
    </ParamField>

    <ParamField query="maxSupportedTransactionVersion" type="number" optional>
      The maximum transaction version to return in responses
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="result" type="object | null">
  Returns `null` if the block is not found. Otherwise, returns an object containing:

  <Expandable title="result fields">
    <ResponseField name="blockhash" type="string">
      The blockhash of this block (base-58)
    </ResponseField>

    <ResponseField name="previousBlockhash" type="string">
      The blockhash of the previous block (base-58)
    </ResponseField>

    <ResponseField name="parentSlot" type="number">
      The slot index of the parent block
    </ResponseField>

    <ResponseField name="transactions" type="array">
      Array of transaction information (if `transactionDetails` != "none"):

      * For `full`: Complete transaction objects
      * For `signatures`: Only transaction signatures
    </ResponseField>

    <ResponseField name="rewards" type="array">
      Array of reward objects (if `rewards` = true):

      * `pubkey`: string - The public key (base-58)
      * `lamports`: number - Number of reward lamports
      * `postBalance`: number - Account balance after reward
      * `rewardType`: string - Type of reward
      * `commission`: number - Vote account commission (vote only)
    </ResponseField>

    <ResponseField name="blockTime" type="number | null">
      Estimated production time (Unix timestamp)
    </ResponseField>

    <ResponseField name="blockHeight" type="number | null">
      The number of blocks beneath this block
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

### Basic Request

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlock",
  "params": [
    430,
    {
      "encoding": "json",
      "transactionDetails": "full",
      "rewards": true
    }
  ]
}'
```

### Request with Parsed Transaction Data

```bash theme={null}
curl https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY -X POST -H "Content-Type: application/json" -d '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "getBlock",
  "params": [
    430,
    {
      "encoding": "jsonParsed",
      "transactionDetails": "full",
      "rewards": true,
      "maxSupportedTransactionVersion": 0
    }
  ]
}'
```

### Using web3.js

```typescript theme={null}
import { Connection } from '@solana/web3.js';

const connection = new Connection('https://fra.rpc.orbitflare.com?api_key=YOUR-API-KEY');
const slot = 430;

const block = await connection.getBlock(
  slot,
  {
    maxSupportedTransactionVersion: 0
  }
);
```

## Notes

1. Block production time is an estimate based on genesis block time and slots elapsed.
2. Not all blocks include rewards.
3. The `jsonParsed` encoding attempts to parse transaction instruction data based on known program layouts.
4. Some blocks might be skipped (no leader assigned or failed block production).
5. Block data may be pruned from the node based on ledger configuration.

## Best Practices

1. Use `transactionDetails: "signatures"` if you only need transaction signatures.
2. Set `rewards: false` if reward data is not needed.
3. Consider using `getBlockHeight` first if you need the latest block.
4. For real-time updates, consider using websocket subscription instead.

## Common Errors

| Code   | Message                         | Solution                                 |
| ------ | ------------------------------- | ---------------------------------------- |
| -32004 | Block not available for slot    | The block was pruned or skipped          |
| -32602 | Invalid param: WrongSize        | Verify the slot number is valid          |
| -32602 | Invalid param: Too large        | Request a more recent block              |
| -32009 | Transaction version unsupported | Specify `maxSupportedTransactionVersion` |
