Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xF2B49397F91De858Ed4138A066b70ECef99dB087
Balance 0 ETH
Nonce 1
Code Size 5873 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5873 bytes
0x608060405234801561001057600080fd5b50600436106100a95760003560e01c80636e6c84d8116100715780636e6c84d81461014d578063715018a6146101915780638da5cb5b146101995780639623cdb8146101aa578063c1586476146101bd578063f2fde38b1461024e57600080fd5b80630fca9687146100ae5780631909c28f146100f25780635dc18aca146101125780635f81f6d11461012557806362c067671461013a575b600080fd5b6100d57f000000000000000000000000000000000000000000000000000000000000dead81565b6040516001600160a01b0390911681526020015b60405180910390f35b61010561010036600461119b565b610261565b6040516100e991906111f4565b6100d561012036600461123a565b610353565b61013861013336600461125c565b61038b565b005b610138610148366004611319565b6108f1565b61018161015b36600461135a565b600460209081526000938452604080852082529284528284209052825290205460ff1681565b60405190151581526020016100e9565b610138610a18565b6000546001600160a01b03166100d5565b6101386101b8366004611381565b610a4e565b6102106101cb36600461141b565b600360205260009081526040902080546001909101546001600160601b03808316926001600160a01b03600160601b90910481169290811691600160a01b9091041684565b6040516100e994939291906001600160601b0394851681526001600160a01b0393841660208201529190921660408201529116606082015260800190565b61013861025c366004611434565b610c54565b60606000825167ffffffffffffffff81111561027f5761027f6110c5565b6040519080825280602002602001820160405280156102a8578160200160208202803683370190505b50905060005b83518110156103485760008681526004602090815260408083206001600160a01b0389168452909152812085519091908690849081106102f0576102f0611451565b6020026020010151815260200190815260200160002060009054906101000a900460ff1682828151811061032657610326611451565b9115156020928302919091019091015261034160018261147d565b90506102ae565b5090505b9392505050565b6002602052816000526040600020818154811061036f57600080fd5b6000918252602090912001546001600160a01b03169150829050565b600260015414156103e35760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026001819055600083815260209182526040808220805482518186028101860190935280835292939192909183018282801561044957602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161042b575b505050600086815260036020908152604091829020825160808101845281546001600160601b0380821683526001600160a01b03600160601b90920482169483019490945260019283015490811694820194909452600160a01b909304909116606083018190529495509093101591506104d89050576040516359746fb560e01b815260040160405180910390fd5b60005b83518110156107fa5782518482815181106104f8576104f8611451565b6020026020010151511461051f57604051631f57942960e21b815260040160405180910390fd5b60005b835181101561078c5760046000878152602001908152602001600020600085838151811061055257610552611451565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600086848151811061058e5761058e611451565b602002602001015183815181106105a7576105a7611451565b60209081029190910181015182528101919091526040016000205460ff16156105e357604051635697be9560e11b815260040160405180910390fd5b336001600160a01b03168482815181106105ff576105ff611451565b60200260200101516001600160a01b0316636352211e87858151811061062757610627611451565b6020026020010151848151811061064057610640611451565b60200260200101516040518263ffffffff1660e01b815260040161066691815260200190565b6020604051808303816000875af1158015610685573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a99190611495565b6001600160a01b0316146106d057604051638b57eb5960e01b815260040160405180910390fd5b60008681526004602052604081208551600192908790859081106106f6576106f6611451565b60200260200101516001600160a01b03166001600160a01b03168152602001908152602001600020600087858151811061073257610732611451565b6020026020010151848151811061074b5761074b611451565b6020026020010151815260200190815260200160002060006101000a81548160ff021916908315150217905550600181610785919061147d565b9050610522565b50336001600160a01b0316857f9b347aa45abdfb56c44f052dd72bfe3b853cb8d508f8fb6be4511923b8d8d8208684815181106107cb576107cb611451565b60200260200101516040516107e091906114b2565b60405180910390a36107f360018261147d565b90506104db565b5080516001600160601b03161561085d5761085d33845183517f000000000000000000000000000000000000000000000000000000000000dead91610847916001600160601b03166114ea565b60408501516001600160a01b0316929190610cef565b60208101516001600160a01b031661178433855184606001516001600160601b031661088991906114ea565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156108cf57600080fd5b505af11580156108e3573d6000803e3d6000fd5b505060018055505050505050565b6000546001600160a01b0316331461091b5760405162461bcd60e51b81526004016103da90611509565b6002600154141561096e5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016103da565b60026001556001600160a01b0383166109fb576000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146109ce576040519150601f19603f3d011682016040523d82523d6000602084013e6109d3565b606091505b50509050806109f557604051639081276360e01b815260040160405180910390fd5b50610a0f565b610a0f6001600160a01b0384168383610d60565b50506001805550565b6000546001600160a01b03163314610a425760405162461bcd60e51b81526004016103da90611509565b610a4c6000610d95565b565b6000546001600160a01b03163314610a785760405162461bcd60e51b81526004016103da90611509565b81610a9657604051630786e6f560e21b815260040160405180910390fd5b6000610aa86040830160208401611434565b6001600160a01b03161415610ad05760405163742bae9d60e01b815260040160405180910390fd5b6000610ae26060830160408401611434565b6001600160a01b03161415610b0a57604051634d9eeba560e11b815260040160405180910390fd5b6000848152600260205260409020610b23908484611038565b50604080516080810190915280610b3d602084018461155a565b6001600160601b03168152602001826020016020810190610b5e9190611434565b6001600160a01b03168152602001610b7c6060840160408501611434565b6001600160a01b03168152602001610b9a608084016060850161155a565b6001600160601b039081169091526000868152600360209081526040918290208451918501516001600160a01b03908116600160601b0292851692909217815584830151606090950151909316600160a01b0293169290921760019091015551610c05908290611575565b60405180910390208383604051610c1d9291906115dc565b6040519081900381209086907eff06517f85da1964aedff2f8fbeb1c1f9e470b35bc581f5b6fdaa8b292c0c590600090a450505050565b6000546001600160a01b03163314610c7e5760405162461bcd60e51b81526004016103da90611509565b6001600160a01b038116610ce35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016103da565b610cec81610d95565b50565b6040516001600160a01b0380851660248301528316604482015260648101829052610d5a9085906323b872dd60e01b906084015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152610de5565b50505050565b6040516001600160a01b038316602482015260448101829052610d9090849063a9059cbb60e01b90606401610d23565b505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610e3a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610eb79092919063ffffffff16565b805190915015610d905780806020019051810190610e58919061161e565b610d905760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016103da565b6060610ec68484600085610ece565b949350505050565b606082471015610f2f5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016103da565b6001600160a01b0385163b610f865760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016103da565b600080866001600160a01b03168587604051610fa2919061166c565b60006040518083038185875af1925050503d8060008114610fdf576040519150601f19603f3d011682016040523d82523d6000602084013e610fe4565b606091505b5091509150610ff4828286610fff565b979650505050505050565b6060831561100e57508161034c565b82511561101e5782518084602001fd5b8160405162461bcd60e51b81526004016103da9190611688565b82805482825590600052602060002090810192821561108b579160200282015b8281111561108b5781546001600160a01b0319166001600160a01b03843516178255602090920191600190910190611058565b5061109792915061109b565b5090565b5b80821115611097576000815560010161109c565b6001600160a01b0381168114610cec57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611104576111046110c5565b604052919050565b600067ffffffffffffffff821115611126576111266110c5565b5060051b60200190565b600082601f83011261114157600080fd5b813560206111566111518361110c565b6110db565b82815260059290921b8401810191818101908684111561117557600080fd5b8286015b848110156111905780358352918301918301611179565b509695505050505050565b6000806000606084860312156111b057600080fd5b8335925060208401356111c2816110b0565b9150604084013567ffffffffffffffff8111156111de57600080fd5b6111ea86828701611130565b9150509250925092565b6020808252825182820181905260009190848201906040850190845b8181101561122e578351151583529284019291840191600101611210565b50909695505050505050565b6000806040838503121561124d57600080fd5b50508035926020909101359150565b6000806040838503121561126f57600080fd5b8235915060208084013567ffffffffffffffff8082111561128f57600080fd5b818601915086601f8301126112a357600080fd5b81356112b16111518261110c565b81815260059190911b830184019084810190898311156112d057600080fd5b8585015b83811015611308578035858111156112ec5760008081fd5b6112fa8c89838a0101611130565b8452509186019186016112d4565b508096505050505050509250929050565b60008060006060848603121561132e57600080fd5b8335611339816110b0565b92506020840135611349816110b0565b929592945050506040919091013590565b60008060006060848603121561136f57600080fd5b833592506020840135611349816110b0565b60008060008084860360c081121561139857600080fd5b85359450602086013567ffffffffffffffff808211156113b757600080fd5b818801915088601f8301126113cb57600080fd5b8135818111156113da57600080fd5b8960208260051b85010111156113ef57600080fd5b6020929092019550909350506080603f198201121561140d57600080fd5b509295919450926040019150565b60006020828403121561142d57600080fd5b5035919050565b60006020828403121561144657600080fd5b813561034c816110b0565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000821982111561149057611490611467565b500190565b6000602082840312156114a757600080fd5b815161034c816110b0565b6020808252825182820181905260009190848201906040850190845b8181101561122e578351835292840192918401916001016114ce565b600081600019048311821515161561150457611504611467565b500290565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b80356001600160601b038116811461155557600080fd5b919050565b60006020828403121561156c57600080fd5b61034c8261153e565b60006001600160601b03806115898561153e565b168352602084013561159a816110b0565b6001600160a01b0390811660208501526040850135906115b9826110b0565b166040840152806115cc6060860161153e565b1660608401525050608001919050565b60008184825b858110156116135781356115f5816110b0565b6001600160a01b0316835260209283019291909101906001016115e2565b509095945050505050565b60006020828403121561163057600080fd5b8151801515811461034c57600080fd5b60005b8381101561165b578181015183820152602001611643565b83811115610d5a5750506000910152565b6000825161167e818460208701611640565b9190910192915050565b60208152600082518060208401526116a7816040850160208701611640565b601f01601f1916919091016040019291505056fea26469706673582212200b8e683fffbdd4600dcfb922327174593b11cb967c72cadf45830b9d0dfdf85f64736f6c634300080b0033

