owanhunte / ethereum-solidity-course-updated-code

Up-to-date Solidity / web3.js / Node.js / React / Next.js code for the udemy.com course Ethereum and Solidity: The Complete Developer's Guide.
183 stars 82 forks source link

Lottery contract fix for EVM Paris upgrade #45

Closed owanhunte closed 1 year ago

owanhunte commented 1 year ago

In September 2022, Ethereum transitioned to proof-of-stake consensus, also known as The Merge. One of the changes this resulted in was the introduction of a new opcode called prevrandao, which replaces the difficulty opcode. As such, since Solidity 0.8.18 block.difficulty has been deprecated and instead, block.prevrandao should be used. This PR makes that change in the Lottery contract's source code.