A decentralized random number generator using Flow's on-chain VRF (Verifiable Random Function).
- Generate random numbers within a specified range
- Select random items from a list
- True randomness powered by Flow's VRF
- Next.js 13+ with App Router
- TypeScript
- Tailwind CSS
- Solidity
- Hardhat
- Flow Network
-
Clone the repository:
git clone https://github.com/yourusername/random.wtf.git && cd random.wtf
-
Install dependencies:
npm install
-
Compile the contracts and generate TypeScript bindings
npm hardhat compile
-
Set up environment variables:
cp .env.example .env
Edit
.env
and add your Flow EVM private key. -
Deploy the smart contract:
npx hardhat run scripts/deploy.ts --network flow_testnet
-
Run the development server:
npm run dev
Open http://localhost:3000 with your browser to see the result.
To run the Hardhat test suite, execute the command:
npx hardhat test test/*.test.ts
The RandomnessWTF
contract is deployed on Testnet
and uses Flow's VRF capabilities to generate true random numbers. The contract provides two main functions:
getRandomNumber(uint256 min, uint256 max)
: Generates a random number within the specified rangeselectRandomItem(string[] items)
: Selects a random item from an array of strings
For more about using Flow's VRF in your contracts, check out the resources below:
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.