# ledger_getSequencerCommitmentByIndex

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://citrea-mainnet.g.alchemy.com/v2/{apiKey}

Returns a sequencer commitment by its global index.

Reference: https://www.alchemy.com/docs/chains/citrea/citrea-api-endpoints/ledger-get-sequencer-commitment-by-index

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| index | string | Yes | Commitment index (hex quantity). |

## Result

**Sequencer commitment** (object): Commitment identified by the supplied index.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "ledger_getSequencerCommitmentByIndex",
  "params": [
    "0xba5"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "merkleRoot": "0xd6dc3eb1a59be7bc1ece68318f82a60919f0f98d8c648337d588ce243a17f473",
    "index": "0xba5",
    "l2EndBlockNumber": "0xb7a20b"
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://citrea-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "ledger_getSequencerCommitmentByIndex",
  "params": [
    "0xba5"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'ledger_getSequencerCommitmentByIndex',
    params: ['0xba5']
  })
};

fetch('https://citrea-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://citrea-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "ledger_getSequencerCommitmentByIndex",
    "params": ["0xba5"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://citrea-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"ledger_getSequencerCommitmentByIndex\",\n  \"params\": [\n    \"0xba5\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://citrea-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"ledger_getSequencerCommitmentByIndex\",\n  \"params\": [\n    \"0xba5\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://citrea-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"ledger_getSequencerCommitmentByIndex\",\n  \"params\": [\n    \"0xba5\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: ledger_getSequencerCommitmentByIndex
description: Returns a sequencer commitment by its global index.
params:
  - name: index
    required: true
    description: Commitment index (hex quantity).
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: Sequencer commitment
  description: Commitment identified by the supplied index.
  schema:
    type: object
    required:
      - merkleRoot
      - index
      - l2EndBlockNumber
    additionalProperties: false
    properties:
      merkleRoot:
        title: 32 byte hex value
        type: string
        pattern: ^0x[0-9a-f]{64}$
        description: Merkle root of sequencer commitment.
      index:
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        description: Global commitment index (hex quantity).
      l2EndBlockNumber:
        title: hex encoded unsigned integer
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        description: Last L2 block included in this commitment (hex quantity).
examples:
  - name: ledger_getSequencerCommitmentByIndex example
    params:
      - name: index
        value: '0xba5'
    result:
      name: Sequencer commitment
      value:
        merkleRoot: '0xd6dc3eb1a59be7bc1ece68318f82a60919f0f98d8c648337d588ce243a17f473'
        index: '0xba5'
        l2EndBlockNumber: '0xb7a20b'
```
