diff --git a/src/cheatcodes/README.md b/src/cheatcodes/README.md index 83dc699b9..760c5b6c0 100644 --- a/src/cheatcodes/README.md +++ b/src/cheatcodes/README.md @@ -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; @@ -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; diff --git a/src/cheatcodes/difficulty.md b/src/cheatcodes/difficulty.md index fad8eb374..6349f5d95 100644 --- a/src/cheatcodes/difficulty.md +++ b/src/cheatcodes/difficulty.md @@ -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 diff --git a/src/cheatcodes/prevrandao.md b/src/cheatcodes/prevrandao.md new file mode 100644 index 000000000..9110c0d1a --- /dev/null +++ b/src/cheatcodes/prevrandao.md @@ -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 +```