ETH Price: $2,526.56 (+0.13%)

Contract

0x0DCA49D777fD938eE476d400d0B477222bD10AA9
 

Overview

ETH Balance

0.011271917328656094 ETH

Eth Value

$28.48 (@ $2,526.56/ETH)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Fetch Randomness206217182024-08-27 18:29:233 days ago1724783363IN
0x0DCA49D7...22bD10AA9
0 ETH0.000201141.67733243
Fetch Randomness203406882024-07-19 12:50:2342 days ago1721393423IN
0x0DCA49D7...22bD10AA9
0 ETH0.000760016.33772961
Fetch Randomness197563112024-04-28 20:51:11124 days ago1714337471IN
0x0DCA49D7...22bD10AA9
0 ETH0.000738835.66317265
Fetch Randomness194587912024-03-18 2:44:11165 days ago1710729851IN
0x0DCA49D7...22bD10AA9
0 ETH0.0030947123.72102095
Fetch Randomness188539412023-12-24 6:48:11250 days ago1703400491IN
0x0DCA49D7...22bD10AA9
0 ETH0.0024425418.72213853
Fetch Randomness185750282023-11-15 4:51:47289 days ago1700023907IN
0x0DCA49D7...22bD10AA9
0 ETH0.0030242723.18111791
Fetch Randomness183398192023-10-13 6:55:35322 days ago1697180135IN
0x0DCA49D7...22bD10AA9
0 ETH0.000840256.44055939
Fetch Randomness182361312023-09-28 18:51:11337 days ago1695927071IN
0x0DCA49D7...22bD10AA9
0 ETH0.0017787413.63405961
Fetch Randomness181367652023-09-14 20:05:11351 days ago1694721911IN
0x0DCA49D7...22bD10AA9
0 ETH0.0031462324.1159111
Fetch Randomness180369752023-08-31 20:35:11365 days ago1693514111IN
0x0DCA49D7...22bD10AA9
0 ETH0.0032276124.73971676
Fetch Randomness179364382023-08-17 18:51:35379 days ago1692298295IN
0x0DCA49D7...22bD10AA9
0 ETH0.0037325128.60976451
Fetch Randomness178363732023-08-03 18:51:59393 days ago1691088719IN
0x0DCA49D7...22bD10AA9
0 ETH0.0040024830.67906749
Fetch Randomness177367002023-07-20 20:15:59407 days ago1689884159IN
0x0DCA49D7...22bD10AA9
0 ETH0.0039102829.97238129
Fetch Randomness176369402023-07-06 19:40:59421 days ago1688672459IN
0x0DCA49D7...22bD10AA9
0 ETH0.0037867929.02584781
Fetch Randomness175370602023-06-22 18:52:59435 days ago1687459979IN
0x0DCA49D7...22bD10AA9
0 ETH0.0020524715.73220787
Fetch Randomness174376182023-06-08 19:22:59449 days ago1686252179IN
0x0DCA49D7...22bD10AA9
0 ETH0.0027491221.07205899
Fetch Randomness173380552023-05-25 18:51:59463 days ago1685040719IN
0x0DCA49D7...22bD10AA9
0 ETH0.0041511631.81867737
Fetch Randomness172528532023-05-13 18:33:23475 days ago1684002803IN
0x0DCA49D7...22bD10AA9
0 ETH0.004997438.30513615
Fetch Randomness171394072023-04-27 18:50:59491 days ago1682621459IN
0x0DCA49D7...22bD10AA9
0 ETH0.0045804735.10936875
Fetch Randomness170904732023-04-20 21:56:59498 days ago1682027819IN
0x0DCA49D7...22bD10AA9
0 ETH0.007621358.41738847
Fetch Randomness170402932023-04-13 18:52:11505 days ago1681411931IN
0x0DCA49D7...22bD10AA9
0 ETH0.0048742137.36087086
Fetch Randomness169914382023-04-06 18:52:35512 days ago1680807155IN
0x0DCA49D7...22bD10AA9
0 ETH0.0030138223.10101921
Fetch Randomness169419472023-03-30 18:49:59519 days ago1680202199IN
0x0DCA49D7...22bD10AA9
0 ETH0.0042694532.72538669
Fetch Randomness168921472023-03-23 18:54:35526 days ago1679597675IN
0x0DCA49D7...22bD10AA9
0 ETH0.0051485839.463971
Fetch Randomness168423022023-03-16 18:51:59533 days ago1678992719IN
0x0DCA49D7...22bD10AA9
0 ETH0.0032429524.85729711
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
206216862024-08-27 18:22:593 days ago1724782979
0x0DCA49D7...22bD10AA9
0.00025775 ETH
203402162024-07-19 11:15:3542 days ago1721387735
0x0DCA49D7...22bD10AA9
0.00119447 ETH
201487942024-06-22 17:40:3569 days ago1719078035
0x0DCA49D7...22bD10AA9
0.000399 ETH
197562852024-04-28 20:45:47124 days ago1714337147
0x0DCA49D7...22bD10AA9
0.00078629 ETH
197519332024-04-28 6:09:23124 days ago1714284563
0x0DCA49D7...22bD10AA9
0.00059383 ETH
194587562024-03-18 2:37:11165 days ago1710729431
0x0DCA49D7...22bD10AA9
0.00303481 ETH
188538952023-12-24 6:38:47250 days ago1703399927
0x0DCA49D7...22bD10AA9
0.00287234 ETH
185749962023-11-15 4:45:23289 days ago1700023523
0x0DCA49D7...22bD10AA9
0.00316768 ETH
183362112023-10-12 18:46:23323 days ago1697136383
0x0DCA49D7...22bD10AA9
0.00102258 ETH
182361012023-09-28 18:45:11337 days ago1695926711
0x0DCA49D7...22bD10AA9
0.0017881 ETH
181366942023-09-14 19:50:59351 days ago1694721059
0x0DCA49D7...22bD10AA9
0.00304862 ETH
180369262023-08-31 20:25:23365 days ago1693513523
0x0DCA49D7...22bD10AA9
0.00319511 ETH
179364072023-08-17 18:45:11379 days ago1692297911
0x0DCA49D7...22bD10AA9
0.00334608 ETH
178363412023-08-03 18:45:35393 days ago1691088335
0x0DCA49D7...22bD10AA9
0.00350681 ETH
177366732023-07-20 20:10:35407 days ago1689883835
0x0DCA49D7...22bD10AA9
0.00386929 ETH
176368962023-07-06 19:32:11421 days ago1688671931
0x0DCA49D7...22bD10AA9
0.00395198 ETH
175370222023-06-22 18:45:11435 days ago1687459511
0x0DCA49D7...22bD10AA9
0.0019938 ETH
174375892023-06-08 19:17:11449 days ago1686251831
0x0DCA49D7...22bD10AA9
0.00316505 ETH
173380232023-05-25 18:45:35463 days ago1685040335
0x0DCA49D7...22bD10AA9
0.00433777 ETH
172528252023-05-13 18:27:35475 days ago1684002455
0x0DCA49D7...22bD10AA9
0.00458048 ETH
171393802023-04-27 18:45:11491 days ago1682621111
0x0DCA49D7...22bD10AA9
0.00524702 ETH
170904432023-04-20 21:50:35498 days ago1682027435
0x0DCA49D7...22bD10AA9
0.00652866 ETH
170402622023-04-13 18:45:23505 days ago1681411523
0x0DCA49D7...22bD10AA9
0.00542496 ETH
169914092023-04-06 18:46:47512 days ago1680806807
0x0DCA49D7...22bD10AA9
0.00387192 ETH
169419242023-03-30 18:45:11519 days ago1680201911
0x0DCA49D7...22bD10AA9
0.00362217 ETH
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RngWitnet

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU GPLv3 license
File 1 of 18 : RngWitnet.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

import "UsingWitnet.sol";

import "RngInterface.sol";
import "WitnetRequestRandomness.sol";

