Building a randomized post review system for Celo Academy using Chainlink's Verifiable Random Function (VRF)

Introduction

Generating random data on the blockchain has not been easy. There are a few ways to generate randomness on the blockchain using on-chain data such as blockhash. These methods are susceptible to attack since they can be manipulated to an extent by the miners. Ralaying external data to contracts has become a lasting solution, but Oracles’ integrity is questionable. Chainlink has proven to be one of the reliable Oracles due to the method it has adopted. This tutorial will provide a comprehensive guide on how to leverage Chainlink’s VRF in your project.

Motivation

Here at Celo Academy, it has been great ever since I became a Sage. Let’s assume there is a challenge where a few of the reviewers have more posts to review than others. It would be unfair to other reviewers. What if we have a system where tutorials in the review section are randomly assigned to the reviewers?

Solution

I am proposing to create a simple dapp that handles tutorial reviews in the academy. Since this involves creating smart contracts, it would require random values. I will be leveraging Chainlink’s VRF to solve this problem.

How it works

  • Reviewers are registered on the dapp, and approved by the leader of the Academy.
  • Authors are approved by the same leader account.
  • Authors who have completed their tutorials will have to make an entry in the dapp with a link to it.
  • Soon as an Author made an entry, the function is triggered and is automatically and randomly assigned to a reviewer. Every reviewer who has been assigned a tutorial will be taken off the list.

Objective

The goal is to ensure fairness. Since reviewers know this works based on randomness, more trust will be enshrined in the system.
This guide will teach developers how to use Chainlink VRF in their projects.

Additionally, developers will

  • Grab the concept of oracle and its relevance to DApp development.

  • Confidently integrate Chainlink VRF into Celo-based projects.

  • Deploy and interact with the DApp.

Requirements

Working with Oracle is a bit complex compared to deploying a simple ERC20 contract Audiences should possess at least intermediate knowledge in smart contract development.

Stacks and Libraries

  • Solidity
  • JavaScript,
  • Typescript
  • MaterialUI

4 Likes