Skip to content

aakash4dev/vrfchain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ VRFChain — Blockchain with Verifiable Random Function (VRF)

VRFChain is a custom blockchain built using Ignite CLI that implements Verifiable Random Functions (VRFs) — cryptographic primitives that generate provably fair and verifiable random numbers on-chain.

This chain allows anyone to create, store, and verify randomness in a decentralized manner — enabling use cases like lotteries, gaming, fair leader election, and secure random selection.


🚀 Features

  • Generate On-Chain Random Numbers using verifiable randomness

  • 🔐 Verify Random Outputs with public-key cryptography

  • ⚙️ Cosmos SDK + Ignite CLI powered blockchain module

  • 📡 Simple REST Endpoints:

    • POST /CreateVerifiableRandomNumber — Create random number request
    • GET /VerifyNumber — Verify generated number against proof

🧠 How It Works

  1. User submits input (shaSeed, publicKey, r, s, maxRange) to generate a verifiable random number.
  2. The chain module computes the random number using VRF cryptography.
  3. A proof is attached that allows anyone to verify the randomness.
  4. Using GET /VerifyNumber, users can validate that the number was truly random and not tampered with.

🏗️ Scaffold Commands Used

This chain was initialized with the following Ignite commands:

ignite scaffold module vrf
ignite scaffold message create-verifiable-random-number shaseed publickey r s max-range --module vrf

These commands create the vrf module and the message handler for verifiable randomness generation.


💻 Run the Blockchain

To start the local blockchain node:

ignite chain serve

This command:

  • Builds and serves the blockchain locally
  • Starts REST and gRPC servers for module interaction
  • Automatically generates the client, daemon, and configuration files

🔍 API Endpoints

Method Endpoint Description
POST /CreateVerifiableRandomNumber Create and broadcast a VRF-based random number transaction
GET /VerifyNumber Verify a previously generated number and proof

🧩 Example Use Cases

  • 🎰 Decentralized lotteries and on-chain games
  • 🗳️ Random validator selection
  • 🎲 Fair random draws in DAOs
  • 🔄 Randomized asset distribution in NFTs

⚙️ Tech Stack

Component Technology
Framework Ignite CLI
Blockchain SDK Cosmos SDK
Language Go (Golang)
Module Custom vrf Cosmos module
Cryptography Verifiable Random Function (VRF)

📦 Project Structure

vrfchain/
 ├── x/vrf/                # VRF module logic
 │   ├── keeper/           # State management and verification
 │   ├── types/            # Message and type definitions
 │   └── module.go         # Cosmos SDK module entry point
 ├── app/                  # Chain initialization and configuration
 ├── cmd/                  # CLI entry points
 ├── config.yml            # Ignite configuration
 └── README.md

🧪 Testing Locally

To test transactions:

# Create random number
ignite tx vrf create-verifiable-random-number <shaSeed> <publicKey> <r> <s> <maxRange> --from <key>

# Verify result
ignite query vrf verify-number <number-id>

🧠 Future Improvements

  • 🔄 Add on-chain proof verification logic
  • 🧮 Integrate BLS or Ed25519-based VRF
  • 🌐 Add front-end dashboard for randomness requests
  • ☁️ Enable Tendermint RPC interaction

📜 License

This project is licensed under the MIT License.


👨‍💻 Author

Aakash 🌐 aakash4dev.com X (Twitter)LinkedInMedium

About

A blockchain with Verifiable Random Function inbuild

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages