# eth_getBlockByHash - Monad RPC Method

Returns information about a block by hash on Monad.

> **Why Monad?** Build on the parallel EVM L1 delivering 10,000 TPS with 400ms blocks and sub-cent gas fees with optimistic parallel execution, MonadBFT consensus, $244M Paradigm-led funding, and consumer-grade validator hardware requirements.

## When to Use This Method

`eth_getBlockByHash` is essential for high-performance dApp developers, DeFi builders, and teams requiring Ethereum compatibility at scale:

- **Block verification using deterministic hash lookup**: Retrieve block data by its unique, immutable hash on Monad
- **Chain reorganization handling**: Track blocks reliably by hash during reorgs on the parallel EVM L1 delivering 10,000 TPS with 400ms blocks and sub-cent gas fees
- **Cross-chain bridge finality verification**: Confirm block existence by its canonical hash for high-throughput DeFi, latency-sensitive trading, and scalable EVM applications
- **Deterministic queries when block number may change**: Ensure consistent results for applications that need stable references regardless of chain state

## Request Parameters

- `blockHash` (`DATA, required`): 32-byte block hash
- `fullTransactions` (`Boolean, required`): If true, returns full transaction objects; if false, returns transaction hashes

## Request Example

```json
{
  "jsonrpc": "2.0",
  "method": "eth_getBlockByHash",
  "params": [
    "0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145",
    false
  ],
  "id": 1
}
```

## Response Fields

- `number` (`QUANTITY, required`): Block number
- `hash` (`DATA, required`): 32-byte block hash
- `parentHash` (`DATA, required`): 32-byte parent block hash
- `timestamp` (`QUANTITY, required`): Unix timestamp
- `gasUsed` (`QUANTITY, required`): Total gas used
- `transactions` (`Array, required`): Transaction objects or hashes

## Successful Response

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "number": "0x1",
    "hash": "<value>",
    "parentHash": "<value>",
    "timestamp": "0x1",
    "gasUsed": "0x1",
    "transactions": []
  }
}
```

## Common Use Cases

### 1. Verify a Specific Block from a Transaction's blockHash Field

When a transaction response includes `blockHash`, use `eth_getBlockByHash` to retrieve the full parent block. This cross-references the transaction's context and confirms which block it was included in on Monad.

```javascript
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY');

async function verifyBlockFromTx(txHash) {
  const tx = await provider.getTransaction(txHash);
  if (!tx || !tx.blockHash) return null;

  const block = await provider.getBlock(tx.blockHash);
  console.log(`Transaction ${txHash} in block #${block.number}`);
  console.log(`Block hash: ${block.hash}`);
  console.log(`Block timestamp: ${new Date(block.timestamp * 1000).toISOString()}`);
  return block;
}

verifyBlockFromTx('0xc2d1de53ff3ce014bbe5d43a740e60a6cdb487a0ab4fda52deb11d0a0c5aa5c9');
```

### 2. Cross-Reference Blocks During Chain Reorganization

During a chain reorganization, block numbers can shift but block hashes remain unique identifiers. Use `eth_getBlockByHash` to verify the canonical chain state and detect whether a previously observed block has been orphaned on the parallel EVM L1 delivering 10,000 TPS with 400ms blocks and sub-cent gas fees.

```python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY'))

def verify_block_still_canonical(block_hash):
    block = w3.eth.get_block(block_hash)
    if block is None:
        print(f'Block {block_hash} has been pruned or orphaned')
        return False
    print(f'Block {block_hash} still canonical at height #{block.number}')
    return True

# Check a known block hash
verify_block_still_canonical('0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145')
```

### 3. Audit Block Data by Known Hash Reference

For compliance and audit workflows, store block hashes as permanent references. Re-querying `eth_getBlockByHash` with a stored hash guarantees you retrieve the exact same block data, even months later on Monad.

```go
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, _ := ethclient.Dial("https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY")

    knownHash := common.HexToHash("0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145")
    block, err := client.BlockByHash(context.Background(), knownHash)
    if err != nil || block == nil {
        log.Fatal("Block not found: may be pruned from node")
    }

    fmt.Printf("Audited block #%d\n", block.Number().Uint64())
    fmt.Printf("Hash: %s\n", block.Hash().Hex())
    fmt.Printf("Transactions: %d\n", len(block.Transactions()))
}
```

## Best Practices

- **Hash-based lookups are more reliable during chain reorgs than number-based**: A block hash uniquely identifies one canonical block, while a block number may shift to a different block after a reorg
- **Store block hashes in your database for future verification**: Persisting the hash alongside related records enables deterministic re-querying for audits and data integrity checks
- **Handle `null` results gracefully**: Blocks can be pruned by the node, especially on non-archive endpoints; your application should treat a null response as a missing or unavailable block
- **For L2 optimistic rollups, verify the L1 anchor hash separately**: The hash on the L2 chain references a different block space than the L1 anchor; validate both independently for full finality confidence

## Code Examples

cURL
JavaScript
Python
Go

```bash
curl -X POST https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_getBlockByHash",
    "params": [
      "0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145",
      false
    ],
    "id": 1
  }'
```

```javascript
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY');

const blockHash = '0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145';
const block = await provider.getBlock(blockHash);

console.log('Block number:', block.number);
console.log('Timestamp:', new Date(block.timestamp * 1000));
```

```python
from web3 import Web3

w3 = Web3(Web3.HTTPProvider('https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY'))

block_hash = '0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145'
block = w3.eth.get_block(block_hash)

print(f'Block number: {block.number}')
print(f'Timestamp: {block.timestamp}')
```

```go
package main

import (
    "context"
    "fmt"
    "log"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, err := ethclient.Dial("https://api-monad-mainnet-full.n.dwellir.com/YOUR_API_KEY")
    if err != nil {
        log.Fatal(err)
    }

    blockHash := common.HexToHash("0xc627c6245574cee468cfccfd9cbfcb93c6d230d46a1b88f3363e0396cb8da145")
    block, err := client.BlockByHash(context.Background(), blockHash)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Block number: %d\n", block.Number().Uint64())
}
```

## Related Methods

- [`eth_getBlockByNumber`](https://www.dwellir.com/docs/monad/eth_getBlockByNumber) - Get block by number
- [`eth_blockNumber`](https://www.dwellir.com/docs/monad/eth_blockNumber) - Get latest block number
