Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- ConsumerMock
- Optimization enabled
- true
- Compiler version
- v0.8.6+commit.11564f7e
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-15T22:15:11.972453Z
Constructor Arguments
0000000000000000000000007fdbf4fe2dbbdf956c010b3dd83177cb86eb1b14
Arg [0] (address) : 0x7fdbf4fe2dbbdf956c010b3dd83177cb86eb1b14
contracts/Mocks/ConsumerMock.sol
pragma solidity ^0.8.6;import "../vrf/VRFConsumerBaseV2.sol";import "../vrf/ErinaceusVRF.sol";import "hardhat/console.sol";contract ConsumerMock is VRFConsumerBaseV2 {ErinaceusVRF public erinaceus;mapping(uint256 => uint256[]) public randomWord;uint256 public currentId;constructor(address erinaceusVRF)VRFConsumerBaseV2(erinaceusVRF){erinaceus = ErinaceusVRF(erinaceusVRF);}function getRandom(uint256 id) public view returns (uint256[] memory){return randomWord[id];}function generateRandomWords(bytes32 keyHash,uint64 subId,uint16 requestConfirmations,uint32 callbackGasLimit,uint32 numWords) external {erinaceus.requestRandomWords(keyHash,subId,requestConfirmations,callbackGasLimit,numWords);}function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual override {randomWord[currentId] = randomWords;currentId++;}}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)pragma solidity ^0.8.0;import "../utils/Context.sol";/*** @dev Contract module which provides a basic access control mechanism, where* there is an account (an owner) that can be granted exclusive access to* specific functions.** By default, the owner account will be the one that deploys the contract. This* can later be changed with {transferOwnership}.** This module is used through inheritance. It will make available the modifier* `onlyOwner`, which can be applied to your functions to restrict their use to* the owner.*/abstract contract Ownable is Context {address private _owner;event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);/*** @dev Initializes the contract setting the deployer as the initial owner.*/constructor() {_transferOwnership(_msgSender());}/*** @dev Throws if called by any account other than the owner.*/modifier onlyOwner() {_checkOwner();_;}/*** @dev Returns the address of the current owner.
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)pragma solidity ^0.8.0;/*** @dev Provides information about the current execution context, including the* sender of the transaction and its data. While these are generally available* via msg.sender and msg.data, they should not be accessed in such a direct* manner, since when dealing with meta-transactions the account sending and* paying for execution may not be the actual sender (as far as an application* is concerned).** This contract is only required for intermediate, library-like contracts.*/abstract contract Context {function _msgSender() internal view virtual returns (address) {return msg.sender;}function _msgData() internal view virtual returns (bytes calldata) {return msg.data;}function _contextSuffixLength() internal view virtual returns (uint256) {return 0;}}
contracts/interfaces/IHashHub.sol
// SPDX-License-Identifier: MITpragma solidity 0.8.6;/*** @title HashHub* @notice This contract provides a way to access blockhashes older than* the 256 block limit imposed by the BLOCKHASH opcode.* You may assume that any blockhash stored by the contract is correct.* Note that the contract depends on the format of serialized Ethereum* blocks. If a future hardfork of Ethereum changes that format, the* logic in this contract may become incorrect and an updated version* would have to be deployed.*/interface IHashHub {function store(uint256 n) external;function requestBlockhash(uint256 _blockNumber) external payable;function claimRewardsForUnregisteredBlocks(uint256[] memory _blocks) external;function getBlockhash(uint256 n) external view returns (bytes32);function rewardForStoring(uint256) external view returns(uint256);function usersRequestedBlocks(address) external view returns(uint256[] memory);function providedRewards(address, uint256) external view returns(uint256);}
contracts/vrf/ErinaceusVRF.sol
// SPDX-License-Identifier: MITpragma solidity 0.8.6;import {ErinaceusVRFInterface} from "./interfaces/ErinaceusVRFInterface.sol";import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";import {VRFConsumerBaseV2} from "./VRFConsumerBaseV2.sol";import {IHashHub} from "../interfaces/IHashHub.sol";import {VRF} from "./VRF.sol";contract ErinaceusVRF is VRF, Ownable, ErinaceusVRFInterface {IHashHub public HashHub;address public team;uint256 public withdrawableForTeam;uint256 public feePercentage;// We need to maintain a list of consuming addresses.// This bound ensures we are able to loop over them as needed.// Should a user require more consumers, they can use multiple subscriptions.uint16 public constant MAX_CONSUMERS = 100;error InvalidCalldata();error CantBeAddressZero();error TooManyConsumers();error InsufficientBalance();error InvalidSubscription();error OnlyCallableFromLink();error PendingRequestExists();error PercentageIsNotInRange();error MustBeSubOwner(address owner);error BlockhashNotInStore(uint256 blocNumber);event FundsRecovered(address to, uint256 amount);error MustBeRequestedOwner(address proposedOwner);error InvalidConsumer(uint64 subId, address consumer);error BalanceInvariantViolated(uint256 internalBalance, uint256 externalBalance); // Should never happen// We use the subscription struct (1 word)// at fulfillment time.struct Subscription {uint256 balance; // Common FTN balance used for all consumer requests.uint256 reqCount; // For fee tiers}// We use the config for the mgmt APIsstruct SubscriptionConfig {
contracts/vrf/VRF.sol
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;/** ***************************************************************************** @notice Verification of verifiable-random-function (VRF) proofs, following* @notice https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05#section-5.3* @notice See https://eprint.iacr.org/2017/099.pdf for security proofs.* @dev Bibliographic references:* @dev Goldberg, et al., "Verifiable Random Functions (VRFs)", Internet Draft* @dev draft-irtf-cfrg-vrf-05, IETF, Aug 11 2019,* @dev https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-vrf-05* @dev Papadopoulos, et al., "Making NSEC5 Practical for DNSSEC", Cryptology* @dev ePrint Archive, Report 2017/099, https://eprint.iacr.org/2017/099.pdf* ***************************************************************************** @dev USAGE* @dev The main entry point is _randomValueFromVRFProof. See its docstring.* ***************************************************************************** @dev PURPOSE* @dev Reggie the Random Oracle (not his real job) wants to provide randomness* @dev to Vera the verifier in such a way that Vera can be sure he's not* @dev making his output up to suit himself. Reggie provides Vera a public key* @dev to which he knows the secret key. Each time Vera provides a seed to* @dev Reggie, he gives back a value which is computed completely* @dev deterministically from the seed and the secret key.* @dev Reggie provides a proof by which Vera can verify that the output was* @dev correctly computed once Reggie tells it to her, but without that proof,* @dev the output is computationally indistinguishable to her from a uniform* @dev random sample from the output space.* @dev The purpose of this contract is to perform that verification.* ***************************************************************************** @dev DESIGN NOTES* @dev The VRF algorithm verified here satisfies the full uniqueness, full* @dev collision resistance, and full pseudo-randomness security properties.
contracts/vrf/VRFConsumerBaseV2.sol
// SPDX-License-Identifier: MITpragma solidity ^0.8.4;/** ***************************************************************************** @notice Interface for contracts using VRF randomness* ****************************************************************************** @dev PURPOSE** @dev Reggie the Random Oracle (not his real job) wants to provide randomness* @dev to Vera the verifier in such a way that Vera can be sure he's not* @dev making his output up to suit himself. Reggie provides Vera a public key* @dev to which he knows the secret key. Each time Vera provides a seed to* @dev Reggie, he gives back a value which is computed completely* @dev deterministically from the seed and the secret key.** @dev Reggie provides a proof by which Vera can verify that the output was* @dev correctly computed once Reggie tells it to her, but without that proof,* @dev the output is indistinguishable to her from a uniform random sample* @dev from the output space.** @dev The purpose of this contract is to make it easy for unrelated contracts* @dev to talk to Vera the verifier about the work Reggie is doing, to provide* @dev simple access to a verifiable source of randomness. It ensures 2 things:* @dev 1. The fulfillment came from the ErinaceusVRF* @dev 2. The consumer contract implements fulfillRandomWords.* ****************************************************************************** @dev USAGE** @dev Calling contracts must inherit from VRFConsumerBase, and can* @dev initialize VRFConsumerBase's attributes in their constructor as* @dev shown:** @dev contract VRFConsumer {* @dev constructor(<other arguments>, address _erinaceusVRF, address _link)* @dev VRFConsumerBase(_erinaceusVRF) public {* @dev <initialization with other arguments goes here>* @dev }* @dev }** @dev The oracle will have given you an ID for the VRF keypair they have* @dev committed to (let's call it keyHash). Create subscription, fund it
contracts/vrf/interfaces/ErinaceusVRFInterface.sol
// SPDX-License-Identifier: MITpragma solidity ^0.8.0;interface ErinaceusVRFInterface {/*** @notice Get configuration relevant for making requests* @return minimumRequestConfirmations global min for request confirmations* @return maxGasLimit global max for request gas limit* @return s_provingKeyHashes list of registered key hashes*/function getRequestConfig() external view returns (uint16, uint32, bytes32[] memory);/*** @notice Request a set of random words.* @param keyHash - Corresponds to a particular oracle job which uses* that key for generating the VRF proof. Different keyHash's have different gas price* ceilings, so you can select a specific one to bound your maximum per request cost.* @param subId - The ID of the VRF subscription. Must be funded* with the minimum subscription balance required for the selected keyHash.* @param minimumRequestConfirmations - How many blocks you'd like the* oracle to wait before responding to the request. See SECURITY CONSIDERATIONS* for why you may want to request more. The acceptable range is* [minimumRequestBlockConfirmations, 200].* @param callbackGasLimit - How much gas you'd like to receive in your* fulfillRandomWords callback. Note that gasleft() inside fulfillRandomWords* may be slightly less than this amount because of gas used calling the function* (argument decoding etc.), so you may need to request slightly more than you expect* to have inside fulfillRandomWords. The acceptable range is* [0, maxGasLimit]* @param numWords - The number of uint256 random values you'd like to receive* in your fulfillRandomWords callback. Note these numbers are expanded in a* secure way by the ErinaceusVRF from a single random value supplied by the oracle.* @return requestId - A unique identifier of the request. Can be used to match* a request to a response in fulfillRandomWords.*/function requestRandomWords(bytes32 keyHash,uint64 subId,uint16 minimumRequestConfirmations,uint32 callbackGasLimit,uint32 numWords
hardhat/console.sol
// SPDX-License-Identifier: MITpragma solidity >=0.4.22 <0.9.0;library console {address constant CONSOLE_ADDRESS =0x000000000000000000636F6e736F6c652e6c6f67;function _sendLogPayloadImplementation(bytes memory payload) internal view {address consoleAddress = CONSOLE_ADDRESS;/// @solidity memory-safe-assemblyassembly {pop(staticcall(gas(),consoleAddress,add(payload, 32),mload(payload),0,0))}}function _castToPure(function(bytes memory) internal view fnIn) internal pure returns (function(bytes memory) pure fnOut) {assembly {fnOut := fnIn}}function _sendLogPayload(bytes memory payload) internal pure {_castToPure(_sendLogPayloadImplementation)(payload);}function log() internal pure {_sendLogPayload(abi.encodeWithSignature("log()"));}function logInt(int256 p0) internal pure {_sendLogPayload(abi.encodeWithSignature("log(int256)", p0));
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":200,"enabled":true},"metadata":{"useLiteralContent":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"erinaceusVRF","internalType":"address"}]},{"type":"error","name":"OnlyErinaceusCanFulfill","inputs":[{"type":"address","name":"have","internalType":"address"},{"type":"address","name":"want","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentId","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract ErinaceusVRF"}],"name":"erinaceus","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"generateRandomWords","inputs":[{"type":"bytes32","name":"keyHash","internalType":"bytes32"},{"type":"uint64","name":"subId","internalType":"uint64"},{"type":"uint16","name":"requestConfirmations","internalType":"uint16"},{"type":"uint32","name":"callbackGasLimit","internalType":"uint32"},{"type":"uint32","name":"numWords","internalType":"uint32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256[]","name":"","internalType":"uint256[]"}],"name":"getRandom","inputs":[{"type":"uint256","name":"id","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"randomWord","inputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rawFulfillRandomWords","inputs":[{"type":"uint256","name":"requestId","internalType":"uint256"},{"type":"uint256[]","name":"randomWords","internalType":"uint256[]"}]}]
Contract Creation Code
0x60a060405234801561001057600080fd5b506040516106a33803806106a383398101604081905261002f91610065565b6001600160601b0319606082901b16608052600080546001600160a01b0319166001600160a01b03909216919091179055610095565b60006020828403121561007757600080fd5b81516001600160a01b038116811461008e57600080fd5b9392505050565b60805160601c6105e96100ba60003960008181610118015261015a01526105e96000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80631fe543e314610067578063c92d973f1461007c578063cd4b69141461008f578063dd4e5920146100b8578063e00dd161146100d9578063fe1d45b0146100e2575b600080fd5b61007a61007536600461043d565b61010d565b005b61007a61008a366004610395565b610199565b6100a261009d36600461040b565b61024d565b6040516100af9190610530565b60405180910390f35b6100cb6100c636600461050e565b6102af565b6040519081526020016100af565b6100cb60025481565b6000546100f5906001600160a01b031681565b6040516001600160a01b0390911681526020016100af565b336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461018b57604051631cdc5ebb60e01b81523360048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016602482015260440160405180910390fd5b61019582826102e0565b5050565b6000546040516305d3b1d360e41b81526004810187905267ffffffffffffffff8616602482015261ffff8516604482015263ffffffff8085166064830152831660848201526001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b15801561020d57600080fd5b505af1158015610221573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102459190610424565b505050505050565b6000818152600160209081526040918290208054835181840281018401909452808452606093928301828280156102a357602002820191906000526020600020905b81548152602001906001019080831161028f575b50505050509050919050565b600160205281600052604060002081815481106102cb57600080fd5b90600052602060002001600091509150505481565b600254600090815260016020908152604090912082516103029284019061031c565b506002805490600061031383610574565b91905055505050565b828054828255906000526020600020908101928215610357579160200282015b8281111561035757825182559160200191906001019061033c565b50610363929150610367565b5090565b5b808211156103635760008155600101610368565b803563ffffffff8116811461039057600080fd5b919050565b600080600080600060a086880312156103ad57600080fd5b85359450602086013567ffffffffffffffff811681146103cc57600080fd5b9350604086013561ffff811681146103e357600080fd5b92506103f16060870161037c565b91506103ff6080870161037c565b90509295509295909350565b60006020828403121561041d57600080fd5b5035919050565b60006020828403121561043657600080fd5b5051919050565b6000806040838503121561045057600080fd5b8235915060208084013567ffffffffffffffff8082111561047057600080fd5b818601915086601f83011261048457600080fd5b8135818111156104965761049661059d565b8060051b604051601f19603f830116810181811085821117156104bb576104bb61059d565b604052828152858101935084860182860187018b10156104da57600080fd5b600095505b838610156104fd5780358552600195909501949386019386016104df565b508096505050505050509250929050565b6000806040838503121561052157600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156105685783518352928401929184019160010161054c565b50909695505050505050565b600060001982141561059657634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212201674f807103d7555a958b73d8ca121f852a91bc96e1fa1cd1fec7c301519b01164736f6c634300080600330000000000000000000000007fdbf4fe2dbbdf956c010b3dd83177cb86eb1b14
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100625760003560e01c80631fe543e314610067578063c92d973f1461007c578063cd4b69141461008f578063dd4e5920146100b8578063e00dd161146100d9578063fe1d45b0146100e2575b600080fd5b61007a61007536600461043d565b61010d565b005b61007a61008a366004610395565b610199565b6100a261009d36600461040b565b61024d565b6040516100af9190610530565b60405180910390f35b6100cb6100c636600461050e565b6102af565b6040519081526020016100af565b6100cb60025481565b6000546100f5906001600160a01b031681565b6040516001600160a01b0390911681526020016100af565b336001600160a01b037f0000000000000000000000007fdbf4fe2dbbdf956c010b3dd83177cb86eb1b14161461018b57604051631cdc5ebb60e01b81523360048201526001600160a01b037f0000000000000000000000007fdbf4fe2dbbdf956c010b3dd83177cb86eb1b1416602482015260440160405180910390fd5b61019582826102e0565b5050565b6000546040516305d3b1d360e41b81526004810187905267ffffffffffffffff8616602482015261ffff8516604482015263ffffffff8085166064830152831660848201526001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b15801561020d57600080fd5b505af1158015610221573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102459190610424565b505050505050565b6000818152600160209081526040918290208054835181840281018401909452808452606093928301828280156102a357602002820191906000526020600020905b81548152602001906001019080831161028f575b50505050509050919050565b600160205281600052604060002081815481106102cb57600080fd5b90600052602060002001600091509150505481565b600254600090815260016020908152604090912082516103029284019061031c565b506002805490600061031383610574565b91905055505050565b828054828255906000526020600020908101928215610357579160200282015b8281111561035757825182559160200191906001019061033c565b50610363929150610367565b5090565b5b808211156103635760008155600101610368565b803563ffffffff8116811461039057600080fd5b919050565b600080600080600060a086880312156103ad57600080fd5b85359450602086013567ffffffffffffffff811681146103cc57600080fd5b9350604086013561ffff811681146103e357600080fd5b92506103f16060870161037c565b91506103ff6080870161037c565b90509295509295909350565b60006020828403121561041d57600080fd5b5035919050565b60006020828403121561043657600080fd5b5051919050565b6000806040838503121561045057600080fd5b8235915060208084013567ffffffffffffffff8082111561047057600080fd5b818601915086601f83011261048457600080fd5b8135818111156104965761049661059d565b8060051b604051601f19603f830116810181811085821117156104bb576104bb61059d565b604052828152858101935084860182860187018b10156104da57600080fd5b600095505b838610156104fd5780358552600195909501949386019386016104df565b508096505050505050509250929050565b6000806040838503121561052157600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156105685783518352928401929184019160010161054c565b50909695505050505050565b600060001982141561059657634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212201674f807103d7555a958b73d8ca121f852a91bc96e1fa1cd1fec7c301519b01164736f6c63430008060033