Verified Source Code Full Match

Compiler: v0.8.11+commit.d7f03943 EVM: london Optimization: Yes (200 runs)
ITiny721.sol 90 lines
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.11;

/**
  @title A minimalistic, gas-efficient ERC-721 implementation forked from the
    `Super721` ERC-721 implementation used by SuperFarm.
  @author Tim Clancy
  @author 0xthrpw
  @author Qazawat Zirak
  @author Rostislav Khlebnikov

  Compared to the original `Super721` implementation that this contract forked
  from, this is a very pared-down contract that includes simple delegated
  minting and transfer locks.

  This contract includes the gas efficiency techniques graciously shared with
  the world in the specific ERC-721 implementation by Chiru Labs that is being
  called "ERC-721A" (https://github.com/chiru-labs/ERC721A). We have validated
  this contract against their test cases.

  February 8th, 2022.
*/
interface ITiny721 {

  /**
    Return whether or not the transfer of a particular token ID `_id` is locked.

    @param _id The ID of the token to check the lock status of.

    @return Whether or not the particular token ID `_id` has transfers locked.
  */
  function transferLocks (
    uint256 _id
  ) external returns (bool);

  /**
    Provided with an address parameter, this function returns the number of all
    tokens in this collection that are owned by the specified address.

    @param _owner The address of the account for which we are checking balances
  */
  function balanceOf (
    address _owner
  ) external returns ( uint256 );

  /**
    Return the address that holds a particular token ID.

    @param _id The token ID to check for the holding address of.

    @return The address that holds the token with ID of `_id`.
  */
  function ownerOf (
    uint256 _id
  ) external returns (address);

  /**
    This function allows permissioned minters of this contract to mint one or
    more tokens dictated by the `_amount` parameter. Any minted tokens are sent
    to the `_recipient` address.

    Note that tokens are always minted sequentially starting at one. That is,
    the list of token IDs is always increasing and looks like [ 1, 2, 3... ].
    Also note that per our use cases the intended recipient of these minted
    items will always be externally-owned accounts and not other contracts. As a
    result there is no safety check on whether or not the mint destination can
    actually correctly handle an ERC-721 token.

    @param _recipient The recipient of the tokens being minted.
    @param _amount The amount of tokens to mint.
  */
  function mint_Qgo (
    address _recipient,
    uint256 _amount
  ) external;

  /**
    This function allows an administrative caller to lock the transfer of
    particular token IDs. This is designed for a non-escrow staking contract
    that comes later to lock a user's NFT while still letting them keep it in
    their wallet.

    @param _id The ID of the token to lock.
    @param _locked The status of the lock; true to lock, false to unlock.
  */
  function lockTransfer (
    uint256 _id,
    bool _locked
  ) external;
}
ImpostorsRedeemer721.sol 336 lines
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.11;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "../interfaces/ITiny721.sol";

