foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Anvil support block.prevrandao?

Open alexbakers opened this issue 1 year ago • 6 comments

Component

Anvil

Describe the feature you would like

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

contract Counter {
    uint256 public number;

    function setPrevrandao() public {
        number = block.prevrandao;
    }
} 

Additional context

block.prevrandao always 0

alexbakers avatar May 26 '23 21:05 alexbakers

You need to set your hardfork to paris or shanghai for this—we've added support recently (https://github.com/foundry-rs/foundry/pull/5061)

Closing for now!

Evalir avatar Jun 07 '23 10:06 Evalir

You need to set your hardfork to paris or shanghai for this—we've added support recently (#5061)

Closing for now!

Thank you for your reply, but so far nothing has changed. I still get always 0.

  • foundryup
  • anvil --hardfork shanghai
image

alexbakers avatar Jun 07 '23 11:06 alexbakers

Can we reopen this? Prevrandao is still always 0 for any block. @Evalir

ualtinok avatar May 09 '24 03:05 ualtinok

can just init this to random

mattsse avatar May 12 '24 11:05 mattsse

Wouldn’t it be better if it gives a different random for each block?

ualtinok avatar May 12 '24 13:05 ualtinok

definitely

mattsse avatar May 12 '24 13:05 mattsse