FRAX Price: $0.81 (-0.68%)

Contract

0xcF7Fd85C75b94d4f6107632E73320B9A9CE13D25

Overview

FRAX Balance | FXTL Balance

0 FRAX | 656 FXTL

FRAX Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To

There are no matching entries

1 Token Transfer found.

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BatchNFTMinter

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;

import './libraries/TransferHelper.sol';
import './interfaces/INFT.sol';

// @notice basic smart contract to allow minting of Hedgeys NFTs in batches
contract BatchNFTMinter {
  event BatchMinted(uint256 mintType);

  ///@notice basic function for minting multiple hedgys in a single transaction
  /// @param nftContract is the Hedgeys NFT contract that will mint the NFTs, the target of the call
  /// @param holders is an array of the recipients who will receive the minted NFTs
  /// @param token is the token address that is going to be locked in each NFT
  /// @param amounts is an array of the amounts of tokens, this should match the length of the holders array and corresponds in order to the amount each will receive
  /// @param unlockDates is the date set for when each NFT will unlock the tokens, also should match the holders array and each index corresponds to that holders unlockDate
  function batchMint(
    address nftContract,
    address[] memory holders,
    address token,
    uint256[] memory amounts,
    uint256[] memory unlockDates
  ) external {
    _batchMint(nftContract, holders, token, amounts, unlockDates);
  }

  ///@notice batch minter function with the additional mintType input which is spit out in an event for analytics purposes
  /// @param nftContract is the Hedgeys NFT contract that will mint the NFTs, the target of the call
  /// @param holders is an array of the recipients who will receive the minted NFTs
  /// @param token is the token address that is going to be locked in each NFT
  /// @param amounts is an array of the amounts of tokens, this should match the length of the holders array and corresponds in order to the amount each will receive
  /// @param unlockDates is the date set for when each NFT will unlock the tokens, also should match the holders array and each index corresponds to that holders unlockDate
  /// @param mintType is an internal identifier used by Hedgey to associate certain minting behaviors based on integrations and UIs used during the minting process.
  function batchMint(
    address nftContract,
    address[] memory holders,
    address token,
    uint256[] memory amounts,
    uint256[] memory unlockDates,
    uint256 mintType
  ) external {
    emit BatchMinted(mintType);
    _batchMint(nftContract, holders, token, amounts, unlockDates);
  }

  /// @notice the internal function for batch minting used by both external methods
  /// @param nftContract is the Hedgeys NFT contract that will mint the NFTs, the target of the call
  /// @param holders is an array of the recipients who will receive the minted NFTs
  /// @param token is the token address that is going to be locked in each NFT
  /// @param amounts is an array of the amounts of tokens, this should match the length of the holders array and corresponds in order to the amount each will receive
  /// @param unlockDates is the date set for when each NFT will unlock the tokens, also should match the holders array and each index corresponds to that holders unlockDate
  function _batchMint(
    address nftContract,
    address[] memory holders,
    address token,
    uint256[] memory amounts,
    uint256[] memory unlockDates
  ) internal {
    require(holders.length == amounts.length && amounts.length == unlockDates.length, 'array error');
    require(token != address(0) && nftContract != address(0));
    uint256 totalAmount;
    for (uint256 i; i < amounts.length; i++) {
      require(amounts[i] > 0, 'amount error');
      require(unlockDates[i] > block.timestamp, 'date error');
      totalAmount += amounts[i];
    }
    TransferHelper.transferTokens(token, msg.sender, address(this), totalAmount);
    SafeERC20.safeIncreaseAllowance(IERC20(token), nftContract, totalAmount);
    for (uint256 i; i < amounts.length; i++) {
      uint256 tokenId = INFT(nftContract).createNFT(holders[i], amounts[i], token, unlockDates[i]);
      require(tokenId > 0, 'mint error');
    }
  }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// 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.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.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;

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    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));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    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");
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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");
        require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
    }

    /**
     * @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).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // 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 cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return
            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
    }
}

// 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: BUSL-1.1
pragma solidity 0.8.13;

/// @dev this is the one contract call that the OTC needs to interact with the NFT contract
interface INFT {
  /// @notice function for publicly viewing a lockedToken (future) details
  /// @param _id is the id of the NFT which is mapped to the future struct
  /// @dev this returns the amount of tokens locked, the token address and the date that they are unlocked
  function futures(uint256 _id)
    external
    view
    returns (
      uint256 amount,
      address token,
      uint256 unlockDate
    );

  /// @param _holder is the new owner of the NFT and timelock future - this can be any address
  /// @param _amount is the amount of tokens that are going to be locked
  /// @param _token is the token address to be locked by the NFT. Use WETH address for ETH - but WETH must be held by the msg.sender
  /// ... as there is no automatic wrapping from ETH to WETH for this function.
  /// @param _unlockDate is the date which the tokens become unlocked and available to be redeemed and withdrawn from the contract
  /// @dev this is a public function that anyone can call
  /// @dev the _holder can be defined as your address, or any chose address - and so you can directly mint NFTs to other addresses
  /// ... in a way to airdrop NFTs directly to contributors
  function createNFT(
    address _holder,
    uint256 _amount,
    address _token,
    uint256 _unlockDate
  ) external returns (uint256);

  /// @dev function for redeeming an NFT
  /// @notice this function will burn the NFT and delete the future struct - in return the locked tokens will be delivered
  function redeemNFT(uint256 _id) external returns (bool);

  /// @notice this event spits out the details of the NFT and future struct when a new NFT & Future is minted
  event NFTCreated(uint256 _i, address _holder, uint256 _amount, address _token, uint256 _unlockDate);

  /// @notice this event spits out the details of the NFT and future structe when an existing NFT and Future is redeemed
  event NFTRedeemed(uint256 _i, address _holder, uint256 _amount, address _token, uint256 _unlockDate);

  /// @notice this event is fired the one time when the baseURI is updated
  event URISet(string newURI);
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;

/// @dev used for handling ETH wrapping into WETH to be stored in smart contracts upon deposit,
/// ... and used to unwrap WETH into ETH to deliver when withdrawing from smart contracts
interface IWETH {
  function deposit() external payable;

  function transfer(address to, uint256 value) external returns (bool);

  function withdraw(uint256) external;
}

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.13;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '../interfaces/IWETH.sol';

/// @notice Library to help safely transfer tokens and handle ETH wrapping and unwrapping of WETH
library TransferHelper {
  using SafeERC20 for IERC20;

  /// @notice Internal function used for standard ERC20 transferFrom method
  /// @notice it contains a pre and post balance check
  /// @notice as well as a check on the msg.senders balance
  /// @param token is the address of the ERC20 being transferred
  /// @param from is the remitting address
  /// @param to is the location where they are being delivered
  function transferTokens(
    address token,
    address from,
    address to,
    uint256 amount
  ) internal {
    uint256 priorBalance = IERC20(token).balanceOf(address(to));
    require(IERC20(token).balanceOf(msg.sender) >= amount, 'THL01');
    SafeERC20.safeTransferFrom(IERC20(token), from, to, amount);
    uint256 postBalance = IERC20(token).balanceOf(address(to));
    require(postBalance - priorBalance == amount, 'THL02');
  }

  /// @notice Internal function is used with standard ERC20 transfer method
  /// @notice this function ensures that the amount received is the amount sent with pre and post balance checking
  /// @param token is the ERC20 contract address that is being transferred
  /// @param to is the address of the recipient
  /// @param amount is the amount of tokens that are being transferred
  function withdrawTokens(
    address token,
    address to,
    uint256 amount
  ) internal {
    uint256 priorBalance = IERC20(token).balanceOf(address(to));
    SafeERC20.safeTransfer(IERC20(token), to, amount);
    uint256 postBalance = IERC20(token).balanceOf(address(to));
    require(postBalance - priorBalance == amount, 'THL02');
  }

  /// @dev Internal function that handles transfering payments from buyers to sellers with special WETH handling
  /// @dev this function assumes that if the recipient address is a contract, it cannot handle ETH - so we always deliver WETH
  /// @dev special care needs to be taken when using contract addresses to sell deals - to ensure it can handle WETH properly when received
  function transferPayment(
    address weth,
    address token,
    address from,
    address payable to,
    uint256 amount
  ) internal {
    if (token == weth) {
      require(msg.value == amount, 'THL03');
      if (!Address.isContract(to)) {
        (bool success, ) = to.call{value: amount}('');
        require(success, 'THL04');
      } else {
        /// @dev we want to deliver WETH from ETH here for better handling at contract
        IWETH(weth).deposit{value: amount}();
        assert(IWETH(weth).transfer(to, amount));
      }
    } else {
      transferTokens(token, from, to, amount);
    }
  }

  /// @dev Internal function that handles withdrawing tokens and WETH that are up for sale to buyers
  /// @dev this function is only called if the tokens are not timelocked
  /// @dev this function handles weth specially and delivers ETH to the recipient
  function withdrawPayment(
    address weth,
    address token,
    address payable to,
    uint256 amount
  ) internal {
    if (token == weth) {
      IWETH(weth).withdraw(amount);
      (bool success, ) = to.call{value: amount}('');
      require(success, 'THL04');
    } else {
      withdrawTokens(token, to, amount);
    }
  }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "viaIR": true,
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "metadata": {
    "useLiteralContent": true
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"mintType","type":"uint256"}],"name":"BatchMinted","type":"event"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"address[]","name":"holders","type":"address[]"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"unlockDates","type":"uint256[]"},{"internalType":"uint256","name":"mintType","type":"uint256"}],"name":"batchMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"nftContract","type":"address"},{"internalType":"address[]","name":"holders","type":"address[]"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"unlockDates","type":"uint256[]"}],"name":"batchMint","outputs":[],"stateMutability":"nonpayable","type":"function"}]

6080806040523461001657610bbe908161001c8239f35b600080fdfe60806040526004361015610013575b600080fd5b6000803560e01c908163560af7261461003e575063b7468c531461003657600080fd5b61000e610250565b346100cc5760c03660031901126100cc576100576100cf565b67ffffffffffffffff906024358281116100c857610079903690600401610184565b6100816100e5565b6064358481116100c4576100999036906004016101f2565b906084359485116100c4576100b56100bf9536906004016101f2565b9260a435946102d0565b604051f35b8580fd5b8380fd5b80fd5b600435906001600160a01b038216820361000e57565b604435906001600160a01b038216820361000e57565b50634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761012e57604052565b6101366100fb565b604052565b90601f8019910116810190811067ffffffffffffffff82111761012e57604052565b60209067ffffffffffffffff8111610177575b60051b0190565b61017f6100fb565b610170565b81601f8201121561000e5780359161019b8361015d565b926101a9604051948561013b565b808452602092838086019260051b82010192831161000e578301905b8282106101d3575050505090565b81356001600160a01b038116810361000e5781529083019083016101c5565b81601f8201121561000e578035916102098361015d565b92610217604051948561013b565b808452602092838086019260051b82010192831161000e578301905b828210610241575050505090565b81358152908301908301610233565b503461000e5760a036600319011261000e5761026a6100cf565b67ffffffffffffffff9060243582811161000e5761028c903690600401610184565b6102946100e5565b60643584811161000e576102ac9036906004016101f2565b9160843594851161000e576102c86102ce9536906004016101f2565b93610478565b005b7f871711e6f05ecc6edc3025cb9c0ab5b2cf4a9733f3f628e62aee9d5702188f88602061030397604051908152a1610478565b565b1561030c57565b60405162461bcd60e51b815260206004820152600b60248201526a30b93930bc9032b93937b960a91b6044820152606490fd5b1561000e57565b50634e487b7160e01b600052601160045260246000fd5b600190600019811461036d570190565b610375610346565b0190565b805182101561038d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b156103aa57565b60405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606490fd5b156103e557565b60405162461bcd60e51b815260206004820152600a6024820152693230ba329032b93937b960b11b6044820152606490fd5b8119811161036d570190565b9081602091031261000e575190565b506040513d6000823e3d90fd5b1561044657565b60405162461bcd60e51b815260206004820152600a60248201526936b4b73a1032b93937b960b11b6044820152606490fd5b94909294939193610496845187518091149081610638575b50610305565b6001600160a01b03858116959091908615158061062d575b6104b79061033f565b600095865b8980518910156105145761050e916104e26104da8b61050894610379565b5115156103a3565b6104f7426104f08c8c610379565b51116103de565b6105018a8d610379565b5190610417565b9761035d565b966104bc565b509092610533929496975080959861052e833033896109bd565b610643565b60005b875181101561062357806105df6105606105536105e49486610379565b516001600160a01b031690565b6105bd61056d848d610379565b5191610579858c610379565b5160405163b273e65360e01b81526001600160a01b039283166004820152602481019490945290881660448401526064830152602091908290829081906084820190565b038160008d8d165af1918215610616575b6000926105e9575b5050151561043f565b61035d565b610536565b6106089250803d1061060f575b610600818361013b565b810190610423565b38806105d6565b503d6105f6565b61061e610432565b6105ce565b5050505050509050565b5081831615156104ae565b905084511438610490565b61068e61030393604051636eb1769f60e11b815230600482015260208160448160018060a01b038099169889602483015288165afa9081156106f8575b6000916106da575b50610417565b6040519263095ea7b360e01b602085015260248401526044830152604482526080820182811067ffffffffffffffff8211176106cd575b60405261077c565b6106d56100fb565b6106c5565b6106f2915060203d811161060f57610600818361013b565b38610688565b610700610432565b610680565b9081602091031261000e5751801515810361000e5790565b1561072457565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b604051610303929161080f91906001600160a01b031661079b82610112565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af13d15610849573d9167ffffffffffffffff831161083c575b60405192610801601f8201601f191688018561013b565b83523d60008785013e61089d565b8051918215928315610824575b50505061071d565b6108349350820181019101610705565b38808061081c565b6108446100fb565b6107ea565b60609161089d565b1561085857565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919290156108c057508151156108b1575090565b6108bd903b1515610851565b90565b8251909150156108d35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251928360248401526000915b848310610925575050918060449311610918575b601f01601f19168101030190fd5b600083828401015261090a565b81830181015186840160440152859350918201916108f6565b1561094557565b60405162461bcd60e51b815260206004820152600560248201526454484c303160d81b6044820152606490fd5b81811061097d570390565b610985610346565b0390565b1561099057565b60405162461bcd60e51b81526020600482015260056024820152642a2426181960d91b6044820152606490fd5b6040516370a0823160e01b8082526001600160a01b0385811660048401526103039695610a9695939460209491939216919087908587602481875afa968715610b23575b600097610af0575b50604051838152336004820152610a7b958795909490939092610a5592869190610a4f9084908a816024818c5afa908115610ae3575b600091610ac6575b50101561093e565b85610b30565b6040519081526001600160a01b0390921660048301529092839190829081906024820190565b03915afa918215610ab9575b600092610a9c575b5050610972565b14610989565b610ab29250803d1061060f57610600818361013b565b3880610a8f565b610ac1610432565b610a87565b610add91508b3d8d1161060f57610600818361013b565b38610a47565b610aeb610432565b610a3f565b8593919750869492610a7b96610b15610a5593883d8a1161060f57610600818361013b565b999395509650929450610a09565b610b2b610432565b610a01565b6040516323b872dd60e01b60208201526001600160a01b0392831660248201529290911660448301526064808301939093529181526103039160a0820182811067ffffffffffffffff8211176106cd5760405261077c56fea2646970667358221220a4cd5ab2b470bbad57c2bc19156b1f510f04dc31dc2a56b1b49ff88cf0300dfb64736f6c634300080d0033

Deployed Bytecode

0x60806040526004361015610013575b600080fd5b6000803560e01c908163560af7261461003e575063b7468c531461003657600080fd5b61000e610250565b346100cc5760c03660031901126100cc576100576100cf565b67ffffffffffffffff906024358281116100c857610079903690600401610184565b6100816100e5565b6064358481116100c4576100999036906004016101f2565b906084359485116100c4576100b56100bf9536906004016101f2565b9260a435946102d0565b604051f35b8580fd5b8380fd5b80fd5b600435906001600160a01b038216820361000e57565b604435906001600160a01b038216820361000e57565b50634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff82111761012e57604052565b6101366100fb565b604052565b90601f8019910116810190811067ffffffffffffffff82111761012e57604052565b60209067ffffffffffffffff8111610177575b60051b0190565b61017f6100fb565b610170565b81601f8201121561000e5780359161019b8361015d565b926101a9604051948561013b565b808452602092838086019260051b82010192831161000e578301905b8282106101d3575050505090565b81356001600160a01b038116810361000e5781529083019083016101c5565b81601f8201121561000e578035916102098361015d565b92610217604051948561013b565b808452602092838086019260051b82010192831161000e578301905b828210610241575050505090565b81358152908301908301610233565b503461000e5760a036600319011261000e5761026a6100cf565b67ffffffffffffffff9060243582811161000e5761028c903690600401610184565b6102946100e5565b60643584811161000e576102ac9036906004016101f2565b9160843594851161000e576102c86102ce9536906004016101f2565b93610478565b005b7f871711e6f05ecc6edc3025cb9c0ab5b2cf4a9733f3f628e62aee9d5702188f88602061030397604051908152a1610478565b565b1561030c57565b60405162461bcd60e51b815260206004820152600b60248201526a30b93930bc9032b93937b960a91b6044820152606490fd5b1561000e57565b50634e487b7160e01b600052601160045260246000fd5b600190600019811461036d570190565b610375610346565b0190565b805182101561038d5760209160051b010190565b634e487b7160e01b600052603260045260246000fd5b156103aa57565b60405162461bcd60e51b815260206004820152600c60248201526b30b6b7bab73a1032b93937b960a11b6044820152606490fd5b156103e557565b60405162461bcd60e51b815260206004820152600a6024820152693230ba329032b93937b960b11b6044820152606490fd5b8119811161036d570190565b9081602091031261000e575190565b506040513d6000823e3d90fd5b1561044657565b60405162461bcd60e51b815260206004820152600a60248201526936b4b73a1032b93937b960b11b6044820152606490fd5b94909294939193610496845187518091149081610638575b50610305565b6001600160a01b03858116959091908615158061062d575b6104b79061033f565b600095865b8980518910156105145761050e916104e26104da8b61050894610379565b5115156103a3565b6104f7426104f08c8c610379565b51116103de565b6105018a8d610379565b5190610417565b9761035d565b966104bc565b509092610533929496975080959861052e833033896109bd565b610643565b60005b875181101561062357806105df6105606105536105e49486610379565b516001600160a01b031690565b6105bd61056d848d610379565b5191610579858c610379565b5160405163b273e65360e01b81526001600160a01b039283166004820152602481019490945290881660448401526064830152602091908290829081906084820190565b038160008d8d165af1918215610616575b6000926105e9575b5050151561043f565b61035d565b610536565b6106089250803d1061060f575b610600818361013b565b810190610423565b38806105d6565b503d6105f6565b61061e610432565b6105ce565b5050505050509050565b5081831615156104ae565b905084511438610490565b61068e61030393604051636eb1769f60e11b815230600482015260208160448160018060a01b038099169889602483015288165afa9081156106f8575b6000916106da575b50610417565b6040519263095ea7b360e01b602085015260248401526044830152604482526080820182811067ffffffffffffffff8211176106cd575b60405261077c565b6106d56100fb565b6106c5565b6106f2915060203d811161060f57610600818361013b565b38610688565b610700610432565b610680565b9081602091031261000e5751801515810361000e5790565b1561072457565b60405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608490fd5b604051610303929161080f91906001600160a01b031661079b82610112565b6000806020958685527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656487860152868151910182855af13d15610849573d9167ffffffffffffffff831161083c575b60405192610801601f8201601f191688018561013b565b83523d60008785013e61089d565b8051918215928315610824575b50505061071d565b6108349350820181019101610705565b38808061081c565b6108446100fb565b6107ea565b60609161089d565b1561085857565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b919290156108c057508151156108b1575090565b6108bd903b1515610851565b90565b8251909150156108d35750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251928360248401526000915b848310610925575050918060449311610918575b601f01601f19168101030190fd5b600083828401015261090a565b81830181015186840160440152859350918201916108f6565b1561094557565b60405162461bcd60e51b815260206004820152600560248201526454484c303160d81b6044820152606490fd5b81811061097d570390565b610985610346565b0390565b1561099057565b60405162461bcd60e51b81526020600482015260056024820152642a2426181960d91b6044820152606490fd5b6040516370a0823160e01b8082526001600160a01b0385811660048401526103039695610a9695939460209491939216919087908587602481875afa968715610b23575b600097610af0575b50604051838152336004820152610a7b958795909490939092610a5592869190610a4f9084908a816024818c5afa908115610ae3575b600091610ac6575b50101561093e565b85610b30565b6040519081526001600160a01b0390921660048301529092839190829081906024820190565b03915afa918215610ab9575b600092610a9c575b5050610972565b14610989565b610ab29250803d1061060f57610600818361013b565b3880610a8f565b610ac1610432565b610a87565b610add91508b3d8d1161060f57610600818361013b565b38610a47565b610aeb610432565b610a3f565b8593919750869492610a7b96610b15610a5593883d8a1161060f57610600818361013b565b999395509650929450610a09565b610b2b610432565b610a01565b6040516323b872dd60e01b60208201526001600160a01b0392831660248201529290911660448301526064808301939093529181526103039160a0820182811067ffffffffffffffff8211176106cd5760405261077c56fea2646970667358221220a4cd5ab2b470bbad57c2bc19156b1f510f04dc31dc2a56b1b49ff88cf0300dfb64736f6c634300080d0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

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.