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

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# getBlockProduction

> Returns block-production counts for validator identities in the requested slot range. If no range is provided, the RPC node returns counts for the current epoch.

<Info>
  **Source**

  [`get_block_production`](https://github.com/anza-xyz/agave/blob/v4.3.2/rpc/src/rpc.rs#L3160)
</Info>

<RequestExample>
  ```bash cURL
  curl https://api.devnet.solana.com -s -X POST \
    -H "Content-Type: application/json" \
    -d '
    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "getBlockProduction",
      "params": [
        {
          "commitment": "finalized"
        }
      ]
    }
  '
  ```

  ```ts Kit
  import { createSolanaRpc } from "@solana/kit";

  const rpc_url = "https://api.devnet.solana.com";
  const rpc = createSolanaRpc(rpc_url);

  let blockProduction = await rpc.getBlockProduction().send();

  console.log("block production:", blockProduction);
  ```

  ```ts web3.js
  import { Connection, clusterApiUrl } from "@solana/web3.js";

  const connection = new Connection(clusterApiUrl("devnet"), "confirmed");

  let blockProduction = await connection.getBlockProduction();

  console.log("block production:", blockProduction);
  ```

  ```rs Rust
  use anyhow::Result;
  use solana_client::nonblocking::rpc_client::RpcClient;
  use solana_commitment_config::CommitmentConfig;

  #[tokio::main]
  async fn main() -> Result<()> {
      let client = RpcClient::new_with_commitment(
          String::from("https://api.devnet.solana.com"),
          CommitmentConfig::confirmed(),
      );

      let block_production = client.get_block_production().await?;

      println!("Block production: {:#?}", block_production);

      Ok(())
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response
  {
    "jsonrpc": "2.0",
    "result": {
      "context": {
        "apiVersion": "4.3.2",
        "slot": 9887
      },
      "value": {
        "byIdentity": {
          "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr": [9888, 9886]
        },
        "range": {
          "firstSlot": 0,
          "lastSlot": 9887
        }
      }
    },
    "id": 1
  }
  ```
</ResponseExample>

## Parameters

<ParamField body="config" type="object">
  Configuration object

  <Expandable title="properties" defaultOpen>
    <ParamField body="commitment" type="string" default="finalized">
      Values: `processed`, `confirmed`, `finalized`

      Solana RPC uses the following commitment levels:

      | Value       | Description                                                                                                                                                                               |
      | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `processed` | Return data from the highest slot this node has processed. This is the newest view, but the block can still be skipped.                                                                   |
      | `confirmed` | Return data from the same slot as `finalized`. Kept for compatibility and planned for removal in a later release.                                                                         |
      | `finalized` | Return data from the highest slot with a finalization certificate, from votes by 80% of stake in one round or 60% of stake in each of two rounds. This is the strongest commitment level. |
    </ParamField>

    <ParamField body="identity" type="string">
      Return only entries for this validator identity, as a base-58 encoded string.

      ```json Example
      { "identity": "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr" }
      ```
    </ParamField>

    <ParamField body="range" type="object">
      Slot range to return block production for. If parameter not provided, defaults
      to current epoch.

      | Field       | Type  | Description                                                                                                                                       |
      | ----------- | ----- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `firstSlot` | `u64` | First slot for which to return block-production information, inclusive.                                                                           |
      | `lastSlot`  | `u64` | Last slot for which to return block-production information, inclusive. If omitted, defaults to the current slot at the selected commitment level. |

      ```json Example
      { "firstSlot": 100, "lastSlot": 200 }
      ```
    </ParamField>
  </Expandable>
</ParamField>

## Result

<ResponseField name="result" type="object">
  RpcResponse object containing:

  <Expandable title="properties" defaultOpen>
    <ResponseField name="context" type="object">
      Slot and API version the node used to answer this request.

      | Field        | Type     | Description                                                                     |
      | ------------ | -------- | ------------------------------------------------------------------------------- |
      | `slot`       | `u64`    | Slot at which the node evaluated this request.                                  |
      | `apiVersion` | `string` | RPC API version reported by the node. This field may be omitted by older nodes. |
    </ResponseField>

    <ResponseField name="value" type="object">
      Block production object containing:

      | Field        | Type     | Description                                                                                                                                                                 |
      | ------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
      | `byIdentity` | `object` | Dictionary keyed by validator identity pubkey. Each value is a two-element array containing the number of leader slots assigned and the number of blocks actually produced. |
      | `range`      | `object` | Slot range covered by the returned block-production data.                                                                                                                   |

      **`byIdentity` entries**

      | Field                 | Type             | Description                                                                  |
      | --------------------- | ---------------- | ---------------------------------------------------------------------------- |
      | `<validatorIdentity>` | `[usize, usize]` | Map entry keyed by a validator identity pubkey, as a base-58 encoded string. |

      **`byIdentity` tuple indexes**

      | Index | Type    | Description                                                               |
      | ----- | ------- | ------------------------------------------------------------------------- |
      | `0`   | `usize` | Number of leader slots assigned to that validator in the requested range. |
      | `1`   | `usize` | Number of blocks that validator actually produced in that range.          |

      **`range` fields**

      | Field       | Type  | Description                                                   |
      | ----------- | ----- | ------------------------------------------------------------- |
      | `firstSlot` | `u64` | First slot in the returned block-production range, inclusive. |
      | `lastSlot`  | `u64` | Last slot in the returned block-production range, inclusive.  |
    </ResponseField>
  </Expandable>
</ResponseField>