contract RngWitnet is RNGInterface, UsingWitnet, Ownable {
    event MaxFeeSet(uint256 indexed maxFee);
    event RandomNumberFailed(uint32 indexed requestId);
    event Received(address indexed sender, uint value);
    event RequesterAdded(address indexed requester);
    event RequesterRemoved(address indexed requester);
    event RngRequested(uint32 indexed requestId, uint256 indexed witnetRequestId);
    event WitnetRequestRandomnessSet(WitnetRequestRandomness indexed witnetRequestRandomness);
    event WrbSet(WitnetRequestBoard indexed witnetRequestBoard);

    error disallowedRequester(address _requester);
    error maxFeeTooLow(uint256 _maxFee, uint256 _fee);
    error balanceTooLow(uint256 _balance, uint256 _fee);
    error randomnessNotAvailable(uint256 _queryId);

    /// @dev Low-level Witnet Data Request composed on construction
    WitnetRequestRandomness public witnetRandomnessRequest;

    /// @dev The maximum allowed request fee for the Witnet RNG to prevent accidentally draining the contract
    uint256 public maxFee;

    /// @dev A counter for the number of requests made used for request ids
    uint32 public requestCount;

    /// @dev The addresses which are allowed to request random numbers
    mapping(address => bool) allowedRequester;

    /// @dev A list of random numbers from past requests mapped by request id
    mapping(uint32 => uint256) internal randomNumbers;

    /// @dev A list of bools to check whether the random number has been fetched
    mapping(uint32 => bool) internal randomNumberFetched;

    /// @dev A mapping from internal request ids to Witnet Request ids
    mapping(uint32 => uint256) internal witnetRequestIds;

    /// @dev Public constructor
    constructor(WitnetRequestBoard _witnetRequestBoard, WitnetRequestRandomness _witnetRequestRandomness) UsingWitnet(_witnetRequestBoard) {
        emit WrbSet(_witnetRequestBoard);

        witnetRandomnessRequest = WitnetRequestRandomness(address(_witnetRequestRandomness.clone()));
        witnetRandomnessRequest.transferOwnership(msg.sender);

        emit WitnetRequestRandomnessSet(_witnetRequestRandomness);
    }

    /// @notice Allows this contract to receive Ether
    receive() external payable {
        emit Received(msg.sender, msg.value);
    }

    /// @notice Allows the owner of this contract to withdraw Ether
    function refund() external onlyOwner {
        payable(msg.sender).transfer(address(this).balance);
    }

    /// @notice Allows owner to set the maximum fee per request (in wei) a Witnet RNG can spend
    /// @notice The remainder of the fee will be payed back after the request has been sent
    /// @param _maxFee The maximum fee that can be charged by a request
    function setMaxFee(uint256 _maxFee) external onlyOwner {
        maxFee = _maxFee;

        emit MaxFeeSet(_maxFee);
    }

    /// @notice Allows owner to set a new Witnet Request Randomness
    /// @param _witnetRequestRandomness The address of the Witnet Request Randomness factory
    function setWitnetRequestRandomness(WitnetRequestRandomness _witnetRequestRandomness) external onlyOwner {
        witnetRandomnessRequest = WitnetRequestRandomness(address(_witnetRequestRandomness.clone()));
        witnetRandomnessRequest.transferOwnership(msg.sender);

        emit WitnetRequestRandomnessSet(_witnetRequestRandomness);
    }

    /// @notice Allows owner to add an address which can generate an RNG request
    /// @param _requester The address that can generate an RNG request
    function addAllowedRequester(address _requester) external onlyOwner {
        allowedRequester[_requester] = true;

        emit RequesterAdded(_requester);
    }

    /// @notice Allows owner to remove an address which can generate an RNG request
    /// @param _requester The address that can generate an RNG request
    function removeAllowedRequester(address _requester) external onlyOwner {
        delete allowedRequester[_requester];

        emit RequesterRemoved(_requester);
    }

    /// @notice Gets the last request id used by the RNG service
    /// @return requestId The last request id used in the last request
    function getLastRequestId() external view override returns (uint32 requestId) {
        return requestCount;
    }

    /// @notice Gets the current fee for making a request against an RNG service based on the latest blocks basefee
    /// @return feeToken Compatibility return value: no fee token is required but payed in Ether
    /// @return requestFee The maximum fee which can be used to launch an RNG request
    function getRequestFee() external view override returns (address feeToken, uint256 requestFee) {
        return (address(0), _witnetEstimateReward(block.basefee));
    }

    /// @notice Gets the fee to launch a Witnet RNG request given a specific gas price
    /// @param _gasPrice The gas price in Wei for which to calculate the reward
    /// @return requestFee The fee required for making a request given a gas price
    function getRequestFee(uint256 _gasPrice) external view returns (uint256 requestFee) {
        return _witnetEstimateReward(_gasPrice);
    }

    /// @notice Sends a request for a random number to a 3rd-party service. This request spends the contract's balance and only
    /// allowed prize strategy contracts (such as deployments of the PoolTogether MultipleWinners contract) are able to call it
    /// @dev Some services will complete the request immediately, others may have a time-delay
    /// @return requestId The ID of the request used to get the results of the RNG service
    /// @return lockBlock The block number at which the RNG service will start generating time-delayed randomness. The calling contract
    /// should "lock" all activity until the result is available via the `requestId`
    function requestRandomNumber() external override returns (uint32 requestId, uint32 lockBlock) {
        if (allowedRequester[msg.sender] == false)
            revert disallowedRequester(msg.sender);

        lockBlock = uint32(block.number);

        requestId = _requestRandomness();

        emit RandomNumberRequested(requestId, msg.sender);
    }

    /// @notice Checks if the request for randomness has completed and the random number can be fetched
    /// @param requestId The ID of the request used to get the results of the RNG service
    /// @return isFetchable True if the request has completed and a random number can be fetched
    function isRngFetchable(uint32 requestId) external view returns (bool isFetchable) {
        uint _queryId = witnetRequestIds[requestId];
        return _queryId != 0 && _witnetCheckResultAvailability(_queryId);
    }

    /// @notice Checks if the request for randomness from the 3rd-party service has completed and has been fetched
    /// @dev For time-delayed requests, this function is used to check/confirm completion
    /// @param requestId The ID of the request used to get the results of the RNG service
    /// @return isCompleted True if the request has completed and a random number is available, false otherwise
    function isRequestComplete(uint32 requestId) external view override returns (bool isCompleted) {
        uint _queryId = witnetRequestIds[requestId];
        return _queryId != 0 && _witnetCheckResultAvailability(_queryId) && randomNumberFetched[requestId];
    }

    /// @notice Gets the random number produced by the 3rd-party service
    /// @param requestId The ID of the request used to get the results of the RNG service
    /// @return randomNum The random number
    function randomNumber(uint32 requestId) external view override returns (uint256 randomNum) {
        return randomNumbers[requestId];
    }

    /// @dev Requests a new random number from the Chainlink VRF
    /// @dev The result of the request is returned in the function `fulfillRandomness`
    /// @return requestId The internal request id
    function _requestRandomness() internal returns (uint32 requestId) {
        uint256 _witnetReward = _witnetEstimateReward();

        if (_witnetReward >= maxFee)
            revert maxFeeTooLow(maxFee, _witnetReward);
        if (address(this).balance < _witnetReward)
            revert balanceTooLow(address(this).balance, _witnetReward);

        // Get next request ID
        requestId = _getNextRequestId();

        // Post the raw randomness request
        uint256 _witnetQueryId = witnet.postRequest{value: _witnetReward}(witnetRandomnessRequest);

        // Save a mapping of internal query ids to Witnet query ids
        witnetRequestIds[requestId] = _witnetQueryId;

        emit RngRequested(requestId, _witnetQueryId);
    }

    /// @notice Function to fetch randomness once it is ready
    /// @dev Check if the result of the randomness function is ready and return the value if it is
    /// @param requestId The ID of the request of which to fetch the random number
    function fetchRandomness(uint32 requestId) external
    {
        uint _queryId = witnetRequestIds[requestId];

        // Check whether the randomness request has already been resolved
        if (!_witnetCheckResultAvailability(_queryId))
            revert randomnessNotAvailable(_queryId);

        // Low-level interaction with the WitnetRequestBoard as to deserialize the result,
        // and check whether the randomness request failed or succeeded:
        Witnet.Result memory _result = witnet.readResponseResult(_queryId);
        if (_result.success) {
            uint256 randomness = uint256(witnet.asBytes32(_result));
            randomNumbers[requestId] = randomness;
            randomNumberFetched[requestId] = true;
            emit RandomNumberCompleted(requestId, randomness);
        } else {
            emit RandomNumberFailed(requestId);
        }
    }

    /// @dev Gets the next consecutive request ID to be used
    /// @return requestId The ID to be used for the next request
    function _getNextRequestId() internal returns (uint32 requestId) {
        requestCount++;
        requestId = requestCount;
    }
}

File 2 of 18 : UsingWitnet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "WitnetRequestBoard.sol";

/// @title The UsingWitnet contract
/// @dev Witnet-aware contracts can inherit from this contract in order to interact with Witnet.
/// @author The Witnet Foundation.
abstract contract UsingWitnet {

    WitnetRequestBoard public immutable witnet;

    /// Include an address to specify the WitnetRequestBoard entry point address.
    /// @param _wrb The WitnetRequestBoard entry point address.
    constructor(WitnetRequestBoard _wrb)
    {
        require(address(_wrb) != address(0), "UsingWitnet: zero address");
        witnet = _wrb;
    }

    /// Provides a convenient way for client contracts extending this to block the execution of the main logic of the
    /// contract until a particular request has been successfully solved and reported by Witnet.
    modifier witnetRequestSolved(uint256 _id) {
        require(
                _witnetCheckResultAvailability(_id),
                "UsingWitnet: request not solved"
            );
        _;
    }

    /// Check if a data request has been solved and reported by Witnet.
    /// @dev Contracts depending on Witnet should not start their main business logic (e.g. receiving value from third.
    /// parties) before this method returns `true`.
    /// @param _id The unique identifier of a previously posted data request.
    /// @return A boolean telling if the request has been already resolved or not. Returns `false` also, if the result was deleted.
    function _witnetCheckResultAvailability(uint256 _id)
        internal view
        virtual
        returns (bool)
    {
        return witnet.getQueryStatus(_id) == Witnet.QueryStatus.Reported;
    }

    /// Estimate the reward amount.
    /// @param _gasPrice The gas price for which we want to retrieve the estimation.
    /// @return The reward to be included when either posting a new request, or upgrading the reward of a previously posted one.
    function _witnetEstimateReward(uint256 _gasPrice)
        internal view
        virtual
        returns (uint256)
    {
        return witnet.estimateReward(_gasPrice);
    }

    /// Estimates the reward amount, considering current transaction gas price.
    /// @return The reward to be included when either posting a new request, or upgrading the reward of a previously posted one.
    function _witnetEstimateReward()
        internal view
        virtual
        returns (uint256)
    {
        return witnet.estimateReward(tx.gasprice);
    }

    /// Send a new request to the Witnet network with transaction value as a reward.
    /// @param _request An instance of `IWitnetRequest` contract.
    /// @return _id Sequential identifier for the request included in the WitnetRequestBoard.
    /// @return _reward Current reward amount escrowed by the WRB until a result gets reported.
    function _witnetPostRequest(IWitnetRequest _request)
        internal
        virtual
        returns (uint256 _id, uint256 _reward)
    {
        _reward = _witnetEstimateReward();
        require(
            _reward <= msg.value,
            "UsingWitnet: reward too low"
        );
        _id = witnet.postRequest{value: _reward}(_request);
    }

    /// Upgrade the reward for a previously posted request.
    /// @dev Call to `upgradeReward` function in the WitnetRequestBoard contract.
    /// @param _id The unique identifier of a request that has been previously sent to the WitnetRequestBoard.
    /// @return Amount in which the reward has been increased.
    function _witnetUpgradeReward(uint256 _id)
        internal
        virtual
        returns (uint256)
    {
        uint256 _currentReward = witnet.readRequestReward(_id);        
        uint256 _newReward = _witnetEstimateReward();
        uint256 _fundsToAdd = 0;
        if (_newReward > _currentReward) {
            _fundsToAdd = (_newReward - _currentReward);
        }
        witnet.upgradeReward{value: _fundsToAdd}(_id); // Let Request.gasPrice be updated
        return _fundsToAdd;
    }

    /// Read the Witnet-provided result to a previously posted request.
    /// @param _id The unique identifier of a request that was posted to Witnet.
    /// @return The result of the request as an instance of `Witnet.Result`.
    function _witnetReadResult(uint256 _id)
        internal view
        virtual
        returns (Witnet.Result memory)
    {
        return witnet.readResponseResult(_id);
    }

    /// Retrieves copy of all response data related to a previously posted request, removing the whole query from storage.
    /// @param _id The unique identifier of a previously posted request.
    /// @return The Witnet-provided result to the request.
    function _witnetDeleteQuery(uint256 _id)
        internal
        virtual
        returns (Witnet.Response memory)
    {
        return witnet.deleteQuery(_id);
    }

}

File 3 of 18 : WitnetRequestBoard.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "IWitnetRequestBoardEvents.sol";
import "IWitnetRequestBoardReporter.sol";
import "IWitnetRequestBoardRequestor.sol";
import "IWitnetRequestBoardView.sol";
import "IWitnetRequestParser.sol";

/// @title Witnet Request Board functionality base contract.
/// @author The Witnet Foundation.
abstract contract WitnetRequestBoard is
    IWitnetRequestBoardEvents,
    IWitnetRequestBoardReporter,
    IWitnetRequestBoardRequestor,
    IWitnetRequestBoardView,
    IWitnetRequestParser
{
    receive() external payable {
        revert("WitnetRequestBoard: no transfers accepted");
    }
}

File 4 of 18 : IWitnetRequestBoardEvents.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

/// @title Witnet Request Board emitting events interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardEvents {
    /// Emitted when a Witnet Data Request is posted to the WRB.
    event PostedRequest(uint256 queryId, address from);

    /// Emitted when a Witnet-solved result is reported to the WRB.
    event PostedResult(uint256 queryId, address from);

    /// Emitted when all data related to given query is deleted from the WRB.
    event DeletedQuery(uint256 queryId, address from);
}

File 5 of 18 : IWitnetRequestBoardReporter.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

/// @title The Witnet Request Board Reporter interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardReporter {
    /// Reports the Witnet-provided result to a previously posted request. 
    /// @dev Will assume `block.timestamp` as the timestamp at which the request was solved.
    /// @dev Fails if:
    /// @dev - the `_queryId` is not in 'Posted' status.
    /// @dev - provided `_drTxHash` is zero;
    /// @dev - length of provided `_result` is zero.
    /// @param _queryId The unique identifier of the data request.
    /// @param _drTxHash The hash of the corresponding data request transaction in Witnet.
    /// @param _result The result itself as bytes.
    function reportResult(
            uint256 _queryId,
            bytes32 _drTxHash,
            bytes calldata _result
        ) external;

    /// Reports the Witnet-provided result to a previously posted request.
    /// @dev Fails if:
    /// @dev - called from unauthorized address;
    /// @dev - the `_queryId` is not in 'Posted' status.
    /// @dev - provided `_drTxHash` is zero;
    /// @dev - length of provided `_result` is zero.
    /// @param _queryId The unique query identifier
    /// @param _timestamp The timestamp of the solving tally transaction in Witnet.
    /// @param _drTxHash The hash of the corresponding data request transaction in Witnet.
    /// @param _result The result itself as bytes.
    function reportResult(
            uint256 _queryId,
            uint256 _timestamp,
            bytes32 _drTxHash,
            bytes calldata _result
        ) external;

    /// Reports Witnet-provided results to multiple requests within a single EVM tx.
    /// @dev Must emit a PostedResult event for every succesfully reported result.
    /// @param _batchResults Array of BatchResult structs, every one containing:
    ///         - unique query identifier;
    ///         - timestamp of the solving tally txs in Witnet. If zero is provided, EVM-timestamp will be used instead;
    ///         - hash of the corresponding data request tx at the Witnet side-chain level;
    ///         - data request result in raw bytes.
    /// @param _verbose If true, must emit a BatchReportError event for every failing report, if any. 
    function reportResultBatch(BatchResult[] calldata _batchResults, bool _verbose) external;
        
        struct BatchResult {
            uint256 queryId;
            uint256 timestamp;
            bytes32 drTxHash;
            bytes   cborBytes;
        }

        event BatchReportError(uint256 queryId, string reason);
}

File 6 of 18 : IWitnetRequestBoardRequestor.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "Witnet.sol";

/// @title Witnet Requestor Interface
/// @notice It defines how to interact with the Witnet Request Board in order to:
///   - request the execution of Witnet Radon scripts (data request);
///   - upgrade the resolution reward of any previously posted request, in case gas price raises in mainnet;
///   - read the result of any previously posted request, eventually reported by the Witnet DON.
///   - remove from storage all data related to past and solved data requests, and results.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardRequestor {
    /// Retrieves a copy of all Witnet-provided data related to a previously posted request, removing the whole query from the WRB storage.
    /// @dev Fails if the `_queryId` is not in 'Reported' status, or called from an address different to
    /// @dev the one that actually posted the given request.
    /// @param _queryId The unique query identifier.
    function deleteQuery(uint256 _queryId) external returns (Witnet.Response memory);

    /// Requests the execution of the given Witnet Data Request in expectation that it will be relayed and solved by the Witnet DON.
    /// A reward amount is escrowed by the Witnet Request Board that will be transferred to the reporter who relays back the Witnet-provided 
    /// result to this request.
    /// @dev Fails if:
    /// @dev - provided reward is too low.
    /// @dev - provided script is zero address.
    /// @dev - provided script bytecode is empty.
    /// @param _addr The address of the IWitnetRequest contract that can provide the actual Data Request bytecode.
    /// @return _queryId An unique query identifier.
    function postRequest(IWitnetRequest _addr) external payable returns (uint256 _queryId);

    /// Increments the reward of a previously posted request by adding the transaction value to it.
    /// @dev Updates request `gasPrice` in case this method is called with a higher 
    /// @dev gas price value than the one used in previous calls to `postRequest` or
    /// @dev `upgradeReward`. 
    /// @dev Fails if the `_queryId` is not in 'Posted' status.
    /// @dev Fails also in case the request `gasPrice` is increased, and the new 
    /// @dev reward value gets below new recalculated threshold. 
    /// @param _queryId The unique query identifier.
    function upgradeReward(uint256 _queryId) external payable;
}

File 7 of 18 : Witnet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "IWitnetRequest.sol";

library Witnet {

    /// @notice Witnet function that computes the hash of a CBOR-encoded Data Request.
    /// @param _bytecode CBOR-encoded RADON.
    function hash(bytes memory _bytecode) internal pure returns (bytes32) {
        return sha256(_bytecode);
    }

    /// Struct containing both request and response data related to every query posted to the Witnet Request Board
    struct Query {
        Request request;
        Response response;
        address from;      // Address from which the request was posted.
    }

    /// Possible status of a Witnet query.
    enum QueryStatus {
        Unknown,
        Posted,
        Reported,
        Deleted
    }

    /// Data kept in EVM-storage for every Request posted to the Witnet Request Board.
    struct Request {
        IWitnetRequest addr;    // The contract containing the Data Request which execution has been requested.
        address requester;      // Address from which the request was posted.
        bytes32 hash;           // Hash of the Data Request whose execution has been requested.
        uint256 gasprice;       // Minimum gas price the DR resolver should pay on the solving tx.
        uint256 reward;         // Escrowed reward to be paid to the DR resolver.
    }

    /// Data kept in EVM-storage containing Witnet-provided response metadata and result.
    struct Response {
        address reporter;       // Address from which the result was reported.
        uint256 timestamp;      // Timestamp of the Witnet-provided result.
        bytes32 drTxHash;       // Hash of the Witnet transaction that solved the queried Data Request.
        bytes   cborBytes;      // Witnet-provided result CBOR-bytes to the queried Data Request.
    }

    /// Data struct containing the Witnet-provided result to a Data Request.
    struct Result {
        bool success;           // Flag stating whether the request could get solved successfully, or not.
        CBOR value;             // Resulting value, in CBOR-serialized bytes.
    }

    /// Data struct following the RFC-7049 standard: Concise Binary Object Representation.
    struct CBOR {
        Buffer buffer;
        uint8 initialByte;
        uint8 majorType;
        uint8 additionalInformation;
        uint64 len;
        uint64 tag;
    }

    /// Iterable bytes buffer.
    struct Buffer {
        bytes data;
        uint32 cursor;
    }

    /// Witnet error codes table.
    enum ErrorCodes {
        // 0x00: Unknown error. Something went really bad!
        Unknown,
        // Script format errors
        /// 0x01: At least one of the source scripts is not a valid CBOR-encoded value.
        SourceScriptNotCBOR,
        /// 0x02: The CBOR value decoded from a source script is not an Array.
        SourceScriptNotArray,
        /// 0x03: The Array value decoded form a source script is not a valid Data Request.
        SourceScriptNotRADON,
        /// Unallocated
        ScriptFormat0x04,
        ScriptFormat0x05,
        ScriptFormat0x06,
        ScriptFormat0x07,
        ScriptFormat0x08,
        ScriptFormat0x09,
        ScriptFormat0x0A,
        ScriptFormat0x0B,
        ScriptFormat0x0C,
        ScriptFormat0x0D,
        ScriptFormat0x0E,
        ScriptFormat0x0F,
        // Complexity errors
        /// 0x10: The request contains too many sources.
        RequestTooManySources,
        /// 0x11: The script contains too many calls.
        ScriptTooManyCalls,
        /// Unallocated
        Complexity0x12,
        Complexity0x13,
        Complexity0x14,
        Complexity0x15,
        Complexity0x16,
        Complexity0x17,
        Complexity0x18,
        Complexity0x19,
        Complexity0x1A,
        Complexity0x1B,
        Complexity0x1C,
        Complexity0x1D,
        Complexity0x1E,
        Complexity0x1F,
        // Operator errors
        /// 0x20: The operator does not exist.
        UnsupportedOperator,
        /// Unallocated
        Operator0x21,
        Operator0x22,
        Operator0x23,
        Operator0x24,
        Operator0x25,
        Operator0x26,
        Operator0x27,
        Operator0x28,
        Operator0x29,
        Operator0x2A,
        Operator0x2B,
        Operator0x2C,
        Operator0x2D,
        Operator0x2E,
        Operator0x2F,
        // Retrieval-specific errors
        /// 0x30: At least one of the sources could not be retrieved, but returned HTTP error.
        HTTP,
        /// 0x31: Retrieval of at least one of the sources timed out.
        RetrievalTimeout,
        /// Unallocated
        Retrieval0x32,
        Retrieval0x33,
        Retrieval0x34,
        Retrieval0x35,
        Retrieval0x36,
        Retrieval0x37,
        Retrieval0x38,
        Retrieval0x39,
        Retrieval0x3A,
        Retrieval0x3B,
        Retrieval0x3C,
        Retrieval0x3D,
        Retrieval0x3E,
        Retrieval0x3F,
        // Math errors
        /// 0x40: Math operator caused an underflow.
        Underflow,
        /// 0x41: Math operator caused an overflow.
        Overflow,
        /// 0x42: Tried to divide by zero.
        DivisionByZero,
        /// Unallocated
        Math0x43,
        Math0x44,
        Math0x45,
        Math0x46,
        Math0x47,
        Math0x48,
        Math0x49,
        Math0x4A,
        Math0x4B,
        Math0x4C,
        Math0x4D,
        Math0x4E,
        Math0x4F,
        // Other errors
        /// 0x50: Received zero reveals
        NoReveals,
        /// 0x51: Insufficient consensus in tally precondition clause
        InsufficientConsensus,
        /// 0x52: Received zero commits
        InsufficientCommits,
        /// 0x53: Generic error during tally execution
        TallyExecution,
        /// Unallocated
        OtherError0x54,
        OtherError0x55,
        OtherError0x56,
        OtherError0x57,
        OtherError0x58,
        OtherError0x59,
        OtherError0x5A,
        OtherError0x5B,
        OtherError0x5C,
        OtherError0x5D,
        OtherError0x5E,
        OtherError0x5F,
        /// 0x60: Invalid reveal serialization (malformed reveals are converted to this value)
        MalformedReveal,
        /// Unallocated
        OtherError0x61,
        OtherError0x62,
        OtherError0x63,
        OtherError0x64,
        OtherError0x65,
        OtherError0x66,
        OtherError0x67,
        OtherError0x68,
        OtherError0x69,
        OtherError0x6A,
        OtherError0x6B,
        OtherError0x6C,
        OtherError0x6D,
        OtherError0x6E,
        OtherError0x6F,
        // Access errors
        /// 0x70: Tried to access a value from an index using an index that is out of bounds
        ArrayIndexOutOfBounds,
        /// 0x71: Tried to access a value from a map using a key that does not exist
        MapKeyNotFound,
        /// Unallocated
        OtherError0x72,
        OtherError0x73,
        OtherError0x74,
        OtherError0x75,
        OtherError0x76,
        OtherError0x77,
        OtherError0x78,
        OtherError0x79,
        OtherError0x7A,
        OtherError0x7B,
        OtherError0x7C,
        OtherError0x7D,
        OtherError0x7E,
        OtherError0x7F,
        OtherError0x80,
        OtherError0x81,
        OtherError0x82,
        OtherError0x83,
        OtherError0x84,
        OtherError0x85,
        OtherError0x86,
        OtherError0x87,
        OtherError0x88,
        OtherError0x89,
        OtherError0x8A,
        OtherError0x8B,
        OtherError0x8C,
        OtherError0x8D,
        OtherError0x8E,
        OtherError0x8F,
        OtherError0x90,
        OtherError0x91,
        OtherError0x92,
        OtherError0x93,
        OtherError0x94,
        OtherError0x95,
        OtherError0x96,
        OtherError0x97,
        OtherError0x98,
        OtherError0x99,
        OtherError0x9A,
        OtherError0x9B,
        OtherError0x9C,
        OtherError0x9D,
        OtherError0x9E,
        OtherError0x9F,
        OtherError0xA0,
        OtherError0xA1,
        OtherError0xA2,
        OtherError0xA3,
        OtherError0xA4,
        OtherError0xA5,
        OtherError0xA6,
        OtherError0xA7,
        OtherError0xA8,
        OtherError0xA9,
        OtherError0xAA,
        OtherError0xAB,
        OtherError0xAC,
        OtherError0xAD,
        OtherError0xAE,
        OtherError0xAF,
        OtherError0xB0,
        OtherError0xB1,
        OtherError0xB2,
        OtherError0xB3,
        OtherError0xB4,
        OtherError0xB5,
        OtherError0xB6,
        OtherError0xB7,
        OtherError0xB8,
        OtherError0xB9,
        OtherError0xBA,
        OtherError0xBB,
        OtherError0xBC,
        OtherError0xBD,
        OtherError0xBE,
        OtherError0xBF,
        OtherError0xC0,
        OtherError0xC1,
        OtherError0xC2,
        OtherError0xC3,
        OtherError0xC4,
        OtherError0xC5,
        OtherError0xC6,
        OtherError0xC7,
        OtherError0xC8,
        OtherError0xC9,
        OtherError0xCA,
        OtherError0xCB,
        OtherError0xCC,
        OtherError0xCD,
        OtherError0xCE,
        OtherError0xCF,
        OtherError0xD0,
        OtherError0xD1,
        OtherError0xD2,
        OtherError0xD3,
        OtherError0xD4,
        OtherError0xD5,
        OtherError0xD6,
        OtherError0xD7,
        OtherError0xD8,
        OtherError0xD9,
        OtherError0xDA,
        OtherError0xDB,
        OtherError0xDC,
        OtherError0xDD,
        OtherError0xDE,
        OtherError0xDF,
        // Bridge errors: errors that only belong in inter-client communication
        /// 0xE0: Requests that cannot be parsed must always get this error as their result.
        /// However, this is not a valid result in a Tally transaction, because invalid requests
        /// are never included into blocks and therefore never get a Tally in response.
        BridgeMalformedRequest,
        /// 0xE1: Witnesses exceeds 100
        BridgePoorIncentives,
        /// 0xE2: The request is rejected on the grounds that it may cause the submitter to spend or stake an
        /// amount of value that is unjustifiably high when compared with the reward they will be getting
        BridgeOversizedResult,
        /// Unallocated
        OtherError0xE3,
        OtherError0xE4,
        OtherError0xE5,
        OtherError0xE6,
        OtherError0xE7,
        OtherError0xE8,
        OtherError0xE9,
        OtherError0xEA,
        OtherError0xEB,
        OtherError0xEC,
        OtherError0xED,
        OtherError0xEE,
        OtherError0xEF,
        OtherError0xF0,
        OtherError0xF1,
        OtherError0xF2,
        OtherError0xF3,
        OtherError0xF4,
        OtherError0xF5,
        OtherError0xF6,
        OtherError0xF7,
        OtherError0xF8,
        OtherError0xF9,
        OtherError0xFA,
        OtherError0xFB,
        OtherError0xFC,
        OtherError0xFD,
        OtherError0xFE,
        // This should not exist:
        /// 0xFF: Some tally error is not intercepted but should
        UnhandledIntercept
    }
}

