# eth_getHeaderByHash

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

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

Returns the block header identified by the given block hash. Structurally identical to `eth_getBlockByHash` but omits body-level fields (`size`, `transactions`, `uncles`, `withdrawals`), making it cheaper to fetch when only consensus fields are needed (e.g., chain-tip anchoring for light clients or stateless validators).

Reference: https://www.alchemy.com/docs/chains/megaeth/mega-eth-api-endpoints/eth-get-header-by-hash

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| Block hash | string | Yes | The 32-byte hash of the block to retrieve. |

## Result

**Block header** (null or object): The block header object, or `null` if no block with the given hash is known.

## Example

### Request

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

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "hash": "0xec3c34973b6ba593643668f2279a715e241fc0ffe95f593b2d49fda556f1c512",
    "parentHash": "0x85b055abc1eab8d988d160dd8ae9a2c07d6548f9609746348c53077cebd80262",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner": "0x4200000000000000000000000000000000000011",
    "stateRoot": "0x80d2e1ad2720c9f9f3fd25a7312e0c9e158c792a37f0ce37f7f6ba2d5a8cfa04",
    "transactionsRoot": "0x92e3342c97eba7aaf7da9d96755ddda67c00574b4d90518a3ab051e5d05d7886",
    "receiptsRoot": "0x42d0fd6b9b85b2da166fb9cf8b73d6f0325b14d676a2913fd7e3c8876d7430b7",
    "logsBloom": "0x0000000100000040001000000000000000200000020080008000000000200500000002000200008000000001000000000000000020000800000040000840008000000000000000000000010840040010001000000000000000010000000100000000000002000000000000000000880080004400000000000004001000000000000000000068000000000001000000001000000000004102000000000040000010080000000000000200000000000004402000402000000000008002000201000000000200a2000000000000000440000000000000000000400000000000a0000400000000008000000000000000000000000080080440000000000000000000",
    "difficulty": "0x0",
    "number": "0x14855a6",
    "gasLimit": "0x2540be400",
    "gasUsed": "0x855371",
    "timestamp": "0x6a5a7b79",
    "extraData": "0x00000000fa00000001",
    "mixHash": "0xcb1f34415ed865cc2a378d1dd767225c8f594560dd39fbf92c29aadec3a4ab78",
    "nonce": "0x0000000000000000",
    "baseFeePerGas": "0xf4240",
    "withdrawalsRoot": "0xcd9d73e1502e68817b06212100d7529fc71d1e8741d712ef8e68310e3600cc26",
    "blobGasUsed": "0x0",
    "excessBlobGas": "0x0",
    "parentBeaconBlockRoot": "0x602625e5c228d3ea1c71f2c9a596ce93c7c9a9e2f2a1c733c832e3a0369cb31c",
    "requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
  },
  "id": 1
}
```

## Code Examples

### cURL

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

### JavaScript

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

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

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

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

### C#

```csharp
using RestSharp;


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

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

```


## OpenRPC Method Specification

```yaml
name: eth_getHeaderByHash
description: Returns the block header identified by the given block hash. Structurally identical to `eth_getBlockByHash` but omits body-level fields (`size`, `transactions`, `uncles`, `withdrawals`), making it cheaper to fetch when only consensus fields are needed (e.g., chain-tip anchoring for light clients or stateless validators).
x-compute-units: 20
params:
  - name: Block hash
    required: true
    description: The 32-byte hash of the block to retrieve.
    schema:
      title: 32 byte hex value
      type: string
      pattern: ^0x[0-9a-f]{64}$
result:
  name: Block header
  description: The block header object, or `null` if no block with the given hash is known.
  schema:
    oneOf:
      - title: Not Found (null)
        type: 'null'
      - title: Block header object
        description: The consensus fields of a block header, as returned by `eth_getHeaderByHash` and `eth_getHeaderByNumber`. Structurally identical to the `Block` object but without body-level fields (`size`, `transactions`, `uncles`, `withdrawals`).
        type: object
        required:
          - hash
          - parentHash
          - sha3Uncles
          - miner
          - stateRoot
          - transactionsRoot
          - receiptsRoot
          - logsBloom
          - number
          - gasLimit
          - gasUsed
          - timestamp
          - extraData
          - mixHash
          - nonce
        additionalProperties: false
        properties:
          hash:
            title: Hash
            type: string
            pattern: ^0x[0-9a-f]{64}$
          parentHash:
            title: Parent block hash
            type: string
            pattern: ^0x[0-9a-f]{64}$
          sha3Uncles:
            title: Ommers hash
            type: string
            pattern: ^0x[0-9a-f]{64}$
          miner:
            title: Coinbase
            type: string
            pattern: ^0x[0-9a-fA-F]{40}$
          stateRoot:
            title: State root
            type: string
            pattern: ^0x[0-9a-f]{64}$
          transactionsRoot:
            title: Transactions root
            type: string
            pattern: ^0x[0-9a-f]{64}$
          receiptsRoot:
            title: Receipts root
            type: string
            pattern: ^0x[0-9a-f]{64}$
          logsBloom:
            title: Bloom filter
            type: string
            pattern: ^0x[0-9a-f]{512}$
          difficulty:
            title: Difficulty
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          number:
            title: Number
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          gasLimit:
            title: Gas limit
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          gasUsed:
            title: Gas used
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          timestamp:
            title: Timestamp
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          extraData:
            title: Extra data
            type: string
            pattern: ^0x[0-9a-f]*$
          mixHash:
            title: Mix hash
            type: string
            pattern: ^0x[0-9a-f]{64}$
          nonce:
            title: Nonce
            type: string
            pattern: ^0x[0-9a-f]{16}$
          baseFeePerGas:
            title: Base fee per gas (EIP-1559, London)
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          withdrawalsRoot:
            title: Withdrawals root (EIP-4895, Shanghai)
            type: string
            pattern: ^0x[0-9a-f]{64}$
          blobGasUsed:
            title: Blob gas used (EIP-4844, Cancun)
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          excessBlobGas:
            title: Excess blob gas (EIP-4844, Cancun)
            type: string
            pattern: ^0x([1-9a-f]+[0-9a-f]*|0)$
          parentBeaconBlockRoot:
            title: Parent Beacon Block Root (EIP-4788, Cancun)
            type: string
            pattern: ^0x[0-9a-f]{64}$
          requestsHash:
            title: Requests hash (EIP-7685, Prague/Pectra)
            type: string
            pattern: ^0x[0-9a-f]{64}$
examples:
  - name: eth_getHeaderByHash example
    params:
      - name: Block hash
        value: '0xec3c34973b6ba593643668f2279a715e241fc0ffe95f593b2d49fda556f1c512'
    result:
      name: Block header
      value:
        hash: '0xec3c34973b6ba593643668f2279a715e241fc0ffe95f593b2d49fda556f1c512'
        parentHash: '0x85b055abc1eab8d988d160dd8ae9a2c07d6548f9609746348c53077cebd80262'
        sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347'
        miner: '0x4200000000000000000000000000000000000011'
        stateRoot: '0x80d2e1ad2720c9f9f3fd25a7312e0c9e158c792a37f0ce37f7f6ba2d5a8cfa04'
        transactionsRoot: '0x92e3342c97eba7aaf7da9d96755ddda67c00574b4d90518a3ab051e5d05d7886'
        receiptsRoot: '0x42d0fd6b9b85b2da166fb9cf8b73d6f0325b14d676a2913fd7e3c8876d7430b7'
        logsBloom: 0x0000000100000040001000000000000000200000020080008000000000200500000002000200008000000001000000000000000020000800000040000840008000000000000000000000010840040010001000000000000000010000000100000000000002000000000000000000880080004400000000000004001000000000000000000068000000000001000000001000000000004102000000000040000010080000000000000200000000000004402000402000000000008002000201000000000200a2000000000000000440000000000000000000400000000000a0000400000000008000000000000000000000000080080440000000000000000000
        difficulty: '0x0'
        number: '0x14855a6'
        gasLimit: '0x2540be400'
        gasUsed: '0x855371'
        timestamp: '0x6a5a7b79'
        extraData: '0x00000000fa00000001'
        mixHash: '0xcb1f34415ed865cc2a378d1dd767225c8f594560dd39fbf92c29aadec3a4ab78'
        nonce: '0x0000000000000000'
        baseFeePerGas: '0xf4240'
        withdrawalsRoot: '0xcd9d73e1502e68817b06212100d7529fc71d1e8741d712ef8e68310e3600cc26'
        blobGasUsed: '0x0'
        excessBlobGas: '0x0'
        parentBeaconBlockRoot: '0x602625e5c228d3ea1c71f2c9a596ce93c7c9a9e2f2a1c733c832e3a0369cb31c'
        requestsHash: '0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
```
