Contract 0xA932e74d5263A754Ea04432E5c53658434b0484B

Contract Overview

Balance:
0 Ether
Txn Hash
Method
Block
From
To
Value
0x1f7dc5d25b19952d21636735d997b04b7d1b6932f86a8d0958d483f682866948Random Number97682222021-12-06 16:09:46210 days 8 hrs ago0x62c751f207517c7f0f4f86720be4e4368f519d67 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00004773 1.00000001
0x666f0b5a5195f2943322964e9be8fd3858478651a340b511d1396015e126e70aRequest Random N...97682202021-12-06 16:09:16210 days 8 hrs ago0x62c751f207517c7f0f4f86720be4e4368f519d67 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00005045 1.00000001
0xc03fa71d6382e5b81fc9bf73fa22f40cbaee8169b2fa2963746b8b2a5d44d3a6Random Number97681572021-12-06 15:53:29210 days 8 hrs ago0x62c751f207517c7f0f4f86720be4e4368f519d67 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00002612 1.00000001
0x815c7752d61102ebb71924d3c16d0ef95aa86b8e77979eeedb604be79262caa2Request Random N...97679322021-12-06 14:57:11210 days 9 hrs ago0x62c751f207517c7f0f4f86720be4e4368f519d67 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00005045 1.00000001
0x615b61aaf486927bfa1f0b72de5b039e7c1f5c93cd70a0e40384735c17b00488Random Number93529162021-09-25 6:12:30282 days 18 hrs ago0x048d0bb5ad612f817a554f0ef56b0585e9460294 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00004773 1
0x3679a98086c02ff21e63788fe4ba0b73f42d111cd8818356dc6733e38a51a486Request Random N...93529102021-09-25 6:11:00282 days 18 hrs ago0x048d0bb5ad612f817a554f0ef56b0585e9460294 IN  0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether0.00005045 1
0xb3977be691623fd88bfb03a1e1e8dd2aaf564f45ce9af19669419e486460f1b30x6080604073525892020-10-11 19:46:13631 days 4 hrs ago0x7808d8cec54602f1b69a12a2804552edfadd1213 IN  Create: RNGBlockhash0 Ether0.0045113510
[ Download CSV Export 
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0x69aa1bdaa5bab6d158b21a7f1ad211fdde8438684362f0ad2d99af4c594c0539109682752022-07-05 0:32:1711 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x69aa1bdaa5bab6d158b21a7f1ad211fdde8438684362f0ad2d99af4c594c0539109682752022-07-05 0:32:1711 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x13d75af781ae326869c87ee2f6b269e609249ad6b63d6292fca60bfedfa76df5109681512022-07-05 0:01:1642 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x13d75af781ae326869c87ee2f6b269e609249ad6b63d6292fca60bfedfa76df5109681512022-07-05 0:01:1642 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xb5b31220ec3098d8d8cf6d8df43e7bb08a1b0c6812c6543df7cc5c017e89d99f109680312022-07-04 23:31:141 hr 12 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xb5b31220ec3098d8d8cf6d8df43e7bb08a1b0c6812c6543df7cc5c017e89d99f109680312022-07-04 23:31:141 hr 12 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xe2ba46708060b7eced0331db540de65a29e41686fde159b4f2e314b5b1a285fa109679072022-07-04 23:00:121 hr 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xe2ba46708060b7eced0331db540de65a29e41686fde159b4f2e314b5b1a285fa109679072022-07-04 23:00:121 hr 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xaa0677ad64238a452c9d02d30b314d46fe12cacf3a15d17518c5c42180df08ce109677872022-07-04 22:30:092 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xaa0677ad64238a452c9d02d30b314d46fe12cacf3a15d17518c5c42180df08ce109677872022-07-04 22:30:092 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x7b141261ae19c937f30fedb3553f9e6751a6700e2d7111a376b5cbb6830a6f7c109676682022-07-04 22:00:212 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x7b141261ae19c937f30fedb3553f9e6751a6700e2d7111a376b5cbb6830a6f7c109676682022-07-04 22:00:212 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x2bb4034d9c52c69f109bb8fb751192f5e19ec3acf3a0f43a81029c8cb92c93c3109675482022-07-04 21:30:193 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x2bb4034d9c52c69f109bb8fb751192f5e19ec3acf3a0f43a81029c8cb92c93c3109675482022-07-04 21:30:193 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xa6ac0fb231898f12a12c95d7195daae5d6db851b1ca188109cc1c727cdbea5da109674282022-07-04 21:00:143 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xa6ac0fb231898f12a12c95d7195daae5d6db851b1ca188109cc1c727cdbea5da109674282022-07-04 21:00:143 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x786e7915dd2ba192b6cad94f51c8ce69ff28fbd26dc51fb9f06ee7d290b2b16d109673092022-07-04 20:30:244 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x786e7915dd2ba192b6cad94f51c8ce69ff28fbd26dc51fb9f06ee7d290b2b16d109673092022-07-04 20:30:244 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x776f93c5de6076aac8f9b5ccbe8f13519fb7d3cc58fe83e400440361edcfad2d109671892022-07-04 20:00:194 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x776f93c5de6076aac8f9b5ccbe8f13519fb7d3cc58fe83e400440361edcfad2d109671892022-07-04 20:00:194 hrs 43 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x40aeecc66769342e92b9c72a736adf8e31ec48ada1b25ea0850bf2473c8d424c109670692022-07-04 19:30:175 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x40aeecc66769342e92b9c72a736adf8e31ec48ada1b25ea0850bf2473c8d424c109670692022-07-04 19:30:175 hrs 13 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x7f2ff2a8b6ffd5fbdeb07b21e50e49295b5a8e6cb1f7ab3bc9d035afa402ff7c109669452022-07-04 18:59:155 hrs 44 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0x7f2ff2a8b6ffd5fbdeb07b21e50e49295b5a8e6cb1f7ab3bc9d035afa402ff7c109669452022-07-04 18:59:155 hrs 44 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
0xd0c04ef0af128e12215c152d75931d62eb6e42bbe5e110d1f1381cb18f33793a109668252022-07-04 18:29:146 hrs 14 mins ago 0x422193556f47b17589325c50af478c724be976e2 0xa932e74d5263a754ea04432e5c53658434b0484b0 Ether
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
RNGBlockhash

Compiler Version
v0.6.6+commit.6c089d02

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, GNU GPLv3 license
File 1 of 6 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.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 GSN meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 2 of 6 : Ownable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

import "../GSN/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.
 */
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 () internal {
        address msgSender = _msgSender();
        _owner = msgSender;
        emit OwnershipTransferred(address(0), msgSender);
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view 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 {
        emit OwnershipTransferred(_owner, address(0));
        _owner = 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");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }
}

File 3 of 6 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction overflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers. Reverts with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 4 of 6 : SafeCast.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.6.0;


/**
 * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */
library SafeCast {

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        require(value >= 0, "SafeCast: value must be positive");
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     *
     * _Available since v3.1._
     */
    function toInt128(int256 value) internal pure returns (int128) {
        require(value >= -2**127 && value < 2**127, "SafeCast: value doesn\'t fit in 128 bits");
        return int128(value);
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     *
     * _Available since v3.1._
     */
    function toInt64(int256 value) internal pure returns (int64) {
        require(value >= -2**63 && value < 2**63, "SafeCast: value doesn\'t fit in 64 bits");
        return int64(value);
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     *
     * _Available since v3.1._
     */
    function toInt32(int256 value) internal pure returns (int32) {
        require(value >= -2**31 && value < 2**31, "SafeCast: value doesn\'t fit in 32 bits");
        return int32(value);
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     *
     * _Available since v3.1._
     */
    function toInt16(int256 value) internal pure returns (int16) {
        require(value >= -2**15 && value < 2**15, "SafeCast: value doesn\'t fit in 16 bits");
        return int16(value);
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits.
     *
     * _Available since v3.1._
     */
    function toInt8(int256 value) internal pure returns (int8) {
        require(value >= -2**7 && value < 2**7, "SafeCast: value doesn\'t fit in 8 bits");
        return int8(value);
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        require(value < 2**255, "SafeCast: value doesn't fit in an int256");
        return int256(value);
    }
}

File 5 of 6 : RNGBlockhash.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.6.6;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/SafeCast.sol";

import "./RNGInterface.sol";

contract RNGBlockhash is RNGInterface, Ownable {
  using SafeMath for uint256;
  using SafeCast for uint256;

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

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

  /// @dev A list of blocks to be locked at based on past requests mapped by request id
  mapping(uint32 => uint32) internal requestLockBlock;

  /// @notice Public constructor
  constructor() public { }

  /// @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 override view returns (uint32 requestId) {
    return requestCount;
  }

  /// @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 override view returns (address feeToken, uint256 requestFee) {
    return (address(0), 0);
  }

  /// @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 virtual override returns (uint32 requestId, uint32 lockBlock) {
    requestId = _getNextRequestId();
    lockBlock = uint32(block.number);

    requestLockBlock[requestId] = lockBlock;

    emit RandomNumberRequested(requestId, msg.sender);
  }

  /// @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 virtual override view returns (bool isCompleted) {
    return _isRequestComplete(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 virtual override returns (uint256 randomNum) {
    require(_isRequestComplete(requestId), "RNGBlockhash/request-incomplete");

    if (randomNumbers[requestId] == 0) {
      _storeResult(requestId, _getSeed());
    }

    return randomNumbers[requestId];
  }

  /// @dev Checks if the request for randomness from the 3rd-party service has completed
  /// @param requestId The ID of the request used to get the results of the RNG service
  /// @return True if the request has completed and a random number is available, false otherwise
  function _isRequestComplete(uint32 requestId) internal view returns (bool) {
    return block.number > (requestLockBlock[requestId] + 1);
  }

  /// @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 = uint256(requestCount).add(1).toUint32();
    requestId = requestCount;
  }

  /// @dev Gets a seed for a random number from the latest available blockhash
  /// @return seed The seed to be used for generating a random number
  function _getSeed() internal virtual view returns (uint256 seed) {
    return uint256(blockhash(block.number - 1));
  }

  /// @dev Stores the latest random number by request ID and logs the event
  /// @param requestId The ID of the request to store the random number
  /// @param result The random number for the request ID
  function _storeResult(uint32 requestId, uint256 result) internal {
    // Store random value
    randomNumbers[requestId] = result;

    emit RandomNumberCompleted(requestId, result);
  }
}

File 6 of 6 : RNGInterface.sol
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.6.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);
}

Settings
{
  "evmVersion": "istanbul",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs",
    "useLiteralContent": true
  },
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "remappings": [],
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"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"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RandomNumberRequested","type":"event"},{"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":"uint32","name":"requestId","type":"uint32"}],"name":"isRequestComplete","outputs":[{"internalType":"bool","name":"isCompleted","type":"bool"}],"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":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"requestRandomNumber","outputs":[{"internalType":"uint32","name":"requestId","type":"uint32"},{"internalType":"uint32","name":"lockBlock","type":"uint32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5060006100246001600160e01b0361007316565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350610077565b3390565b6106c3806100866000396000f3fe608060405234801561001057600080fd5b50600436106100885760003560e01c80638678a7b21161005b5780638678a7b21461011a5780638da5cb5b146101455780639d2a5f9814610169578063f2fde38b1461019e57610088565b80630d37b5371461008d57806319c2b4c3146100b85780633a19b9bc146100d9578063715018a614610110575b600080fd5b6100956101c4565b604080516001600160a01b03909316835260208301919091528051918290030190f35b6100c06101cb565b6040805163ffffffff9092168252519081900360200190f35b6100fc600480360360208110156100ef57600080fd5b503563ffffffff166101de565b604080519115158252519081900360200190f35b6101186101ef565b005b6101226102a3565b6040805163ffffffff938416815291909216602082015281519081900390910190f35b61014d610307565b604080516001600160a01b039092168252519081900360200190f35b61018c6004803603602081101561017f57600080fd5b503563ffffffff16610316565b60408051918252519081900360200190f35b610118600480360360208110156101b457600080fd5b50356001600160a01b03166103b6565b6000809091565b600054600160a01b900463ffffffff1690565b60006101e9826104c0565b92915050565b6101f76104e2565b6000546001600160a01b03908116911614610259576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b6000806102ae6104e6565b63ffffffff818116600081815260026020526040808220805463ffffffff19164395861617905551939550919350339290917fcf635b20f2defc1e71326dc4f0b616fa676e29a5bae87da19fcaddc550b33f0391a39091565b6000546001600160a01b031690565b6000610321826104c0565b610372576040805162461bcd60e51b815260206004820152601f60248201527f524e47426c6f636b686173682f726571756573742d696e636f6d706c65746500604482015290519081900360640190fd5b63ffffffff821660009081526001602052604090205461039d5761039d8261039861053d565b610546565b5063ffffffff1660009081526001602052604090205490565b6103be6104e2565b6000546001600160a01b03908116911614610420576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b6001600160a01b0381166104655760405162461bcd60e51b81526004018080602001828103825260268152602001806106426026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b63ffffffff908116600090815260026020526040902054811660010116431190565b3390565b600080546105109061050b9063ffffffff600160a01b90910481169060019061059716565b6105f8565b6000805463ffffffff60a01b1916600160a01b63ffffffff93841681029190911791829055900416919050565b60001943014090565b63ffffffff8216600081815260016020908152604091829020849055815184815291517f629394f18de7accce1179c28c39be59503a57cbcf45980a2772743b041b362719281900390910190a25050565b6000828201838110156105f1576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6000640100000000821061063d5760405162461bcd60e51b81526004018080602001828103825260268152602001806106686026913960400191505060405180910390fd5b509056fe4f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737353616665436173743a2076616c756520646f65736e27742066697420696e2033322062697473a2646970667358221220da9756ea6235c31ce2c22e7387ddf5d83dc4e14bf7c378e155090ad5109ad18d64736f6c63430006060033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading

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.