API3QRNGAdapter
Inherits: IAPI3QRNGAdapter
Title: API3QRNGAdapter
Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from API3 (https://github.com/api3dao/airnode)
Diamond facet for API3 QRNG (quantum randomness) over the Airnode Request-Response Protocol (self-sponsoring).
Stateless delegator — all logic and storage live in API3QRNGAdapterLib.
This facet handles the request/track layer only. Consumer facets that
inherit this contract should override fulfillRandomNumber to act on
delivered randomness after calling super.fulfillRandomNumber.
Notes:
- lattice-version: 0.1.0
- lattice-source: API3
Functions
getConfig
Returns the current QRNG configuration.
function getConfig() external view virtual override returns (QRNGConfig memory);Returns
| Name | Type | Description |
|---|---|---|
| <none> | QRNGConfig |
getUserKey
Returns the user key associated with a pending request.
function getUserKey(bytes32 requestId) external view virtual override returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| requestId | bytes32 | The RRP-assigned request ID. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 | The user-supplied key, or bytes32(0) if not found. |
setConfig
Sets or replaces the QRNG configuration.
Caller must hold DEFAULT_ADMIN_ROLE. Reverts QRNGInvalidConfig on any zero field.
function setConfig(QRNGConfig calldata config) external virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| config | QRNGConfig | The new configuration. |
setSelfSponsorship
Registers (or revokes) this contract as its own sponsor with the Airnode RRP.
Caller must hold DEFAULT_ADMIN_ROLE. A full request only succeeds while self-sponsored.
function setSelfSponsorship(bool status) external virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| status | bool | True to self-sponsor, false to revoke. |
requestRandomNumber
Requests a quantum random number via the Airnode RRP.
Caller must hold DEFAULT_ADMIN_ROLE.
function requestRandomNumber(bytes32 userKey) external virtual override returns (bytes32 requestId);Parameters
| Name | Type | Description |
|---|---|---|
| userKey | bytes32 | Arbitrary key the caller wants associated with this request. |
Returns
| Name | Type | Description |
|---|---|---|
| requestId | bytes32 | The RRP-assigned request ID. |
fulfillRandomNumber
Called by the Airnode RRP to deliver the random number.
Verifies the caller is the configured Airnode RRP, looks up the user key, clears the
pending entry, decodes the random number, and emits RandomNumberFulfilled. Consumer
facets should override this to consume the randomness.
function fulfillRandomNumber(bytes32 requestId, bytes calldata data) external virtual override;Parameters
| Name | Type | Description |
|---|---|---|
| requestId | bytes32 | The RRP-assigned request ID. |
| data | bytes | The ABI-encoded random number (abi.encode(uint256)). |
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 API3QRNGAdapter methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
fulfillRandomNumber(bytes32,bytes) 0xf43a72e3
getConfig() 0xc3f909d4
getUserKey(bytes32) 0xa1cfedf0
requestRandomNumber(bytes32) 0xbd313d78
setConfig((address,address,bytes32,address)) 0xa601dfb6
setSelfSponsorship(bool) 0x230bc58e
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |