# getBlock

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

#### Parameters required for this RPC call

* **T**he slot number for which the corresponding block will be returned. This is a <mark style="color:yellow;">u64 number</mark>.
* **configuration** : This contains the following parameters, all are optional fields.
  * **commitment**: The commitment describes how finalized a block is at that point in time. Only <mark style="color:yellow;">confirmed</mark> and <mark style="color:yellow;">finalized</mark> are supported, defaults to <mark style="color:yellow;">finalized</mark>.
  * **encoding**: Encoding format for each returned transaction. The supported options are *json*, *jsonParsed*, <mark style="color:yellow;">base58</mark> and <mark style="color:yellow;">base64</mark>. You can know more about [Parsed responses](https://solana.com/docs/rpc#parsed-responses) more on Solana docs.
  * **transactionDetails**: Specifies the level of transaction detail to return.

    * If `accounts` are requested, transaction details only include signatures and an annotated list of accounts in each transaction.
    * Transaction metadata is limited to only: *fee, err, pre\_balances, post\_balances, pre\_token\_balances,* and *post\_token\_balances*.

    Supports the following values: <mark style="color:yellow;">full</mark>, <mark style="color:yellow;">accounts</mark>, <mark style="color:yellow;">signatures</mark> or <mark style="color:yellow;">none</mark>. Defaults to <mark style="color:yellow;">full</mark>.

{% tabs %}
{% tab title="cURL" %}

<pre class="language-bash"><code class="lang-bash">curl https://rpc.shyft.to?api_key=YOUR-API-KEY -s -X \
<strong>  POST -H "Content-Type: application/json" -d ' 
</strong>   {
     "jsonrpc": "2.0",
     "id": 1,
     "method": "getBlock",
     "params": [
       378967388,
       {
         "commitment": "finalized",
         "encoding": "json",
         "transactionDetails": "full",
         "maxSupportedTransactionVersion": 0,
         "rewards": false
       }
     ]
   }
 '
</code></pre>

{% endtab %}

{% tab title="Web3.js" %}

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

const connection = new Connection("https://rpc.shyft.to?api_key=YOUR-API-KEY", "confirmed");

const slot_number = 377261141;

const block = await connection.getBlock(
  slot_number,
  {
    commitment: "finalized",
    transactionDetails: "full",
    maxSupportedTransactionVersion: 0,
    rewards: false,
  },
);

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

{% endtab %}

{% tab title="Response" %}

```json
{
  "jsonrpc": "2.0",
  "result": {
    "blockHeight": 428,
    "blockTime": null, //if present, estimated production time in unix timestamp
    "blockhash": "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA",
    "parentSlot": 429, //slot index of this blocks parent
    "previousBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B", //blockhash of this block's parent
    "transactions": // Present if "full" transaction details are requested
        "meta": {
          "err": null,
          "fee": 5000,
          "innerInstructions": [],
          "logMessages": [],
          "postBalances": [499998932500, 26858640, 1, 1, 1],
          "postTokenBalances": [],
          "preBalances": [499998937500, 26858640, 1, 1, 1],
          "preTokenBalances": [],
          "rewards": null,
          "status": {
            "Ok": null
          }
        },
        "transaction": {
          "message": {
            "accountKeys": [
              "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe",
              "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc",
              "SysvarS1otHashes111111111111111111111111111",
              "SysvarC1ock11111111111111111111111111111111",
              "Vote111111111111111111111111111111111111111"
            ],
            "header": {
              "numReadonlySignedAccounts": 0,
              "numReadonlyUnsignedAccounts": 3,
              "numRequiredSignatures": 1
            },
            "instructions": [
              {
                "accounts": [1, 2, 3, 0],
                "data": "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1",
                "programIdIndex": 4
              }
            ],
            "recentBlockhash": "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"
          },
          "signatures": [
            "2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"
          ]
        }
      }
    ]
  },
  "id": 1
}
```

{% endtab %}
{% endtabs %}
