GelatoVRFAdapter
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
| Name | Type | Description |
|---|---|---|
| <none> | address |
getUserKey
Returns the user key associated with a pending request.
function getUserKey(uint256 requestId) external view virtual override returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| requestId | uint256 | The adapter-assigned request ID. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
| operator | address | The 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
| Name | Type | Description |
|---|---|---|
| userKey | bytes32 | Arbitrary key the caller wants associated with this request. |
Returns
| Name | Type | Description |
|---|---|---|
| requestId | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| randomness | uint256 | The drand-derived randomness for the requested round. |
| dataWithRound | bytes | The 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
| Name | Type | Description |
|---|---|---|
| selectors | bytes |