Source Code
Overview
ETH Balance
More Info
ContractCreator
Multichain Info
N/A
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
8127550 | 9 days ago | 0 ETH | ||||
8127548 | 9 days ago | 0 ETH | ||||
8127548 | 9 days ago | 0 ETH | ||||
8127538 | 9 days ago | 0 ETH | ||||
8127534 | 9 days ago | 0 ETH | ||||
8127534 | 9 days ago | 0 ETH | ||||
8127526 | 9 days ago | 0 ETH | ||||
8127523 | 9 days ago | 0 ETH | ||||
8127523 | 9 days ago | 0 ETH | ||||
8127461 | 9 days ago | 0 ETH | ||||
8127457 | 9 days ago | 0 ETH | ||||
8127457 | 9 days ago | 0 ETH | ||||
8127448 | 9 days ago | 0 ETH | ||||
8127445 | 9 days ago | 0 ETH | ||||
8127445 | 9 days ago | 0 ETH | ||||
8127438 | 9 days ago | 0 ETH | ||||
8127434 | 9 days ago | 0 ETH | ||||
8127434 | 9 days ago | 0 ETH | ||||
8127408 | 9 days ago | 0 ETH | ||||
8127404 | 9 days ago | 0 ETH | ||||
8127404 | 9 days ago | 0 ETH | ||||
8127391 | 9 days ago | 0 ETH | ||||
8127387 | 9 days ago | 0 ETH | ||||
8127387 | 9 days ago | 0 ETH | ||||
8127362 | 9 days ago | 0 ETH |
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
Anyrand
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import {Ownable} from "solady/src/auth/Ownable.sol"; import {ReentrancyGuardUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol"; import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; import {Gas} from "./lib/Gas.sol"; import {ITypeAndVersion} from "./interfaces/ITypeAndVersion.sol"; import {IRandomiserCallbackV3} from "./interfaces/IRandomiserCallbackV3.sol"; import {AnyrandStorage} from "./AnyrandStorage.sol"; import {IGasStation} from "./interfaces/IGasStation.sol"; import {IDrandBeacon} from "./interfaces/IDrandBeacon.sol"; /// @title Anyrand /// @author Kevin Charm ([email protected]) /// @notice Coordinator for requesting and receiving verified randomness from /// a drand (https://drand.love) beacon. contract Anyrand is AnyrandStorage, ITypeAndVersion, Ownable, UUPSUpgradeable, ReentrancyGuardUpgradeable { constructor() { _disableInitializers(); } /// @notice Initialise the contract /// @param beacon_ The address of contract with drand beacon data /// @param requestPremiumMultiplierBps_ The percentage multiplier applied /// to the raw tx cost /// @param maxCallbackGasLimit_ The maximum callback gas limit /// @param maxDeadlineDelta_ The maximum deadline delta /// @param gasStation_ The address of the gas station /// @param maxFeePerGas_ The maximum effective fee per gas for requests function init( address beacon_, uint256 requestPremiumMultiplierBps_, uint256 maxCallbackGasLimit_, uint256 maxDeadlineDelta_, address gasStation_, uint256 maxFeePerGas_ ) public initializer { __UUPSUpgradeable_init(); // solady/auth/Ownable requires explicit initialisation _initializeOwner(msg.sender); MainStorage storage $ = _getMainStorage(); _setBeacon(beacon_); $.nextRequestId = 1; $.requestPremiumMultiplierBps = requestPremiumMultiplierBps_; emit RequestPremiumMultiplierUpdated(requestPremiumMultiplierBps_); $.maxCallbackGasLimit = maxCallbackGasLimit_; emit MaxCallbackGasLimitUpdated(maxCallbackGasLimit_); $.maxDeadlineDelta = maxDeadlineDelta_; emit MaxDeadlineDeltaUpdated(maxDeadlineDelta_); $.gasStation = gasStation_; emit GasStationUpdated(gasStation_); $.maxFeePerGas = maxFeePerGas_; emit MaxFeePerGasUpdated(maxFeePerGas_); } /// @inheritdoc UUPSUpgradeable function _authorizeUpgrade( address newImplementation ) internal override onlyOwner {} /// @notice See {ITypeAndVersion-typeAndVersion} function typeAndVersion() external pure returns (string memory) { return "Anyrand 1.0.0"; } /// @notice Compute keccak256 of a request /// @param requestId Request id, acts as a nonce /// @param requester Address of contract that initiated the request. /// @param pubKeyHash hash of the beacon's public key /// @param round Target round of the drand beacon. /// @param callbackGasLimit Gas limit for callback function _hashRequest( uint256 requestId, address requester, bytes32 pubKeyHash, uint256 round, uint256 callbackGasLimit ) internal view returns (bytes32) { return keccak256( abi.encode( block.chainid, address(this), requestId, requester, pubKeyHash, round, callbackGasLimit ) ); } /// @notice Withdraw ETH /// @param amount Amount of ETH (in wei) to withdraw. Input 0 /// to withdraw entire balance function withdrawETH(uint256 amount) external onlyOwner { if (amount == 0) { amount = address(this).balance; } (bool success, ) = msg.sender.call{value: amount}(""); if (!success) { revert TransferFailed(msg.sender, amount); } emit ETHWithdrawn(amount); } /// @notice Compute the total request price. /// @notice NB: The gas calculation uses `tx.gasprice`, so gas prices must /// be explicitly specified if calling this function statically! /// Calling this function from a block explorer will give an incorrect /// price. /// @param callbackGasLimit The callback gas limit that will be used for /// the randomness request function getRequestPrice( uint256 callbackGasLimit ) public view virtual returns (uint256, uint256) { MainStorage storage $ = _getMainStorage(); (uint256 rawTxCost, uint256 effectiveFeePerGas) = IGasStation( $.gasStation ).getTxCost( 200_000 /** fulfillRandomness overhead */ + callbackGasLimit ); uint256 totalCost = (rawTxCost * $.requestPremiumMultiplierBps) / 1e4; if (effectiveFeePerGas > $.maxFeePerGas) { // Cap gas price at maxFeePerGas (keeper will only fulfill when gas // price <= maxFeePerGas) // Importantly, fulfilment is permissionless, so it's possible to // override this behaviour and fulfill randomness even when the // keeper refuses to. totalCost = $.maxFeePerGas * callbackGasLimit; effectiveFeePerGas = $.maxFeePerGas; } return (totalCost, effectiveFeePerGas); } /// @notice Compute the drand beacon round given a genesis timestamp, /// deadline and period. /// @param genesis The genesis timestamp of the drand beacon /// @param deadline The deadline timestamp after which the randomness will /// be available /// @param period The period of the drand beacon function getRound( uint256 genesis, uint256 deadline, uint256 period ) public pure returns (uint64) { uint256 delta = deadline - genesis; return uint64(delta / period + (delta % period > 0 ? 1 : 0)); } /// @notice Request randomness. Note that the fulfilment of the request will /// always be *after* the deadline, but never before. /// @param deadline Timestamp of when the randomness should be fulfilled. A /// beacon round closest to this timestamp (rounding up to the nearest /// future round) will be used as the round from which to derive /// randomness. /// @param callbackGasLimit Gas limit for callback function requestRandomness( uint256 deadline, uint256 callbackGasLimit ) external payable override nonReentrant returns (uint256) { // Compute the total request price (including the premium) that will be // used to cover the keeper's costs (uint256 reqPrice, uint256 effectiveFeePerGas) = getRequestPrice( callbackGasLimit ); if (msg.value != reqPrice) { revert IncorrectPayment(msg.value, reqPrice); } MainStorage storage $ = _getMainStorage(); if (callbackGasLimit > $.maxCallbackGasLimit) { revert OverGasLimit(callbackGasLimit); } bytes32 pubKeyHash = $.currentBeaconPubKeyHash; // Here we find the nearest round uint64 round; { IDrandBeacon drandBeacon = IDrandBeacon($.beacons[pubKeyHash]); pubKeyHash = drandBeacon.publicKeyHash(); uint256 genesis = drandBeacon.genesisTimestamp(); uint256 period = drandBeacon.period(); if ( (deadline > block.timestamp + $.maxDeadlineDelta) || (deadline < genesis) || deadline < (block.timestamp + period) ) { revert InvalidDeadline(deadline); } // Calculate nearest round from deadline (rounding to the future) round = getRound(genesis, deadline, period); } // Record the commitment of this request uint256 requestId = $.nextRequestId++; assert($.requestStates[requestId] == RequestState.Nonexistent); $.requestStates[requestId] = RequestState.Pending; $.requests[requestId] = _hashRequest( requestId, msg.sender, pubKeyHash, round, callbackGasLimit ); emit RandomnessRequested( requestId, msg.sender, pubKeyHash, round, callbackGasLimit, reqPrice, effectiveFeePerGas ); return requestId; } /// @notice Call a function, forwarding an exact amount of gas, whilst also /// measuring how much gas was actually used. /// @param callbackGasLimit The amount of gas to use /// @param target The address to call /// @param data The data to send /// @return success Whether the call succeeded /// @return gasUsed The amount of gas used function _callWithExactGas( uint256 callbackGasLimit, address target, bytes memory data ) private returns (bool success, uint256 gasUsed) { gasUsed = gasleft(); success = Gas.callWithExactGas(callbackGasLimit, target, data); gasUsed -= gasleft(); } /// @notice Fulfill a randomness request (for beacon keepers). /// @notice Note that fulfilment only depends on the validity of the BLS /// signature over the expected beacon round, and DOES NOT check /// the block timestamp against that round. /// @param requestId Which request id to fulfill /// @param requester Address of account that initiated the request. /// @param round Target round of the drand beacon. /// @param callbackGasLimit Gas limit for callback /// @param signature Beacon signature of the round, from which randomness /// is derived. function fulfillRandomness( uint256 requestId, address requester, bytes32 pubKeyHash, uint256 round, uint256 callbackGasLimit, uint256[2] calldata signature ) external nonReentrant { MainStorage storage $ = _getMainStorage(); // Ensure the request is in the correct state if ($.requestStates[requestId] != RequestState.Pending) { revert InvalidRequestState($.requestStates[requestId]); } // The inputs provided by the keeper must match the commitment we // recorded when the request was made. bytes32 reqHash = _hashRequest( requestId, requester, pubKeyHash, round, callbackGasLimit ); if ($.requests[requestId] != reqHash) { revert InvalidRequestHash(reqHash); } // Nullify the request hash; fulfilments must never be replayable $.requests[requestId] = bytes32(0); // Beacon verification: we check that the signature over the round is // valid for the given pubkey. IDrandBeacon($.beacons[pubKeyHash]).verifyBeaconRound(round, signature); // Derive randomness from the signature uint256 randomness = uint256( keccak256( abi.encode( signature[0] /** entropy */, signature[1] /** entropy */, block.chainid /** domain separator */, address(this) /** salt */, requestId /** salt */, requester /** salt */ ) ) ); (bool didCallbackSucceed, uint256 gasUsed) = _callWithExactGas( callbackGasLimit, requester, abi.encodePacked( IRandomiserCallbackV3.receiveRandomness.selector, abi.encode(requestId, randomness) ) ); if (!didCallbackSucceed) { // The following code is to help debug any issues that occur in the // case that the callback fails. bytes32 retdata; assembly { function min(a, b) -> c { switch lt(a, b) case 1 { c := a } default { c := b } } mstore(0, 0) // Copy a maximum of 32B from returndata, to ease debugging let r := returndatasize() returndatacopy(0, 0, min(r, 32)) retdata := mload(0) } emit RandomnessCallbackFailed( requestId, retdata, callbackGasLimit, gasUsed ); $.requestStates[requestId] = RequestState.Failed; } else { $.requestStates[requestId] = RequestState.Fulfilled; } emit RandomnessFulfilled( requestId, randomness, didCallbackSucceed, gasUsed ); } /// @notice Get the state of a request /// @param requestId The request identifier function getRequestState( uint256 requestId ) external view returns (RequestState) { MainStorage storage $ = _getMainStorage(); return $.requestStates[requestId]; } /// @notice Add a new beacon and set the current beacon to it /// @param newBeacon The new beacon function _setBeacon(address newBeacon) internal { // Sanity check try IDrandBeacon(newBeacon).publicKeyHash() returns ( bytes32 pubKeyHash ) { if (pubKeyHash == bytes32(0) || pubKeyHash == keccak256(hex"")) { revert InvalidBeacon(newBeacon); } // Looks good - add the beacon and update it MainStorage storage $ = _getMainStorage(); $.beacons[pubKeyHash] = newBeacon; $.currentBeaconPubKeyHash = pubKeyHash; emit BeaconUpdated(newBeacon); } catch { revert InvalidBeacon(newBeacon); } } /////////////////////////////////////////////////////////////////////////// /// Privileged setters //////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// /// @notice Add a new beacon and set the current beacon to it (privileged) /// @notice This is intended to be used only in the case that the evmnet /// beacon is deprecated in favour of the BLS12-381 beacon. /// @notice NB: This can replace/fix a beacon that is known to this /// contract by its public key hash. /// @param newBeacon The new beacon function setBeacon(address newBeacon) external onlyOwner { _setBeacon(newBeacon); } /// @notice Update request price /// @param newRequestPremiumMultiplierBps The new request premium multiplier function setRequestPremiumMultiplierBps( uint256 newRequestPremiumMultiplierBps ) external onlyOwner { MainStorage storage $ = _getMainStorage(); $.requestPremiumMultiplierBps = newRequestPremiumMultiplierBps; emit RequestPremiumMultiplierUpdated(newRequestPremiumMultiplierBps); } /// @notice Update max callback gas limit /// @param newMaxCallbackGasLimit The new max callback gas limit function setMaxCallbackGasLimit( uint256 newMaxCallbackGasLimit ) external onlyOwner { MainStorage storage $ = _getMainStorage(); $.maxCallbackGasLimit = newMaxCallbackGasLimit; emit MaxCallbackGasLimitUpdated(newMaxCallbackGasLimit); } /// @notice Update max deadline delta /// @param newMaxDeadlineDelta The new max deadline delta function setMaxDeadlineDelta( uint256 newMaxDeadlineDelta ) external onlyOwner { MainStorage storage $ = _getMainStorage(); $.maxDeadlineDelta = newMaxDeadlineDelta; emit MaxDeadlineDeltaUpdated(newMaxDeadlineDelta); } /// @notice Set the gas station /// @param newGasStation The new gas station function setGasStation(address newGasStation) external onlyOwner { MainStorage storage $ = _getMainStorage(); $.gasStation = newGasStation; emit GasStationUpdated(newGasStation); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.20; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Storage of the initializable contract. * * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions * when using with upgradeable contracts. * * @custom:storage-location erc7201:openzeppelin.storage.Initializable */ struct InitializableStorage { /** * @dev Indicates that the contract has been initialized. */ uint64 _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00; /** * @dev The contract is already initialized. */ error InvalidInitialization(); /** * @dev The contract is not initializing. */ error NotInitializing(); /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint64 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in * production. * * Emits an {Initialized} event. */ modifier initializer() { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); // Cache values to avoid duplicated sloads bool isTopLevelCall = !$._initializing; uint64 initialized = $._initialized; // Allowed calls: // - initialSetup: the contract is not in the initializing state and no previous version was // initialized // - construction: the contract is initialized at version 1 (no reininitialization) and the // current contract is just being deployed bool initialSetup = initialized == 0 && isTopLevelCall; bool construction = initialized == 1 && address(this).code.length == 0; if (!initialSetup && !construction) { revert InvalidInitialization(); } $._initialized = 1; if (isTopLevelCall) { $._initializing = true; } _; if (isTopLevelCall) { $._initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint64 version) { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing || $._initialized >= version) { revert InvalidInitialization(); } $._initialized = version; $._initializing = true; _; $._initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { _checkInitializing(); _; } /** * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}. */ function _checkInitializing() internal view virtual { if (!_isInitializing()) { revert NotInitializing(); } } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { // solhint-disable-next-line var-name-mixedcase InitializableStorage storage $ = _getInitializableStorage(); if ($._initializing) { revert InvalidInitialization(); } if ($._initialized != type(uint64).max) { $._initialized = type(uint64).max; emit Initialized(type(uint64).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint64) { return _getInitializableStorage()._initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _getInitializableStorage()._initializing; } /** * @dev Returns a pointer to the storage namespace. */ // solhint-disable-next-line var-name-mixedcase function _getInitializableStorage() private pure returns (InitializableStorage storage $) { assembly { $.slot := INITIALIZABLE_STORAGE } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/UUPSUpgradeable.sol) pragma solidity ^0.8.20; import {IERC1822Proxiable} from "@openzeppelin/contracts/interfaces/draft-IERC1822.sol"; import {ERC1967Utils} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Utils.sol"; import {Initializable} from "./Initializable.sol"; /** * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy. * * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing * `UUPSUpgradeable` with a custom implementation of upgrades. * * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism. */ abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable { /// @custom:oz-upgrades-unsafe-allow state-variable-immutable address private immutable __self = address(this); /** * @dev The version of the upgrade interface of the contract. If this getter is missing, both `upgradeTo(address)` * and `upgradeToAndCall(address,bytes)` are present, and `upgradeTo` must be used if no function should be called, * while `upgradeToAndCall` will invoke the `receive` function if the second argument is the empty byte string. * If the getter returns `"5.0.0"`, only `upgradeToAndCall(address,bytes)` is present, and the second argument must * be the empty byte string if no function should be called, making it impossible to invoke the `receive` function * during an upgrade. */ string public constant UPGRADE_INTERFACE_VERSION = "5.0.0"; /** * @dev The call is from an unauthorized context. */ error UUPSUnauthorizedCallContext(); /** * @dev The storage `slot` is unsupported as a UUID. */ error UUPSUnsupportedProxiableUUID(bytes32 slot); /** * @dev Check that the execution is being performed through a delegatecall call and that the execution context is * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to * fail. */ modifier onlyProxy() { _checkProxy(); _; } /** * @dev Check that the execution is not being performed through a delegate call. This allows a function to be * callable on the implementing contract but not through proxies. */ modifier notDelegated() { _checkNotDelegated(); _; } function __UUPSUpgradeable_init() internal onlyInitializing { } function __UUPSUpgradeable_init_unchained() internal onlyInitializing { } /** * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the * implementation. It is used to validate the implementation's compatibility when performing an upgrade. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier. */ function proxiableUUID() external view virtual notDelegated returns (bytes32) { return ERC1967Utils.IMPLEMENTATION_SLOT; } /** * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call * encoded in `data`. * * Calls {_authorizeUpgrade}. * * Emits an {Upgraded} event. * * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy { _authorizeUpgrade(newImplementation); _upgradeToAndCallUUPS(newImplementation, data); } /** * @dev Reverts if the execution is not performed via delegatecall or the execution * context is not of a proxy with an ERC1967-compliant implementation pointing to self. * See {_onlyProxy}. */ function _checkProxy() internal view virtual { if ( address(this) == __self || // Must be called through delegatecall ERC1967Utils.getImplementation() != __self // Must be called through an active proxy ) { revert UUPSUnauthorizedCallContext(); } } /** * @dev Reverts if the execution is performed via delegatecall. * See {notDelegated}. */ function _checkNotDelegated() internal view virtual { if (address(this) != __self) { // Must not be called through delegatecall revert UUPSUnauthorizedCallContext(); } } /** * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by * {upgradeToAndCall}. * * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}. * * ```solidity * function _authorizeUpgrade(address) internal onlyOwner {} * ``` */ function _authorizeUpgrade(address newImplementation) internal virtual; /** * @dev Performs an implementation upgrade with a security check for UUPS proxies, and additional setup call. * * As a security check, {proxiableUUID} is invoked in the new implementation, and the return value * is expected to be the implementation slot in ERC1967. * * Emits an {IERC1967-Upgraded} event. */ function _upgradeToAndCallUUPS(address newImplementation, bytes memory data) private { try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) { if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) { revert UUPSUnsupportedProxiableUUID(slot); } ERC1967Utils.upgradeToAndCall(newImplementation, data); } catch { // The implementation is not UUPS revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; import {Initializable} from "../proxy/utils/Initializable.sol"; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuardUpgradeable is Initializable { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; /// @custom:storage-location erc7201:openzeppelin.storage.ReentrancyGuard struct ReentrancyGuardStorage { uint256 _status; } // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff)) bytes32 private constant ReentrancyGuardStorageLocation = 0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00; function _getReentrancyGuardStorage() private pure returns (ReentrancyGuardStorage storage $) { assembly { $.slot := ReentrancyGuardStorageLocation } } /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); $._status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // On the first call to nonReentrant, _status will be NOT_ENTERED if ($._status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail $._status = ENTERED; } function _nonReentrantAfter() private { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) $._status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { ReentrancyGuardStorage storage $ = _getReentrancyGuardStorage(); return $._status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/beacon/IBeacon.sol) pragma solidity ^0.8.20; /** * @dev This is the interface that {BeaconProxy} expects of its beacon. */ interface IBeacon { /** * @dev Must return an address that can be used as a delegate call target. * * {UpgradeableBeacon} will check that this address is a contract. */ function implementation() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (proxy/ERC1967/ERC1967Utils.sol) pragma solidity ^0.8.20; import {IBeacon} from "../beacon/IBeacon.sol"; import {Address} from "../../utils/Address.sol"; import {StorageSlot} from "../../utils/StorageSlot.sol"; /** * @dev This abstract contract provides getters and event emitting update functions for * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots. */ library ERC1967Utils { // We re-declare ERC-1967 events here because they can't be used directly from IERC1967. // This will be fixed in Solidity 0.8.21. At that point we should remove these events. /** * @dev Emitted when the implementation is upgraded. */ event Upgraded(address indexed implementation); /** * @dev Emitted when the admin account has changed. */ event AdminChanged(address previousAdmin, address newAdmin); /** * @dev Emitted when the beacon is changed. */ event BeaconUpgraded(address indexed beacon); /** * @dev Storage slot with the address of the current implementation. * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; /** * @dev The `implementation` of the proxy is invalid. */ error ERC1967InvalidImplementation(address implementation); /** * @dev The `admin` of the proxy is invalid. */ error ERC1967InvalidAdmin(address admin); /** * @dev The `beacon` of the proxy is invalid. */ error ERC1967InvalidBeacon(address beacon); /** * @dev An upgrade function sees `msg.value > 0` that may be lost. */ error ERC1967NonPayable(); /** * @dev Returns the current implementation address. */ function getImplementation() internal view returns (address) { return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value; } /** * @dev Stores a new address in the EIP1967 implementation slot. */ function _setImplementation(address newImplementation) private { if (newImplementation.code.length == 0) { revert ERC1967InvalidImplementation(newImplementation); } StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value = newImplementation; } /** * @dev Performs implementation upgrade with additional setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-Upgraded} event. */ function upgradeToAndCall(address newImplementation, bytes memory data) internal { _setImplementation(newImplementation); emit Upgraded(newImplementation); if (data.length > 0) { Address.functionDelegateCall(newImplementation, data); } else { _checkNonPayable(); } } /** * @dev Storage slot with the admin of the contract. * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; /** * @dev Returns the current admin. * * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using * the https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call. * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103` */ function getAdmin() internal view returns (address) { return StorageSlot.getAddressSlot(ADMIN_SLOT).value; } /** * @dev Stores a new address in the EIP1967 admin slot. */ function _setAdmin(address newAdmin) private { if (newAdmin == address(0)) { revert ERC1967InvalidAdmin(address(0)); } StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin; } /** * @dev Changes the admin of the proxy. * * Emits an {IERC1967-AdminChanged} event. */ function changeAdmin(address newAdmin) internal { emit AdminChanged(getAdmin(), newAdmin); _setAdmin(newAdmin); } /** * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy. * This is the keccak-256 hash of "eip1967.proxy.beacon" subtracted by 1. */ // solhint-disable-next-line private-vars-leading-underscore bytes32 internal constant BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50; /** * @dev Returns the current beacon. */ function getBeacon() internal view returns (address) { return StorageSlot.getAddressSlot(BEACON_SLOT).value; } /** * @dev Stores a new beacon in the EIP1967 beacon slot. */ function _setBeacon(address newBeacon) private { if (newBeacon.code.length == 0) { revert ERC1967InvalidBeacon(newBeacon); } StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon; address beaconImplementation = IBeacon(newBeacon).implementation(); if (beaconImplementation.code.length == 0) { revert ERC1967InvalidImplementation(beaconImplementation); } } /** * @dev Change the beacon and trigger a setup call if data is nonempty. * This function is payable only if the setup call is performed, otherwise `msg.value` is rejected * to avoid stuck value in the contract. * * Emits an {IERC1967-BeaconUpgraded} event. * * CAUTION: Invoking this function has no effect on an instance of {BeaconProxy} since v5, since * it uses an immutable beacon without looking at the value of the ERC-1967 beacon slot for * efficiency. */ function upgradeBeaconToAndCall(address newBeacon, bytes memory data) internal { _setBeacon(newBeacon); emit BeaconUpgraded(newBeacon); if (data.length > 0) { Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data); } else { _checkNonPayable(); } } /** * @dev Reverts if `msg.value` is not zero. It can be used to avoid `msg.value` stuck in the contract * if an upgrade doesn't perform an initialization call. */ function _checkNonPayable() private { if (msg.value > 0) { revert ERC1967NonPayable(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.28; import {IAnyrand} from "./interfaces/IAnyrand.sol"; /// @title AnyrandStorage /// @author Kevin Charm ([email protected]) /// @notice Base abstract contract for Anyrand, defining storage layout and /// external getter boilerplate. abstract contract AnyrandStorage is IAnyrand { /// @custom:storage-location erc7201:io.frogworks.anyrand.v1.main_storage struct MainStorage { /// @notice Current beacon public key hash bytes32 currentBeaconPubKeyHash; /// @notice The multiplier applied to the raw tx cost of fulfilment uint256 requestPremiumMultiplierBps; /// @notice Maximum callback gas limit uint256 maxCallbackGasLimit; /// @notice Maximum number of seconds in the future from which randomness /// can be requested uint256 maxDeadlineDelta; /// @notice Self-explanatory uint256 nextRequestId; /// @notice Request hashes - see {Anyrand-hashRequest} mapping(uint256 requestId => bytes32 requestHash) requests; /// @notice Gas station address gasStation; /// @notice Maximum effective gas price (in wei) for requests uint256 maxFeePerGas; /// @notice Request states mapping(uint256 requestId => RequestState state) requestStates; /// @notice Beacons mapped by their public key hash mapping(bytes32 pubkeyHash => address beacon) beacons; } /// @notice Get contract storage function _getMainStorage() internal pure returns (MainStorage storage $) { assembly { // (keccak256("io.frogworks.anyrand.v1.main_storage") - 1) & ~0xff $.slot := 0x73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200 } } function currentBeaconPubKeyHash() external view returns (bytes32) { return _getMainStorage().currentBeaconPubKeyHash; } function beacon(bytes32 pubkeyHash) external view returns (address) { return _getMainStorage().beacons[pubkeyHash]; } function requestPremiumMultiplierBps() external view returns (uint256) { return _getMainStorage().requestPremiumMultiplierBps; } function maxCallbackGasLimit() external view returns (uint256) { return _getMainStorage().maxCallbackGasLimit; } function maxDeadlineDelta() external view returns (uint256) { return _getMainStorage().maxDeadlineDelta; } function nextRequestId() external view returns (uint256) { return _getMainStorage().nextRequestId; } function requests(uint256 requestId) external view returns (bytes32) { return _getMainStorage().requests[requestId]; } function gasStation() external view returns (address) { return _getMainStorage().gasStation; } function maxFeePerGas() external view returns (uint256) { return _getMainStorage().maxFeePerGas; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; interface IAnyrand { /// @notice State of a request enum RequestState { /// @notice The request does not exist Nonexistent, /// @notice A request has been made, waiting for fulfilment Pending, /// @notice The request has been fulfilled successfully Fulfilled, /// @notice The request was fulfilled, but the callback failed Failed } event RandomnessRequested( uint256 indexed requestId, address indexed requester, bytes32 indexed pubKeyHash, uint256 round, uint256 callbackGasLimit, uint256 feePaid, uint256 effectiveFeePerGas ); event RandomnessFulfilled( uint256 indexed requestId, uint256 randomness, bool callbackSuccess, uint256 actualGasUsed ); event RandomnessCallbackFailed( uint256 indexed requestId, bytes32 retdata, uint256 gasLimit, uint256 actualGasUsed ); event RequestPremiumMultiplierUpdated(uint256 newPrice); event ETHWithdrawn(uint256 amount); event BeaconUpdated(address indexed newBeacon); event MaxCallbackGasLimitUpdated(uint256 newMaxCallbackGasLimit); event MaxDeadlineDeltaUpdated(uint256 maxDeadlineDelta); event GasStationUpdated(address indexed newGasStation); event MaxFeePerGasUpdated(uint256 maxFeePerGas); error TransferFailed(address to, uint256 value); error IncorrectPayment(uint256 got, uint256 want); error OverGasLimit(uint256 callbackGasLimit); error InvalidRequestHash(bytes32 requestHash); error InvalidDeadline(uint256 deadline); error InsufficientGas(); error InvalidBeacon(address beacon); error InvalidRequestState(RequestState state); /// @notice Compute the total request price /// @param callbackGasLimit The callback gas limit that will be used for /// the randomness request function getRequestPrice( uint256 callbackGasLimit ) external view returns (uint256 totalPrice, uint256 effectiveFeePerGas); /// @notice Request randomness /// @param deadline Timestamp of when the randomness should be fulfilled. A /// beacon round closest to this timestamp (rounding up to the nearest /// future round) will be used as the round from which to derive /// randomness. /// @param callbackGasLimit Gas limit for callback function requestRandomness( uint256 deadline, uint256 callbackGasLimit ) external payable returns (uint256); /// @notice Get the state of a request /// @param requestId The request identifier function getRequestState( uint256 requestId ) external view returns (RequestState); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; /// @title IDrandBeacon /// @author Kevin Charm ([email protected]) /// @notice Contract containing immutable information about a drand beacon. interface IDrandBeacon { /// @notice Get the public key of the beacon function publicKey() external view returns (bytes memory); /// @notice Get the public key hash of the beacon function publicKeyHash() external view returns (bytes32); /// @notice Get the genesis timestamp of the beacon function genesisTimestamp() external view returns (uint256); /// @notice Get the period of the beacon function period() external view returns (uint256); /// @notice Verify the signature produced by a drand beacon round against /// the known public key. Should revert if the signature is invalid. /// @param round The beacon round to verify /// @param signature The signature to verify function verifyBeaconRound( uint256 round, uint256[2] memory signature ) external; }
// SPDX-License-Identifier: MIT pragma solidity 0.8; import {ITypeAndVersion} from "./ITypeAndVersion.sol"; interface IGasStation is ITypeAndVersion { /// @notice Compute the instantaneous cost of a transaction that consumes /// `gasLimit` of gas /// @param gasLimit The gas limit that will be used to calculate the cost /// of the transaction. /// @return totalCost The total transaction cost (in wei) /// @return effectiveFeePerGas The effective fee per gas, after accounting /// for multidimensional pricing for L2s function getTxCost( uint256 gasLimit ) external view returns (uint256 totalCost, uint256 effectiveFeePerGas); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; interface IRandomiserCallbackV3 { /// @notice Receive random words from a randomiser. /// @dev Ensure that proper access control is enforced on this function; /// only the designated randomiser may call this function and the /// requestId should be as expected from the randomness request. /// @param requestId The identifier for the original randomness request /// @param randomWord Uniform random number in the range [0, 2**256) function receiveRandomness(uint256 requestId, uint256 randomWord) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; /// @title ITypeAndVersion interface ITypeAndVersion { /// @notice Identifier for contract type and version function typeAndVersion() external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8; /// Code here was taken from the Chainlink repo at https://github.com/smartcontractkit/chainlink, /// /// The MIT License (MIT) /// /// Copyright (c) 2018 SmartContract ChainLink, Ltd. /// /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. library Gas { // 5k is plenty for an EXTCODESIZE call (2600) + warm CALL (100) // and some arithmetic operations. uint256 internal constant GAS_FOR_CALL_EXACT_CHECK = 5_000; /// @dev calls target address with exactly gasAmount gas and data as calldata /// or reverts if at least gasAmount gas is not available. function callWithExactGas( uint256 gasAmount, address target, bytes memory data ) internal returns (bool success) { assembly { let g := gas() // Compute g -= GAS_FOR_CALL_EXACT_CHECK and check for underflow // The gas actually passed to the callee is min(gasAmount, 63//64*gas available). // We want to ensure that we revert if gasAmount > 63//64*gas available // as we do not want to provide them with less, however that check itself costs // gas. GAS_FOR_CALL_EXACT_CHECK ensures we have at least enough gas to be able // to revert if gasAmount > 63//64*gas available. if lt(g, GAS_FOR_CALL_EXACT_CHECK) { revert(0, 0) } g := sub(g, GAS_FOR_CALL_EXACT_CHECK) // if g - g//64 <= gasAmount, revert // (we subtract g//64 because of EIP-150) if iszero(gt(sub(g, div(g, 64)), gasAmount)) { revert(0, 0) } // solidity calls check that a contract actually exists at the destination, so we do the same if iszero(extcodesize(target)) { revert(0, 0) } // call and return whether we succeeded. ignore return data // call(gas,addr,value,argsOffset,argsLength,retOffset,retLength) success := call( gasAmount, target, 0, add(data, 0x20), mload(data), 0, 0 ) } return success; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple single owner authorization mixin. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol) /// /// @dev Note: /// This implementation does NOT auto-initialize the owner to `msg.sender`. /// You MUST call the `_initializeOwner` in the constructor / initializer. /// /// While the ownable portion follows /// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility, /// the nomenclature for the 2-step ownership handover may be unique to this codebase. abstract contract Ownable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The caller is not authorized to call the function. error Unauthorized(); /// @dev The `newOwner` cannot be the zero address. error NewOwnerIsZeroAddress(); /// @dev The `pendingOwner` does not have a valid handover request. error NoHandoverRequest(); /// @dev Cannot double-initialize. error AlreadyInitialized(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ownership is transferred from `oldOwner` to `newOwner`. /// This event is intentionally kept the same as OpenZeppelin's Ownable to be /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), /// despite it not being as lightweight as a single argument event. event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); /// @dev An ownership handover to `pendingOwner` has been requested. event OwnershipHandoverRequested(address indexed pendingOwner); /// @dev The ownership handover to `pendingOwner` has been canceled. event OwnershipHandoverCanceled(address indexed pendingOwner); /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`. uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE = 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0; /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE = 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d; /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE = 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The owner slot is given by: /// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`. /// It is intentionally chosen to be a high value /// to avoid collision with lower slots. /// The choice of manual storage layout is to enable compatibility /// with both regular and upgradeable contracts. bytes32 internal constant _OWNER_SLOT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927; /// The ownership handover slot of `newOwner` is given by: /// ``` /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED)) /// let handoverSlot := keccak256(0x00, 0x20) /// ``` /// It stores the expiry timestamp of the two-step ownership handover. uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override to return true to make `_initializeOwner` prevent double-initialization. function _guardInitializeOwner() internal pure virtual returns (bool guard) {} /// @dev Initializes the owner directly without authorization guard. /// This function must be called upon initialization, /// regardless of whether the contract is upgradeable or not. /// This is to enable generalization to both regular and upgradeable contracts, /// and to save gas in case the initial owner is not the caller. /// For performance reasons, this function will not check if there /// is an existing owner. function _initializeOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT if sload(ownerSlot) { mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`. revert(0x1c, 0x04) } // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } else { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(_OWNER_SLOT, newOwner) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } } /// @dev Sets the owner directly without authorization guard. function _setOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) } } else { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, newOwner) } } } /// @dev Throws if the sender is not the owner. function _checkOwner() internal view virtual { /// @solidity memory-safe-assembly assembly { // If the caller is not the stored owner, revert. if iszero(eq(caller(), sload(_OWNER_SLOT))) { mstore(0x00, 0x82b42900) // `Unauthorized()`. revert(0x1c, 0x04) } } } /// @dev Returns how long a two-step ownership handover is valid for in seconds. /// Override to return a different value if needed. /// Made internal to conserve bytecode. Wrap it in a public function if needed. function _ownershipHandoverValidFor() internal view virtual returns (uint64) { return 48 * 3600; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC UPDATE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Allows the owner to transfer the ownership to `newOwner`. function transferOwnership(address newOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { if iszero(shl(96, newOwner)) { mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`. revert(0x1c, 0x04) } } _setOwner(newOwner); } /// @dev Allows the owner to renounce their ownership. function renounceOwnership() public payable virtual onlyOwner { _setOwner(address(0)); } /// @dev Request a two-step ownership handover to the caller. /// The request will automatically expire in 48 hours (172800 seconds) by default. function requestOwnershipHandover() public payable virtual { unchecked { uint256 expires = block.timestamp + _ownershipHandoverValidFor(); /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to `expires`. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), expires) // Emit the {OwnershipHandoverRequested} event. log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller()) } } } /// @dev Cancels the two-step ownership handover to the caller, if any. function cancelOwnershipHandover() public payable virtual { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), 0) // Emit the {OwnershipHandoverCanceled} event. log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller()) } } /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`. /// Reverts if there is no existing ownership handover requested by `pendingOwner`. function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) let handoverSlot := keccak256(0x0c, 0x20) // If the handover does not exist, or has expired. if gt(timestamp(), sload(handoverSlot)) { mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`. revert(0x1c, 0x04) } // Set the handover slot to 0. sstore(handoverSlot, 0) } _setOwner(pendingOwner); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC READ FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the owner of the contract. function owner() public view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { result := sload(_OWNER_SLOT) } } /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`. function ownershipHandoverExpiresAt(address pendingOwner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Compute the handover slot. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) // Load the handover slot. result := sload(keccak256(0x0c, 0x20)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MODIFIERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Marks a function as only callable by the owner. modifier onlyOwner() virtual { _checkOwner(); _; } }
{ "viaIR": false, "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"implementation","type":"address"}],"name":"ERC1967InvalidImplementation","type":"error"},{"inputs":[],"name":"ERC1967NonPayable","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"got","type":"uint256"},{"internalType":"uint256","name":"want","type":"uint256"}],"name":"IncorrectPayment","type":"error"},{"inputs":[],"name":"InsufficientGas","type":"error"},{"inputs":[{"internalType":"address","name":"beacon","type":"address"}],"name":"InvalidBeacon","type":"error"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"InvalidDeadline","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[{"internalType":"bytes32","name":"requestHash","type":"bytes32"}],"name":"InvalidRequestHash","type":"error"},{"inputs":[{"internalType":"enum IAnyrand.RequestState","name":"state","type":"uint8"}],"name":"InvalidRequestState","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"OverGasLimit","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferFailed","type":"error"},{"inputs":[],"name":"UUPSUnauthorizedCallContext","type":"error"},{"inputs":[{"internalType":"bytes32","name":"slot","type":"bytes32"}],"name":"UUPSUnsupportedProxiableUUID","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newBeacon","type":"address"}],"name":"BeaconUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ETHWithdrawn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newGasStation","type":"address"}],"name":"GasStationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newMaxCallbackGasLimit","type":"uint256"}],"name":"MaxCallbackGasLimitUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxDeadlineDelta","type":"uint256"}],"name":"MaxDeadlineDeltaUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"maxFeePerGas","type":"uint256"}],"name":"MaxFeePerGasUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"retdata","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"gasLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actualGasUsed","type":"uint256"}],"name":"RandomnessCallbackFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"randomness","type":"uint256"},{"indexed":false,"internalType":"bool","name":"callbackSuccess","type":"bool"},{"indexed":false,"internalType":"uint256","name":"actualGasUsed","type":"uint256"}],"name":"RandomnessFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"requester","type":"address"},{"indexed":true,"internalType":"bytes32","name":"pubKeyHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"round","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"callbackGasLimit","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feePaid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"effectiveFeePerGas","type":"uint256"}],"name":"RandomnessRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"RequestPremiumMultiplierUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"UPGRADE_INTERFACE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"pubkeyHash","type":"bytes32"}],"name":"beacon","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"currentBeaconPubKeyHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"address","name":"requester","type":"address"},{"internalType":"bytes32","name":"pubKeyHash","type":"bytes32"},{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"},{"internalType":"uint256[2]","name":"signature","type":"uint256[2]"}],"name":"fulfillRandomness","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gasStation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"getRequestPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"getRequestState","outputs":[{"internalType":"enum IAnyrand.RequestState","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"genesis","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"getRound","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"beacon_","type":"address"},{"internalType":"uint256","name":"requestPremiumMultiplierBps_","type":"uint256"},{"internalType":"uint256","name":"maxCallbackGasLimit_","type":"uint256"},{"internalType":"uint256","name":"maxDeadlineDelta_","type":"uint256"},{"internalType":"address","name":"gasStation_","type":"address"},{"internalType":"uint256","name":"maxFeePerGas_","type":"uint256"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxCallbackGasLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDeadlineDelta","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxFeePerGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestPremiumMultiplierBps","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"callbackGasLimit","type":"uint256"}],"name":"requestRandomness","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"requests","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newBeacon","type":"address"}],"name":"setBeacon","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGasStation","type":"address"}],"name":"setGasStation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxCallbackGasLimit","type":"uint256"}],"name":"setMaxCallbackGasLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMaxDeadlineDelta","type":"uint256"}],"name":"setMaxDeadlineDelta","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newRequestPremiumMultiplierBps","type":"uint256"}],"name":"setRequestPremiumMultiplierBps","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"typeAndVersion","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040523060805234801561001457600080fd5b5061001d610022565b6100d4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000900460ff16156100725760405163f92ee8a960e01b815260040160405180910390fd5b80546001600160401b03908116146100d15780546001600160401b0319166001600160401b0390811782556040519081527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b50565b6080516124266100fd6000396000818161188f015281816118b80152611a3b01526124266000f3fe6080604052600436106101e35760003560e01c80638da5cb5b11610102578063ed979dd611610095578063f14210a611610064578063f14210a6146106af578063f2fde38b146106cf578063fc679411146106e2578063fee81cf41461071b57600080fd5b8063ed979dd6146105b7578063eddcef8514610613578063f01a214014610668578063f04e283e1461069c57600080fd5b8063ad3cb1cc116100d1578063ad3cb1cc146104f1578063d42afb561461053a578063dbb602fd1461055a578063e3073fb71461059757600080fd5b80638da5cb5b1461045057806394aa6a4b1461047d57806395415d431461049d578063a31659f6146104bd57600080fd5b806352d1902d1161017a578063715018a611610149578063715018a6146103a85780637b49e281146103b05780637eeef9a9146103e457806381d12c581461040457600080fd5b806352d1902d1461033757806354d1f13d1461034c57806355face6d146103545780636a84a9851461037457600080fd5b806325692962116101b657806325692962146102b45780632728bf2c146102bc57806338e576c8146102f05780634f1ef2861461032457600080fd5b806308a957a9146101e857806310b0d1d21461020a578063181f5a77146102445780631f53cf0414610293575b600080fd5b3480156101f457600080fd5b50610208610203366004611fb2565b61074e565b005b34801561021657600080fd5b5061022a610225366004611fcd565b6107f0565b604080519283526020830191909152015b60405180910390f35b34801561025057600080fd5b5060408051808201909152600d81527f416e7972616e6420312e302e300000000000000000000000000000000000000060208201525b60405161023b919061200a565b6102a66102a136600461203d565b61090c565b60405190815260200161023b565b610208610d2a565b3480156102c857600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99207546102a6565b3480156102fc57600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99203546102a6565b610208610332366004612075565b610d7a565b34801561034357600080fd5b506102a6610d99565b610208610dc8565b34801561036057600080fd5b5061020861036f36600461213f565b610e04565b34801561038057600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99204546102a6565b6102086110be565b3480156103bc57600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99202546102a6565b3480156103f057600080fd5b506102086103ff366004611fcd565b6110d2565b34801561041057600080fd5b506102a661041f366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99205602052604090205490565b34801561045c57600080fd5b50638b78c6d819545b6040516001600160a01b03909116815260200161023b565b34801561048957600080fd5b50610208610498366004611fcd565b611158565b3480156104a957600080fd5b506102086104b8366004612199565b6111d6565b3480156104c957600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200546102a6565b3480156104fd57600080fd5b506102866040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b34801561054657600080fd5b50610208610555366004611fb2565b6115f6565b34801561056657600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99206546001600160a01b0316610465565b3480156105a357600080fd5b506102086105b2366004611fcd565b61160a565b3480156105c357600080fd5b506106066105d2366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99208602052604090205460ff1690565b60405161023b919061220f565b34801561061f57600080fd5b5061046561062e366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920960205260409020546001600160a01b031690565b34801561067457600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99201546102a6565b6102086106aa366004611fb2565b611688565b3480156106bb57600080fd5b506102086106ca366004611fcd565b6116c5565b6102086106dd366004611fb2565b611793565b3480156106ee57600080fd5b506107026106fd366004612237565b6117ba565b60405167ffffffffffffffff909116815260200161023b565b34801561072757600080fd5b506102a6610736366004611fb2565b63389a75e1600c908152600091909152602090205490565b610756611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99206805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920091907feace2e43f1e38a3104cd1d140b379c1e6f5283916eef36bff925e63a329ab79990600090a25050565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992065460009081907f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920090829081906001600160a01b031663a158ff8b6108588862030d40612279565b6040518263ffffffff1660e01b815260040161087691815260200190565b6040805180830381865afa158015610892573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b6919061228c565b9150915060006127108460010154846108cf91906122b0565b6108d991906122dd565b90508360070154821115610901578684600701546108f791906122b0565b9050836007015491505b969095509350505050565b6000610916611821565b600080610922846107f0565b9150915081341461096d576040517f0d35e921000000000000000000000000000000000000000000000000000000008152346004820152602481018390526044015b60405180910390fd5b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99202547f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200908511156109ed576040517f45453f3700000000000000000000000000000000000000000000000000000000815260048101869052602401610964565b8054600081815260098301602090815260408083205481517f5e7e341600000000000000000000000000000000000000000000000000000000815291516001600160a01b03909116928392635e7e341692600480830193928290030181865afa158015610a5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8291906122f1565b92506000816001600160a01b031663cacf66ab6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae891906122f1565b90506000826001600160a01b031663ef78d4fd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e91906122f1565b9050856003015442610b609190612279565b8b1180610b6c5750818b105b80610b7f5750610b7c8142612279565b8b105b15610bb9576040517f277b2d74000000000000000000000000000000000000000000000000000000008152600481018c9052602401610964565b610bc4828c836117ba565b93505050506000836004016000815480929190610be09061230a565b90915550905060008082815260088601602052604090205460ff166003811115610c0c57610c0c6121f9565b14610c1957610c19612323565b6000818152600885016020908152604091829020805460ff191660011790558151468183015230818401526060810184905233608082015260a0810186905267ffffffffffffffff851660c082015260e08082018c9052835180830390910181526101009091019092528151910120600082815260058601602090815260409182902092909255805167ffffffffffffffff851681529182018a90528101879052606081018690528390339083907f4d742ad77e9e8ee172d944c464321fc0e5c49465017bf65357c77b62de3a1b589060800160405180910390a495505050505050610d2460017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b92915050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b610d82611884565b610d8b8261193b565b610d958282611943565b5050565b6000610da3611a30565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610e4f5750825b905060008267ffffffffffffffff166001148015610e6c5750303b155b905081158015610e7a575080155b15610eb1576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ee557845468ff00000000000000001916680100000000000000001785555b610eed611a79565b610ef633611a81565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200610f208c611abd565b60016004820181905581018b90556040518b81527fe7af51792ad24f09099d1aa1b9ce24a68de1b1b1ceff0ae3b861cd25cb483ede9060200160405180910390a1600281018a90556040518a81527f134a3c9ab0f6f4624f16cae2e8b5ed62e867f01bae73ab143b957c2a2e6c9ee59060200160405180910390a1600381018990556040518981527f4bdf088aaa547d0a8b8f4aa78a191f0faf72f3bc7fddd8d39be2492d883684789060200160405180910390a160068101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038a169081179091556040517feace2e43f1e38a3104cd1d140b379c1e6f5283916eef36bff925e63a329ab79990600090a2600781018790556040518781527ffc932d0f51343f664c735ccefa1ee05d148cffdd438cdc72966c6029305016a69060200160405180910390a15083156110b157845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b6110c6611806565b6110d06000611c3e565b565b6110da611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992018190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907fe7af51792ad24f09099d1aa1b9ce24a68de1b1b1ceff0ae3b861cd25cb483ede906020015b60405180910390a15050565b611160611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992028190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907f134a3c9ab0f6f4624f16cae2e8b5ed62e867f01bae73ab143b957c2a2e6c9ee59060200161114c565b6111de611821565b60008681527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920860205260409020547f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992009060019060ff166003811115611245576112456121f9565b14611292576000878152600882016020526040908190205490517f1d8105940000000000000000000000000000000000000000000000000000000081526109649160ff169060040161220f565b60408051466020808301919091523082840152606082018a90526001600160a01b038916608083015260a0820188905260c0820187905260e080830187905283518084039091018152610100909201835281519181019190912060008a815260058501909252919020548114611337576040517fa537f75800000000000000000000000000000000000000000000000000000000815260048101829052602401610964565b6000888152600583016020908152604080832083905588835260098501909152908190205490517fe3d4ff160000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063e3d4ff16906113a39088908790600401612339565b600060405180830381600087803b1580156113bd57600080fd5b505af11580156113d1573d6000803e3d6000fd5b505050506000836000600281106113ea576113ea61234f565b604080516020928302939093013583830152908601359082015246606082015230608082015260a081018a90526001600160a01b03891660c082015260e00160408051601f1981840301815282825280516020918201209083018c9052908201819052915060009081906114b39088908c907f210b9f03000000000000000000000000000000000000000000000000000000009060600160408051601f198184030181529082905261149f9291602001612365565b604051602081830303815290604052611c7c565b91509150816115605760006114e3565b6000828210600181146114d8578391506114dc565b8291505b5092915050565b600080523d6114f36020826114c3565b6000803e505060005160408051828152602081018a90529081018390528c907f593290c667cb0c88d24734b31a95f8ae731fe3ae3ca3e3439ddcaf24b4c89be19060600160405180910390a25060008b81526008860160205260409020805460ff1916600317905561157c565b60008b81526008860160205260409020805460ff191660021790555b6040805184815283151560208201529081018290528b907fa3e5c16005338901ba1b866e14b095a75e88ad9432e26075e6d6edad9cf73f579060600160405180910390a250505050506115ee60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b505050505050565b6115fe611806565b61160781611abd565b50565b611612611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992038190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907f4bdf088aaa547d0a8b8f4aa78a191f0faf72f3bc7fddd8d39be2492d883684789060200161114c565b611690611806565b63389a75e1600c52806000526020600c2080544211156116b857636f5e88186000526004601cfd5b6000905561160781611c3e565b6116cd611806565b806000036116d85750475b604051600090339083908381818185875af1925050503d806000811461171a576040519150601f19603f3d011682016040523d82523d6000602084013e61171f565b606091505b5050905080611763576040517f1c43b97600000000000000000000000000000000000000000000000000000000815233600482015260248101839052604401610964565b6040518281527f043f607a14d3b4f0a11a0b2e192bbfcd894298ba5abf22553be6081406db28aa9060200161114c565b61179b611806565b8060601b6117b157637448fbae6000526004601cfd5b61160781611c3e565b6000806117c785856123ad565b905060006117d584836123c0565b116117e15760006117e4565b60015b60ff166117f184836122dd565b6117fb9190612279565b9150505b9392505050565b638b78c6d8195433146110d0576382b429006000526004601cfd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080546001190161187e576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016148061191d57507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166119117f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b156110d05760405163703e46dd60e11b815260040160405180910390fd5b611607611806565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561199d575060408051601f3d908101601f1916820190925261199a918101906122f1565b60015b6119c557604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610964565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611a21576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610964565b611a2b8383611ca4565b505050565b306001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146110d05760405163703e46dd60e11b815260040160405180910390fd5b6110d0611cfa565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b806001600160a01b0316635e7e34166040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b17575060408051601f3d908101601f19168201909252611b14918101906122f1565b60015b611b3f57604051638ebc912f60e01b81526001600160a01b0382166004820152602401610964565b801580611b6b57507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081145b15611b9457604051638ebc912f60e01b81526001600160a01b0383166004820152602401610964565b60008181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992096020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386169081179091557f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992008481559151919290917fb6c98a2d14fe1d3cc6112a6fab11204e6e526a4e568d000a85f55dac167b94839190a2505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6000805a9050611c8d858585611d61565b91505a611c9a90826123ad565b9050935093915050565b611cad82611dad565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115611cf257611a2b8282611e31565b610d95611ea7565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff166110d0576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005a611388811015611d7357600080fd5b611388810390508460408204820311611d8b57600080fd5b50823b611d9757600080fd5b60008083516020850160008789f1949350505050565b806001600160a01b03163b600003611de357604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610964565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051611e4e91906123d4565b600060405180830381855af49150503d8060008114611e89576040519150601f19603f3d011682016040523d82523d6000602084013e611e8e565b606091505b5091509150611e9e858383611edf565b95945050505050565b34156110d0576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606082611ef457611eef82611f54565b6117ff565b8151158015611f0b57506001600160a01b0384163b155b15611f4d576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610964565b50806117ff565b805115611f645780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80356001600160a01b0381168114611fad57600080fd5b919050565b600060208284031215611fc457600080fd5b6117ff82611f96565b600060208284031215611fdf57600080fd5b5035919050565b60005b83811015612001578181015183820152602001611fe9565b50506000910152565b6020815260008251806020840152612029816040850160208701611fe6565b601f01601f19169190910160400192915050565b6000806040838503121561205057600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561208857600080fd5b61209183611f96565b9150602083013567ffffffffffffffff8111156120ad57600080fd5b8301601f810185136120be57600080fd5b803567ffffffffffffffff8111156120d8576120d861205f565b604051601f8201601f19908116603f0116810167ffffffffffffffff811182821017156121075761210761205f565b60405281815282820160200187101561211f57600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060008060008060c0878903121561215857600080fd5b61216187611f96565b955060208701359450604087013593506060870135925061218460808801611f96565b9598949750929591949360a090920135925050565b60008060008060008060e087890312156121b257600080fd5b863595506121c260208801611f96565b945060408701359350606087013592506080870135915060e087018810156121e957600080fd5b60a0870190509295509295509295565b634e487b7160e01b600052602160045260246000fd5b602081016004831061223157634e487b7160e01b600052602160045260246000fd5b91905290565b60008060006060848603121561224c57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610d2457610d24612263565b6000806040838503121561229f57600080fd5b505080516020909101519092909150565b8082028115828204841417610d2457610d24612263565b634e487b7160e01b600052601260045260246000fd5b6000826122ec576122ec6122c7565b500490565b60006020828403121561230357600080fd5b5051919050565b60006001820161231c5761231c612263565b5060010190565b634e487b7160e01b600052600160045260246000fd5b8281526060810160408360208401379392505050565b634e487b7160e01b600052603260045260246000fd5b7fffffffff00000000000000000000000000000000000000000000000000000000831681526000825161239f816004850160208701611fe6565b919091016004019392505050565b81810381811115610d2457610d24612263565b6000826123cf576123cf6122c7565b500690565b600082516123e6818460208701611fe6565b919091019291505056fea26469706673582212204ab431dead71256a4825942c6096d8492ecca6eb342cc8b6bf69a52a8451af4264736f6c634300081c0033
Deployed Bytecode
0x6080604052600436106101e35760003560e01c80638da5cb5b11610102578063ed979dd611610095578063f14210a611610064578063f14210a6146106af578063f2fde38b146106cf578063fc679411146106e2578063fee81cf41461071b57600080fd5b8063ed979dd6146105b7578063eddcef8514610613578063f01a214014610668578063f04e283e1461069c57600080fd5b8063ad3cb1cc116100d1578063ad3cb1cc146104f1578063d42afb561461053a578063dbb602fd1461055a578063e3073fb71461059757600080fd5b80638da5cb5b1461045057806394aa6a4b1461047d57806395415d431461049d578063a31659f6146104bd57600080fd5b806352d1902d1161017a578063715018a611610149578063715018a6146103a85780637b49e281146103b05780637eeef9a9146103e457806381d12c581461040457600080fd5b806352d1902d1461033757806354d1f13d1461034c57806355face6d146103545780636a84a9851461037457600080fd5b806325692962116101b657806325692962146102b45780632728bf2c146102bc57806338e576c8146102f05780634f1ef2861461032457600080fd5b806308a957a9146101e857806310b0d1d21461020a578063181f5a77146102445780631f53cf0414610293575b600080fd5b3480156101f457600080fd5b50610208610203366004611fb2565b61074e565b005b34801561021657600080fd5b5061022a610225366004611fcd565b6107f0565b604080519283526020830191909152015b60405180910390f35b34801561025057600080fd5b5060408051808201909152600d81527f416e7972616e6420312e302e300000000000000000000000000000000000000060208201525b60405161023b919061200a565b6102a66102a136600461203d565b61090c565b60405190815260200161023b565b610208610d2a565b3480156102c857600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99207546102a6565b3480156102fc57600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99203546102a6565b610208610332366004612075565b610d7a565b34801561034357600080fd5b506102a6610d99565b610208610dc8565b34801561036057600080fd5b5061020861036f36600461213f565b610e04565b34801561038057600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99204546102a6565b6102086110be565b3480156103bc57600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99202546102a6565b3480156103f057600080fd5b506102086103ff366004611fcd565b6110d2565b34801561041057600080fd5b506102a661041f366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99205602052604090205490565b34801561045c57600080fd5b50638b78c6d819545b6040516001600160a01b03909116815260200161023b565b34801561048957600080fd5b50610208610498366004611fcd565b611158565b3480156104a957600080fd5b506102086104b8366004612199565b6111d6565b3480156104c957600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200546102a6565b3480156104fd57600080fd5b506102866040518060400160405280600581526020017f352e302e3000000000000000000000000000000000000000000000000000000081525081565b34801561054657600080fd5b50610208610555366004611fb2565b6115f6565b34801561056657600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99206546001600160a01b0316610465565b3480156105a357600080fd5b506102086105b2366004611fcd565b61160a565b3480156105c357600080fd5b506106066105d2366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99208602052604090205460ff1690565b60405161023b919061220f565b34801561061f57600080fd5b5061046561062e366004611fcd565b60009081527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920960205260409020546001600160a01b031690565b34801561067457600080fd5b507f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99201546102a6565b6102086106aa366004611fb2565b611688565b3480156106bb57600080fd5b506102086106ca366004611fcd565b6116c5565b6102086106dd366004611fb2565b611793565b3480156106ee57600080fd5b506107026106fd366004612237565b6117ba565b60405167ffffffffffffffff909116815260200161023b565b34801561072757600080fd5b506102a6610736366004611fb2565b63389a75e1600c908152600091909152602090205490565b610756611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99206805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0383169081179091556040517f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920091907feace2e43f1e38a3104cd1d140b379c1e6f5283916eef36bff925e63a329ab79990600090a25050565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992065460009081907f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920090829081906001600160a01b031663a158ff8b6108588862030d40612279565b6040518263ffffffff1660e01b815260040161087691815260200190565b6040805180830381865afa158015610892573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b6919061228c565b9150915060006127108460010154846108cf91906122b0565b6108d991906122dd565b90508360070154821115610901578684600701546108f791906122b0565b9050836007015491505b969095509350505050565b6000610916611821565b600080610922846107f0565b9150915081341461096d576040517f0d35e921000000000000000000000000000000000000000000000000000000008152346004820152602481018390526044015b60405180910390fd5b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99202547f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200908511156109ed576040517f45453f3700000000000000000000000000000000000000000000000000000000815260048101869052602401610964565b8054600081815260098301602090815260408083205481517f5e7e341600000000000000000000000000000000000000000000000000000000815291516001600160a01b03909116928392635e7e341692600480830193928290030181865afa158015610a5e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8291906122f1565b92506000816001600160a01b031663cacf66ab6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ac4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae891906122f1565b90506000826001600160a01b031663ef78d4fd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b4e91906122f1565b9050856003015442610b609190612279565b8b1180610b6c5750818b105b80610b7f5750610b7c8142612279565b8b105b15610bb9576040517f277b2d74000000000000000000000000000000000000000000000000000000008152600481018c9052602401610964565b610bc4828c836117ba565b93505050506000836004016000815480929190610be09061230a565b90915550905060008082815260088601602052604090205460ff166003811115610c0c57610c0c6121f9565b14610c1957610c19612323565b6000818152600885016020908152604091829020805460ff191660011790558151468183015230818401526060810184905233608082015260a0810186905267ffffffffffffffff851660c082015260e08082018c9052835180830390910181526101009091019092528151910120600082815260058601602090815260409182902092909255805167ffffffffffffffff851681529182018a90528101879052606081018690528390339083907f4d742ad77e9e8ee172d944c464321fc0e5c49465017bf65357c77b62de3a1b589060800160405180910390a495505050505050610d2460017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b92915050565b60006202a30067ffffffffffffffff164201905063389a75e1600c5233600052806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d600080a250565b610d82611884565b610d8b8261193b565b610d958282611943565b5050565b6000610da3611a30565b507f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc90565b63389a75e1600c523360005260006020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92600080a2565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00805468010000000000000000810460ff16159067ffffffffffffffff16600081158015610e4f5750825b905060008267ffffffffffffffff166001148015610e6c5750303b155b905081158015610e7a575080155b15610eb1576040517ff92ee8a900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b845467ffffffffffffffff191660011785558315610ee557845468ff00000000000000001916680100000000000000001785555b610eed611a79565b610ef633611a81565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200610f208c611abd565b60016004820181905581018b90556040518b81527fe7af51792ad24f09099d1aa1b9ce24a68de1b1b1ceff0ae3b861cd25cb483ede9060200160405180910390a1600281018a90556040518a81527f134a3c9ab0f6f4624f16cae2e8b5ed62e867f01bae73ab143b957c2a2e6c9ee59060200160405180910390a1600381018990556040518981527f4bdf088aaa547d0a8b8f4aa78a191f0faf72f3bc7fddd8d39be2492d883684789060200160405180910390a160068101805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b038a169081179091556040517feace2e43f1e38a3104cd1d140b379c1e6f5283916eef36bff925e63a329ab79990600090a2600781018790556040518781527ffc932d0f51343f664c735ccefa1ee05d148cffdd438cdc72966c6029305016a69060200160405180910390a15083156110b157845468ff000000000000000019168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b5050505050505050505050565b6110c6611806565b6110d06000611c3e565b565b6110da611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992018190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907fe7af51792ad24f09099d1aa1b9ce24a68de1b1b1ceff0ae3b861cd25cb483ede906020015b60405180910390a15050565b611160611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992028190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907f134a3c9ab0f6f4624f16cae2e8b5ed62e867f01bae73ab143b957c2a2e6c9ee59060200161114c565b6111de611821565b60008681527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f9920860205260409020547f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992009060019060ff166003811115611245576112456121f9565b14611292576000878152600882016020526040908190205490517f1d8105940000000000000000000000000000000000000000000000000000000081526109649160ff169060040161220f565b60408051466020808301919091523082840152606082018a90526001600160a01b038916608083015260a0820188905260c0820187905260e080830187905283518084039091018152610100909201835281519181019190912060008a815260058501909252919020548114611337576040517fa537f75800000000000000000000000000000000000000000000000000000000815260048101829052602401610964565b6000888152600583016020908152604080832083905588835260098501909152908190205490517fe3d4ff160000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063e3d4ff16906113a39088908790600401612339565b600060405180830381600087803b1580156113bd57600080fd5b505af11580156113d1573d6000803e3d6000fd5b505050506000836000600281106113ea576113ea61234f565b604080516020928302939093013583830152908601359082015246606082015230608082015260a081018a90526001600160a01b03891660c082015260e00160408051601f1981840301815282825280516020918201209083018c9052908201819052915060009081906114b39088908c907f210b9f03000000000000000000000000000000000000000000000000000000009060600160408051601f198184030181529082905261149f9291602001612365565b604051602081830303815290604052611c7c565b91509150816115605760006114e3565b6000828210600181146114d8578391506114dc565b8291505b5092915050565b600080523d6114f36020826114c3565b6000803e505060005160408051828152602081018a90529081018390528c907f593290c667cb0c88d24734b31a95f8ae731fe3ae3ca3e3439ddcaf24b4c89be19060600160405180910390a25060008b81526008860160205260409020805460ff1916600317905561157c565b60008b81526008860160205260409020805460ff191660021790555b6040805184815283151560208201529081018290528b907fa3e5c16005338901ba1b866e14b095a75e88ad9432e26075e6d6edad9cf73f579060600160405180910390a250505050506115ee60017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0055565b505050505050565b6115fe611806565b61160781611abd565b50565b611612611806565b7f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992038190556040518181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f99200907f4bdf088aaa547d0a8b8f4aa78a191f0faf72f3bc7fddd8d39be2492d883684789060200161114c565b611690611806565b63389a75e1600c52806000526020600c2080544211156116b857636f5e88186000526004601cfd5b6000905561160781611c3e565b6116cd611806565b806000036116d85750475b604051600090339083908381818185875af1925050503d806000811461171a576040519150601f19603f3d011682016040523d82523d6000602084013e61171f565b606091505b5050905080611763576040517f1c43b97600000000000000000000000000000000000000000000000000000000815233600482015260248101839052604401610964565b6040518281527f043f607a14d3b4f0a11a0b2e192bbfcd894298ba5abf22553be6081406db28aa9060200161114c565b61179b611806565b8060601b6117b157637448fbae6000526004601cfd5b61160781611c3e565b6000806117c785856123ad565b905060006117d584836123c0565b116117e15760006117e4565b60015b60ff166117f184836122dd565b6117fb9190612279565b9150505b9392505050565b638b78c6d8195433146110d0576382b429006000526004601cfd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0080546001190161187e576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60029055565b306001600160a01b037f00000000000000000000000036056aa78a03017568489fd2fff0913fe1d8918216148061191d57507f00000000000000000000000036056aa78a03017568489fd2fff0913fe1d891826001600160a01b03166119117f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6001600160a01b031614155b156110d05760405163703e46dd60e11b815260040160405180910390fd5b611607611806565b816001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801561199d575060408051601f3d908101601f1916820190925261199a918101906122f1565b60015b6119c557604051634c9c8ce360e01b81526001600160a01b0383166004820152602401610964565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc8114611a21576040517faa1d49a400000000000000000000000000000000000000000000000000000000815260048101829052602401610964565b611a2b8383611ca4565b505050565b306001600160a01b037f00000000000000000000000036056aa78a03017568489fd2fff0913fe1d8918216146110d05760405163703e46dd60e11b815260040160405180910390fd5b6110d0611cfa565b6001600160a01b0316638b78c6d8198190558060007f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b806001600160a01b0316635e7e34166040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015611b17575060408051601f3d908101601f19168201909252611b14918101906122f1565b60015b611b3f57604051638ebc912f60e01b81526001600160a01b0382166004820152602401610964565b801580611b6b57507fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47081145b15611b9457604051638ebc912f60e01b81526001600160a01b0383166004820152602401610964565b60008181527f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992096020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386169081179091557f73bb1f7ad954352194401771e442b57f02df3da05251c4536bf437f932f992008481559151919290917fb6c98a2d14fe1d3cc6112a6fab11204e6e526a4e568d000a85f55dac167b94839190a2505050565b638b78c6d81980546001600160a01b039092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a355565b6000805a9050611c8d858585611d61565b91505a611c9a90826123ad565b9050935093915050565b611cad82611dad565b6040516001600160a01b038316907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a2805115611cf257611a2b8282611e31565b610d95611ea7565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005468010000000000000000900460ff166110d0576040517fd7e6bcf800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005a611388811015611d7357600080fd5b611388810390508460408204820311611d8b57600080fd5b50823b611d9757600080fd5b60008083516020850160008789f1949350505050565b806001600160a01b03163b600003611de357604051634c9c8ce360e01b81526001600160a01b0382166004820152602401610964565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6060600080846001600160a01b031684604051611e4e91906123d4565b600060405180830381855af49150503d8060008114611e89576040519150601f19603f3d011682016040523d82523d6000602084013e611e8e565b606091505b5091509150611e9e858383611edf565b95945050505050565b34156110d0576040517fb398979f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b606082611ef457611eef82611f54565b6117ff565b8151158015611f0b57506001600160a01b0384163b155b15611f4d576040517f9996b3150000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401610964565b50806117ff565b805115611f645780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80356001600160a01b0381168114611fad57600080fd5b919050565b600060208284031215611fc457600080fd5b6117ff82611f96565b600060208284031215611fdf57600080fd5b5035919050565b60005b83811015612001578181015183820152602001611fe9565b50506000910152565b6020815260008251806020840152612029816040850160208701611fe6565b601f01601f19169190910160400192915050565b6000806040838503121561205057600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b6000806040838503121561208857600080fd5b61209183611f96565b9150602083013567ffffffffffffffff8111156120ad57600080fd5b8301601f810185136120be57600080fd5b803567ffffffffffffffff8111156120d8576120d861205f565b604051601f8201601f19908116603f0116810167ffffffffffffffff811182821017156121075761210761205f565b60405281815282820160200187101561211f57600080fd5b816020840160208301376000602083830101528093505050509250929050565b60008060008060008060c0878903121561215857600080fd5b61216187611f96565b955060208701359450604087013593506060870135925061218460808801611f96565b9598949750929591949360a090920135925050565b60008060008060008060e087890312156121b257600080fd5b863595506121c260208801611f96565b945060408701359350606087013592506080870135915060e087018810156121e957600080fd5b60a0870190509295509295509295565b634e487b7160e01b600052602160045260246000fd5b602081016004831061223157634e487b7160e01b600052602160045260246000fd5b91905290565b60008060006060848603121561224c57600080fd5b505081359360208301359350604090920135919050565b634e487b7160e01b600052601160045260246000fd5b80820180821115610d2457610d24612263565b6000806040838503121561229f57600080fd5b505080516020909101519092909150565b8082028115828204841417610d2457610d24612263565b634e487b7160e01b600052601260045260246000fd5b6000826122ec576122ec6122c7565b500490565b60006020828403121561230357600080fd5b5051919050565b60006001820161231c5761231c612263565b5060010190565b634e487b7160e01b600052600160045260246000fd5b8281526060810160408360208401379392505050565b634e487b7160e01b600052603260045260246000fd5b7fffffffff00000000000000000000000000000000000000000000000000000000831681526000825161239f816004850160208701611fe6565b919091016004019392505050565b81810381811115610d2457610d24612263565b6000826123cf576123cf6122c7565b500690565b600082516123e6818460208701611fe6565b919091019291505056fea26469706673582212204ab431dead71256a4825942c6096d8492ecca6eb342cc8b6bf69a52a8451af4264736f6c634300081c0033
Loading...
Loading
Loading...
Loading
[ 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.