/*
  It saves bytecode to revert on custom errors instead of using require
  statements. We are just declaring these errors for reverting with upon various
  conditions later in this contract.
*/
error CannotConfigureEmptyCriteria();
error CannotConfigureWithoutOutputItem();
error CannotConfigureWithoutPaymentToken();
error CannotRedeemForZeroItems();
error CannotRedeemCriteriaLengthMismatch();
error CannotRedeemItemAlreadyRedeemed();
error CannotRedeemUnownedItem();
error SweepingTransferFailed();


/**
  @title A contract for minting ERC-721 items given an ERC-20 token burn and
    ownership of some prerequisite ERC-721 items.
  @author 0xthrpw
  @author Tim Clancy

  This contract allows for the configuration of multiple redemption rounds. Each
  redemption round is configured with a set of ERC-721 item collection addresses
  in the `redemptionCriteria` mapping that any prospective redeemers must hold.

  Each redemption round is also configured with a redemption configuration per
  the `redemptionConfigs` mapping. This configuration allows a caller holding
  the required ERC-721 items to mint some amount `amountOut` of a new ERC-721
  `tokenOut` item in exchange for burning `price` amount of a `payingToken`
  ERC-20 token.

  Any ERC-721 collection being minted by this redeemer must grant minting
  permissions to this contract in some fashion. Users must also approve this
  contract to spend any requisite `payingToken` ERC-20 tokens on their behalf.

  April 27th, 2022.
*/
contract ImpostorsRedeemer721 is
  Ownable, ReentrancyGuard
{
  using SafeERC20 for IERC20;

  /**
    A configurable address to transfer burned ERC-20 tokens to. The intent of
    specifying an address like this is to support burning otherwise unburnable
    ERC-20 tokens by transferring them to provably unrecoverable destinations,
    such as blackhole smart contracts.
  */
  address public immutable burnDestination;

  /**
    A mapping from a redemption round ID to an array of ERC-721 item collection
    addresses required to be held in fulfilling a redemption claim. In order to
    participate in a redemption round, a caller must hold a specific item from
    each of these required ERC-721 item collections.
  */
  mapping ( uint256 => address[] ) public redemptionCriteria;

  /**
    This struct is used when configuring a redemption round to specify a
    caller's required payment and the ERC-721 items they may be minted in
    return.

    @param price The amount of `payingToken` that a caller must pay for each set
      of items redeemed in this round.
    @param tokenOut The address of the ERC-721 item collection from which a
      caller will receive newly-minted items.
    @param payingToken The ERC-20 token of which `price` must be paid for each
      redemption.
    @param amountOut The number of new `tokenOut` ERC-721 items a caller will
      receive in return for fulfilling a claim.
  */
  struct RedemptionConfig {
    uint96 price;
    address tokenOut;
    address payingToken;
    uint96 amountOut;
  }

  /// A mapping from a redemption round ID to its configuration details.
  mapping ( uint256 => RedemptionConfig ) public redemptionConfigs;

  /**
    A triple mapping from a redemption round ID to an ERC-721 item collection
    address to the token ID of a specific item in the ERC-721 item collection.
    This mapping ensures that a specific item can only be used once in any given
    redemption round.
  */
  mapping (
    uint256 => mapping (
      address => mapping (
        uint256 => bool
      )
    )
  ) public redeemed;

  /**
    An event tracking a claim in a redemption round for some ERC-721 items.

    @param round The redemption round ID involved in the claim.
    @param caller The caller who triggered the claim.
    @param tokenIds The array of token IDs for specific items keyed against the
      matching `criteria` paramter.
  */
  event TokenRedemption (
    uint256 indexed round,
    address indexed caller,
    uint256[] tokenIds
  );

  /**
    An event tracking a configuration update for the details of a particular
    redemption round.

    @param round The redemption round ID with updated configuration.
    @param criteria The array of ERC-721 item collection addresses required for
      fulfilling a redemption claim in this round.
    @param configuration The updated `RedemptionConfig` configuration details
      for this round.
  */
  event ConfigUpdate (
    uint256 indexed round,
    address[] indexed criteria,
    RedemptionConfig indexed configuration
  );

  /**
    Construct a new item redeemer by specifying a destination for burnt tokens.

    @param _burnDestination An address where tokens received for fulfilling
      redemptions are sent.
  */
  constructor (
    address _burnDestination
  ) {
    burnDestination = _burnDestination;
  }

  /**
    Easily check the redemption status of multiple tokens of a single
    collection in a single round.

    @param _round The round to check for token redemption against.
    @param _collection The address of the specific item collection to check.
    @param _tokenIds An array of token IDs belonging to the collection
      `_collection` to check for redemption status.

    @return An array of boolean redemption status for each of the items being
      checked in `_tokenIds`.
  */
  function isRedeemed (
    uint256 _round,
    address _collection,
    uint256[] memory _tokenIds
  ) external view returns (bool[] memory) {
    bool[] memory redemptionStatus = new bool[](_tokenIds.length);
    for (uint256 i = 0; i < _tokenIds.length; i += 1) {
      redemptionStatus[i] = redeemed[_round][_collection][_tokenIds[i]];
    }
    return redemptionStatus;
  }

  /**
    Set the configuration details for a particular redemption round. A specific
    redemption round may be effectively disabled by setting the `amountOut`
    field of the given `RedemptionConfig` `_config` value to 0.

    @param _round The redemption round ID to configure.
    @param _criteria An array of ERC-721 item collection addresses to require
      holdings from when a caller attempts to redeem from the round of ID
      `_round`.
    @param _config The `RedemptionConfig` configuration data to use for setting
      new configuration details for the round of ID `_round`.
  */
  function setConfig (
    uint256 _round,
    address[] calldata _criteria,
    RedemptionConfig calldata _config
  ) external onlyOwner {

    /*
      Prevent a redemption round from being configured with no requisite ERC-721
      item collection holding criteria.
    */
    if (_criteria.length == 0) {
      revert CannotConfigureEmptyCriteria();
    }

    /*
      Perform input validation on the provided configuration details. A
      redemption round may not be configured with no ERC-721 item collection to
      mint as output.
    */
    if (_config.tokenOut == address(0)) {
      revert CannotConfigureWithoutOutputItem();
    }

    /*
      A redemption round may not be configured with no ERC-20 token address to
      attempt to enforce payment from.
    */
    if (_config.payingToken == address(0)) {
      revert CannotConfigureWithoutPaymentToken();
    }

    // Update the redemption criteria of this round.
    redemptionCriteria[_round] = _criteria;

    // Update the contents of the round configuration mapping.
    redemptionConfigs[_round] = RedemptionConfig({
      amountOut: _config.amountOut,
      price: _config.price,
      tokenOut: _config.tokenOut,
      payingToken: _config.payingToken
    });

    // Emit the configuration update event.
    emit ConfigUpdate(_round, _criteria, _config);
  }

  /**
    Allow a caller to redeem potentially multiple sets of criteria ERC-721 items
    in `_tokenIds` against the redemption round of ID `_round`.

    @param _round The ID of the redemption round to redeem against.
    @param _tokenIds An array of token IDs for the specific ERC-721 items keyed
      to the item collection criteria addresses for this round in
      the `redemptionCriteria` mapping.
  */
  function redeem (
    uint256 _round,
    uint256[][] memory _tokenIds
  ) external nonReentrant {
    address[] memory criteria = redemptionCriteria[_round];
    RedemptionConfig memory config = redemptionConfigs[_round];

    // Prevent a caller from redeeming from a round with zero output items.
    if (config.amountOut < 1) {
      revert CannotRedeemForZeroItems();
    }

    /*
      The caller may be attempting to redeem for multiple independent sets of
      items in this redemption round. Process each set of token IDs against the
      criteria addresses.
    */
    for (uint256 set = 0; set < _tokenIds.length; set += 1) {

      /*
        If the item set is not the same length as the criteria array, we have a
        mismatch and the set cannot possibly be fulfilled.
      */
      if (_tokenIds[set].length != criteria.length) {
        revert CannotRedeemCriteriaLengthMismatch();
      }

      /*
        Check each item in the set against each of the expected, required
        criteria collections.
      */
      for (uint256 i; i < criteria.length; i += 1) {

        // Verify that no item may be redeemed twice against a single round.
        if (redeemed[_round][criteria[i]][_tokenIds[set][i]]) {
          revert CannotRedeemItemAlreadyRedeemed();
        }

        /*
          Verify that the caller owns each of the items involved in the
          redemption claim.
        */
        if (ITiny721(criteria[i]).ownerOf(_tokenIds[set][i]) != _msgSender()) {
          revert CannotRedeemUnownedItem();
        }

        // Flag each item as redeemed against this round.
        redeemed[_round][criteria[i]][_tokenIds[set][i]] = true;
      }

      // Emit an event indicating which tokens were redeemed.
      emit TokenRedemption(_round, _msgSender(), _tokenIds[set]);
    }

    // If there is a non-zero redemption price, perform the required token burn.
    if (config.price > 0) {
      IERC20(config.payingToken).safeTransferFrom(
        _msgSender(),
        burnDestination,
        config.price * _tokenIds.length
      );
    }

    // Mint the caller their redeemed items.
    ITiny721(config.tokenOut).mint_Qgo(
      _msgSender(),
      config.amountOut * _tokenIds.length
    );
  }

  /**
    Allow the owner to sweep either Ether or a particular ERC-20 token from the
    contract and send it to another address. This allows the owner of the shop
    to withdraw their funds after the sale is completed.

    @param _token The token to sweep the balance from; if a zero address is sent
      then the contract's balance of Ether will be swept.
    @param _destination The address to send the swept tokens to.
    @param _amount The amount of token to sweep.
  */
  function sweep (
    address _token,
    address _destination,
    uint256 _amount
  ) external onlyOwner nonReentrant {

    // A zero address means we should attempt to sweep Ether.
    if (_token == address(0)) {
      (bool success, ) = payable(_destination).call{ value: _amount }("");
      if (!success) { revert SweepingTransferFailed(); }

    // Otherwise, we should try to sweep an ERC-20 token.
    } else {
      IERC20(_token).safeTransfer(_destination, _amount);
    }
  }
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.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
     * ====
     *
     * [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://diligence.consensys.net/posts/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.5.11/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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
    }
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _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);
    }
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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);

    /**
     * @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);
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

Read Contract

burnDestination 0x0fca9687 → address
isRedeemed 0x1909c28f → bool[]
owner 0x8da5cb5b → address
redeemed 0x6e6c84d8 → bool
redemptionConfigs 0xc1586476 → uint96, address, address, uint96
redemptionCriteria 0x5dc18aca → address

Write Contract 5 functions

These functions modify contract state and require a wallet transaction to execute.

redeem 0x5f81f6d1
uint256 _round
uint256[][] _tokenIds
renounceOwnership 0x715018a6
No parameters
setConfig 0xbf3e924c
uint256 _round
address[] _criteria
tuple _config
sweep 0x62c06767
address _token
address _destination
uint256 _amount
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address