Overview
AVAX Balance
AVAX Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 39,591 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Play Game | 60805764 | 6 mins ago | IN | 5.25 AVAX | 0.00067906 | ||||
Play Game | 60805603 | 10 mins ago | IN | 5.25 AVAX | 0.00068648 | ||||
Play Game | 60805580 | 10 mins ago | IN | 5.25 AVAX | 0.00068552 | ||||
Play Game | 60805555 | 11 mins ago | IN | 5.25 AVAX | 0.00068474 | ||||
Play Game | 60805501 | 12 mins ago | IN | 10.5 AVAX | 0.00068887 | ||||
Play Game | 60805391 | 14 mins ago | IN | 4.2 AVAX | 0.00065449 | ||||
Play Game | 60805371 | 14 mins ago | IN | 2.1 AVAX | 0.00065134 | ||||
Play Game | 60805314 | 15 mins ago | IN | 10.5 AVAX | 0.00065831 | ||||
Play Game | 60805253 | 16 mins ago | IN | 10.5 AVAX | 0.00067948 | ||||
Play Game | 60805206 | 17 mins ago | IN | 10.5 AVAX | 0.00067475 | ||||
Play Game | 60805157 | 18 mins ago | IN | 10.5 AVAX | 0.00067953 | ||||
Play Game | 60805123 | 19 mins ago | IN | 10.5 AVAX | 0.00067727 | ||||
Play Game | 60805068 | 20 mins ago | IN | 5.25 AVAX | 0.00068915 | ||||
Play Game | 60805028 | 21 mins ago | IN | 5.25 AVAX | 0.00067308 | ||||
Play Game | 60804995 | 21 mins ago | IN | 5.25 AVAX | 0.00067322 | ||||
Play Game | 60804837 | 25 mins ago | IN | 5.25 AVAX | 0.00070627 | ||||
Play Game | 60804719 | 28 mins ago | IN | 10.5 AVAX | 0.00073439 | ||||
Play Game | 60804681 | 28 mins ago | IN | 4.2 AVAX | 0.00071601 | ||||
Play Game | 60804628 | 30 mins ago | IN | 10.5 AVAX | 0.00074182 | ||||
Play Game | 60804603 | 30 mins ago | IN | 5.25 AVAX | 0.00072851 | ||||
Play Game | 60804576 | 31 mins ago | IN | 4.2 AVAX | 0.00073209 | ||||
Play Game | 60804559 | 31 mins ago | IN | 2.1 AVAX | 0.00073467 | ||||
Play Game | 60804547 | 31 mins ago | IN | 1.05 AVAX | 0.00074194 | ||||
Play Game | 60804379 | 35 mins ago | IN | 10.5 AVAX | 0.00083834 | ||||
Play Game | 60804345 | 36 mins ago | IN | 21 AVAX | 0.00087937 |
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
60805764 | 6 mins ago | 0.25 AVAX | ||||
60805764 | 6 mins ago | 5 AVAX | ||||
60805603 | 10 mins ago | 0.25 AVAX | ||||
60805603 | 10 mins ago | 5 AVAX | ||||
60805580 | 10 mins ago | 0.25 AVAX | ||||
60805580 | 10 mins ago | 5 AVAX | ||||
60805555 | 11 mins ago | 0.25 AVAX | ||||
60805555 | 11 mins ago | 5 AVAX | ||||
60805501 | 12 mins ago | 0.5 AVAX | ||||
60805501 | 12 mins ago | 10 AVAX | ||||
60805391 | 14 mins ago | 0.2 AVAX | ||||
60805391 | 14 mins ago | 4 AVAX | ||||
60805371 | 14 mins ago | 0.1 AVAX | ||||
60805371 | 14 mins ago | 2 AVAX | ||||
60805314 | 15 mins ago | 0.5 AVAX | ||||
60805314 | 15 mins ago | 10 AVAX | ||||
60805253 | 16 mins ago | 0.5 AVAX | ||||
60805253 | 16 mins ago | 10 AVAX | ||||
60805206 | 17 mins ago | 0.5 AVAX | ||||
60805206 | 17 mins ago | 10 AVAX | ||||
60805157 | 18 mins ago | 0.5 AVAX | ||||
60805157 | 18 mins ago | 10 AVAX | ||||
60805123 | 19 mins ago | 0.5 AVAX | ||||
60805123 | 19 mins ago | 10 AVAX | ||||
60805068 | 20 mins ago | 0.25 AVAX |
Loading...
Loading
Contract Name:
Flip
Compiler Version
v0.8.22+commit.4fc1097e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable.sol"; import "../CentralGameBase.sol"; import "../GameBet.sol"; import "../GameVRF.sol"; import "../IRakeDistributor.sol"; import "../ITreasury.sol"; /// Flip a coin. contract Flip is CentralGameBase, GameBet, GameVRF { /// Game input provided by user. enum RoundChoice { HEADS, // 0 TAILS // 1 } /// Standardized game complete info. struct RoundInfo { RoundChoice selected; RoundState state; uint256 sent; } /// Emitted when game is started. event GameStarted( address indexed creator, uint256 indexed gameId, uint8 subgame, uint256 numRounds, RoundChoice[] choices, address referrer, uint256 betPerRound, uint256 rakePerRound, FulfillmentMethod method ); /// Emitted when game is fully completed with no other actions available. event WinnerPicked(uint256 indexed gameId, RoundInfo[] results); /// Per-game user choices, by gameId. mapping(uint256 => RoundChoice[]) public choicesByGameId; /// Contract can be funded. receive() external payable {} /// Constructor populates generic Chainlink values. constructor() GameVRF() {} /// Create a new game. /// User can choose heads or tails independently for each round. function playGame( RoundChoice[] memory choices, string memory referralCode, FulfillmentMethod method ) external payable isEOA isNotPaused isEnoughTreasury returns (uint256) { IRakeDistributor rakeDistributor = IRakeDistributor(rakeDistributorAddress); uint256 numRounds = choices.length; BetDetails memory details = validateBet( treasuryAddress.balance, rakeDistributor.getTotalRake(), numRounds); currentGameId++; GameInfo memory gi; gi.creator = msg.sender; gi.referrer = rakeDistributor.getReferrerFromGamerAndCode(msg.sender, referralCode); gi.gameId = currentGameId; gi.state = GameState.CALCULATING; gi.numRounds = numRounds; gi.betPerRound = details.betPerRound; gi.rakePerRound = details.rakePerRound; gi.subgame = 1; gameById[gi.gameId] = gi; choicesByGameId[gi.gameId] = choices; { (bool success,) = payable(treasuryAddress).call{value: details.bet}(""); require(success, "Failed to send to treasury"); } gameById[gi.gameId] = gi; emit GameStarted( msg.sender, gi.gameId, gi.subgame, numRounds, choices, gi.referrer, gi.betPerRound, gi.rakePerRound, method ); rakeDistributor.distributeReferredRake{value: details.rake}(gi.gameId, msg.sender, gi.referrer); _requestGameFulfillment(gi.gameId, method); return gi.gameId; } /// Receives the random number from VRF and calculates win/loss/tie. /// Transfers the appropriate amount of funds from treasury to the user on wins. function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal override { uint256 gameId = gameIdByRequestId[requestId]; require(gameId != 0, "Request already fulfilled"); GameInfo storage gi = gameById[gameId]; require(gi.state == GameState.CALCULATING, "Game not waiting for results"); RoundChoice[] memory savedChoices = choicesByGameId[gameId]; uint256 choicesLength = savedChoices.length; RoundInfo[] memory results = new RoundInfo[](choicesLength); uint256 winnings; for (uint256 i; i < choicesLength; ++i) { uint256 flipRandom = uint256(keccak256(abi.encode(randomWords[0], i))); results[i].selected = flipRandom % 2 == 0 ? RoundChoice.HEADS : RoundChoice.TAILS; results[i].state = RoundState.LOST; if (savedChoices[i] == results[i].selected) { results[i].state = RoundState.WON; winnings += gi.betPerRound; results[i].sent = gi.betPerRound * 2; } } emit WinnerPicked(gameId, results); address creator = gi.creator; delete gameById[gameId]; delete gameIdByRequestId[requestId]; delete choicesByGameId[gameId]; if (winnings > 0) { ITreasury(treasuryAddress).sendPayout(creator, winnings * 2); } } /// Triggers VRF process for a given game in case of emergency. function forceRequestWinner(uint256 gameId, FulfillmentMethod method) external onlyOwner { GameInfo storage gi = gameById[gameId]; require(gi.state != GameState.CLOSED, "already closed"); _requestGameFulfillment(gi.gameId, method); } /// Compute the max bet, for use by the UI. Slightly trims the actual max amount. function getMaxBetPerRound() external view returns (uint256 safeMaxPotentialBet) { uint256 maxPotentialWin = treasuryAddress.balance / maxBetDivisor; uint256 maxPotentialBet = maxPotentialWin; safeMaxPotentialBet = maxPotentialBet * 100 / 95; } }
// 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. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable2Step.sol"; import "./Rescue.sol"; import "./ITreasury.sol"; /// Centralized handling of a lot of stuff our games need. All games inherit from this. abstract contract CentralGameBase is Ownable2Step, Rescue { /// Status of an individual betting round in a game. /// Not all states apply to all games (e.g. TIE). enum RoundState { UNKNOWN, // Should never be used. LOST, TIE, WON } /// The status of the game, consisting of a set of rounds. enum GameState { /// Waiting for RNG. CALCULATING, /// Game is finalized and no actions can be taken. CLOSED, /// For PvP games, waiting for 1 or more other players. WAITING_FOR_PLAYER, /// For PvP games, the game creator canceled play. CANCELED } /// Every game played has a GameInfo created for it. /// The details for the individual game are stored separately per game. struct GameInfo { uint256 gameId; uint256 betPerRound; uint256 rakePerRound; uint256 numRounds; address creator; address referrer; uint8 subgame; GameState state; } /// Incrementing counter for the current gameId. uint256 public currentGameId; /// Standardized GameInfo structs mapped by gameId. mapping(uint256 => GameInfo) public gameById; /// Global switch to disallow play. bool public paused; /// Address of the rake distributor. address public rakeDistributorAddress; /// Address of the referral tracker address public referralTrackerAddress; /// Address of the treasury. address public treasuryAddress; /// Prevent contracts from playing with this modifier. modifier isEOA() { require(tx.origin == msg.sender, "No contracts allowed"); _; } /// Prevent play when the game is paused. modifier isNotPaused() { require(!paused, "Game is paused"); _; } modifier isEnoughTreasury() { require(!ITreasury(treasuryAddress).isTreasuryTooLow(), "Treasury is too low!"); _; } /// Fetch details about an individual game. function getGameInfo(uint256 gameId) public view returns (GameInfo memory) { return gameById[gameId]; } /// Fetch details about many games simultaneously. /// This is just a helper function for offline use. function getManyGameInfo(uint256[] memory gameIds) public view returns (GameInfo[] memory) { uint256 gameIdLength = gameIds.length; GameInfo[] memory ret = new GameInfo[](gameIdLength); for (uint256 i; i < gameIdLength; ++i) { ret[i] = gameById[gameIds[i]]; } return ret; } function setPaused(bool paused_) public onlyOwner { paused = paused_; } function setRakeDistributorAddress(address rakeAddress) external onlyOwner { rakeDistributorAddress = rakeAddress; } function setTreasuryAddress(address _treasuryAddress) external onlyOwner { treasuryAddress = _treasuryAddress; } function setReferralTrackerAddress(address _referralTrackerAddress) external onlyOwner { referralTrackerAddress = _referralTrackerAddress; } function setCurrentGameId(uint256 gameId_) external onlyOwner { currentGameId = gameId_; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@openzeppelin/contracts/access/Ownable2Step.sol"; abstract contract GameBet is Ownable2Step { /// Minimum allowed bet. uint256 public minBet = .5 ether; /// Maximum single bet amount is treasury divided by this. uint256 public maxBetDivisor = 20; /// Maxmimum number of rounds that can be played in a single game. // /// The total amount bet is the limiting factor, so this is just a reasonable-ness limit /// on the number of rounds allowed. uint256 public maxConsecutiveRounds = 10; /// Bet amounts per round must be a multiple of this uint256 public betMultiplePerRound = .01 ether; struct BetDetails { uint256 bet; uint256 rake; uint256 betPerRound; uint256 rakePerRound; uint256 payoutPerRound; } function validateBet(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds) internal returns (BetDetails memory) { // TODO: this is retarded, pass the bet in instead? uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 rake = msg.value - bet; require(bet >= minBet, "Gamble more, pleb"); // TODO: This should probably apply to the potentialWin instead of the bet amount // Currently this assumes 2x win values? require(bet <= (treasuryBalance / maxBetDivisor), "Gamble less, king"); require(numRounds > 0, "Gamble at least once, pleb"); require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king"); uint256 betPerRound = bet / numRounds; require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb"); require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb"); uint256 rakePerRound = rake / numRounds; require(rake % numRounds == 0, "Internal error; wrong rake amount"); return BetDetails({ bet: bet, rake: rake, betPerRound: betPerRound, rakePerRound: rakePerRound, payoutPerRound: 0 // Not supported }); } function validateBetWithPayout(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds, uint256 betNumerator, uint256 betDenominator) internal returns (BetDetails memory) { uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 maxPayoutValue = bet * betNumerator / betDenominator; return validateBetWithMaxPayoutValue(treasuryBalance, totalRake, numRounds, maxPayoutValue); } function validateBetWithMaxPayoutValue(uint256 treasuryBalance, uint256 totalRake, uint256 numRounds, uint256 maxPayoutValue) internal returns (BetDetails memory) { require(numRounds > 0, "Gamble at least one round, pleb"); uint256 bet = (msg.value * 10000 / (totalRake + 10000)); uint256 rake = msg.value - bet; require(bet >= minBet, "Gamble more, pleb"); require(numRounds > 0, "Gamble at least once, pleb"); require(numRounds <= maxConsecutiveRounds, "Gamble fewer times, king"); uint256 betPerRound = bet / numRounds; require(bet % numRounds == 0, "Gamble an amount divisible by your bets, pleb"); require(betPerRound % betMultiplePerRound == 0, "Gamble the right amount per bet, pleb"); uint256 rakePerRound = rake / numRounds; require(rake % numRounds == 0, "Internal error; wrong rake amount"); uint256 maxPayoutPerRound = maxPayoutValue / numRounds; require(betPerRound < maxPayoutPerRound, "Place a gamble that won't guarantee you lose, pleb"); require(maxPayoutPerRound - betPerRound <= (treasuryBalance / maxBetDivisor), "Gamble less, king"); return BetDetails({ bet: bet, rake: rake, betPerRound: betPerRound, rakePerRound: rakePerRound, payoutPerRound: maxPayoutPerRound }); } function setMinBet(uint256 minBet_) external onlyOwner { minBet = minBet_; } function setMaxBetDivisor(uint256 maxBetDivisor_) external onlyOwner { maxBetDivisor = maxBetDivisor_; } function setMaxConsecutiveRounds(uint256 maxConsecutiveRounds_) external onlyOwner { maxConsecutiveRounds = maxConsecutiveRounds_; } function setBetMultiplePerRound(uint256 betMultiplePerRound_) external onlyOwner { betMultiplePerRound = betMultiplePerRound_; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; import "@chainlink/contracts/src/v0.8/interfaces/VRFCoordinatorV2Interface.sol"; import "@chainlink/contracts/src/v0.8/VRFConsumerBaseV2.sol"; import "./FerdyMultiVRFConsumerBase.sol"; /// We have 3 different potential mechanisms for requesting randomness. /// Avax: Chainlink / FerdyRNG /// Base: FerdyRNG /// FerdyNet: On-chain via difficulty parameter // // These utilities abstracts that fact from each game. // The FerdyRNG and on-chain providers both copy the ChainLink coordinator mechanism. abstract contract GameVRF is FerdyMultiVRFConsumerBase { enum FulfillmentMethod { CHAINLINK, // 0 FERDY, // 1 ONCHAIN // 2 - no longer used, was for ferdynet } struct CoordinatorInfo { bytes32 gasLane; address coordAddress; uint64 subscriptionId; uint32 callbackGasLimit; } mapping(FulfillmentMethod => CoordinatorInfo) private coordinatorInfoByMethod; /// Minimum on AVAX is 2; might need changing for other chains. uint16 private _requestConfirmations = 2; /// We always request one word, and just permute it in the fulfillment as required. uint32 private constant NUM_WORDS = 1; /// Game IDs mapped by VRF request ID. /// Keeps track of which request was for which game, so they can be fulfilled mapping(uint256 => uint256) public gameIdByRequestId; /// Emitted when a VRF request has been sent for a game. event RequestedGameWinner(uint256 indexed requestId, address indexed vrfCoordinator, uint256 indexed gameId); constructor() {} function setVRFCoordinatorInfoByMethod(FulfillmentMethod method, bytes32 gasLane, address coordAddress, uint64 subscriptionId, uint32 callbackGasLimit) external onlyOwner { coordinatorInfoByMethod[method] = CoordinatorInfo(gasLane, coordAddress, subscriptionId, callbackGasLimit); setVRFCoordinator(coordAddress, true); } /// Requests VRF for a game and tracks the mapping from request to game. function _requestGameFulfillment(uint256 gameId, FulfillmentMethod method) internal { address coordinatorAddress = coordinatorInfoByMethod[method].coordAddress; require(coordinatorAddress != address(0), "Invalid VRF address"); VRFCoordinatorV2Interface vrfCoordinator = VRFCoordinatorV2Interface(coordinatorAddress); uint256 requestId = vrfCoordinator.requestRandomWords( coordinatorInfoByMethod[method].gasLane, coordinatorInfoByMethod[method].subscriptionId, _requestConfirmations, coordinatorInfoByMethod[method].callbackGasLimit, NUM_WORDS ); gameIdByRequestId[requestId] = gameId; } function getRequestConfirmations() public view returns (uint16) { return _requestConfirmations; } function setRequestConfirmations(uint16 requestConfirmations) public onlyOwner { _requestConfirmations = requestConfirmations; } function getNumWords() public pure returns (uint256) { return NUM_WORDS; } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; interface IRakeDistributor { function getTotalRake() external view returns (uint256); function distributeReferredRake(uint256 gameId, address player, address referrer) external payable; function getReferrerFromGamerAndCode(address gamer, string memory referralCode) external view returns (address); function setOperator(address operator, bool isValid) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; interface ITreasury { function sendPayout(address gamer, uint256 amount) external; function setGame(address game, bool isValid) external; function isTreasuryTooLow() external returns (bool); }
// 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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol) pragma solidity ^0.8.0; import "./Ownable.sol"; /** * @dev Contract module which provides 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} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner"); _transferOwnership(sender); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; import "@openzeppelin/contracts/access/Ownable2Step.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; abstract contract Rescue is Ownable2Step { /// Withdraws native funds to contract owner in case of emergency. function rescueNative(uint256 amount) external onlyOwner { (bool success,) = payable(msg.sender).call{value: amount}(""); require(success); } /// Withdraws ERC20 to contract owner in case of emergency. function rescueERC20(address tokenAddress) public onlyOwner { IERC20 token = IERC20(tokenAddress); token.transfer(msg.sender, token.balanceOf(address(this))); } /// Withdraws ERC721 to contract owner in case of emergency. function rescueERC721(address tokenAddress, uint256 tokenId) public onlyOwner { IERC721 token = IERC721(tokenAddress); token.transferFrom(address(this), msg.sender, tokenId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface VRFCoordinatorV2Interface { /** * @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 VRFCoordinator 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 ) external returns (uint256 requestId); /** * @notice Create a VRF subscription. * @return subId - A unique subscription id. * @dev You can manage the consumer set dynamically with addConsumer/removeConsumer. * @dev Note to fund the subscription, use transferAndCall. For example * @dev LINKTOKEN.transferAndCall( * @dev address(COORDINATOR), * @dev amount, * @dev abi.encode(subId)); */ function createSubscription() external returns (uint64 subId); /** * @notice Get a VRF subscription. * @param subId - ID of the subscription * @return balance - LINK balance of the subscription in juels. * @return reqCount - number of requests for this subscription, determines fee tier. * @return owner - owner of the subscription. * @return consumers - list of consumer address which are able to use this subscription. */ function getSubscription(uint64 subId) external view returns ( uint96 balance, uint64 reqCount, address owner, address[] memory consumers ); /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @param newOwner - proposed new owner of the subscription */ function requestSubscriptionOwnerTransfer(uint64 subId, address newOwner) external; /** * @notice Request subscription owner transfer. * @param subId - ID of the subscription * @dev will revert if original owner of subId has * not requested that msg.sender become the new owner. */ function acceptSubscriptionOwnerTransfer(uint64 subId) external; /** * @notice Add a consumer to a VRF subscription. * @param subId - ID of the subscription * @param consumer - New consumer which can use the subscription */ function addConsumer(uint64 subId, address consumer) external; /** * @notice Remove a consumer from a VRF subscription. * @param subId - ID of the subscription * @param consumer - Consumer to remove from the subscription */ function removeConsumer(uint64 subId, address consumer) external; /** * @notice Cancel a subscription * @param subId - ID of the subscription * @param to - Where to send the remaining LINK to */ function cancelSubscription(uint64 subId, address to) external; /* * @notice Check to see if there exists a request commitment consumers * for all consumers and keyhashes for a given sub. * @param subId - ID of the subscription * @return true if there exists at least one unfulfilled request for the subscription, false * otherwise. */ function pendingRequestExists(uint64 subId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma 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 VRFCoordinator * @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 _vrfCoordinator, address _link) * @dev VRFConsumerBase(_vrfCoordinator) 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 * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface * @dev subscription management functions). * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind, * @dev if your contract could have multiple requests in flight simultaneously. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. * * ***************************************************************************** * @dev SECURITY CONSIDERATIONS * * @dev A method with the ability to call your fulfillRandomness method directly * @dev could spoof a VRF response with any random value, so it's critical that * @dev it cannot be directly called by anything other than this base contract * @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method). * * @dev For your users to trust that your contract's random behavior is free * @dev from malicious interference, it's best if you can write it so that all * @dev behaviors implied by a VRF response are executed *during* your * @dev fulfillRandomness method. If your contract must store the response (or * @dev anything derived from it) and use it later, you must ensure that any * @dev user-significant behavior which depends on that stored value cannot be * @dev manipulated by a subsequent VRF request. * * @dev Similarly, both miners and the VRF oracle itself have some influence * @dev over the order in which VRF responses appear on the blockchain, so if * @dev your contract could have multiple VRF requests in flight simultaneously, * @dev you must ensure that the order in which the VRF responses arrive cannot * @dev be used to manipulate your contract's user-significant behavior. * * @dev Since the block hash of the block which contains the requestRandomness * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful * @dev miner could, in principle, fork the blockchain to evict the block * @dev containing the request, forcing the request to be included in a * @dev different block with a different hash, and therefore a different input * @dev to the VRF. However, such an attack would incur a substantial economic * @dev cost. This cost scales with the number of blocks the VRF oracle waits * @dev until it calls responds to a request. It is for this reason that * @dev that you can signal to an oracle you'd like them to wait longer before * @dev responding to the request (however this is not enforced in the contract * @dev and so remains effective only in the case of unmodified oracle software). */ abstract contract VRFConsumerBaseV2 { error OnlyCoordinatorCanFulfill(address have, address want); address private immutable vrfCoordinator; /** * @param _vrfCoordinator address of VRFCoordinator contract */ constructor(address _vrfCoordinator) { vrfCoordinator = _vrfCoordinator; } /** * @notice fulfillRandomness handles the VRF response. Your contract must * @notice implement it. See "SECURITY CONSIDERATIONS" above for important * @notice principles to keep in mind when implementing your fulfillRandomness * @notice method. * * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words */ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (msg.sender != vrfCoordinator) { revert OnlyCoordinatorCanFulfill(msg.sender, vrfCoordinator); } fulfillRandomWords(requestId, randomWords); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.22; /** **************************************************************************** * @notice Interface for contracts using VRF randomness * Modified version of Chainlinks VRFConsumerBase to use multiple coordinators * ***************************************************************************** * * @dev Calling contracts must inherit from VRFConsumerBase * * @dev USAGE * * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, * @dev callbackGasLimit, numWords), * @dev see (VRFCoordinatorInterface for a description of the arguments). * * @dev Once the VRFCoordinator has received and validated the oracle's response * @dev to your request, it will call your contract's fulfillRandomWords method. * * @dev The randomness argument to fulfillRandomWords is a set of random words * @dev generated from your requestId and the blockHash of the request. * * @dev If your contract could have concurrent requests open, you can use the * @dev requestId returned from requestRandomWords to track which response is associated * @dev with which randomness request. * * @dev Colliding `requestId`s are cryptographically impossible as long as seeds * @dev differ. **/ import "@openzeppelin/contracts/access/Ownable2Step.sol"; abstract contract FerdyMultiVRFConsumerBase is Ownable2Step { error OnlyCoordinatorCanFulfill(address have); /// List of coordinators that can send randomness. /// We support 3 different types, not just Chainlink. mapping(address => bool) private vrfCoordinators; function setVRFCoordinator(address coordinator, bool active) public onlyOwner { vrfCoordinators[coordinator] = active; } /** * @notice fulfillRandomWords handles the VRF response. Your contract must * @notice implement it. * * @dev VRFConsumerBaseV2 expects its subcontracts to have a method with this * @dev signature, and will call it once it has verified the proof * @dev associated with the randomness. (It is triggered via a call to * @dev rawFulfillRandomness, below.) * * @param requestId The Id initially returned by requestRandomness * @param randomWords the VRF output expanded to the requested number of words **/ function fulfillRandomWords(uint256 requestId, uint256[] memory randomWords) internal virtual; // rawFulfillRandomWords is called by VRFCoordinator when it receives a valid VRF // proof. rawFulfillRandomness then calls fulfillRandomness, after validating // the origin of the call function rawFulfillRandomWords(uint256 requestId, uint256[] memory randomWords) external { if (vrfCoordinators[msg.sender] != true) { revert OnlyCoordinatorCanFulfill(msg.sender); } fulfillRandomWords(requestId, randomWords); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {} /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such * that `ownerOf(tokenId)` is `a`. */ // solhint-disable-next-line func-name-mixedcase function __unsafe_increaseBalance(address account, uint256 amount) internal { _balances[account] += amount; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
{ "remappings": [ "@openzeppelin/=lib/openzeppelin-contracts/", "@chainlink/=lib/chainlink/", "chainlink/=lib/chainlink/", "ds-test/=lib/forge-std/lib/ds-test/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "forge-std/=lib/forge-std/src/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "openzeppelin/=lib/openzeppelin-contracts/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"have","type":"address"}],"name":"OnlyCoordinatorCanFulfill","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"indexed":false,"internalType":"uint8","name":"subgame","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"numRounds","type":"uint256"},{"indexed":false,"internalType":"enum Flip.RoundChoice[]","name":"choices","type":"uint8[]"},{"indexed":false,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"betPerRound","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"indexed":false,"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"GameStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":true,"internalType":"address","name":"vrfCoordinator","type":"address"},{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"RequestedGameWinner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"gameId","type":"uint256"},{"components":[{"internalType":"enum Flip.RoundChoice","name":"selected","type":"uint8"},{"internalType":"enum CentralGameBase.RoundState","name":"state","type":"uint8"},{"internalType":"uint256","name":"sent","type":"uint256"}],"indexed":false,"internalType":"struct Flip.RoundInfo[]","name":"results","type":"tuple[]"}],"name":"WinnerPicked","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"betMultiplePerRound","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"choicesByGameId","outputs":[{"internalType":"enum Flip.RoundChoice","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentGameId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"forceRequestWinner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameById","outputs":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"gameIdByRequestId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId","type":"uint256"}],"name":"getGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"gameIds","type":"uint256[]"}],"name":"getManyGameInfo","outputs":[{"components":[{"internalType":"uint256","name":"gameId","type":"uint256"},{"internalType":"uint256","name":"betPerRound","type":"uint256"},{"internalType":"uint256","name":"rakePerRound","type":"uint256"},{"internalType":"uint256","name":"numRounds","type":"uint256"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint8","name":"subgame","type":"uint8"},{"internalType":"enum CentralGameBase.GameState","name":"state","type":"uint8"}],"internalType":"struct CentralGameBase.GameInfo[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxBetPerRound","outputs":[{"internalType":"uint256","name":"safeMaxPotentialBet","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumWords","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"getRequestConfirmations","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxBetDivisor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxConsecutiveRounds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minBet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum Flip.RoundChoice[]","name":"choices","type":"uint8[]"},{"internalType":"string","name":"referralCode","type":"string"},{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"}],"name":"playGame","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"rakeDistributorAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"rawFulfillRandomWords","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"referralTrackerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"rescueERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"rescueERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueNative","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"betMultiplePerRound_","type":"uint256"}],"name":"setBetMultiplePerRound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gameId_","type":"uint256"}],"name":"setCurrentGameId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxBetDivisor_","type":"uint256"}],"name":"setMaxBetDivisor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxConsecutiveRounds_","type":"uint256"}],"name":"setMaxConsecutiveRounds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"minBet_","type":"uint256"}],"name":"setMinBet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"paused_","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rakeAddress","type":"address"}],"name":"setRakeDistributorAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_referralTrackerAddress","type":"address"}],"name":"setReferralTrackerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"requestConfirmations","type":"uint16"}],"name":"setRequestConfirmations","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasuryAddress","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"coordinator","type":"address"},{"internalType":"bool","name":"active","type":"bool"}],"name":"setVRFCoordinator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum GameVRF.FulfillmentMethod","name":"method","type":"uint8"},{"internalType":"bytes32","name":"gasLane","type":"bytes32"},{"internalType":"address","name":"coordAddress","type":"address"},{"internalType":"uint64","name":"subscriptionId","type":"uint64"},{"internalType":"uint32","name":"callbackGasLimit","type":"uint32"}],"name":"setVRFCoordinatorInfoByMethod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasuryAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60806040526706f05b59d3b200006007556014600855600a6009819055662386f26fc100009055600d805461ffff191660021790553480156200004157600080fd5b506200004d3362000053565b620000c1565b600180546001600160a01b03191690556200006e8162000071565b50565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b612ab780620000d16000396000f3fe60806040526004361061023f5760003560e01c806379ba50971161012e578063c072a4b8116100ab578063d39b5cbb1161006f578063d39b5cbb14610711578063d798183414610736578063d9b61f6814610756578063e30c397814610776578063f2fde38b1461079457600080fd5b8063c072a4b81461067b578063c20ee3fb1461069b578063c5f956af146106bb578063ccec3716146106db578063ccf1719f146106fb57600080fd5b8063990d2dbd116100f2578063990d2dbd146105cb5780639d4b950c146105f8578063a7f3606114610618578063b497b35414610638578063b4a91e1e1461064e57600080fd5b806379ba50971461052e5780638824f5a71461054357806388ea41b9146105635780638da5cb5b146105835780639619367d146105b557600080fd5b8063536a3ddc116101bc5780635f1b0fd8116101805780635f1b0fd8146104375780636605bfda1461045a57806369124c3d1461047a578063715018a61461048f57806376623022146104a457600080fd5b8063536a3ddc146103a357806353a2c19a146103b957806353ccbeea146103cd5780635a3e2e8b146103e05780635c975abb1461040d57600080fd5b806321154ec51161020357806321154ec5146102ed5780632e35a3021461030d578063398497711461032d578063454aa6691461035657806347e1d5501461037657600080fd5b806305287f0c1461024b57806316c38b3c1461026d5780631bdb2d991461028d5780631fa33a2a146102ad5780631fe543e3146102cd57600080fd5b3661024657005b600080fd5b34801561025757600080fd5b5061026b610266366004612214565b6107b4565b005b34801561027957600080fd5b5061026b61028836600461223b565b6107c1565b34801561029957600080fd5b5061026b6102a8366004612288565b6107dc565b3480156102b957600080fd5b5061026b6102c8366004612303565b6108d1565b3480156102d957600080fd5b5061026b6102e8366004612414565b610904565b3480156102f957600080fd5b5061026b610308366004612214565b61094e565b34801561031957600080fd5b5061026b61032836600461245a565b61095b565b34801561033957600080fd5b5061034360085481565b6040519081526020015b60405180910390f35b34801561036257600080fd5b5061026b610371366004612214565b61098b565b34801561038257600080fd5b50610396610391366004612214565b6109e8565b60405161034d9190612507565b3480156103af57600080fd5b5061034360025481565b3480156103c557600080fd5b506001610343565b6103436103db36600461258b565b610a9f565b3480156103ec57600080fd5b506104006103fb366004612661565b611071565b60405161034d919061269d565b34801561041957600080fd5b506004546104279060ff1681565b604051901515815260200161034d565b34801561044357600080fd5b50600d5460405161ffff909116815260200161034d565b34801561046657600080fd5b5061026b61047536600461245a565b6111cc565b34801561048657600080fd5b506103436111f6565b34801561049b57600080fd5b5061026b611236565b3480156104b057600080fd5b5061051a6104bf366004612214565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b60405161034d9897969594939291906126ec565b34801561053a57600080fd5b5061026b61124a565b34801561054f57600080fd5b5061026b61055e366004612745565b6112c4565b34801561056f57600080fd5b5061026b61057e366004612214565b6112e4565b34801561058f57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161034d565b3480156105c157600080fd5b5061034360075481565b3480156105d757600080fd5b506105eb6105e6366004612769565b6112f1565b60405161034d919061279f565b34801561060457600080fd5b5061026b61061336600461245a565b611334565b34801561062457600080fd5b5061026b6106333660046127ad565b61135e565b34801561064457600080fd5b5061034360095481565b34801561065a57600080fd5b50610343610669366004612214565b600e6020526000908152604090205481565b34801561068757600080fd5b5061026b610696366004612214565b6113e5565b3480156106a757600080fd5b5061026b6106b6366004612214565b6113f2565b3480156106c757600080fd5b5060065461059d906001600160a01b031681565b3480156106e757600080fd5b5061026b6106f636600461245a565b6113ff565b34801561070757600080fd5b50610343600a5481565b34801561071d57600080fd5b5060045461059d9061010090046001600160a01b031681565b34801561074257600080fd5b5061026b6107513660046127d9565b6114ea565b34801561076257600080fd5b5060055461059d906001600160a01b031681565b34801561078257600080fd5b506001546001600160a01b031661059d565b3480156107a057600080fd5b5061026b6107af36600461245a565b61155f565b6107bc6115d0565b600255565b6107c96115d0565b6004805460ff1916911515919091179055565b6107e46115d0565b6040518060800160405280858152602001846001600160a01b03168152602001836001600160401b031681526020018263ffffffff16815250600c600087600281111561083357610833612477565b600281111561084457610844612477565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b036001600160401b03909616600160a01b026001600160e01b03199094166001600160a01b03909316929092179290921793909316929092179091556108ca9084906108d1565b5050505050565b6108d96115d0565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff16151560011461094057604051637885129b60e01b81523360048201526024015b60405180910390fd5b61094a828261162a565b5050565b6109566115d0565b600855565b6109636115d0565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6109936115d0565b604051600090339083908381818185875af1925050503d80600081146109d5576040519150601f19603f3d011682016040523d82523d6000602084013e6109da565b606091505b505090508061094a57600080fd5b6109f06120e8565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b90920490911690811115610a8557610a85612477565b6003811115610a9657610a96612477565b90525092915050565b6000323314610ae75760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b6044820152606401610937565b60045460ff1615610b2b5760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b6044820152606401610937565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba49190612805565b15610be85760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b6044820152606401610937565b6004805485516006546040805163e54c9f6b60e01b815290516001600160a01b036101009095048516959394600094610c74949091163192879263e54c9f6b928281019260209291908290030181865afa158015610c4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6e9190612822565b84611b4a565b600280549192506000610c8683612851565b9190505550610c936120e8565b3360808201819052604051636431085f60e11b81526001600160a01b0386169163c86210be91610cc891908b9060040161286a565b602060405180830381865afa158015610ce5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0991906128c9565b6001600160a01b031660a08201526002548152600060e08201819052506060808201848152604080850151602080860191825293860151828601908152600160c0870181815287516000908152600397889052949094208751815592519083015551600282015591518284015560808401516004830180546001600160a01b039283166001600160a01b031990911617905560a0850151600584018054935160ff16600160a01b026001600160a81b031990941691909216179190911780825560e0850151859490929160ff60a81b191690600160a81b908490811115610df257610df2612477565b02179055505081516000908152600f602090815260409091208a51610e1c935090918b019061212a565b5060065482516040516000926001600160a01b031691908381818185875af1925050503d8060008114610e6b576040519150601f19603f3d011682016040523d82523d6000602084013e610e70565b606091505b5050905080610ec15760405162461bcd60e51b815260206004820152601a60248201527f4661696c656420746f2073656e6420746f2074726561737572790000000000006044820152606401610937565b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115610f7857610f78612477565b02179055509050508060000151336001600160a01b03167f2a80d95dcb4fafb2329fb7116567dbcac44ab9b9fca9a3d8493fd9de9bfa7e758360c00151868c8660a00151876020015188604001518e604051610fda97969594939291906128f6565b60405180910390a36020820151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015286169163919ac7ff916064016000604051808303818588803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b5050505050611065816000015187611e67565b51979650505050505050565b80516060906000816001600160401b038111156110905761109061233c565b6040519080825280602002602001820160405280156110c957816020015b6110b66120e8565b8152602001906001900390816110ae5790505b50905060005b828110156111c457600360008683815181106110ed576110ed612987565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b909204169081111561118a5761118a612477565b600381111561119b5761119b612477565b815250508282815181106111b1576111b1612987565b60209081029190910101526001016110cf565b509392505050565b6111d46115d0565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b600854600654600091829161121591906001600160a01b0316316129b3565b905080605f6112258260646129c7565b61122f91906129b3565b9250505090565b61123e6115d0565b6112486000612084565b565b60015433906001600160a01b031681146112b85760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610937565b6112c181612084565b50565b6112cc6115d0565b600d805461ffff191661ffff92909216919091179055565b6112ec6115d0565b600755565b600f602052816000526040600020818154811061130d57600080fd5b9060005260206000209060209182820401919006915091509054906101000a900460ff1681565b61133c6115d0565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6113666115d0565b600082815260036020526040902060016005820154600160a81b900460ff16600381111561139657611396612477565b036113d45760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b6044820152606401610937565b80546113e09083611e67565b505050565b6113ed6115d0565b600955565b6113fa6115d0565b600a55565b6114076115d0565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b9190612822565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156114c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e09190612805565b6114f26115d0565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561154257600080fd5b505af1158015611556573d6000803e3d6000fd5b50505050505050565b6115676115d0565b600180546001600160a01b0383166001600160a01b031990911681179091556115986000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146112485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610937565b6000828152600e6020526040812054908190036116895760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c6564000000000000006044820152606401610937565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156116b8576116b8612477565b146117055760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c7473000000006044820152606401610937565b6000828152600f602090815260408083208054825181850281018501909352808352919290919083018282801561178b57602002820191906000526020600020906000905b82829054906101000a900460ff16600181111561176957611769612477565b81526020600192830181810494850194909303909202910180841161174a5790505b505050505090506000815190506000816001600160401b038111156117b2576117b261233c565b60405190808252806020026020018201604052801561180857816020015b6117f56040805160608101909152806000815260200160008152602001600081525090565b8152602001906001900390816117d05790505b5090506000805b83811015611a055760008860008151811061182c5761182c612987565b60200260200101518260405160200161184f929190918252602082015260400190565b60408051601f19818403018152919052805160209091012090506118746002826129de565b15611880576001611883565b60005b84838151811061189557611895612987565b60200260200101516000019060018111156118b2576118b2612477565b908160018111156118c5576118c5612477565b8152505060018483815181106118dd576118dd612987565b60200260200101516020019060038111156118fa576118fa612477565b9081600381111561190d5761190d612477565b8152505083828151811061192357611923612987565b602002602001015160000151600181111561194057611940612477565b86838151811061195257611952612987565b6020026020010151600181111561196b5761196b612477565b036119fc57600384838151811061198457611984612987565b60200260200101516020019060038111156119a1576119a1612477565b908160038111156119b4576119b4612477565b90525060018701546119c690846129f2565b9250866001015460026119d991906129c7565b8483815181106119eb576119eb612987565b602002602001015160400181815250505b5060010161180f565b50857fd19a8beba6d94e6fe6a16804fc461f8a08a13176419a5ceee005d7d48f81366e83604051611a369190612a05565b60405180910390a26004808601546000888152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558b8252600e8152838220829055898252600f90529182206001600160a01b0390911691611abd91906121de565b8115611b3f576006546001600160a01b031663cf8d133f82611ae08560026129c7565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015611b2657600080fd5b505af1158015611b3a573d6000803e3d6000fd5b505050505b505050505050505050565b611b7c6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000611b8a846127106129f2565b611b96346127106129c7565b611ba091906129b3565b90506000611bae8234612a6e565b9050600754821015611bf65760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b6044820152606401610937565b600854611c0390876129b3565b821115611c465760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b6044820152606401610937565b60008411611c965760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c65620000000000006044820152606401610937565b600954841115611ce85760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e6700000000000000006044820152606401610937565b6000611cf485846129b3565b9050611d0085846129de565b15611d635760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b6064820152608401610937565b600a54611d7090826129de565b15611dcb5760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b6064820152608401610937565b6000611dd786846129b3565b9050611de386846129de565b15611e3a5760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b6064820152608401610937565b6040805160a081018252948552602085019390935291830152606082015260006080820152949350505050565b6000600c6000836002811115611e7f57611e7f612477565b6002811115611e9057611e90612477565b81526020810191909152604001600020600101546001600160a01b0316905080611ef25760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b6044820152606401610937565b8060006001600160a01b038216635d3b1d30600c83876002811115611f1957611f19612477565b6002811115611f2a57611f2a612477565b815260200190815260200160002060000154600c6000886002811115611f5257611f52612477565b6002811115611f6357611f63612477565b815260200190815260200160002060010160149054906101000a90046001600160401b0316600d60009054906101000a900461ffff16600c60008a6002811115611faf57611faf612477565b6002811115611fc057611fc0612477565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b16815260048101959095526001600160401b03909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af1158015612048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206c9190612822565b6000908152600e602052604090209490945550505050565b600180546001600160a01b03191690556112c181600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b82805482825590600052602060002090601f016020900481019282156121ce5791602002820160005b8382111561219f57835183826101000a81548160ff0219169083600181111561217e5761217e612477565b02179055509260200192600101602081600001049283019260010302612153565b80156121cc5782816101000a81549060ff021916905560010160208160000104928301926001030261219f565b505b506121da9291506121ff565b5090565b50805460008255601f0160209004906000526020600020908101906112c191905b5b808211156121da5760008155600101612200565b60006020828403121561222657600080fd5b5035919050565b80151581146112c157600080fd5b60006020828403121561224d57600080fd5b81356122588161222d565b9392505050565b80356003811061226e57600080fd5b919050565b6001600160a01b03811681146112c157600080fd5b600080600080600060a086880312156122a057600080fd5b6122a98661225f565b94506020860135935060408601356122c081612273565b925060608601356001600160401b03811681146122dc57600080fd5b9150608086013563ffffffff811681146122f557600080fd5b809150509295509295909350565b6000806040838503121561231657600080fd5b823561232181612273565b915060208301356123318161222d565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561237a5761237a61233c565b604052919050565b60006001600160401b0382111561239b5761239b61233c565b5060051b60200190565b600082601f8301126123b657600080fd5b813560206123cb6123c683612382565b612352565b8083825260208201915060208460051b8701019350868411156123ed57600080fd5b602086015b8481101561240957803583529183019183016123f2565b509695505050505050565b6000806040838503121561242757600080fd5b8235915060208301356001600160401b0381111561244457600080fd5b612450858286016123a5565b9150509250929050565b60006020828403121561246c57600080fd5b813561225881612273565b634e487b7160e01b600052602160045260246000fd5b600481106112c1576112c1612477565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e08101516124fc8161248d565b8060e0840152505050565b6101008101612516828461249d565b92915050565b600082601f83011261252d57600080fd5b81356001600160401b038111156125465761254661233c565b612559601f8201601f1916602001612352565b81815284602083860101111561256e57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000606084860312156125a057600080fd5b83356001600160401b03808211156125b757600080fd5b818601915086601f8301126125cb57600080fd5b813560206125db6123c683612382565b82815260059290921b8401810191818101908a8411156125fa57600080fd5b948201945b83861015612626578535600281106126175760008081fd5b825294820194908201906125ff565b9750508701359250508082111561263c57600080fd5b506126498682870161251c565b9250506126586040850161225f565b90509250925092565b60006020828403121561267357600080fd5b81356001600160401b0381111561268957600080fd5b612695848285016123a5565b949350505050565b6020808252825182820181905260009190848201906040850190845b818110156126e0576126cc83855161249d565b9284019261010092909201916001016126b9565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016127328361248d565b8260e08301529998505050505050505050565b60006020828403121561275757600080fd5b813561ffff8116811461225857600080fd5b6000806040838503121561277c57600080fd5b50508035926020909101359150565b6002811061279b5761279b612477565b9052565b60208101612516828461278b565b600080604083850312156127c057600080fd5b823591506127d06020840161225f565b90509250929050565b600080604083850312156127ec57600080fd5b82356127f781612273565b946020939093013593505050565b60006020828403121561281757600080fd5b81516122588161222d565b60006020828403121561283457600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000600182016128635761286361283b565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156128a75785810183015185820160600152820161288b565b506000606082860101526060601f19601f830116850101925050509392505050565b6000602082840312156128db57600080fd5b815161225881612273565b6003811061279b5761279b612477565b600060e0820160ff8a168352602089602085015260e060408501528189518084526101008601915060208b01935060005b8181101561294a5761293a83865161278b565b9383019391830191600101612927565b50506001600160a01b03891660608601526080850188905260a08501879052925061297b91505060c08301846128e6565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6000826129c2576129c261299d565b500490565b80820281158282048414176125165761251661283b565b6000826129ed576129ed61299d565b500690565b808201808211156125165761251661283b565b602080825282518282018190526000919060409081850190868401855b82811015612a61578151612a3785825161278b565b86810151612a448161248d565b858801528501518585015260609093019290850190600101612a22565b5091979650505050505050565b818103818111156125165761251661283b56fea26469706673582212207a83fd8c6c2ada27205b1b7439c263091094ff00e2b3ebbe50e7b5046033dab764736f6c63430008160033
Deployed Bytecode
0x60806040526004361061023f5760003560e01c806379ba50971161012e578063c072a4b8116100ab578063d39b5cbb1161006f578063d39b5cbb14610711578063d798183414610736578063d9b61f6814610756578063e30c397814610776578063f2fde38b1461079457600080fd5b8063c072a4b81461067b578063c20ee3fb1461069b578063c5f956af146106bb578063ccec3716146106db578063ccf1719f146106fb57600080fd5b8063990d2dbd116100f2578063990d2dbd146105cb5780639d4b950c146105f8578063a7f3606114610618578063b497b35414610638578063b4a91e1e1461064e57600080fd5b806379ba50971461052e5780638824f5a71461054357806388ea41b9146105635780638da5cb5b146105835780639619367d146105b557600080fd5b8063536a3ddc116101bc5780635f1b0fd8116101805780635f1b0fd8146104375780636605bfda1461045a57806369124c3d1461047a578063715018a61461048f57806376623022146104a457600080fd5b8063536a3ddc146103a357806353a2c19a146103b957806353ccbeea146103cd5780635a3e2e8b146103e05780635c975abb1461040d57600080fd5b806321154ec51161020357806321154ec5146102ed5780632e35a3021461030d578063398497711461032d578063454aa6691461035657806347e1d5501461037657600080fd5b806305287f0c1461024b57806316c38b3c1461026d5780631bdb2d991461028d5780631fa33a2a146102ad5780631fe543e3146102cd57600080fd5b3661024657005b600080fd5b34801561025757600080fd5b5061026b610266366004612214565b6107b4565b005b34801561027957600080fd5b5061026b61028836600461223b565b6107c1565b34801561029957600080fd5b5061026b6102a8366004612288565b6107dc565b3480156102b957600080fd5b5061026b6102c8366004612303565b6108d1565b3480156102d957600080fd5b5061026b6102e8366004612414565b610904565b3480156102f957600080fd5b5061026b610308366004612214565b61094e565b34801561031957600080fd5b5061026b61032836600461245a565b61095b565b34801561033957600080fd5b5061034360085481565b6040519081526020015b60405180910390f35b34801561036257600080fd5b5061026b610371366004612214565b61098b565b34801561038257600080fd5b50610396610391366004612214565b6109e8565b60405161034d9190612507565b3480156103af57600080fd5b5061034360025481565b3480156103c557600080fd5b506001610343565b6103436103db36600461258b565b610a9f565b3480156103ec57600080fd5b506104006103fb366004612661565b611071565b60405161034d919061269d565b34801561041957600080fd5b506004546104279060ff1681565b604051901515815260200161034d565b34801561044357600080fd5b50600d5460405161ffff909116815260200161034d565b34801561046657600080fd5b5061026b61047536600461245a565b6111cc565b34801561048657600080fd5b506103436111f6565b34801561049b57600080fd5b5061026b611236565b3480156104b057600080fd5b5061051a6104bf366004612214565b600360208190526000918252604090912080546001820154600283015493830154600484015460059094015492949193919290916001600160a01b03908116919081169060ff600160a01b8204811691600160a81b90041688565b60405161034d9897969594939291906126ec565b34801561053a57600080fd5b5061026b61124a565b34801561054f57600080fd5b5061026b61055e366004612745565b6112c4565b34801561056f57600080fd5b5061026b61057e366004612214565b6112e4565b34801561058f57600080fd5b506000546001600160a01b03165b6040516001600160a01b03909116815260200161034d565b3480156105c157600080fd5b5061034360075481565b3480156105d757600080fd5b506105eb6105e6366004612769565b6112f1565b60405161034d919061279f565b34801561060457600080fd5b5061026b61061336600461245a565b611334565b34801561062457600080fd5b5061026b6106333660046127ad565b61135e565b34801561064457600080fd5b5061034360095481565b34801561065a57600080fd5b50610343610669366004612214565b600e6020526000908152604090205481565b34801561068757600080fd5b5061026b610696366004612214565b6113e5565b3480156106a757600080fd5b5061026b6106b6366004612214565b6113f2565b3480156106c757600080fd5b5060065461059d906001600160a01b031681565b3480156106e757600080fd5b5061026b6106f636600461245a565b6113ff565b34801561070757600080fd5b50610343600a5481565b34801561071d57600080fd5b5060045461059d9061010090046001600160a01b031681565b34801561074257600080fd5b5061026b6107513660046127d9565b6114ea565b34801561076257600080fd5b5060055461059d906001600160a01b031681565b34801561078257600080fd5b506001546001600160a01b031661059d565b3480156107a057600080fd5b5061026b6107af36600461245a565b61155f565b6107bc6115d0565b600255565b6107c96115d0565b6004805460ff1916911515919091179055565b6107e46115d0565b6040518060800160405280858152602001846001600160a01b03168152602001836001600160401b031681526020018263ffffffff16815250600c600087600281111561083357610833612477565b600281111561084457610844612477565b815260208082019290925260409081016000208351815591830151600192830180549285015160609095015163ffffffff16600160e01b026001600160e01b036001600160401b03909616600160a01b026001600160e01b03199094166001600160a01b03909316929092179290921793909316929092179091556108ca9084906108d1565b5050505050565b6108d96115d0565b6001600160a01b03919091166000908152600b60205260409020805460ff1916911515919091179055565b336000908152600b602052604090205460ff16151560011461094057604051637885129b60e01b81523360048201526024015b60405180910390fd5b61094a828261162a565b5050565b6109566115d0565b600855565b6109636115d0565b600480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b6109936115d0565b604051600090339083908381818185875af1925050503d80600081146109d5576040519150601f19603f3d011682016040523d82523d6000602084013e6109da565b606091505b505090508061094a57600080fd5b6109f06120e8565b6000828152600360208181526040928390208351610100810185528154815260018201549281019290925260028101549382019390935282820154606082015260048301546001600160a01b039081166080830152600584015490811660a083015260ff600160a01b8204811660c084015291939260e0850192600160a81b90920490911690811115610a8557610a85612477565b6003811115610a9657610a96612477565b90525092915050565b6000323314610ae75760405162461bcd60e51b8152602060048201526014602482015273139bc818dbdb9d1c9858dd1cc8185b1b1bddd95960621b6044820152606401610937565b60045460ff1615610b2b5760405162461bcd60e51b815260206004820152600e60248201526d11d85b59481a5cc81c185d5cd95960921b6044820152606401610937565b600660009054906101000a90046001600160a01b03166001600160a01b031663344049676040518163ffffffff1660e01b81526004016020604051808303816000875af1158015610b80573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba49190612805565b15610be85760405162461bcd60e51b8152602060048201526014602482015273547265617375727920697320746f6f206c6f772160601b6044820152606401610937565b6004805485516006546040805163e54c9f6b60e01b815290516001600160a01b036101009095048516959394600094610c74949091163192879263e54c9f6b928281019260209291908290030181865afa158015610c4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c6e9190612822565b84611b4a565b600280549192506000610c8683612851565b9190505550610c936120e8565b3360808201819052604051636431085f60e11b81526001600160a01b0386169163c86210be91610cc891908b9060040161286a565b602060405180830381865afa158015610ce5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d0991906128c9565b6001600160a01b031660a08201526002548152600060e08201819052506060808201848152604080850151602080860191825293860151828601908152600160c0870181815287516000908152600397889052949094208751815592519083015551600282015591518284015560808401516004830180546001600160a01b039283166001600160a01b031990911617905560a0850151600584018054935160ff16600160a01b026001600160a81b031990941691909216179190911780825560e0850151859490929160ff60a81b191690600160a81b908490811115610df257610df2612477565b02179055505081516000908152600f602090815260409091208a51610e1c935090918b019061212a565b5060065482516040516000926001600160a01b031691908381818185875af1925050503d8060008114610e6b576040519150601f19603f3d011682016040523d82523d6000602084013e610e70565b606091505b5050905080610ec15760405162461bcd60e51b815260206004820152601a60248201527f4661696c656420746f2073656e6420746f2074726561737572790000000000006044820152606401610937565b5080516000908152600360208181526040928390208451815590840151600182015591830151600283015560608301518282015560808301516004830180546001600160a01b039283166001600160a01b031990911617905560a084015160058401805460c087015160ff16600160a01b026001600160a81b031990911692909316919091179190911780825560e085015185949390929160ff60a81b191690600160a81b908490811115610f7857610f78612477565b02179055509050508060000151336001600160a01b03167f2a80d95dcb4fafb2329fb7116567dbcac44ab9b9fca9a3d8493fd9de9bfa7e758360c00151868c8660a00151876020015188604001518e604051610fda97969594939291906128f6565b60405180910390a36020820151815160a083015160405163919ac7ff60e01b815260048101929092523360248301526001600160a01b03908116604483015286169163919ac7ff916064016000604051808303818588803b15801561103e57600080fd5b505af1158015611052573d6000803e3d6000fd5b5050505050611065816000015187611e67565b51979650505050505050565b80516060906000816001600160401b038111156110905761109061233c565b6040519080825280602002602001820160405280156110c957816020015b6110b66120e8565b8152602001906001900390816110ae5790505b50905060005b828110156111c457600360008683815181106110ed576110ed612987565b602090810291909101810151825281810192909252604090810160002081516101008101835281548152600182015493810193909352600281015491830191909152600380820154606084015260048201546001600160a01b039081166080850152600583015490811660a085015260ff600160a01b8204811660c086015260e0850192600160a81b909204169081111561118a5761118a612477565b600381111561119b5761119b612477565b815250508282815181106111b1576111b1612987565b60209081029190910101526001016110cf565b509392505050565b6111d46115d0565b600680546001600160a01b0319166001600160a01b0392909216919091179055565b600854600654600091829161121591906001600160a01b0316316129b3565b905080605f6112258260646129c7565b61122f91906129b3565b9250505090565b61123e6115d0565b6112486000612084565b565b60015433906001600160a01b031681146112b85760405162461bcd60e51b815260206004820152602960248201527f4f776e61626c6532537465703a2063616c6c6572206973206e6f7420746865206044820152683732bb9037bbb732b960b91b6064820152608401610937565b6112c181612084565b50565b6112cc6115d0565b600d805461ffff191661ffff92909216919091179055565b6112ec6115d0565b600755565b600f602052816000526040600020818154811061130d57600080fd5b9060005260206000209060209182820401919006915091509054906101000a900460ff1681565b61133c6115d0565b600580546001600160a01b0319166001600160a01b0392909216919091179055565b6113666115d0565b600082815260036020526040902060016005820154600160a81b900460ff16600381111561139657611396612477565b036113d45760405162461bcd60e51b815260206004820152600e60248201526d185b1c9958591e4818db1bdcd95960921b6044820152606401610937565b80546113e09083611e67565b505050565b6113ed6115d0565b600955565b6113fa6115d0565b600a55565b6114076115d0565b6040516370a0823160e01b815230600482015281906001600160a01b0382169063a9059cbb90339083906370a0823190602401602060405180830381865afa158015611457573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061147b9190612822565b6040516001600160e01b031960e085901b1681526001600160a01b03909216600483015260248201526044016020604051808303816000875af11580156114c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e09190612805565b6114f26115d0565b6040516323b872dd60e01b81523060048201523360248201526044810182905282906001600160a01b038216906323b872dd90606401600060405180830381600087803b15801561154257600080fd5b505af1158015611556573d6000803e3d6000fd5b50505050505050565b6115676115d0565b600180546001600160a01b0383166001600160a01b031990911681179091556115986000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b6000546001600160a01b031633146112485760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610937565b6000828152600e6020526040812054908190036116895760405162461bcd60e51b815260206004820152601960248201527f5265717565737420616c72656164792066756c66696c6c6564000000000000006044820152606401610937565b6000818152600360205260408120906005820154600160a81b900460ff1660038111156116b8576116b8612477565b146117055760405162461bcd60e51b815260206004820152601c60248201527f47616d65206e6f742077616974696e6720666f7220726573756c7473000000006044820152606401610937565b6000828152600f602090815260408083208054825181850281018501909352808352919290919083018282801561178b57602002820191906000526020600020906000905b82829054906101000a900460ff16600181111561176957611769612477565b81526020600192830181810494850194909303909202910180841161174a5790505b505050505090506000815190506000816001600160401b038111156117b2576117b261233c565b60405190808252806020026020018201604052801561180857816020015b6117f56040805160608101909152806000815260200160008152602001600081525090565b8152602001906001900390816117d05790505b5090506000805b83811015611a055760008860008151811061182c5761182c612987565b60200260200101518260405160200161184f929190918252602082015260400190565b60408051601f19818403018152919052805160209091012090506118746002826129de565b15611880576001611883565b60005b84838151811061189557611895612987565b60200260200101516000019060018111156118b2576118b2612477565b908160018111156118c5576118c5612477565b8152505060018483815181106118dd576118dd612987565b60200260200101516020019060038111156118fa576118fa612477565b9081600381111561190d5761190d612477565b8152505083828151811061192357611923612987565b602002602001015160000151600181111561194057611940612477565b86838151811061195257611952612987565b6020026020010151600181111561196b5761196b612477565b036119fc57600384838151811061198457611984612987565b60200260200101516020019060038111156119a1576119a1612477565b908160038111156119b4576119b4612477565b90525060018701546119c690846129f2565b9250866001015460026119d991906129c7565b8483815181106119eb576119eb612987565b602002602001015160400181815250505b5060010161180f565b50857fd19a8beba6d94e6fe6a16804fc461f8a08a13176419a5ceee005d7d48f81366e83604051611a369190612a05565b60405180910390a26004808601546000888152600360208181526040808420848155600181018590556002810185905592830184905594820180546001600160a01b0319169055600590910180546001600160b01b03191690558b8252600e8152838220829055898252600f90529182206001600160a01b0390911691611abd91906121de565b8115611b3f576006546001600160a01b031663cf8d133f82611ae08560026129c7565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015611b2657600080fd5b505af1158015611b3a573d6000803e3d6000fd5b505050505b505050505050505050565b611b7c6040518060a0016040528060008152602001600081526020016000815260200160008152602001600081525090565b6000611b8a846127106129f2565b611b96346127106129c7565b611ba091906129b3565b90506000611bae8234612a6e565b9050600754821015611bf65760405162461bcd60e51b815260206004820152601160248201527023b0b6b136329036b7b9329610383632b160791b6044820152606401610937565b600854611c0390876129b3565b821115611c465760405162461bcd60e51b815260206004820152601160248201527047616d626c65206c6573732c206b696e6760781b6044820152606401610937565b60008411611c965760405162461bcd60e51b815260206004820152601a60248201527f47616d626c65206174206c65617374206f6e63652c20706c65620000000000006044820152606401610937565b600954841115611ce85760405162461bcd60e51b815260206004820152601860248201527f47616d626c652066657765722074696d65732c206b696e6700000000000000006044820152606401610937565b6000611cf485846129b3565b9050611d0085846129de565b15611d635760405162461bcd60e51b815260206004820152602d60248201527f47616d626c6520616e20616d6f756e7420646976697369626c6520627920796f60448201526c3ab9103132ba399610383632b160991b6064820152608401610937565b600a54611d7090826129de565b15611dcb5760405162461bcd60e51b815260206004820152602560248201527f47616d626c652074686520726967687420616d6f756e7420706572206265742c60448201526410383632b160d91b6064820152608401610937565b6000611dd786846129b3565b9050611de386846129de565b15611e3a5760405162461bcd60e51b815260206004820152602160248201527f496e7465726e616c206572726f723b2077726f6e672072616b6520616d6f756e6044820152601d60fa1b6064820152608401610937565b6040805160a081018252948552602085019390935291830152606082015260006080820152949350505050565b6000600c6000836002811115611e7f57611e7f612477565b6002811115611e9057611e90612477565b81526020810191909152604001600020600101546001600160a01b0316905080611ef25760405162461bcd60e51b8152602060048201526013602482015272496e76616c696420565246206164647265737360681b6044820152606401610937565b8060006001600160a01b038216635d3b1d30600c83876002811115611f1957611f19612477565b6002811115611f2a57611f2a612477565b815260200190815260200160002060000154600c6000886002811115611f5257611f52612477565b6002811115611f6357611f63612477565b815260200190815260200160002060010160149054906101000a90046001600160401b0316600d60009054906101000a900461ffff16600c60008a6002811115611faf57611faf612477565b6002811115611fc057611fc0612477565b81526020810191909152604090810160002060019081015491516001600160e01b031960e088901b16815260048101959095526001600160401b03909316602485015261ffff909116604484015263ffffffff600160e01b909104166064830152608482015260a4016020604051808303816000875af1158015612048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206c9190612822565b6000908152600e602052604090209490945550505050565b600180546001600160a01b03191690556112c181600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040805161010081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081018290529060e082015290565b82805482825590600052602060002090601f016020900481019282156121ce5791602002820160005b8382111561219f57835183826101000a81548160ff0219169083600181111561217e5761217e612477565b02179055509260200192600101602081600001049283019260010302612153565b80156121cc5782816101000a81549060ff021916905560010160208160000104928301926001030261219f565b505b506121da9291506121ff565b5090565b50805460008255601f0160209004906000526020600020908101906112c191905b5b808211156121da5760008155600101612200565b60006020828403121561222657600080fd5b5035919050565b80151581146112c157600080fd5b60006020828403121561224d57600080fd5b81356122588161222d565b9392505050565b80356003811061226e57600080fd5b919050565b6001600160a01b03811681146112c157600080fd5b600080600080600060a086880312156122a057600080fd5b6122a98661225f565b94506020860135935060408601356122c081612273565b925060608601356001600160401b03811681146122dc57600080fd5b9150608086013563ffffffff811681146122f557600080fd5b809150509295509295909350565b6000806040838503121561231657600080fd5b823561232181612273565b915060208301356123318161222d565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171561237a5761237a61233c565b604052919050565b60006001600160401b0382111561239b5761239b61233c565b5060051b60200190565b600082601f8301126123b657600080fd5b813560206123cb6123c683612382565b612352565b8083825260208201915060208460051b8701019350868411156123ed57600080fd5b602086015b8481101561240957803583529183019183016123f2565b509695505050505050565b6000806040838503121561242757600080fd5b8235915060208301356001600160401b0381111561244457600080fd5b612450858286016123a5565b9150509250929050565b60006020828403121561246c57600080fd5b813561225881612273565b634e487b7160e01b600052602160045260246000fd5b600481106112c1576112c1612477565b80518252602081015160208301526040810151604083015260608101516060830152608081015160018060a01b0380821660808501528060a08401511660a0850152505060ff60c08201511660c083015260e08101516124fc8161248d565b8060e0840152505050565b6101008101612516828461249d565b92915050565b600082601f83011261252d57600080fd5b81356001600160401b038111156125465761254661233c565b612559601f8201601f1916602001612352565b81815284602083860101111561256e57600080fd5b816020850160208301376000918101602001919091529392505050565b6000806000606084860312156125a057600080fd5b83356001600160401b03808211156125b757600080fd5b818601915086601f8301126125cb57600080fd5b813560206125db6123c683612382565b82815260059290921b8401810191818101908a8411156125fa57600080fd5b948201945b83861015612626578535600281106126175760008081fd5b825294820194908201906125ff565b9750508701359250508082111561263c57600080fd5b506126498682870161251c565b9250506126586040850161225f565b90509250925092565b60006020828403121561267357600080fd5b81356001600160401b0381111561268957600080fd5b612695848285016123a5565b949350505050565b6020808252825182820181905260009190848201906040850190845b818110156126e0576126cc83855161249d565b9284019261010092909201916001016126b9565b50909695505050505050565b8881526020810188905260408101879052606081018690526001600160a01b038581166080830152841660a082015260ff831660c082015261010081016127328361248d565b8260e08301529998505050505050505050565b60006020828403121561275757600080fd5b813561ffff8116811461225857600080fd5b6000806040838503121561277c57600080fd5b50508035926020909101359150565b6002811061279b5761279b612477565b9052565b60208101612516828461278b565b600080604083850312156127c057600080fd5b823591506127d06020840161225f565b90509250929050565b600080604083850312156127ec57600080fd5b82356127f781612273565b946020939093013593505050565b60006020828403121561281757600080fd5b81516122588161222d565b60006020828403121561283457600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b6000600182016128635761286361283b565b5060010190565b60018060a01b03831681526000602060406020840152835180604085015260005b818110156128a75785810183015185820160600152820161288b565b506000606082860101526060601f19601f830116850101925050509392505050565b6000602082840312156128db57600080fd5b815161225881612273565b6003811061279b5761279b612477565b600060e0820160ff8a168352602089602085015260e060408501528189518084526101008601915060208b01935060005b8181101561294a5761293a83865161278b565b9383019391830191600101612927565b50506001600160a01b03891660608601526080850188905260a08501879052925061297b91505060c08301846128e6565b98975050505050505050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601260045260246000fd5b6000826129c2576129c261299d565b500490565b80820281158282048414176125165761251661283b565b6000826129ed576129ed61299d565b500690565b808201808211156125165761251661283b565b602080825282518282018190526000919060409081850190868401855b82811015612a61578151612a3785825161278b565b86810151612a448161248d565b858801528501518585015260609093019290850190600101612a22565b5091979650505050505050565b818103818111156125165761251661283b56fea26469706673582212207a83fd8c6c2ada27205b1b7439c263091094ff00e2b3ebbe50e7b5046033dab764736f6c63430008160033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
POL | 100.00% | $0.222569 | 0.0315 | $0.007011 |
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.