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

# Mine Blocks \[block.mine]

Mines a specified number of blocks.

## Usage

This example mines a specified number of blocks.

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

await client.block.mine({
  blocks: 1,
  interval: 1,
})
```

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

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

### Standalone Action

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

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

await Actions.block.mine(client, {
  blocks: 1,
  interval: 1,
})
```

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

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

## Recipes

### Mine Multiple Spaced Blocks

Set `blocks` and `interval` to mine several blocks with a fixed timestamp interval in seconds.

```ts twoslash
import { Client, http, testActions } from 'viem'
import { anvil } from 'viem/chains'

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

await client.block.mine({
  blocks: 5, // [!code focus]
  interval: 12, // [!code focus]
})
```

## Return Value

`void`

No value is returned.

## Parameters

### blocks

* **Type:** `number`

Number of blocks to mine.

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

const client = Client.create({
  chain: mainnet,
  transport: http(),
})
// ---cut---
await Actions.block.mine(client, {
  blocks: 1, // [!code focus]
  interval: 1,
  mode: 'hardhat',
})
```

### interval

* **Type:** `number`
* **Default:** `0`

Interval between each block, in seconds.

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

const client = Client.create({
  chain: mainnet,
  transport: http(),
})
// ---cut---
await Actions.block.mine(client, {
  blocks: 1,
  interval: 1, // [!code focus]
  mode: 'hardhat',
})
```

### mode

* **Type:** `'anvil' | 'hardhat' | 'ganache'`
* **Default:** `'anvil'`

The test node implementation to target.

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

const client = Client.create({
  chain: mainnet,
  transport: http(),
})
// ---cut---
await Actions.block.mine(client, {
  blocks: 1,
  interval: 1,
  mode: 'hardhat', // [!code focus]
})
```
