---
description: Activates a previously created fork
---

## `selectFork`

### Signature

```solidity
function selectFork(uint256 forkId) external;
```

### Description

Takes a fork identifier created by [`createFork`](/reference/cheatcodes/create-fork) and sets the corresponding forked state as active.

### Parameters

| Parameter | Type      | Description                           |
|-----------|-----------|---------------------------------------|
| `forkId`  | `uint256` | The fork identifier to activate       |

### Examples

```solidity [test/SelectFork.t.sol]
function testSelectFork() public {
    uint256 mainnetFork = vm.createFork(MAINNET_RPC_URL);
    uint256 optimismFork = vm.createFork(OPTIMISM_RPC_URL);

    vm.selectFork(mainnetFork);
    assertEq(vm.activeFork(), mainnetFork);

    vm.selectFork(optimismFork);
    assertEq(vm.activeFork(), optimismFork);
}
```

### Related Cheatcodes

- [`createFork`](/reference/cheatcodes/create-fork) - Create a new fork
- [`createSelectFork`](/reference/cheatcodes/create-select-fork) - Create and select in one call
- [`activeFork`](/reference/cheatcodes/active-fork) - Get the currently active fork