File 8 of 18 : IWitnetRequest.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

/// @title The Witnet Data Request basic interface.
/// @author The Witnet Foundation.
interface IWitnetRequest {
    /// A `IWitnetRequest` is constructed around a `bytes` value containing 
    /// a well-formed Witnet Data Request using Protocol Buffers.
    function bytecode() external view returns (bytes memory);

    /// Returns SHA256 hash of Witnet Data Request as CBOR-encoded bytes.
    function hash() external view returns (bytes32);
}

File 9 of 18 : IWitnetRequestBoardView.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "Witnet.sol";

/// @title Witnet Request Board info interface.
/// @author The Witnet Foundation.
interface IWitnetRequestBoardView {
    /// Estimates the amount of reward we need to insert for a given gas price.
    /// @param _gasPrice The gas price for which we need to calculate the rewards.
    function estimateReward(uint256 _gasPrice) external view returns (uint256);

    /// Returns next query id to be generated by the Witnet Request Board.
    function getNextQueryId() external view returns (uint256);

    /// Gets the whole Query data contents, if any, no matter its current status.
    function getQueryData(uint256 _queryId) external view returns (Witnet.Query memory);

    /// Gets current status of given query.
    function getQueryStatus(uint256 _queryId) external view returns (Witnet.QueryStatus);

    /// Retrieves the whole Request record posted to the Witnet Request Board.
    /// @dev Fails if the `_queryId` is not valid or, if it has already been reported
    /// @dev or deleted.
    /// @param _queryId The unique identifier of a previously posted query.
    function readRequest(uint256 _queryId) external view returns (Witnet.Request memory);

    /// Retrieves the serialized bytecode of a previously posted Witnet Data Request.
    /// @dev Fails if the `_queryId` is not valid, or if the related script bytecode 
    /// @dev got changed after being posted. Returns empty array once it gets reported, 
    /// @dev or deleted.
    /// @param _queryId The unique query identifier.
    function readRequestBytecode(uint256 _queryId) external view returns (bytes memory);

    /// Retrieves the gas price that any assigned reporter will have to pay when reporting 
    /// result to a previously posted Witnet data request.
    /// @dev Fails if the `_queryId` is not valid or, if it has already been 
    /// @dev reported, or deleted. 
    /// @param _queryId The unique query identifie
    function readRequestGasPrice(uint256 _queryId) external view returns (uint256);

    /// Retrieves the reward currently set for the referred query.
    /// @dev Fails if the `_queryId` is not valid or, if it has already been 
    /// @dev reported, or deleted. 
    /// @param _queryId The unique query identifier.
    function readRequestReward(uint256 _queryId) external view returns (uint256);

    /// Retrieves the whole `Witnet.Response` record referred to a previously posted Witnet Data Request.
    /// @dev Fails if the `_queryId` is not in 'Reported' status.
    /// @param _queryId The unique query identifier.
    function readResponse(uint256 _queryId) external view returns (Witnet.Response memory);

    /// Retrieves the hash of the Witnet transaction hash that actually solved the referred query.
    /// @dev Fails if the `_queryId` is not in 'Reported' status.
    /// @param _queryId The unique query identifier.
    function readResponseDrTxHash(uint256 _queryId) external view returns (bytes32);    

    /// Retrieves the address that reported the result to a previously-posted request.
    /// @dev Fails if the `_queryId` is not in 'Reported' status.
    /// @param _queryId The unique query identifier.
    function readResponseReporter(uint256 _queryId) external view returns (address);

    /// Retrieves the Witnet-provided CBOR-bytes result of a previously posted request.
    /// @dev Fails if the `_queryId` is not in 'Reported' status.
    /// @param _queryId The unique query identifier.
    function readResponseResult(uint256 _queryId) external view returns (Witnet.Result memory);

    /// Retrieves the timestamp in which the result to the referred query was solved by the Witnet DON.
    /// @dev Fails if the `_queryId` is not in 'Reported' status.
    /// @param _queryId The unique query identifier.
    function readResponseTimestamp(uint256 _queryId) external view returns (uint256);
}

File 10 of 18 : IWitnetRequestParser.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;
pragma experimental ABIEncoderV2;

import "Witnet.sol";

/// @title The Witnet interface for decoding Witnet-provided request to Data Requests.
/// This interface exposes functions to check for the success/failure of
/// a Witnet-provided result, as well as to parse and convert result into
/// Solidity types suitable to the application level. 
/// @author The Witnet Foundation.
interface IWitnetRequestParser {

    /// Decode raw CBOR bytes into a Witnet.Result instance.
    /// @param _cborBytes Raw bytes representing a CBOR-encoded value.
    /// @return A `Witnet.Result` instance.
    function resultFromCborBytes(bytes memory _cborBytes) external pure returns (Witnet.Result memory);

    /// Decode a CBOR value into a Witnet.Result instance.
    /// @param _cborValue An instance of `Witnet.CBOR`.
    /// @return A `Witnet.Result` instance.
    function resultFromCborValue(Witnet.CBOR memory _cborValue) external pure returns (Witnet.Result memory);

    /// Tell if a Witnet.Result is successful.
    /// @param _result An instance of Witnet.Result.
    /// @return `true` if successful, `false` if errored.
    function isOk(Witnet.Result memory _result) external pure returns (bool);

    /// Tell if a Witnet.Result is errored.
    /// @param _result An instance of Witnet.Result.
    /// @return `true` if errored, `false` if successful.
    function isError(Witnet.Result memory _result) external pure returns (bool);

    /// Decode a bytes value from a Witnet.Result as a `bytes` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `bytes` decoded from the Witnet.Result.
    function asBytes(Witnet.Result memory _result) external pure returns (bytes memory);

    /// Decode a bytes value from a Witnet.Result as a `bytes32` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `bytes32` decoded from the Witnet.Result.
    function asBytes32(Witnet.Result memory _result) external pure returns (bytes32);

    /// Decode an error code from a Witnet.Result as a member of `Witnet.ErrorCodes`.
    /// @param _result An instance of `Witnet.Result`.
    /// @return The `CBORValue.Error memory` decoded from the Witnet.Result.
    function asErrorCode(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes);


    /// Generate a suitable error message for a member of `Witnet.ErrorCodes` and its corresponding arguments.
    /// @dev WARN: Note that client contracts should wrap this function into a try-catch foreseing potential errors generated in this function
    /// @param _result An instance of `Witnet.Result`.
    /// @return A tuple containing the `CBORValue.Error memory` decoded from the `Witnet.Result`, plus a loggable error message.
    function asErrorMessage(Witnet.Result memory _result) external pure returns (Witnet.ErrorCodes, string memory);

    /// Decode a raw error from a `Witnet.Result` as a `uint64[]`.
    /// @param _result An instance of `Witnet.Result`.
    /// @return The `uint64[]` raw error as decoded from the `Witnet.Result`.
    function asRawError(Witnet.Result memory _result) external pure returns(uint64[] memory);

    /// Decode a boolean value from a Witnet.Result as an `bool` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `bool` decoded from the Witnet.Result.
    function asBool(Witnet.Result memory _result) external pure returns (bool);

    /// Decode a fixed16 (half-precision) numeric value from a Witnet.Result as an `int32` value.
    /// @dev Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values.
    /// by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`.
    /// use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`.
    /// @param _result An instance of Witnet.Result.
    /// @return The `int128` decoded from the Witnet.Result.
    function asFixed16(Witnet.Result memory _result) external pure returns (int32);

    /// Decode an array of fixed16 values from a Witnet.Result as an `int128[]` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `int128[]` decoded from the Witnet.Result.
    function asFixed16Array(Witnet.Result memory _result) external pure returns (int32[] memory);

    /// Decode a integer numeric value from a Witnet.Result as an `int128` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `int128` decoded from the Witnet.Result.
    function asInt128(Witnet.Result memory _result) external pure returns (int128);

    /// Decode an array of integer numeric values from a Witnet.Result as an `int128[]` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `int128[]` decoded from the Witnet.Result.
    function asInt128Array(Witnet.Result memory _result) external pure returns (int128[] memory);

    /// Decode a string value from a Witnet.Result as a `string` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `string` decoded from the Witnet.Result.
    function asString(Witnet.Result memory _result) external pure returns (string memory);

    /// Decode an array of string values from a Witnet.Result as a `string[]` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `string[]` decoded from the Witnet.Result.
    function asStringArray(Witnet.Result memory _result) external pure returns (string[] memory);

    /// Decode a natural numeric value from a Witnet.Result as a `uint64` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `uint64` decoded from the Witnet.Result.
    function asUint64(Witnet.Result memory _result) external pure returns(uint64);

    /// Decode an array of natural numeric values from a Witnet.Result as a `uint64[]` value.
    /// @param _result An instance of Witnet.Result.
    /// @return The `uint64[]` decoded from the Witnet.Result.
    function asUint64Array(Witnet.Result memory _result) external pure returns (uint64[] memory);

}

File 11 of 18 : RngInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Random Number Generator Interface
 * @notice Provides an interface for requesting random numbers from 3rd-party RNG services (Chainlink VRF, Starkware VDF, etc..)
 */
interface RNGInterface {
  /**
   * @notice Emitted when a new request for a random number has been submitted
   * @param requestId The indexed ID of the request used to get the results of the RNG service
   * @param sender The indexed address of the sender of the request
   */
  event RandomNumberRequested(uint32 indexed requestId, address indexed sender);

  /**
   * @notice Emitted when an existing request for a random number has been completed
   * @param requestId The indexed ID of the request used to get the results of the RNG service
   * @param randomNumber The random number produced by the 3rd-party service
   */
  event RandomNumberCompleted(uint32 indexed requestId, uint256 randomNumber);

  /**
   * @notice Gets the last request id used by the RNG service
   * @return requestId The last request id used in the last request
   */
  function getLastRequestId() external view returns (uint32 requestId);

  /**
   * @notice Gets the Fee for making a Request against an RNG service
   * @return feeToken The address of the token that is used to pay fees
   * @return requestFee The fee required to be paid to make a request
   */
  function getRequestFee() external view returns (address feeToken, uint256 requestFee);

  /**
   * @notice Sends a request for a random number to the 3rd-party service
   * @dev Some services will complete the request immediately, others may have a time-delay
   * @dev Some services require payment in the form of a token, such as $LINK for Chainlink VRF
   * @return requestId The ID of the request used to get the results of the RNG service
   * @return lockBlock The block number at which the RNG service will start generating time-delayed randomness.
   * The calling contract should "lock" all activity until the result is available via the `requestId`
   */
  function requestRandomNumber() external returns (uint32 requestId, uint32 lockBlock);

  /**
   * @notice Checks if the request for randomness from the 3rd-party service has completed
   * @dev For time-delayed requests, this function is used to check/confirm completion
   * @param requestId The ID of the request used to get the results of the RNG service
   * @return isCompleted True if the request has completed and a random number is available, false otherwise
   */
  function isRequestComplete(uint32 requestId) external view returns (bool isCompleted);

  /**
   * @notice Gets the random number produced by the 3rd-party service
   * @param requestId The ID of the request used to get the results of the RNG service
   * @return randomNum The random number
   */
  function randomNumber(uint32 requestId) external returns (uint256 randomNum);
}

File 12 of 18 : WitnetRequestRandomness.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

import "WitnetRequestMalleableBase.sol";

contract WitnetRequestRandomness is WitnetRequestMalleableBase {
    bytes internal constant _WITNET_RANDOMNESS_BYTECODE_TEMPLATE = hex"0a0f120508021a01801a0210022202100b";

    constructor() {
        initialize(bytes(""));
    }

    function initialize(bytes memory)
        public
        virtual override
    {
        super.initialize(_WITNET_RANDOMNESS_BYTECODE_TEMPLATE);
    }
}

File 13 of 18 : WitnetRequestMalleableBase.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.7.0 <0.9.0;

import "Witnet.sol";
import "Clonable.sol";
import "Ownable.sol";
import "Proxiable.sol";

