# prevrandao

Description: prevrandao 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/prevrandao.mdx

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

### Signature

```solidity
function prevrandao(bytes32) external;
function prevrandao(uint256) external;
```

### Description

Sets `block.prevrandao`.

If used with an EVM version previous to the Paris hard fork, it will revert. In that case, use [`vm.difficulty`][difficulty] instead.

### Examples

```solidity
vm.prevrandao(bytes32(uint256(42)));
emit log_uint(block.prevrandao); // 42
```

[difficulty]: /docs/reference/cheatcodes/environment/difficulty
