Skip to content
Lattice

GelatoVRFAdapter

Git Source

Inherits: IGelatoVRFAdapter

Title: GelatoVRFAdapter

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Gelato (https://github.com/gelatodigital/vrf-contracts)

Diamond facet for Gelato VRF (drand-backed) randomness — no on-chain fee.

Stateless delegator — all logic and storage live in GelatoVRFAdapterLib.

This facet handles the request/track layer only. Consumer facets that inherit this contract should override fulfillRandomness to act on delivered randomness after calling super.fulfillRandomness.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Gelato

Functions

getOperator

Returns the configured dedicated operator.

function getOperator() external view virtual override returns (address);

Returns

NameTypeDescription
<none>address

getUserKey

Returns the user key associated with a pending request.

function getUserKey(uint256 requestId) external view virtual override returns (bytes32);

Parameters

NameTypeDescription
requestIduint256The adapter-assigned request ID.

Returns

NameTypeDescription
<none>bytes32The user-supplied key, or bytes32(0) if not found.

setOperator

Sets or replaces the dedicated operator.

Caller must hold DEFAULT_ADMIN_ROLE. Reverts GelatoVRFInvalidOperator if zero.

function setOperator(address operator) external virtual override;

Parameters

NameTypeDescription
operatoraddressThe new dedicated operator.

requestRandomness

Requests randomness from Gelato VRF.

Caller must hold DEFAULT_ADMIN_ROLE. Emits RequestedRandomness for the operator.

function requestRandomness(bytes32 userKey) external virtual override returns (uint256 requestId);

Parameters

NameTypeDescription
userKeybytes32Arbitrary key the caller wants associated with this request.

Returns

NameTypeDescription
requestIduint256The adapter-assigned request ID.

fulfillRandomness

Called by the dedicated operator to deliver randomness.

Verifies the caller is the configured operator, decodes the request, domain-separates the randomness, clears the pending entry, and emits RandomnessFulfilled. Consumer facets should override this to consume the randomness.

function fulfillRandomness(uint256 randomness, bytes calldata dataWithRound) external virtual override;

Parameters

NameTypeDescription
randomnessuint256The drand-derived randomness for the requested round.
dataWithRoundbytesThe opaque payload originally emitted in RequestedRandomness.

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect GelatoVRFAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: fulfillRandomness(uint256,bytes) 0xb3f6b99a getOperator() 0xe7f43c68 getUserKey(uint256) 0xdd1e2651 requestRandomness(bytes32) 0x5e3b709f setOperator(address) 0xb3ab15fb

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes