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

# Reset State \[state.reset]

Resets the fork back to its original state.

## Usage

This example resets the fork back to its original state.

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

await client.state.reset({
  blockNumber: 19_868_020n,
  jsonRpcUrl: 'https://eth.merkle.io',
})
```

```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.state.reset` 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.state.reset(client, {
  blockNumber: 19_868_020n,
  jsonRpcUrl: 'https://eth.merkle.io',
})
```

```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

### Reset to the Original Fork

Omit fork options to reset the node to its original fork configuration.

```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.state.reset() // [!code focus]
```

## Return Value

`void`

No value is returned.

## Parameters

### blockNumber

* **Type:** `bigint`
* **Optional**

The block number to reset the fork to.

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

const client = Client.create({
  chain: mainnet,
  transport: http(),
})
// ---cut---
await Actions.state.reset(client, {
  blockNumber: 19_868_020n, // [!code focus]
  jsonRpcUrl: 'https://eth.merkle.io',
  mode: 'hardhat',
})
```

### jsonRpcUrl

* **Type:** `string`
* **Optional**

The JSON-RPC URL of the chain to fork from.

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

const client = Client.create({
  chain: mainnet,
  transport: http(),
})
// ---cut---
await Actions.state.reset(client, {
  blockNumber: 19_868_020n,
  jsonRpcUrl: 'https://eth.merkle.io', // [!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.state.reset(client, {
  blockNumber: 19_868_020n,
  jsonRpcUrl: 'https://eth.merkle.io',
  mode: 'hardhat', // [!code focus]
})
```
