Protect against uncle bandits

In your docs it is stated that in order the get protection against uncled blocks, the following check should be included in the smart contratc function or transaction:

require(blockhash(block.number - 1) == expectedParentHash, "block was uncled");

My question is: where do I source the expectedParentHash? How can I implement this correctly? As far as I know, expectedParentHash is not a global variable. How can I make my contract find the right one?

Thanks

1 Like