StarkRandomizer

A reusable smart contract module for randomizing flexible NFT draws, applicable to blockchain games, lotteries, event ticketing, and more!

StarkRandomizer

Created At

StarkHack

Project Description

Blockchain applications like games and lotteries need random prize distributions but face challenges in maintaining consistent draw rates. For StarkHack, our team developed a smart contract module with a multi-layer structure that enhances NFT design flexibility and resolves the issue where draw rates are dependent on the NFT supply count.

The StarkRandomizer Drawing Contract contains three pool layers: TokenID (Prize) Pool, Unit Pools, and Drawing Pools:

TokenID Pool: This pool contains all possible prizes (NFTs) and is designed for ERC-1155 lotteries that support batch-drawing through the ERC-1155 mintBatch function. It lacks associated rates, allowing it to be replenished without altering existing draw rates. Blockchain developers can set and modify the supply count for each TokenID (prize) independently. The maximum values for supply count and type are 2^32 - 1 and 2^256 - 1, respectively.

Unit Pools: Each Unit Pool contains a set of draw rates for the corresponding TokenIDs from the TokenID Pool. Multiple Unit Pools can be configured with desired probabilities for the given TokenIDs, providing flexibility in use case design.

Drawing Pools: These pools can draw from multiple Unit Pools with varying probabilities for each. Developers can combine multiple Unit Pools and Drawing Pools to create the desired probability distribution. Having multiple Drawing Pools allows for setting different draw rates for Unit Pools in each, such as having a “privileged” Drawing Pool with higher Rare draw rates.

When the supply count of a TokenID is depleted, its own probability is set to 0%, but the Unit Pool's probability remains constant. This ensures that users maintain the same chance (e.g., 0.5%) of drawing a rare item, even if one rare item has reached its mint cap. Only when all TokenIDs in a Unit Pool are exhausted does the TokenID Pool need replenishing. Developers can avoid this issue by setting at least one TokenID in each Unit Pool to have an unlimited supply.

How it's Made

RNG: P is used for random number generation to ensure complete transparency and fairness during draws.

FRONTEND

  • Built with the Next.js framework.
  • Interacts with the contracts using the starknet-react library.
  • Deployed with Vercel.

SMART CONTRACT DETAILS

StarkRandomizer Drawing Contract -- Requests a random number from the VRFManager and mints the corresponding NFT(s) to user. 0

ERC-1155 NFT Contract -- ERC-1155 contract for minting NFTs. 0

VRF Manager Contract -- Communicates with the Pragma VRF Contract. 0

Pragma VRF Contract -- A VRF Contract provided by Pragma that generates trusted random numbers. 0

background image mobile

Join the mailing list

Get the latest news and updates

StarkRandomizer | ETHGlobal