DEV Community

Mahima Thacker
Mahima Thacker

Posted on

1

The Danger of Randomness in Smart Contracts and its solution

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.

Image description

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

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay