> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://www.getfoundry.sh/api/mcp` to find what you need.
>
> **Have feedback?** Use `submit_feedback` on the same MCP server.

## `roll`

### Signature

```solidity
function roll(uint256 blockNumber) external;
```

### Description

Sets `block.number` to the specified value.

### Parameters

| Parameter     | Type      | Description                        |
|---------------|-----------|-----------------------------------|
| `blockNumber` | `uint256` | The new block number to set       |

### Examples

```solidity [test/Roll.t.sol]
function testRoll() public {
    vm.roll(100);
    assertEq(block.number, 100);
}
```

### Gotchas

:::warning
When using `--via-ir` compilation, direct access to `block.number` may be optimized to a constant value. Use [`vm.getBlockNumber()`](/reference/cheatcodes/get-block-number) instead to ensure you get the current value after rolling.
:::

### Related Cheatcodes

* [`getBlockNumber`](/reference/cheatcodes/get-block-number) - Gets the current block number (avoids IR optimization issues)
* [`rollFork`](/reference/cheatcodes/roll-fork) - Rolls the fork to a specific block
* [`warp`](/reference/cheatcodes/warp) - Sets `block.timestamp`