abstract contract WitnetRequestMalleableBase
    is
        IWitnetRequest,
        Clonable,
        Ownable,
        Proxiable
{
    using Witnet for bytes;

    event WitnessingParamsChanged(
        address indexed by,
        uint8 numWitnesses,
        uint8 minWitnessingConsensus,
        uint64 witnssingCollateral,
        uint64 witnessingReward,
        uint64 witnessingUnitaryFee
    );

    error requestAlreadyInitialized();
    error noWitnessingReward();
    error invalidNumWitnesses(uint8 _numWitnesses);
    error invalidWitnessingConsensus(uint8 _minWitnessingConsensus);
    error invalidWitnessingCollateral(uint64 _witnessingCollateral);

    struct WitnetRequestMalleableBaseContext {
        /// Contract owner address.
        address owner;
        /// Immutable bytecode template.
        bytes template;
        /// Current request bytecode.
        bytes bytecode;
        /// Current request hash.
        bytes32 hash;
        /// Current request witnessing params.
        WitnetRequestWitnessingParams params;
    }

    struct WitnetRequestWitnessingParams {
        /// Number of witnesses required to be involved for solving this Witnet Data Request.
        uint8 numWitnesses;

        /// Threshold percentage for aborting resolution of a request if the witnessing nodes did not arrive to a broad consensus.
        uint8 minWitnessingConsensus;

        /// Amount of nanowits that a witness solving the request will be required to collateralize in the commitment transaction.
        uint64 witnessingCollateral;

        /// Amount of nanowits that every request-solving witness will be rewarded with.
        uint64 witnessingReward;

        /// Amount of nanowits that will be earned by Witnet miners for each each valid commit/reveal transaction they include in a block.
        uint64 witnessingUnitaryFee;
    }

    /// Returns current Witnet Data Request bytecode, encoded using Protocol Buffers.
    function bytecode() external view override returns (bytes memory) {
        return _request().bytecode;
    }

    /// Returns SHA256 hash of current Witnet Data Request bytecode.
    function hash() external view override returns (bytes32) {
        return _request().hash;
    }

    /// Specifies how much you want to pay for rewarding each of the Witnet nodes.
    /// @param _witnessingCollateral Sets amount of nanowits that a witness solving the request will be required to collateralize.
    /// @param _witnessingReward Amount of nanowits that every request-solving witness will be rewarded with.
    /// @param _witnessingUnitaryFee Amount of nanowits that will be earned by Witnet miners for each each valid 
    /// commit/reveal transaction they include in a block.
    function setWitnessingMonetaryPolicy(uint64 _witnessingCollateral, uint64 _witnessingReward, uint64 _witnessingUnitaryFee)
        public
        virtual
        onlyOwner
    {
        WitnetRequestWitnessingParams storage _params = _request().params;
        _params.witnessingCollateral = _witnessingCollateral;
        _params.witnessingReward = _witnessingReward;
        _params.witnessingUnitaryFee = _witnessingUnitaryFee;
        _malleateBytecode(
            _params.numWitnesses,
            _params.minWitnessingConsensus,
            _witnessingCollateral,
            _witnessingReward,
            _witnessingUnitaryFee
        );
    }

    /// Sets how many Witnet nodes will be "hired" for resolving the request.
    /// @param _numWitnesses Number of witnesses required to be involved for solving this Witnet Data Request.
    /// @param _minWitnessingConsensus Threshold percentage for aborting resolution of a request if the witnessing 
    /// nodes did not arrive to a broad consensus.
    function setWitnessingQuorum(uint8 _numWitnesses, uint8 _minWitnessingConsensus)
        public
        virtual
        onlyOwner
    {
        WitnetRequestWitnessingParams storage _params = _request().params;
        _params.numWitnesses = _numWitnesses;
        _params.minWitnessingConsensus = _minWitnessingConsensus;
        _malleateBytecode(
            _numWitnesses,
            _minWitnessingConsensus,
            _params.witnessingCollateral,
            _params.witnessingReward,
            _params.witnessingUnitaryFee
        );
    }

    /// Sets all witness parameters for a request
    /// @param _witnessingCollateral: Amount of nanowits that a witness solving the request will be required to collateralize in the commitment transaction.
    /// @param _witnessingReward Amount of nanowits that every request-solving witness will be rewarded with.
    /// @param _witnessingUnitaryFee Amount of nanowits that will be earned by Witnet miners for each each valid 
    /// commit/reveal transaction they include in a block.
    /// @param _numWitnesses Number of witnesses required to be involved for solving this Witnet Data Request.
    /// @param _minWitnessingConsensus Threshold percentage for aborting resolution of a request if the witnessing 
    /// nodes did not arrive to a broad consensus.
    function setWitnessingParameters(uint64 _witnessingCollateral, uint64 _witnessingReward, uint64 _witnessingUnitaryFee, uint8 _numWitnesses, uint8 _minWitnessingConsensus)
        public
        virtual
        onlyOwner
    {
        WitnetRequestWitnessingParams storage _params = _request().params;
        _params.witnessingCollateral = _witnessingCollateral;
        _params.witnessingReward = _witnessingReward;
        _params.witnessingUnitaryFee = _witnessingUnitaryFee;
        _params.numWitnesses = _numWitnesses;
        _params.minWitnessingConsensus = _minWitnessingConsensus;
        _malleateBytecode(
            _numWitnesses,
            _minWitnessingConsensus,
            _witnessingCollateral,
            _witnessingReward,
            _witnessingUnitaryFee
        );
    }

    /// Returns immutable template bytecode: actual CBOR-encoded data request at the Witnet protocol
    /// level, including no witnessing parameters at all.
    function template()
        external view
        returns (bytes memory)
    {
        return _request().template;
    }

    /// Returns total amount of nanowits that witnessing nodes will need to collateralize all together.
    function totalWitnessingCollateral()
        external view
        returns (uint128)
    {
        WitnetRequestWitnessingParams storage _params = _request().params;
        return _params.numWitnesses * _params.witnessingCollateral;
    }

    /// Returns total amount of nanowits that will have to be paid in total for this request to be solved.
    function totalWitnessingFee()
        external view
        returns (uint128)
    {
        WitnetRequestWitnessingParams storage _params = _request().params;
        return _params.numWitnesses * (2 * _params.witnessingUnitaryFee + _params.witnessingReward);
    }

    /// Returns witnessing parameters of current Witnet Data Request.
    function witnessingParams()
        external view
        returns (WitnetRequestWitnessingParams memory)
    {
        return _request().params;
    }


    // ================================================================================================================
    // --- 'Clonable' overriden functions -----------------------------------------------------------------------------

    /// Deploys and returns the address of a minimal proxy clone that replicates contract
    /// behaviour while using its own EVM storage.
    /// @dev This function should always provide a new address, no matter how many times 
    /// @dev is actually called from the same `msg.sender`.
    function clone()
        public
        virtual override
        returns (Clonable _instance)
    {
        _instance = super.clone();
        _instance.initialize(_request().template);
        Ownable(address(_instance)).transferOwnership(msg.sender);
    }

    /// Deploys and returns the address of a minimal proxy clone that replicates contract 
    /// behaviour while using its own EVM storage.
    /// @dev This function uses the CREATE2 opcode and a `_salt` to deterministically deploy
    /// @dev the clone. Using the same `_salt` multiple time will revert, since
    /// @dev no contract can be deployed more than once at the same address.
    function cloneDeterministic(bytes32 _salt)
        public
        virtual override
        returns (Clonable _instance)
    {
        _instance = super.cloneDeterministic(_salt);
        _instance.initialize(_request().template);
        Ownable(address(_instance)).transferOwnership(msg.sender);
    }


    // ================================================================================================================
    // --- 'Initializable' overriden functions ------------------------------------------------------------------------

    /// @dev Initializes contract's storage context.
    function initialize(bytes memory _template)
        public
        virtual override
    {
        if (_request().template.length > 0)
            revert requestAlreadyInitialized();
        _initialize(_template);
        _transferOwnership(_msgSender());
    }

    // ================================================================================================================
    // --- 'Ownable' overriden functions ------------------------------------------------------------------------------

    /// Returns the address of the current owner.
    function owner()
        public view
        virtual override
        returns (address)
    {
        return _request().owner;
    }

    /// @dev Transfers ownership of the contract to a new account (`newOwner`).
    function _transferOwnership(address newOwner)
        internal
        virtual override
    {
        address oldOwner = _request().owner;
        _request().owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

    // ================================================================================================================
    // --- 'Proxiable 'overriden functions ----------------------------------------------------------------------------

    /// @dev Complying with EIP-1822: Universal Upgradable Proxy Standard (UUPS)
    /// @dev See https://eips.ethereum.org/EIPS/eip-1822.
    function proxiableUUID()
        external pure
        virtual override
        returns (bytes32)
    {
        return (
            /* keccak256("io.witnet.requests.malleable") */
            0x851d0a92a3ad30295bef33afc69d6874779826b7789386b336e22621365ed2c2
        );
    }


    // ================================================================================================================
    // --- INTERNAL FUNCTIONS -----------------------------------------------------------------------------------------    

    /// @dev Initializes witnessing params and template bytecode.
    function _initialize(bytes memory _template)
        internal
    {
        assert(_template.length > 0);
        _request().template = _template;

        WitnetRequestWitnessingParams storage _params = _request().params;
        _params.numWitnesses = 2;
        _params.minWitnessingConsensus = 51;
        _params.witnessingCollateral = 10 ** 9;      // 1 WIT
        _params.witnessingReward = 5 * 10 ** 5;      // 0.5 milliWITs
        _params.witnessingUnitaryFee = 25 * 10 ** 4; // 0.25 milliWITs

        _malleateBytecode(
            _params.numWitnesses,
            _params.minWitnessingConsensus,
            _params.witnessingCollateral,
            _params.witnessingReward,
            _params.witnessingUnitaryFee
        );
    }

    /// @dev Serializes new `bytecode` by combining immutable template with given parameters.
    function _malleateBytecode(
            uint8 _numWitnesses,
            uint8 _minWitnessingConsensus,
            uint64 _witnessingCollateral,
            uint64 _witnessingReward,
            uint64 _witnessingUnitaryFee
        )
        internal
        virtual
    {
        if (_witnessingReward == 0)
            revert noWitnessingReward();
        if (_numWitnesses > 125 || _numWitnesses == 0)
            revert invalidNumWitnesses(_numWitnesses);
        if (_minWitnessingConsensus < 51 || _minWitnessingConsensus > 99)
            revert invalidWitnessingConsensus(_minWitnessingConsensus);
        if (_witnessingCollateral < 10 ** 9)
            revert invalidWitnessingCollateral(_witnessingCollateral);

        _request().bytecode = abi.encodePacked(
            _request().template,
            _uint64varint(bytes1(0x10), _witnessingReward),
            _uint8varint(bytes1(0x18), _numWitnesses),
            _uint64varint(0x20, _witnessingUnitaryFee),
            _uint8varint(0x28, _minWitnessingConsensus),
            _uint64varint(0x30, _witnessingCollateral)
        );
        _request().hash = _request().bytecode.hash();
        emit WitnessingParamsChanged(
            msg.sender,
            _numWitnesses,
            _minWitnessingConsensus,
            _witnessingCollateral,
            _witnessingReward,
            _witnessingUnitaryFee
        );
    }

    /// @dev Returns pointer to storage slot where State struct is located.
    function _request()
        internal pure
        virtual
        returns (WitnetRequestMalleableBaseContext storage _ptr)
    {
        assembly {
            _ptr.slot :=
                /* keccak256("io.witnet.requests.malleable.context") */
                0x375930152e1d0d102998be6e496b0cee86c9ecd0efef01014ecff169b17dfba7
        }
    }

    /// @dev Encode uint64 into tagged varint.
    /// @dev See https://developers.google.com/protocol-buffers/docs/encoding#varints.
    /// @param t Tag
    /// @param n Number
    /// @return Marshaled bytes
    function _uint64varint(bytes1 t, uint64 n)
        internal pure
        returns (bytes memory)
    {
        // Count the number of groups of 7 bits
        // We need this pre-processing step since Solidity doesn't allow dynamic memory resizing
        uint64 tmp = n;
        uint64 numBytes = 2;
        while (tmp > 0x7F) {
            tmp = tmp >> 7;
            unchecked {
                numBytes += 1;
            }
        }
        bytes memory buf = new bytes(numBytes);
        tmp = n;
        buf[0] = t;
        for (uint64 i = 1; i < numBytes;) {
            // Set the first bit in the byte for each group of 7 bits
            buf[i] = bytes1(0x80 | uint8(tmp & 0x7F));
            tmp = tmp >> 7;
            unchecked {
                i++;
            }
        }
        // Unset the first bit of the last byte
        buf[numBytes - 1] &= 0x7F;
        return buf;
    }

    /// @dev Encode uint8 into tagged varint.
    /// @param t Tag
    /// @param n Number
    /// @return Marshaled bytes
    function _uint8varint(bytes1 t, uint8 n)
        internal pure
        returns (bytes memory)
    {
        return _uint64varint(t, uint64(n));
    }
}

File 14 of 18 : Clonable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.9.0;

import "Initializable.sol";

abstract contract Clonable is Initializable {
    /// Immutable contract address that actually attends all calls to this contract.
    /// @dev Differs from `address(this)` when reached within a DELEGATECALL.
    address immutable public self = address(this);

    event Cloned(address indexed by, Clonable indexed self, Clonable indexed clone);

    /// Tells whether this contract is a clone of another (i.e. `self()`)
    function cloned()
        public view
        returns (bool)
    {
        return (
            address(this) != self
        );
    }

    /// Deploys and returns the address of a minimal proxy clone that replicates contract
    /// behaviour while using its own EVM storage.
    /// @dev This function should always provide a new address, no matter how many times 
    /// @dev is actually called from the same `msg.sender`.
    /// @dev See https://eips.ethereum.org/EIPS/eip-1167.
    /// @dev See https://blog.openzeppelin.com/deep-dive-into-the-minimal-proxy-contract/.
    function clone()
        public virtual
        returns (Clonable _instance)
    {
        address _self = self;
        assembly {
            // ptr to free mem:
            let ptr := mload(0x40)
            // begin minimal proxy construction bytecode:
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            // make minimal proxy delegate all calls to `self()`:
            mstore(add(ptr, 0x14), shl(0x60, _self))
            // end minimal proxy construction bytecode:
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            // CREATE new instance:
            _instance := create(0, ptr, 0x37)
        }        
        require(address(_instance) != address(0), "Clonable: CREATE failed");
        emit Cloned(msg.sender, Clonable(self), _instance);
    }

    /// Deploys and returns the address of a minimal proxy clone that replicates contract 
    /// behaviour while using its own EVM storage.
    /// @dev This function uses the CREATE2 opcode and a `_salt` to deterministically deploy
    /// @dev the clone. Using the same `_salt` multiple times will revert, since
    /// @dev no contract can be deployed more than once at the same address.
    /// @dev See https://eips.ethereum.org/EIPS/eip-1167.
    /// @dev See https://blog.openzeppelin.com/deep-dive-into-the-minimal-proxy-contract/.
    function cloneDeterministic(bytes32 _salt)
        public virtual
        returns (Clonable _instance)
    {
        address _self = self;
        assembly {
            // ptr to free mem:
            let ptr := mload(0x40)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
            // make minimal proxy delegate all calls to `self()`:
            mstore(add(ptr, 0x14), shl(0x60, _self))
            // end minimal proxy construction bytecode:
            mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
            // CREATE2 new instance:
            _instance := create2(0, ptr, 0x37, _salt)
        }
        require(address(_instance) != address(0), "Clonable: CREATE2 failed");
        emit Cloned(msg.sender, Clonable(self), _instance);
    }
}

File 15 of 18 : Initializable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.9.0;

interface Initializable {
    /// @dev Initialize contract's storage context.
    function initialize(bytes calldata) external;
}

File 16 of 18 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.3.2 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "Context.sol";

/// @dev Contract module which provides a basic access control mechanism, where
/// there is an account (an owner) that can be granted exclusive access to
/// specific functions.
///
/// By default, the owner account will be the one that deploys the contract. This
/// can later be changed with {transferOwnership}.
///
/// This module is used through inheritance. It will make available the modifier
/// `onlyOwner`, which can be applied to your functions to restrict their use to
/// the owner.

abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /// @dev Initializes the contract setting the deployer as the initial owner.
    constructor() {
        _transferOwnership(_msgSender());
    }

    /// @dev Returns the address of the current owner.
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /// @dev Throws if called by any account other than the owner.
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /// @dev Leaves the contract without owner. It will not be possible to call
    /// `onlyOwner` functions anymore. Can only be called by the current owner.
    /// NOTE: Renouncing ownership will leave the contract without an owner,
    /// thereby removing any functionality that is only available to the owner.
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /// @dev Transfers ownership of the contract to a new account (`newOwner`).
    /// Can only be called by the current owner.
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /// @dev Transfers ownership of the contract to a new account (`newOwner`).
    /// Internal function without access restriction.
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 17 of 18 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @dev Provides information about the current execution context, including the
/// sender of the transaction and its data. While these are generally available
/// via msg.sender and msg.data, they should not be accessed in such a direct
/// manner, since when dealing with meta-transactions the account sending and
/// paying for execution may not be the actual sender (as far as an application
/// is concerned).
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _msgValue() internal view virtual returns (uint256) {
        return msg.value;
    }
}

File 18 of 18 : Proxiable.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.9.0;

interface Proxiable {
    /// @dev Complying with EIP-1822: Universal Upgradable Proxy Standard (UUPS)
    /// @dev See https://eips.ethereum.org/EIPS/eip-1822.
    function proxiableUUID() external pure returns (bytes32);
}

