# chainId

Description: chainId cheatcode documentation

Note: This document was authored using MDX

  Source: https://github.com/NomicFoundation/hardhat-website/tree/main/src/content/docs/docs/reference/cheatcodes/Environment/chain-id.mdx

{/* This document contains content copied/adapted from the Foundry Book (MIT licensed). See LICENSE in the parent directory. */}

### Signature

```solidity
function chainId(uint256) external;
```

### Description

Sets `block.chainid`.

### Examples

```solidity
vm.chainId(31337);
emit log_uint(block.chainid); // 31337
```
