Provably-fair randomness as a service for onchain games and finance on KUB. Your users sign once, a keeper settles in seconds, and your contract gets a callback. Every result is recomputable from public chain data. No oracle, no VRF service.
The number comes from the hash of a future block, unknown to everyone at commit time. Your user signs once; settlement is permissionless, so a keeper (or anyone) reveals it and your contract gets the callback.
Atomic grinding is impossible. Because reveal reverts until the next block is mined, an attacker cannot compute the result and revert on a loss inside one transaction. The most common on-chain gambling exploit is closed by construction.
A primitive that handles value should never overclaim, so we document exactly what it defends and what it does not. It passes 36/36 tests, internal multi-agent passes, and an external hard audit, with no fund-loss bug in the core.
Inherit EntropyConsumer and implement _onRandomness; the base handles the fee, callback auth, anti-spoof, and a recovery path. Open the full SDK & API reference →
// inherit the SDK base; bind the live DurianEntropyV2 on KUB (chainId 96) contract GigaKingMint is EntropyConsumer { constructor(address e) EntropyConsumer(e) {} // 0xE2BA…4caB // user signs ONCE: pay the gas-scaled fee, reserve a future-block roll function mint() external payable { require(msg.value >= entropy.fee(CB_GAS)); pending[_roll(seed, CB_GAS)] = msg.sender; } // a keeper reveals; the base calls you back, grind-proof (paid at request) function _onRandomness(uint256 id, uint256 r) internal override { _mint(pending[id], pickTier(r)); } }
uint256 r = entropy.reveal(drawId); uint256 winning = r.digits(6); // 482917
uint256 r = entropy.reveal(spinId); uint8 pocket = uint8(r.pick(0, 37)); // 0 to 36
_roll calls); request(seed) is the free, callback-less pathDerive as many independent values as you need from a single reveal with the EntropyLib helper. Each demo draw below commits and then waits for a real future block to seal, so it can't be rushed.
Every value is keccak256 of a real, unpredictable KUB block hash, so the output is uniformly distributed and nothing the caller controls can bias it. Pick any game and run it hundreds of times from a single block, then watch the distribution level out. The one caveat is economic, not statistical: a block producer can bias a single block, so cap per-round value.
Connect a wallet and the draw runs the live DurianEntropy V2 contract: request() then reveal() (the self-serve path, ~0.003 KUB). In production a keeper sends the second transaction, so your users sign once. No wallet? Run a gasless read-only preview.