# zone_getCommit

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

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

Returns the block hash, state root, and block commitment of an Interop Zone block, along with the beacon heights at which the block was committed and settled.

`committedAt` and `settledAt` are beacon chain heights. `settledAt` and `settledStateRoot` are `null` until the block is settled.

The commit history starts at zone block `19309` (`0x4b6d`). Requesting an earlier height returns an "invalid params" error whose `data.firstHeight` is the first available height.

Reference: https://www.alchemy.com/docs/chains/zero/zero-api-endpoints/zone-get-commit

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Height | string | Yes | The zone block height, as a hex-encoded quantity. Must be `0x4b6d` (19309) or higher. |

## Result

**Block commit** (object): The commitment and settlement record for the requested zone block.

## Example

### Request

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

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "height": "0x61a8",
    "blockHash": "0x295c3a364dc0f392e8c9593b3f32c863c151972f3991d5131fcc11a405a4eecb",
    "stateRoot": "0x13d71ebbbceee6e5e8fccd2474ca08a288cffaab0015f08b53e933929a25b96b",
    "blockCommitment": "0x7b7a9e4a18111365ba2cec1a23de8039485a8dbd094416be9808f26a79f9bb4a",
    "committedAt": "0x556de",
    "settledAt": "0x556e1",
    "settledStateRoot": "0x13d71ebbbceee6e5e8fccd2474ca08a288cffaab0015f08b53e933929a25b96b"
  },
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

fetch('https://zerointerop-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://zerointerop-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "zone_getCommit",
    "params": ["0x61a8"]
}
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://zerointerop-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"zone_getCommit\",\n  \"params\": [\n    \"0x61a8\"\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://zerointerop-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"zone_getCommit\",\n  \"params\": [\n    \"0x61a8\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://zerointerop-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\": \"zone_getCommit\",\n  \"params\": [\n    \"0x61a8\"\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: zone_getCommit
summary: Returns the commitment and settlement record for a zone block at a given height.
description: |-
  Returns the block hash, state root, and block commitment of an Interop Zone block, along with the beacon heights at which the block was committed and settled.

  `committedAt` and `settledAt` are beacon chain heights. `settledAt` and `settledStateRoot` are `null` until the block is settled.

  The commit history starts at zone block `19309` (`0x4b6d`). Requesting an earlier height returns an "invalid params" error whose `data.firstHeight` is the first available height.
x-compute-units: 20
params:
  - name: Height
    required: true
    description: The zone block height, as a hex-encoded quantity. Must be `0x4b6d` (19309) or higher.
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: Block commit
  description: The commitment and settlement record for the requested zone block.
  schema:
    title: Block commit
    type: object
    required:
      - height
      - blockHash
      - stateRoot
      - blockCommitment
      - committedAt
      - settledAt
      - settledStateRoot
    properties:
      height:
        title: Height
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        description: The zone block height.
      blockHash:
        title: Block hash
        type: string
        pattern: ^0x[0-9a-f]{64}$
        description: The hash of the zone block.
      stateRoot:
        title: State root
        type: string
        pattern: ^0x[0-9a-f]{64}$
        description: The state root after the zone block.
      blockCommitment:
        title: Block commitment
        type: string
        pattern: ^0x[0-9a-f]{64}$
        description: The commitment to the zone block.
      committedAt:
        title: Committed at
        type: string
        pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
        description: The beacon height that committed the zone block.
      settledAt:
        title: Settled at
        description: The beacon height that settled the zone block, or `null` if the block isn't settled yet.
        oneOf:
          - title: hex encoded unsigned integer
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          - title: Not Found (null)
            type: 'null'
      settledStateRoot:
        title: Settled state root
        description: The state root recorded at settlement, or `null` if the block isn't settled yet.
        oneOf:
          - title: 32 byte hex value
            type: string
            pattern: ^0x[0-9a-f]{64}$
          - title: Not Found (null)
            type: 'null'
examples:
  - name: zone_getCommit example
    params:
      - name: Height
        value: '0x61a8'
    result:
      name: Block commit
      value:
        height: '0x61a8'
        blockHash: '0x295c3a364dc0f392e8c9593b3f32c863c151972f3991d5131fcc11a405a4eecb'
        stateRoot: '0x13d71ebbbceee6e5e8fccd2474ca08a288cffaab0015f08b53e933929a25b96b'
        blockCommitment: '0x7b7a9e4a18111365ba2cec1a23de8039485a8dbd094416be9808f26a79f9bb4a'
        committedAt: '0x556de'
        settledAt: '0x556e1'
        settledStateRoot: '0x13d71ebbbceee6e5e8fccd2474ca08a288cffaab0015f08b53e933929a25b96b'
errors:
  - code: -32602
    message: block 1 precedes this node's commit history, which starts at 19309
    data:
      firstHeight: '0x4b6d'
  - code: -32001
    message: The block isn't committed, executed, or published yet
  - code: -32000
    message: Read failure or timeout
```
