Skip to content

Latest commit

 

History

History
28 lines (17 loc) · 5.27 KB

witnetrandomnessrequestconsumer.md

File metadata and controls

28 lines (17 loc) · 5.27 KB

📃 WitnetRandomnessRequestConsumer

{% content-ref url="../../solidity-wizard.md" %} solidity-wizard.md {% endcontent-ref %}

Constructor

ParametersTypeDescription
_witnetOracleWitnetOracleAddress of the WitnetOracle instance to interact with.
_baseFeeOverheadPercentageuint16Percentage over base fee to pay when querying new data updates.
_callbackGasLimituint24Maximum gas expected to be spent by the callback methods.

Modifiers

Modifier Description
onlyFromWitnet To be added on callback methods for attending query results from the Wit/Oracle.
witnetQuerySolved(uint256 queryId) Provides a convenient way for consuming contracts to block execution of the contract's logic until a particular randomness query gets ultimately reported from the Wit/Oracle blockchain.

Properties

NameVisibilityDescription
__witnetImmutable internalAddress of the WitnetOracle instance to directly interact with.
__witnetBaseFeeOverheadPercentageInternalPercentage over base fee to pay when querying new data updates. Defaults to 33%.
__witnetCallbackGasLimitInternalMaximum gas expected to be spent by the callback methods.
__witnetDefaultSLAInternalDefault Service Level Agreement parameters to be fulfilled by the Wit/Oracle blockchain when solving data updates.
__witnetRequestRadHashImmutable internalImmutable RAD hash identifying the actual sources and computations being solved by the Wit/Oracle upon every data update.

Internal methods

MethodsDescription
_witnetCheckQueryResultAvailability(uint256)Check if the specified query was already reported back from the Wit/Oracle blockchain.
_witnetEstimateEvmReward()Estimate the minimum reward required for posting a data request, using tx.gasprice as a reference.
_witnetCheckQueryResponseStatus(uint256)Check current WitnetV2.ResponseStatus of the specified query.
_witnetCheckQueryResultError(uint256)Get detailed Witnet.ResultError for the specified query.
_witnetRandomUniformUint32(u32,u256,b32)O(1) uniform random generator based on given range, nonce and seed.
__witnetReadRandomizeFromResultValue(CBOR)Extract a bytes32 value from some Radon Result as reported from the Wit/Oracle blockchain.
__witnetRandomize(uint256 _evmReward)Post a randomize query in expectation that it will get eventually solved and reported from the Wit/Oracle blockchain, specifying how much fee to pay out from this contract's balance.
__witnetRandomize(uint256, RadonSLA)Post a randomize query in expectation that it will get eventually solved and reported, specifying how much fee to pay and the SLA parameters to be fulfilled by the Wit/Oracle blockchain.

Events

EventsArgumentsDescription
WitnetQuery

address evmRequester

uint256 evmGasPrice

uint256 evmReward

uint256 queryId

bytes32 queryRadHash

RadonSLA querySLA

Emitted every time a new randomize query gets posted to the WitnetOracle contract.
WitnetQueryUpgrade

uint256 queryId

address evmSender

uint256 evmGasPrice

uint256 evmReward

Emitted if the EVM reward for solving a previously posted randomize is increased by anyone in any amount.