# eth_getRootHash

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

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

Returns the root hash for a specified block range.

Reference: https://www.alchemy.com/docs/chains/polygon-pos/polygon-po-s-api-endpoints/eth-get-root-hash

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| fromBlock | string | Yes | The block number from which the range starts. |
| toBlock | string | Yes | The block number where the range ends. |

## Result

**RootHash** (string): The root hash of the specified block range.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getRootHash",
  "params": [
    "1000000",
    "1000010"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": "0xabc123...def456",
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

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

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

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

### C#

```csharp
using RestSharp;


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

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

```


## OpenRPC Method Specification

```yaml
name: eth_getRootHash
description: Returns the root hash for a specified block range.
params:
  - name: fromBlock
    required: true
    description: The block number from which the range starts.
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
  - name: toBlock
    required: true
    description: The block number where the range ends.
    schema:
      title: hex encoded unsigned integer
      type: string
      pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
result:
  name: RootHash
  description: The root hash of the specified block range.
  schema:
    title: 32 byte hex value
    type: string
    pattern: ^0x[0-9a-f]{64}$
examples:
  - name: eth_getRootHash example
    params:
      - name: fromBlock
        value: '1000000'
      - name: toBlock
        value: '1000010'
    result:
      name: RootHash
      value: 0xabc123...def456
```
