> **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.

# Block

:::info
`Block` is a re-export of ox's [`Block`](https://oxlib.sh/api/Block). Refer to the ox documentation for the full reference.
:::

Utilities & types for working with Blocks as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml)

## Examples

### Converting from RPC Format

Blocks can be converted from RPC format to internal format using [`Block.fromRpc`](/docs/utilities/block/fromRpc):

```ts twoslash
// @noErrors
import 'ox/window'
import { Block } from 'viem/utils'

const block = await window
  .ethereum!.request({
    method: 'eth_getBlockByNumber',
    params: ['latest', false]
  })
  .then(Block.fromRpc) // [!code hl]
// @log: {
// @log:   // ...
// @log:   hash: '0xebc3644804e4040c0a74c5a5bbbc6b46a71a5d4010fe0c92ebb2fdf4a43ea5dd',
// @log:   number: 19868020n,
// @log:   size: 520n,
// @log:   timestamp: 1662222222n,
// @log:   // ...
// @log: }
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Block.fromRpc`](/docs/utilities/block/fromRpc) | Converts a [`Block.Rpc`](/docs/utilities/block/types#rpc) to an [`Block.Block`](/docs/utilities/block/types#block). |
| [`Block.toRpc`](/docs/utilities/block/toRpc) | Converts a [`Block.Block`](/docs/utilities/block/types#block) to an [`Block.Rpc`](/docs/utilities/block/types#rpc). |

## Types

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Block.Block`](/docs/utilities/block/types#blockblock) | A Block as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml). |
| [`Block.Hash`](/docs/utilities/block/types#blockhash) | A Block hash. |
| [`Block.Identifier`](/docs/utilities/block/types#blockidentifier) | A Block identifier. |
| [`Block.Number`](/docs/utilities/block/types#blocknumber) | A Block number. |
| [`Block.Rpc`](/docs/utilities/block/types#blockrpc) | An RPC Block as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml). |
| [`Block.Tag`](/docs/utilities/block/types#blocktag) | A Block Tag as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/block.yaml). |
