dev-resources.site
for different kinds of informations.
The Danger of Randomness in Smart Contracts and its solution
Published at
12/31/2024
Categories
ethereum
smartcontract
solidity
blockchain
Author
Mahima Thacker
In Ethereum smart contracts, getting true randomness can be tricky and dangerous. Here’s why:
The Problem:
When you use common methods like blockhash or now for randomness in Solidity, it can be manipulated by miners. This makes your contract vulnerable to attacks, especially in games or lotteries.
The code in the below attached image seems to generate a random number, but it’s predictable and can be exploited.
The Solution: Chainlink VRF 👀
Chainlink’s Verifiable Random Function (VRF) provides a secure and verifiable way to get true randomness that cannot be tampered with.
Here’s how Chainlink VRF solves the problem:
- Chainlink VRF generates a random number off-chain and provides cryptographic proof that it was done fairly.
- The smart contract verifies this proof on-chain, ensuring the randomness is - reliable and cannot be tampered with.
- The cryptographic process ensures that even miners or oracles cannot influence the outcome, hence guaranteeing true randomness
Articles
9 articles in total
Have You Fallen for a Phishing Scam? Let’s Talk About It 👀
read article
OverFlow and UnderFlow causes in Solidity
read article
OverFlow and UnderFlow causes in Solidity
read article
The Danger of Randomness in Smart Contracts and its solution
currently reading
🤑 What are Stablecoins? Let's break it down!
read article
Why You Should Attend Events Like Devcon?
read article
Ethereum Transaction Calls and State Changes
read article
Ever wonder what happens when you send a transaction on Ethereum? 👀
read article
What's Version Control and Why Should You Care? 📣
read article
Featured ones: