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-05-20T14:54:10.430161Z
Constructor Arguments
0000000000000000000000007dede566d7736d979a7d0dfece03290abfa0aff6
Arg [0] (address) : 0x7dede566d7736d979a7d0dfece03290abfa0aff6
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;uint256[] public random;// uint public constant totalSupply = 10**27;// string public constant name = "ChainLink Token";// uint8 public constant decimals = 18;// string public constant symbol = "LINK";// function LinkToken()// public// {// balances[msg.sender] = totalSupply;// }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 getRandom1() public view returns (uint256[] memory){return random;}function generateRandomWords(bytes32 keyHash,uint64 subId,uint16 requestConfirmations,uint32 callbackGasLimit,uint32 numWords) external {erinaceus.requestRandomWords(
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, uint256 _reward) external;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);}
@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/IWFTN.sol
// SPDX-License-Identifier: MIT// Copyright (C) 2024 Fasttoken// This program is free software: you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation, either version 3 of the License, or// (at your option) any later version.// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.// You should have received a copy of the GNU General Public License// along with this program. If not, see <http://www.gnu.org/licenses/>.pragma solidity ^0.8.6;interface IWFTN {receive() external payable;function deposit() external payable;function withdraw(uint256 amount_) external;function balanceOf(address account) external view returns (uint256);function totalSupply() external view returns (uint256);function approve(address to_, uint256 amount_) external returns (bool);function transfer(address to_, uint256 amount_) external returns (bool);function transferFrom(address src_, address to_, uint256 amount_)externalreturns (bool);}
contracts/vrf/ErinaceusVRF.sol
// SPDX-License-Identifier: MITpragma solidity 0.8.6;import {VRF} from "./VRF.sol";import {IWFTN} from "../interfaces/IWFTN.sol";import {VRFConsumerBaseV2} from "./VRFConsumerBaseV2.sol";import {IHashHub} from "../interfaces/IHashHub.sol";import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";import {ErinaceusVRFInterface} from "./interfaces/ErinaceusVRFInterface.sol";import "hardhat/console.sol";contract ErinaceusVRF is VRF, Ownable, ErinaceusVRFInterface {// solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-iIWFTN public wFTN;IHashHub public HashHub;address public team;uint256 public withdrawableForTeam;uint256 public feePercentage;// solhint-disable-next-line chainlink-solidity/prefix-immutable-variables-with-i// 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 {
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":"getRandom1","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"random","inputs":[{"type":"uint256","name":"","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[]"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"test","inputs":[{"type":"uint256[]","name":"randomWords","internalType":"uint256[]"}]}]
Contract Creation Code
0x60a060405234801561001057600080fd5b5060405161080538038061080583398101604081905261002f91610065565b6001600160601b0319606082901b16608052600080546001600160a01b0319166001600160a01b03909216919091179055610095565b60006020828403121561007757600080fd5b81516001600160a01b038116811461008e57600080fd5b9392505050565b60805160601c61074b6100ba6000396000818161017701526101b9015261074b6000f3fe608060405234801561001057600080fd5b50600436106100935760003560e01c8063ca16068411610066578063ca160684146100ff578063cd4b691414610112578063dd4e592014610125578063e00dd16114610138578063fe1d45b01461014157600080fd5b80631fe543e31461009857806395d430f2146100ad578063b863bd37146100cb578063c92d973f146100ec575b600080fd5b6100ab6100a6366004610629565b61016c565b005b6100b56101f8565b6040516100c29190610692565b60405180910390f35b6100de6100d93660046105f7565b610250565b6040519081526020016100c2565b6100ab6100fa366004610581565b610271565b6100ab61010d366004610544565b610325565b6100b56101203660046105f7565b61035b565b6100de610133366004610670565b6103bd565b6100de60035481565b600054610154906001600160a01b031681565b6040516001600160a01b0390911681526020016100c2565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146101ea57604051631cdc5ebb60e01b81523360048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016602482015260440160405180910390fd5b6101f482826103ee565b5050565b6060600180548060200260200160405190810160405280929190818152602001828054801561024657602002820191906000526020600020905b815481526020019060010190808311610232575b5050505050905090565b6001818154811061026057600080fd5b600091825260209091200154905081565b6000546040516305d3b1d360e41b81526004810187905267ffffffffffffffff8616602482015261ffff8516604482015263ffffffff8085166064830152831660848201526001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b1580156102e557600080fd5b505af11580156102f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031d9190610610565b505050505050565b805161033890600190602084019061042a565b50600354600090815260026020908152604090912082516101f49284019061042a565b6000818152600260209081526040918290208054835181840281018401909452808452606093928301828280156103b157602002820191906000526020600020905b81548152602001906001019080831161039d575b50505050509050919050565b600260205281600052604060002081815481106103d957600080fd5b90600052602060002001600091509150505481565b600354600090815260026020908152604090912082516104109284019061042a565b5060038054906000610421836106d6565b91905055505050565b828054828255906000526020600020908101928215610465579160200282015b8281111561046557825182559160200191906001019061044a565b50610471929150610475565b5090565b5b808211156104715760008155600101610476565b600082601f83011261049b57600080fd5b8135602067ffffffffffffffff808311156104b8576104b86106ff565b8260051b604051601f19603f830116810181811084821117156104dd576104dd6106ff565b604052848152838101925086840182880185018910156104fc57600080fd5b600092505b8583101561051f578035845292840192600192909201918401610501565b50979650505050505050565b803563ffffffff8116811461053f57600080fd5b919050565b60006020828403121561055657600080fd5b813567ffffffffffffffff81111561056d57600080fd5b6105798482850161048a565b949350505050565b600080600080600060a0868803121561059957600080fd5b85359450602086013567ffffffffffffffff811681146105b857600080fd5b9350604086013561ffff811681146105cf57600080fd5b92506105dd6060870161052b565b91506105eb6080870161052b565b90509295509295909350565b60006020828403121561060957600080fd5b5035919050565b60006020828403121561062257600080fd5b5051919050565b6000806040838503121561063c57600080fd5b82359150602083013567ffffffffffffffff81111561065a57600080fd5b6106668582860161048a565b9150509250929050565b6000806040838503121561068357600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156106ca578351835292840192918401916001016106ae565b50909695505050505050565b60006000198214156106f857634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212205ae26ee7ff09efde67974496d9b74a1a6fef13e7f1f459e62b0adf3d33df4e3c64736f6c634300080600330000000000000000000000007dede566d7736d979a7d0dfece03290abfa0aff6
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100935760003560e01c8063ca16068411610066578063ca160684146100ff578063cd4b691414610112578063dd4e592014610125578063e00dd16114610138578063fe1d45b01461014157600080fd5b80631fe543e31461009857806395d430f2146100ad578063b863bd37146100cb578063c92d973f146100ec575b600080fd5b6100ab6100a6366004610629565b61016c565b005b6100b56101f8565b6040516100c29190610692565b60405180910390f35b6100de6100d93660046105f7565b610250565b6040519081526020016100c2565b6100ab6100fa366004610581565b610271565b6100ab61010d366004610544565b610325565b6100b56101203660046105f7565b61035b565b6100de610133366004610670565b6103bd565b6100de60035481565b600054610154906001600160a01b031681565b6040516001600160a01b0390911681526020016100c2565b336001600160a01b037f0000000000000000000000007dede566d7736d979a7d0dfece03290abfa0aff616146101ea57604051631cdc5ebb60e01b81523360048201526001600160a01b037f0000000000000000000000007dede566d7736d979a7d0dfece03290abfa0aff616602482015260440160405180910390fd5b6101f482826103ee565b5050565b6060600180548060200260200160405190810160405280929190818152602001828054801561024657602002820191906000526020600020905b815481526020019060010190808311610232575b5050505050905090565b6001818154811061026057600080fd5b600091825260209091200154905081565b6000546040516305d3b1d360e41b81526004810187905267ffffffffffffffff8616602482015261ffff8516604482015263ffffffff8085166064830152831660848201526001600160a01b0390911690635d3b1d309060a401602060405180830381600087803b1580156102e557600080fd5b505af11580156102f9573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031d9190610610565b505050505050565b805161033890600190602084019061042a565b50600354600090815260026020908152604090912082516101f49284019061042a565b6000818152600260209081526040918290208054835181840281018401909452808452606093928301828280156103b157602002820191906000526020600020905b81548152602001906001019080831161039d575b50505050509050919050565b600260205281600052604060002081815481106103d957600080fd5b90600052602060002001600091509150505481565b600354600090815260026020908152604090912082516104109284019061042a565b5060038054906000610421836106d6565b91905055505050565b828054828255906000526020600020908101928215610465579160200282015b8281111561046557825182559160200191906001019061044a565b50610471929150610475565b5090565b5b808211156104715760008155600101610476565b600082601f83011261049b57600080fd5b8135602067ffffffffffffffff808311156104b8576104b86106ff565b8260051b604051601f19603f830116810181811084821117156104dd576104dd6106ff565b604052848152838101925086840182880185018910156104fc57600080fd5b600092505b8583101561051f578035845292840192600192909201918401610501565b50979650505050505050565b803563ffffffff8116811461053f57600080fd5b919050565b60006020828403121561055657600080fd5b813567ffffffffffffffff81111561056d57600080fd5b6105798482850161048a565b949350505050565b600080600080600060a0868803121561059957600080fd5b85359450602086013567ffffffffffffffff811681146105b857600080fd5b9350604086013561ffff811681146105cf57600080fd5b92506105dd6060870161052b565b91506105eb6080870161052b565b90509295509295909350565b60006020828403121561060957600080fd5b5035919050565b60006020828403121561062257600080fd5b5051919050565b6000806040838503121561063c57600080fd5b82359150602083013567ffffffffffffffff81111561065a57600080fd5b6106668582860161048a565b9150509250929050565b6000806040838503121561068357600080fd5b50508035926020909101359150565b6020808252825182820181905260009190848201906040850190845b818110156106ca578351835292840192918401916001016106ae565b50909695505050505050565b60006000198214156106f857634e487b7160e01b600052601160045260246000fd5b5060010190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212205ae26ee7ff09efde67974496d9b74a1a6fef13e7f1f459e62b0adf3d33df4e3c64736f6c63430008060033