Skip to main content
Use this guide when you need on-chain verifiable randomness or provably fair NFT minting on Berachain. Pyth Entropy lets you request secure random numbers and use them in smart contract callbacks (e.g. mint an NFT with a random trait).

Repository

Official documentation

Requirements

  • Node v20.11.0 or greater, npm
  • Wallet with Berachain testnet $BERA — Bepolia Faucet
  • Foundry (foundryup)

Stack

Solidity, Foundry (Forge), Node.js, @pythnetwork/entropy-sdk-solidity, OpenZeppelin contracts.

Quick start

  1. Clone and install
    Add remappings to foundry.toml (see README).
  2. Configure .env at project root: RPC_URL, PRIVATE_KEY, ENTROPY_ADDRESS, PROVIDER_ADDRESS (values in README).
  3. Deploy the NFT contract
    Set ENTROPY_NFT_ADDRESS in .env to the deployed address.
  4. Request a mint (script requests random number from Pyth and polls for the mint callback)

Key files