Skip to main content
Use this guide when you need verifiable on-chain randomness (e.g. for games, NFTs, or randomized logic) on Berachain. Gelato VRF lets your contract request randomness and receive a fulfilled callback.

Repository

Official documentation

Requirements

  • Node v20.0.0 or greater, npm or yarn
  • Wallet with $BERA — bArtio Faucet
  • Hardhat

Stack

Solidity, Hardhat, Node.js, Gelato VRF (requester + fulfillment).

Quick start

  1. Clone and install
    git clone https://github.com/berachain/guides.git && cd guides/apps/gelato-vrf
    npm install
    
  2. Configure .env from .env.example: PRIVATE_KEY, DEDICATED_MSG_SENDER, and later SC_ADDRESS (your deployed contract).
  3. Deploy
    npx hardhat deploy --network berachain
    
    Note the deployed address from deployments/ and set SC_ADDRESS in .env.
  4. Create a Gelato VRF task at app.gelato.network/vrf: choose Berachain bArtio, enter your requester contract address, then launch the VRF instance.
  5. Request randomness
    npx hardhat run ./scripts/requestRandomness.ts --network berachain
    
    Monitor execution in the Gelato app.

Key files

PurposePath
VRF contractContracts in repo (see README)
Deploy outputdeployments/
Request scriptscripts/requestRandomness.ts