Skip to content
Lattice

IHederaPrngAdapter

Git Source

Title: IHederaPrngAdapter

Author: Modified from hiero-ledger/hiero-contracts (https://github.com/hiero-ledger/hiero-contracts)

Interface for the HederaPrngAdapter Diamond facet — consensus-derived randomness from the PRNG system contract (HIP-351), the Hedera-native counterpart of the VRF / Entropy adapters.

Unlike VRF, the seed is available synchronously in the same transaction (no request / fulfil round trip) and is derived from the previous transaction record's running hash — not manipulable by the caller, but visible to the node that orders the transaction. Not a view: the network records the draw as a child transaction.

Functions

drawSeed

Draws a fresh 32-byte seed.

function drawSeed() external returns (bytes32 seed);

Returns

NameTypeDescription
seedbytes32

drawInRange

Draws a seed and reduces it to a number in [lo, hi).

function drawInRange(uint32 lo, uint32 hi) external returns (uint32 number);

Parameters

NameTypeDescription
louint32
hiuint32

Returns

NameTypeDescription
numberuint32

Events

HederaSeedDrawn

Emitted on every draw.

event HederaSeedDrawn(bytes32 seed, address indexed requester);

Parameters

NameTypeDescription
seedbytes32
requesteraddress

Errors

HederaPrngCallFailed

The PRNG system contract halted.

error HederaPrngCallFailed();

HederaPrngInvalidRange

lo must be less than hi.

error HederaPrngInvalidRange(uint32 lo, uint32 hi);

Parameters

NameTypeDescription
louint32
hiuint32