Settings
{
  "evmVersion": "london",
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "libraries": {
    "RngWitnet.sol": {}
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract WitnetRequestBoard","name":"_witnetRequestBoard","type":"address"},{"internalType":"contract WitnetRequestRandomness","name":"_witnetRequestRandomness","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256","name":"_balance","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"balanceTooLow","type":"error"},{"inputs":[{"internalType":"address","name":"_requester","type":"address"}],"name":"disallowedRequester","type":"error"},{"inputs":[{"internalType":"uint256","name":"_maxFee","type":"uint256"},{"internalType":"uint256","name":"_fee","type":"uint256"}],"name":"maxFeeTooLow","type":"error"},{"inputs":[{"internalType":"uint256","name":"_queryId","type":"uint256"}],"name":"randomnessNotAvailable","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"maxFee","type":"uint256"}],"name":"MaxFeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":false,"internalType":"uint256","name":"randomNumber","type":"uint256"}],"name":"RandomNumberCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"}],"name":"RandomNumberFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"}],"name":"RequesterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"requester","type":"address"}],"name":"RequesterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint32","name":"requestId","type":"uint32"},{"indexed":true,"internalType":"uint256","name":"witnetRequestId","type":"uint256"}],"name":"RngRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract WitnetRequestRandomness","name":"witnetRequestRandomness","type":"address"}],"name":"WitnetRequestRandomnessSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract WitnetRequestBoard","name":"witnetRequestBoard","type":"address"}],"name":"WrbSet","type":"event"},{"inputs":[{"internalType":"address","name":"_requester","type":"address"}],"name":"addAllowedRequester","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"name":"fetchRandomness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getLastRequestId","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getRequestFee","outputs":[{"internalType":"address","name":"feeToken","type":"address"},{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gasPrice","type":"uint256"}],"name":"getRequestFee","outputs":[{"internalType":"uint256","name":"requestFee","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"name":"isRngFetchable","outputs":[{"internalType":"bool","name":"isFetchable","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint32","name":"requestId","type":"uint32"}],"name":"randomNumber","outputs":[{"internalType":"uint256","name":"randomNum","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_requester","type":"address"}],"name":"removeAllowedRequester","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestCount","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxFee","type":"uint256"}],"name":"setMaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract WitnetRequestRandomness","name":"_witnetRequestRandomness","type":"address"}],"name":"setWitnetRequestRandomness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"witnet","outputs":[{"internalType":"contract WitnetRequestBoard","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"witnetRandomnessRequest","outputs":[{"internalType":"contract WitnetRequestRandomness","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523480156200001157600080fd5b506040516200171b3803806200171b83398101604081905262000034916200027f565b816001600160a01b038116620000905760405162461bcd60e51b815260206004820152601960248201527f5573696e675769746e65743a207a65726f206164647265737300000000000000604482015260640160405180910390fd5b60601b6001600160601b031916608052620000b2620000ac3390565b62000208565b6040516001600160a01b038316907f7afdccc159739ec774a24152aa98afb18f16d85a744656e76a1b42d35760c4a590600090a2806001600160a01b03166309ed46076040518163ffffffff1660e01b8152600401602060405180830381600087803b1580156200012257600080fd5b505af115801562000137573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200015d919062000258565b600180546001600160a01b0319166001600160a01b0392909216918217905560405163f2fde38b60e01b815233600482015263f2fde38b90602401600060405180830381600087803b158015620001b357600080fd5b505af1158015620001c8573d6000803e3d6000fd5b50506040516001600160a01b03841692507fc4e717786c682a15388f84eda226fbfa2bbf6ea8b15adbd768881e2cba1e184d9150600090a25050620002d7565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000602082840312156200026b57600080fd5b81516200027881620002be565b9392505050565b600080604083850312156200029357600080fd5b8251620002a081620002be565b6020840151909250620002b381620002be565b809150509250929050565b6001600160a01b0381168114620002d457600080fd5b50565b60805160601c6113fb620003206000396000818161026701528181610519015281816105c301528181610b6801528181610c0401528181610d850152610e6501526113fb6000f3fe6080604052600436106101235760003560e01c8063710e5d2f116100a05780638da5cb5b116100645780638da5cb5b146103a45780639d2a5f98146103c2578063ec6a2192146103f5578063f2fde38b14610415578063f7d235c41461043557600080fd5b8063710e5d2f146102fd578063715018a61461031d57806371f7846f146103325780637d934ed4146103525780638678a7b21461037257600080fd5b806346d1d21a116100e757806346d1d21a146102555780634df26a6e14610289578063543aba9e146102ab578063590e1ae3146102cb5780635badbe4c146102e057600080fd5b806301f59d16146101645780630d37b5371461018d57806319c2b4c3146101c15780633a19b9bc146101ed5780633b13e76e1461021d57600080fd5b3661015f5760405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b600080fd5b34801561017057600080fd5b5061017a60025481565b6040519081526020015b60405180910390f35b34801561019957600080fd5b506101a2610455565b604080516001600160a01b039093168352602083019190915201610184565b3480156101cd57600080fd5b5060035463ffffffff165b60405163ffffffff9091168152602001610184565b3480156101f957600080fd5b5061020d610208366004611187565b61046b565b6040519015158152602001610184565b34801561022957600080fd5b5060015461023d906001600160a01b031681565b6040516001600160a01b039091168152602001610184565b34801561026157600080fd5b5061023d7f000000000000000000000000000000000000000000000000000000000000000081565b34801561029557600080fd5b506102a96102a4366004611187565b6104bc565b005b3480156102b757600080fd5b506102a96102c6366004610f66565b6106ef565b3480156102d757600080fd5b506102a9610830565b3480156102ec57600080fd5b506003546101d89063ffffffff1681565b34801561030957600080fd5b506102a961031836600461116e565b610889565b34801561032957600080fd5b506102a96108e6565b34801561033e57600080fd5b5061020d61034d366004611187565b61091c565b34801561035e57600080fd5b5061017a61036d36600461116e565b610945565b34801561037e57600080fd5b50610387610956565b6040805163ffffffff938416815292909116602083015201610184565b3480156103b057600080fd5b506000546001600160a01b031661023d565b3480156103ce57600080fd5b5061017a6103dd366004611187565b63ffffffff1660009081526005602052604090205490565b34801561040157600080fd5b506102a9610410366004610f66565b6109ce565b34801561042157600080fd5b506102a9610430366004610f66565b610a44565b34801561044157600080fd5b506102a9610450366004610f66565b610adc565b600080600061046348610b4f565b915091509091565b63ffffffff81166000908152600760205260408120548015801590610494575061049481610bea565b80156104b5575063ffffffff831660009081526006602052604090205460ff165b9392505050565b63ffffffff81166000908152600760205260409020546104db81610bea565b6105005760405163012c123b60e71b8152600481018290526024015b60405180910390fd5b6040516335369a6b60e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063d4da69ac9060240160006040518083038186803b15801561056357600080fd5b505afa158015610577573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261059f9190810190610fda565b8051909150156106b95760405163cf62d11560e01b81526000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063cf62d115906105f89085906004016111d9565b60206040518083038186803b15801561061057600080fd5b505afa158015610624573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106489190610f83565b63ffffffff85166000818152600560209081526040808320859055600690915290819020805460ff1916600117905551919250907f629394f18de7accce1179c28c39be59503a57cbcf45980a2772743b041b36271906106ab9084815260200190565b60405180910390a250505050565b60405163ffffffff8416907f02023f7a63a4abc447a7167bfe48e72aa7acab88411756453d0da9320c3cdac290600090a2505050565b6000546001600160a01b031633146107195760405162461bcd60e51b81526004016104f7906111a4565b806001600160a01b03166309ed46076040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561075457600080fd5b505af1158015610768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078c9190610f9c565b600180546001600160a01b0319166001600160a01b0392909216918217905560405163f2fde38b60e01b815233600482015263f2fde38b90602401600060405180830381600087803b1580156107e157600080fd5b505af11580156107f5573d6000803e3d6000fd5b50506040516001600160a01b03841692507fc4e717786c682a15388f84eda226fbfa2bbf6ea8b15adbd768881e2cba1e184d9150600090a250565b6000546001600160a01b0316331461085a5760405162461bcd60e51b81526004016104f7906111a4565b60405133904780156108fc02916000818181858888f19350505050158015610886573d6000803e3d6000fd5b50565b6000546001600160a01b031633146108b35760405162461bcd60e51b81526004016104f7906111a4565b600281905560405181907fd0f8c51945dea723082a25e6655046533b6c6d26e9ac825098d4f8d5b6594f1b90600090a250565b6000546001600160a01b031633146109105760405162461bcd60e51b81526004016104f7906111a4565b61091a6000610c9e565b565b63ffffffff811660009081526007602052604081205480158015906104b557506104b581610bea565b600061095082610b4f565b92915050565b33600090815260046020526040812054819060ff1661098a576040516380bf169360e01b81523360048201526024016104f7565b5043610994610cee565b604051909250339063ffffffff8416907fcf635b20f2defc1e71326dc4f0b616fa676e29a5bae87da19fcaddc550b33f0390600090a39091565b6000546001600160a01b031633146109f85760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116600081815260046020526040808220805460ff19166001179055517f1616bf4c0898e95cbe6407827ef9ba6f5887a571df69e07eeda76b2b2a4f7daf9190a250565b6000546001600160a01b03163314610a6e5760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116610ad35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104f7565b61088681610c9e565b6000546001600160a01b03163314610b065760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116600081815260046020526040808220805460ff19169055517ffac6f04e18535b820487cce1312e5a45366b7326f7e956a9c48d70fecdde87619190a250565b60405163d2e8756160e01b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063d2e875619060240160206040518083038186803b158015610bb257600080fd5b505afa158015610bc6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190610f83565b60006002604051631bc1eaf360e21b8152600481018490527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690636f07abcc9060240160206040518083038186803b158015610c4e57600080fd5b505afa158015610c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c869190610fb9565b6003811115610c9757610c97611372565b1492915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080610cf9610e4d565b90506002548110610d2b576002546040516317f0f6c560e01b81526004810191909152602481018290526044016104f7565b80471015610d555760405163aa0bc9bb60e01b8152476004820152602481018290526044016104f7565b610d5d610eec565b60015460405163b281a7bd60e01b81526001600160a01b0391821660048201529193506000917f00000000000000000000000000000000000000000000000000000000000000009091169063b281a7bd9084906024016020604051808303818588803b158015610dcc57600080fd5b505af1158015610de0573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610e059190610f83565b63ffffffff84166000818152600760205260408082208490555192935083927ff6a58745e475eee85fb9eb6b263b211f4b159c9a488a3b460da87d04b999f58e9190a3505090565b60405163d2e8756160e01b81523a60048201526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063d2e875619060240160206040518083038186803b158015610eaf57600080fd5b505afa158015610ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee79190610f83565b905090565b6003805460009163ffffffff9091169082610f0683611340565b82546101009290920a63ffffffff8181021990931691831602179091556003541692915050565b8051610f38816113b3565b919050565b805167ffffffffffffffff81168114610f3857600080fd5b805160ff81168114610f3857600080fd5b600060208284031215610f7857600080fd5b81356104b58161139e565b600060208284031215610f9557600080fd5b5051919050565b600060208284031215610fae57600080fd5b81516104b58161139e565b600060208284031215610fcb57600080fd5b8151600481106104b557600080fd5b60006020808385031215610fed57600080fd5b825167ffffffffffffffff8082111561100557600080fd5b908401906040828703121561101957600080fd5b611021611293565b8251801515811461103157600080fd5b8152828401518281111561104457600080fd5b929092019160c0838803121561105957600080fd5b6110616112bc565b83518381111561107057600080fd5b84016040818a03121561108257600080fd5b61108a611293565b81518581111561109957600080fd5b8201601f81018b136110aa57600080fd5b8051868111156110bc576110bc611388565b6110ce601f8201601f19168a016112df565b96508087528b898284010111156110e457600080fd5b6110f3818a89018b8501611310565b5050848152611103878301610f2d565b81880152825250611115848601610f55565b8582015261112560408501610f55565b604082015261113660608501610f55565b606082015261114760808501610f3d565b608082015261115860a08501610f3d565b60a0820152938101939093525090949350505050565b60006020828403121561118057600080fd5b5035919050565b60006020828403121561119957600080fd5b81356104b5816113b3565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020808352835115158184015280840151604080850152805160c060608601528051604061012087015280518061016088015261018061122082828a01888601611310565b9285015163ffffffff166101408801529383015160ff9081166080808901919091526040850151821660a0808a0191909152606086015190921660c089015284015167ffffffffffffffff90811660e0890152930151909216610100860152601f909201601f1916909301019392505050565b6040805190810167ffffffffffffffff811182821017156112b6576112b6611388565b60405290565b60405160c0810167ffffffffffffffff811182821017156112b6576112b6611388565b604051601f8201601f1916810167ffffffffffffffff8111828210171561130857611308611388565b604052919050565b60005b8381101561132b578181015183820152602001611313565b8381111561133a576000848401525b50505050565b600063ffffffff8083168181141561136857634e487b7160e01b600052601160045260246000fd5b6001019392505050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461088657600080fd5b63ffffffff8116811461088657600080fdfea2646970667358221220068c714043b3000ad666850abcffd30f38d6cc37da07c1f11aeafb89a1dc8ab264736f6c634300080700330000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda000000000000000000000000b9c7d8dceca7c830bd0fef36cb9182822e165209

Deployed Bytecode

0x6080604052600436106101235760003560e01c8063710e5d2f116100a05780638da5cb5b116100645780638da5cb5b146103a45780639d2a5f98146103c2578063ec6a2192146103f5578063f2fde38b14610415578063f7d235c41461043557600080fd5b8063710e5d2f146102fd578063715018a61461031d57806371f7846f146103325780637d934ed4146103525780638678a7b21461037257600080fd5b806346d1d21a116100e757806346d1d21a146102555780634df26a6e14610289578063543aba9e146102ab578063590e1ae3146102cb5780635badbe4c146102e057600080fd5b806301f59d16146101645780630d37b5371461018d57806319c2b4c3146101c15780633a19b9bc146101ed5780633b13e76e1461021d57600080fd5b3661015f5760405134815233907f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258749060200160405180910390a2005b600080fd5b34801561017057600080fd5b5061017a60025481565b6040519081526020015b60405180910390f35b34801561019957600080fd5b506101a2610455565b604080516001600160a01b039093168352602083019190915201610184565b3480156101cd57600080fd5b5060035463ffffffff165b60405163ffffffff9091168152602001610184565b3480156101f957600080fd5b5061020d610208366004611187565b61046b565b6040519015158152602001610184565b34801561022957600080fd5b5060015461023d906001600160a01b031681565b6040516001600160a01b039091168152602001610184565b34801561026157600080fd5b5061023d7f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda81565b34801561029557600080fd5b506102a96102a4366004611187565b6104bc565b005b3480156102b757600080fd5b506102a96102c6366004610f66565b6106ef565b3480156102d757600080fd5b506102a9610830565b3480156102ec57600080fd5b506003546101d89063ffffffff1681565b34801561030957600080fd5b506102a961031836600461116e565b610889565b34801561032957600080fd5b506102a96108e6565b34801561033e57600080fd5b5061020d61034d366004611187565b61091c565b34801561035e57600080fd5b5061017a61036d36600461116e565b610945565b34801561037e57600080fd5b50610387610956565b6040805163ffffffff938416815292909116602083015201610184565b3480156103b057600080fd5b506000546001600160a01b031661023d565b3480156103ce57600080fd5b5061017a6103dd366004611187565b63ffffffff1660009081526005602052604090205490565b34801561040157600080fd5b506102a9610410366004610f66565b6109ce565b34801561042157600080fd5b506102a9610430366004610f66565b610a44565b34801561044157600080fd5b506102a9610450366004610f66565b610adc565b600080600061046348610b4f565b915091509091565b63ffffffff81166000908152600760205260408120548015801590610494575061049481610bea565b80156104b5575063ffffffff831660009081526006602052604090205460ff165b9392505050565b63ffffffff81166000908152600760205260409020546104db81610bea565b6105005760405163012c123b60e71b8152600481018290526024015b60405180910390fd5b6040516335369a6b60e21b8152600481018290526000907f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda6001600160a01b03169063d4da69ac9060240160006040518083038186803b15801561056357600080fd5b505afa158015610577573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261059f9190810190610fda565b8051909150156106b95760405163cf62d11560e01b81526000906001600160a01b037f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda169063cf62d115906105f89085906004016111d9565b60206040518083038186803b15801561061057600080fd5b505afa158015610624573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106489190610f83565b63ffffffff85166000818152600560209081526040808320859055600690915290819020805460ff1916600117905551919250907f629394f18de7accce1179c28c39be59503a57cbcf45980a2772743b041b36271906106ab9084815260200190565b60405180910390a250505050565b60405163ffffffff8416907f02023f7a63a4abc447a7167bfe48e72aa7acab88411756453d0da9320c3cdac290600090a2505050565b6000546001600160a01b031633146107195760405162461bcd60e51b81526004016104f7906111a4565b806001600160a01b03166309ed46076040518163ffffffff1660e01b8152600401602060405180830381600087803b15801561075457600080fd5b505af1158015610768573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061078c9190610f9c565b600180546001600160a01b0319166001600160a01b0392909216918217905560405163f2fde38b60e01b815233600482015263f2fde38b90602401600060405180830381600087803b1580156107e157600080fd5b505af11580156107f5573d6000803e3d6000fd5b50506040516001600160a01b03841692507fc4e717786c682a15388f84eda226fbfa2bbf6ea8b15adbd768881e2cba1e184d9150600090a250565b6000546001600160a01b0316331461085a5760405162461bcd60e51b81526004016104f7906111a4565b60405133904780156108fc02916000818181858888f19350505050158015610886573d6000803e3d6000fd5b50565b6000546001600160a01b031633146108b35760405162461bcd60e51b81526004016104f7906111a4565b600281905560405181907fd0f8c51945dea723082a25e6655046533b6c6d26e9ac825098d4f8d5b6594f1b90600090a250565b6000546001600160a01b031633146109105760405162461bcd60e51b81526004016104f7906111a4565b61091a6000610c9e565b565b63ffffffff811660009081526007602052604081205480158015906104b557506104b581610bea565b600061095082610b4f565b92915050565b33600090815260046020526040812054819060ff1661098a576040516380bf169360e01b81523360048201526024016104f7565b5043610994610cee565b604051909250339063ffffffff8416907fcf635b20f2defc1e71326dc4f0b616fa676e29a5bae87da19fcaddc550b33f0390600090a39091565b6000546001600160a01b031633146109f85760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116600081815260046020526040808220805460ff19166001179055517f1616bf4c0898e95cbe6407827ef9ba6f5887a571df69e07eeda76b2b2a4f7daf9190a250565b6000546001600160a01b03163314610a6e5760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116610ad35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104f7565b61088681610c9e565b6000546001600160a01b03163314610b065760405162461bcd60e51b81526004016104f7906111a4565b6001600160a01b038116600081815260046020526040808220805460ff19169055517ffac6f04e18535b820487cce1312e5a45366b7326f7e956a9c48d70fecdde87619190a250565b60405163d2e8756160e01b8152600481018290526000907f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda6001600160a01b03169063d2e875619060240160206040518083038186803b158015610bb257600080fd5b505afa158015610bc6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109509190610f83565b60006002604051631bc1eaf360e21b8152600481018490527f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda6001600160a01b031690636f07abcc9060240160206040518083038186803b158015610c4e57600080fd5b505afa158015610c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c869190610fb9565b6003811115610c9757610c97611372565b1492915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080610cf9610e4d565b90506002548110610d2b576002546040516317f0f6c560e01b81526004810191909152602481018290526044016104f7565b80471015610d555760405163aa0bc9bb60e01b8152476004820152602481018290526044016104f7565b610d5d610eec565b60015460405163b281a7bd60e01b81526001600160a01b0391821660048201529193506000917f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda9091169063b281a7bd9084906024016020604051808303818588803b158015610dcc57600080fd5b505af1158015610de0573d6000803e3d6000fd5b50505050506040513d601f19601f82011682018060405250810190610e059190610f83565b63ffffffff84166000818152600760205260408082208490555192935083927ff6a58745e475eee85fb9eb6b263b211f4b159c9a488a3b460da87d04b999f58e9190a3505090565b60405163d2e8756160e01b81523a60048201526000907f0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda6001600160a01b03169063d2e875619060240160206040518083038186803b158015610eaf57600080fd5b505afa158015610ec3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ee79190610f83565b905090565b6003805460009163ffffffff9091169082610f0683611340565b82546101009290920a63ffffffff8181021990931691831602179091556003541692915050565b8051610f38816113b3565b919050565b805167ffffffffffffffff81168114610f3857600080fd5b805160ff81168114610f3857600080fd5b600060208284031215610f7857600080fd5b81356104b58161139e565b600060208284031215610f9557600080fd5b5051919050565b600060208284031215610fae57600080fd5b81516104b58161139e565b600060208284031215610fcb57600080fd5b8151600481106104b557600080fd5b60006020808385031215610fed57600080fd5b825167ffffffffffffffff8082111561100557600080fd5b908401906040828703121561101957600080fd5b611021611293565b8251801515811461103157600080fd5b8152828401518281111561104457600080fd5b929092019160c0838803121561105957600080fd5b6110616112bc565b83518381111561107057600080fd5b84016040818a03121561108257600080fd5b61108a611293565b81518581111561109957600080fd5b8201601f81018b136110aa57600080fd5b8051868111156110bc576110bc611388565b6110ce601f8201601f19168a016112df565b96508087528b898284010111156110e457600080fd5b6110f3818a89018b8501611310565b5050848152611103878301610f2d565b81880152825250611115848601610f55565b8582015261112560408501610f55565b604082015261113660608501610f55565b606082015261114760808501610f3d565b608082015261115860a08501610f3d565b60a0820152938101939093525090949350505050565b60006020828403121561118057600080fd5b5035919050565b60006020828403121561119957600080fd5b81356104b5816113b3565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60006020808352835115158184015280840151604080850152805160c060608601528051604061012087015280518061016088015261018061122082828a01888601611310565b9285015163ffffffff166101408801529383015160ff9081166080808901919091526040850151821660a0808a0191909152606086015190921660c089015284015167ffffffffffffffff90811660e0890152930151909216610100860152601f909201601f1916909301019392505050565b6040805190810167ffffffffffffffff811182821017156112b6576112b6611388565b60405290565b60405160c0810167ffffffffffffffff811182821017156112b6576112b6611388565b604051601f8201601f1916810167ffffffffffffffff8111828210171561130857611308611388565b604052919050565b60005b8381101561132b578181015183820152602001611313565b8381111561133a576000848401525b50505050565b600063ffffffff8083168181141561136857634e487b7160e01b600052601160045260246000fd5b6001019392505050565b634e487b7160e01b600052602160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461088657600080fd5b63ffffffff8116811461088657600080fdfea2646970667358221220068c714043b3000ad666850abcffd30f38d6cc37da07c1f11aeafb89a1dc8ab264736f6c63430008070033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda000000000000000000000000b9c7d8dceca7c830bd0fef36cb9182822e165209

-----Decoded View---------------
Arg [0] : _witnetRequestBoard (address): 0x9E4fae1c7ac543a81E4E2a5486a0dDaad8194bdA
Arg [1] : _witnetRequestRandomness (address): 0xb9C7D8dcEca7C830Bd0feF36cb9182822e165209

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000009e4fae1c7ac543a81e4e2a5486a0ddaad8194bda
Arg [1] : 000000000000000000000000b9c7d8dceca7c830bd0fef36cb9182822e165209


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.