What is the PREVRANDAO system

The PREVRANDAO System in Ethereum

The term PREVRANDAO refers to a specific change implemented in the Ethereum protocol following The Merge, which transitioned the network from Proof-of-Work (PoW) to Proof-of-Stake (PoS) 1.

Function and Purpose

PREVRANDAO is the new name and function for the old DIFFICULTY opcode (0x44) 1.
  • Randomness Source: Post-Merge, the DIFFICULTY opcode was updated and renamed to PREVRANDAO 1.
  • Output: The PREVRANDAO opcode returns the output of the randomness beacon provided by the beacon chain 1.
  • Use Case: This opcode serves as a stronger, though still biasable, source of randomness for application developers to use compared to the older BLOCKHASH opcode 1.
  • Implementation: This change was formalized in EIP-4399 1.

Technical Details

The value exposed by PREVRANDAO is stored in the ExecutionPayload 12.
  • Storage Location: It is stored in the field that previously contained mixHash, a value associated with PoW computation 1.
  • Field Renaming: The payload's mixHash field was also renamed to prevRandao 1.
  • Execution Payload: The ExecutionPayload structure includes PrevRandao as a 32-byte field 2.
Before The Merge, the 0x44 opcode returned the difficulty field in the block header. After The Merge, the opcode, renamed to PREVRANDAO, points to the header field that now stores the prevRandao value from the beacon chain state 1.
You're viewing a shared conversation. Your questions will start a new chat.