Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/cheatcodes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ interface CheatCodes {
function fee(uint256) external;

// Set block.difficulty
// Does not work from the Paris hard fork and onwards, and will revert instead.
function difficulty(uint256) external;

// Set block.prevrandao
// Does not work before the Paris hard fork, and will revert instead.
function prevrandao(bytes32) external;

// Set block.chainid
function chainId(uint256) external;
Expand Down Expand Up @@ -250,6 +255,9 @@ interface CheatCodes {

// Label an address in test traces
function label(address addr, string calldata label) external;

// Retrieve the label of an address
function getLabel(address addr) external returns (string memory);

// When fuzzing, generate new inputs if conditional not met
function assume(bool) external;
Expand Down
2 changes: 2 additions & 0 deletions src/cheatcodes/difficulty.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function difficulty(uint256) external;

Sets `block.difficulty`.

If used with a post-merge EVM version (Paris and onwards), it will revert. In that case, use [`vm.prevrandao`](./prevrandao.md) instead.

### Examples

```solidity
Expand Down
20 changes: 20 additions & 0 deletions src/cheatcodes/prevrandao.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## `prevrandao`

### Signature

```solidity
function prevrandao(bytes32) 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.md) instead.

### Examples

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