> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Get Block \[block.get]

Returns information about a block at a block number, hash, or tag.

## Usage

This example returns information about a block at a block number, hash, or tag.

:::code-group
```ts twoslash [example.ts]
import { client } from './viem.config'

const block = await client.block.get()
// @log: {
// @log:   baseFeePerGas: 10789405161n,
// @log:   hash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d',
// @log:   number: 19868020n,
// @log:   timestamp: 1715852123n,
// @log:   transactions: ['0x...', '0x...'],
// @log:   ...
// @log: }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())
```
:::

### Standalone Action

Call `Actions.block.get` directly by passing the Client as the first argument.

:::code-group
```ts twoslash [example.ts]
import { Actions } from 'viem'
import { client } from './viem.config'

const block = await Actions.block.get(client)
// @log: {
// @log:   baseFeePerGas: 10789405161n,
// @log:   hash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d',
// @log:   number: 19868020n,
// @log:   timestamp: 1715852123n,
// @log:   transactions: ['0x...', '0x...'],
// @log:   ...
// @log: }
```

```ts twoslash [viem.config.ts] filename="viem.config.ts"
import { Client, http } from 'viem'
import { mainnet } from 'viem/chains'

export const client = Client.create({
  chain: mainnet,
  transport: http(),
})
```
:::

## Recipes

### Get a Block by Hash

Pass a known canonical block hash to select that exact block. This action does not independently verify canonicality.

```ts twoslash
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())

const block = await client.block.get({
  blockHash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d', // [!code focus]
})
```

### Include Full Transactions

Set `includeTransactions` to return transaction objects instead of hashes.

```ts twoslash
import { Client, http, publicActions } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({
  chain: mainnet,
  transport: http(),
}).extend(publicActions())

const block = await client.block.get({
  blockNumber: 19_868_020n,
  includeTransactions: true, // [!code focus]
})

block.transactions
```

## Return Value

`Block`

Information about the block. When the connected Client's [`chain`](/docs/chains) defines a `codecs.block` codec, the return type reflects that chain's custom block shape.

## Parameters

### blockHash

* **Type:** `Hex`

Information at a given block hash.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const block = await Actions.block.get(client, {
  blockHash: '0x89644bbd5c8d682a2e9611170e6c1f02573d866d286f006cbf517eec7254ec2d', // [!code focus]
})
```

### blockNumber

* **Type:** `bigint`

Information at a given block number.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const block = await Actions.block.get(client, {
  blockNumber: 42069n, // [!code focus]
})
```

### blockTag

* **Type:** `'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'`
* **Default:** `client.blockTag ?? 'latest'`

Information at a given block tag.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const block = await Actions.block.get(client, {
  blockTag: 'safe', // [!code focus]
})
```

### includeTransactions

* **Type:** `boolean`
* **Default:** `false`

Whether to include full transaction objects in the `transactions` field, instead of transaction hashes.

```ts twoslash
import { Actions, Client, http } from 'viem'
import { mainnet } from 'viem/chains'

const client = Client.create({ chain: mainnet, transport: http() })
// ---cut---
const block = await Actions.block.get(client, {
  includeTransactions: true, // [!code focus]
})

block.transactions // [!code focus]
//    ^ full Transaction objects
```

## Errors

| Error | Description |
| --- | --- |
| `Actions.block.Errors.BlockNotFoundError` | The block could not be found. |
