Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0xE1F38F1D63bAb0608a42a8C08B4E8DF9a53779c3
Balance 0 ETH
Nonce 1
Code Size 6120 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6120 bytes
0x6080604052600436106100c75760003560e01c8063a217fddf11610074578063d51089c11161004e578063d51089c11461022d578063d547741f14610240578063fe6d81241461026057600080fd5b8063a217fddf146101e5578063acf779d5146101fa578063cfbd48851461020d57600080fd5b80632f2ff15d116100a55780632f2ff15d1461016157806336568abe1461018157806391d14854146101a157600080fd5b806301ffc9a7146100cc578063248a9ca314610101578063261707fa1461013f575b600080fd5b3480156100d857600080fd5b506100ec6100e73660046111ba565b610294565b60405190151581526020015b60405180910390f35b34801561010d57600080fd5b5061013161011c3660046111e4565b60009081526020819052604090206001015490565b6040519081526020016100f8565b34801561014b57600080fd5b5061015f61015a366004611212565b6102fd565b005b34801561016d57600080fd5b5061015f61017c36600461122f565b6103ad565b34801561018d57600080fd5b5061015f61019c36600461122f565b6103d7565b3480156101ad57600080fd5b506100ec6101bc36600461122f565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b3480156101f157600080fd5b50610131600081565b61015f6102083660046112ab565b610463565b34801561021957600080fd5b5061015f610228366004611212565b61091e565b61015f61023b36600461136f565b6109c6565b34801561024c57600080fd5b5061015f61025b36600461122f565b610e01565b34801561026c57600080fd5b506101317ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc981565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806102f757507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff166103805760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206d757374206265206f776e657200000000000000000000000060448201526064015b60405180910390fd5b6103aa7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc9826103ad565b50565b6000828152602081905260409020600101546103c881610e26565b6103d28383610e30565b505050565b6001600160a01b03811633146104555760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401610377565b61045f8282610ece565b5050565b3360009081527f213adc0a84cc939081f025f2b699be0ed944ae23aa7816da33f513ef6fc3cdfb602052604090205460ff166104e15760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206d7573742068617665204d494e54455220726f6c65000000006044820152606401610377565b86851480156104ef57508683145b61053b5760405162461bcd60e51b815260206004820152601f60248201527f616c6c20617272617973206d75737420626520657175616c206c656e677468006044820152606401610377565b60005b8781101561091357600089898381811061055a5761055a611409565b905060200201602081019061056f9190611212565b9050806001600160a01b031663156e29f685858581811061059257610592611409565b90506020020160208101906105a79190611212565b8a8a868181106105b9576105b9611409565b905060200201358989878181106105d2576105d2611409565b6040516001600160e01b031960e088901b1681526001600160a01b039095166004860152602485019390935250602090910201356044820152606401600060405180830381600087803b15801561062857600080fd5b505af1925050508015610639575060015b6108105761064561141f565b806308c379a003610728575061065961148c565b80610664575061072a565b7fbe04b1f6196edcb361966f40ee016a26b6c8bb97b6d34dbfea40f02a60a462a96000828d8d8781811061069a5761069a611409565b90506020020160208101906106af9190611212565b8c8c888181106106c1576106c1611409565b905060200201358b8b898181106106da576106da611409565b905060200201358a8a8a8181106106f3576106f3611409565b90506020020160208101906107089190611212565b60405161071a96959493929190611566565b60405180910390a15061090a565b505b3d808015610754576040519150601f19603f3d011682016040523d82523d6000602084013e610759565b606091505b507fbe04b1f6196edcb361966f40ee016a26b6c8bb97b6d34dbfea40f02a60a462a96000828d8d8781811061079057610790611409565b90506020020160208101906107a59190611212565b8c8c888181106107b7576107b7611409565b905060200201358b8b898181106107d0576107d0611409565b905060200201358a8a8a8181106107e9576107e9611409565b90506020020160208101906107fe9190611212565b60405161071a969594939291906115c3565b7fbe04b1f6196edcb361966f40ee016a26b6c8bb97b6d34dbfea40f02a60a462a960018b8b8581811061084557610845611409565b905060200201602081019061085a9190611212565b8a8a8681811061086c5761086c611409565b9050602002013589898781811061088557610885611409565b9050602002013588888881811061089e5761089e611409565b90506020020160208101906108b39190611212565b60408051951515865260e0602087018190526000908701819052610100918701829052908601526001600160a01b039384166060860152608085019290925260a08401521660c08201526101200160405180910390a15b5060010161053e565b505050505050505050565b3360009081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1661099c5760405162461bcd60e51b815260206004820152601460248201527f43616c6c6572206d757374206265206f776e65720000000000000000000000006044820152606401610377565b6103aa7ff0887ba65ee2024ea881d91b74c2450ef19e1557f03bed3ea9f16b037cbe2dc982610e01565b3360009081527f213adc0a84cc939081f025f2b699be0ed944ae23aa7816da33f513ef6fc3cdfb602052604090205460ff16610a445760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206d7573742068617665204d494e54455220726f6c65000000006044820152606401610377565b848314610a935760405162461bcd60e51b815260206004820152601f60248201527f616c6c20617272617973206d75737420626520657175616c206c656e677468006044820152606401610377565b60005b85811015610df8576000878783818110610ab257610ab2611409565b9050602002016020810190610ac79190611212565b9050806001600160a01b03166340c10f19858585818110610aea57610aea611409565b9050602002016020810190610aff9190611212565b888886818110610b1157610b11611409565b6040516001600160e01b031960e087901b1681526001600160a01b0390941660048501526020029190910135602483015250604401600060405180830381600087803b158015610b6057600080fd5b505af1925050508015610b71575060015b610d1457610b7d61141f565b806308c379a003610c465750610b9161148c565b80610b9c5750610c48565b7fdd74f084707f56bd458cc7deda36927c226cae8c0078ab5179c03e98e0de588e6000828b8b87818110610bd257610bd2611409565b9050602002016020810190610be79190611212565b8a8a88818110610bf957610bf9611409565b90506020020135898989818110610c1257610c12611409565b9050602002016020810190610c279190611212565b604051610c38959493929190611620565b60405180910390a150610def565b505b3d808015610c72576040519150601f19603f3d011682016040523d82523d6000602084013e610c77565b606091505b507fdd74f084707f56bd458cc7deda36927c226cae8c0078ab5179c03e98e0de588e6000828b8b87818110610cae57610cae611409565b9050602002016020810190610cc39190611212565b8a8a88818110610cd557610cd5611409565b90506020020135898989818110610cee57610cee611409565b9050602002016020810190610d039190611212565b604051610c38959493929190611673565b7fdd74f084707f56bd458cc7deda36927c226cae8c0078ab5179c03e98e0de588e6001898985818110610d4957610d49611409565b9050602002016020810190610d5e9190611212565b888886818110610d7057610d70611409565b90506020020135878787818110610d8957610d89611409565b9050602002016020810190610d9e9190611212565b60408051941515855260c060208601819052600090860181905260e0918601829052908501526001600160a01b03928316606085015260808401919091521660a08201526101000160405180910390a15b50600101610a96565b50505050505050565b600082815260208190526040902060010154610e1c81610e26565b6103d28383610ece565b6103aa8133610f4d565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661045f576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055610e8a3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff161561045f576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1661045f57610f7e81610fc0565b610f89836020610fd2565b604051602001610f9a9291906116c7565b60408051601f198184030181529082905262461bcd60e51b825261037791600401611748565b60606102f76001600160a01b03831660145b60606000610fe1836002611771565b610fec906002611788565b67ffffffffffffffff8111156110045761100461143b565b6040519080825280601f01601f19166020018201604052801561102e576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061106557611065611409565b60200101906001600160f81b031916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106110b0576110b0611409565b60200101906001600160f81b031916908160001a90535060006110d4846002611771565b6110df906001611788565b90505b6001811115611164577f303132333435363738396162636465660000000000000000000000000000000085600f166010811061112057611120611409565b1a60f81b82828151811061113657611136611409565b60200101906001600160f81b031916908160001a90535060049490941c9361115d8161179b565b90506110e2565b5083156111b35760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610377565b9392505050565b6000602082840312156111cc57600080fd5b81356001600160e01b0319811681146111b357600080fd5b6000602082840312156111f657600080fd5b5035919050565b6001600160a01b03811681146103aa57600080fd5b60006020828403121561122457600080fd5b81356111b3816111fd565b6000806040838503121561124257600080fd5b823591506020830135611254816111fd565b809150509250929050565b60008083601f84011261127157600080fd5b50813567ffffffffffffffff81111561128957600080fd5b6020830191508360208260051b85010111156112a457600080fd5b9250929050565b6000806000806000806000806080898b0312156112c757600080fd5b883567ffffffffffffffff808211156112df57600080fd5b6112eb8c838d0161125f565b909a50985060208b013591508082111561130457600080fd5b6113108c838d0161125f565b909850965060408b013591508082111561132957600080fd5b6113358c838d0161125f565b909650945060608b013591508082111561134e57600080fd5b5061135b8b828c0161125f565b999c989b5096995094979396929594505050565b6000806000806000806060878903121561138857600080fd5b863567ffffffffffffffff808211156113a057600080fd5b6113ac8a838b0161125f565b909850965060208901359150808211156113c557600080fd5b6113d18a838b0161125f565b909650945060408901359150808211156113ea57600080fd5b506113f789828a0161125f565b979a9699509497509295939492505050565b634e487b7160e01b600052603260045260246000fd5b600060033d11156114385760046000803e5060005160e01c5b90565b634e487b7160e01b600052604160045260246000fd5b601f8201601f1916810167ffffffffffffffff8111828210171561148557634e487b7160e01b600052604160045260246000fd5b6040525050565b600060443d101561149a5790565b6040516003193d81016004833e81513d67ffffffffffffffff81602484011181841117156114ca57505050505090565b82850191508151818111156114e25750505050505090565b843d87010160208285010111156114fc5750505050505090565b61150b60208286010187611451565b509095945050505050565b60005b83811015611531578181015183820152602001611519565b50506000910152565b60008151808452611552816020860160208601611516565b601f01601f19169290920160200192915050565b861515815260e06020820152600060e082015260006101008060408401526115908184018961153a565b9150506001600160a01b0380871660608401528560808401528460a084015280841660c084015250979650505050505050565b861515815260e0602082015260006115de60e083018861153a565b8281036040840152600081526001600160a01b03968716606084015260808301959095525060a081019290925290921660c09092019190915260200192915050565b851515815260c06020820152600060c082015260e06040820152600061164960e083018761153a565b6001600160a01b039586166060840152608083019490945250921660a09092019190915292915050565b851515815260c06020820152600061168e60c083018761153a565b8281036040840152600081526001600160a01b039586166060840152608083019490945250921660a09092019190915260200192915050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516116ff816017850160208801611516565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000601791840191820152835161173c816028840160208801611516565b01602801949350505050565b6020815260006111b3602083018461153a565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176102f7576102f761175b565b808201808211156102f7576102f761175b565b6000816117aa576117aa61175b565b50600019019056fea264697066735822122003dde0fd27410579e28a95c3b0b3baff340d781d04be4eb64e50f3f4baeebb8e64736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: paris Optimization: Yes (1000 runs)
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;
    }
}
Strings.sol 70 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}
Math.sol 345 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}
AccessControl.sol 247 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " is missing role ",
                        Strings.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}
MagicDirectAggregator.sol 88 lines
// contracts/MagicAggregator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.24;

import "./IMagicDirectAggregator.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

interface MintInterface721 {
    function mint(address _userWallet, uint256 _quantity) external payable;
}

interface MintInterface1155 {
    function mint(address _userWallet, uint256 _quantity, uint256 _tokenId) external payable;
}

contract MagicDirectAggregator is IMagicAggregator, AccessControl {
    event batchMint721Response(bool success, bytes data, string msg, address contract_address, uint256 amount, address destination);    
    event batchMint1155Response(bool success, bytes data, string msg, address contract_address, uint256 amount, uint256 token_id, address destination);

    bytes32 public constant MINTER = keccak256("MINTER");

    constructor(address root) {
        _setupRole(DEFAULT_ADMIN_ROLE, root);
    }

    function grantMinter(address account) public virtual {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller must be owner");
        grantRole(MINTER, account);
    }

    function revokeMinter(address account) public virtual {
        require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller must be owner");
        revokeRole(MINTER, account);
    }

    function batchMint721(
        address payable[] calldata contracts,
        uint256[] calldata amounts,
        address payable[] calldata destinations
    ) external payable {
        require(hasRole(MINTER, msg.sender), "Caller must have MINTER role");
        // All arrays must be equal
        require(
            contracts.length == amounts.length,
            "all arrays must be equal length"
        );

        // Loop through the contracts and mint
        for (uint i=0; i<contracts.length; i++) {
            MintInterface721 underlying_contract = MintInterface721(contracts[i]);
            try underlying_contract.mint(destinations[i], amounts[i]) {
                emit batchMint721Response(true, "", "", contracts[i], amounts[i], destinations[i]);
            } catch Error(string memory _err) {
                emit batchMint721Response(false, "", _err, contracts[i], amounts[i], destinations[i]);
            } catch (bytes memory _err) {
                emit batchMint721Response(false, _err, "", contracts[i], amounts[i], destinations[i]);
            }
        }
    }

    function batchMint1155(
        address payable[] calldata contracts,
        uint256[] calldata amounts,
        uint256[] calldata token_ids,
        address payable[] calldata destinations
    ) external payable {
        require(hasRole(MINTER, msg.sender), "Caller must have MINTER role");
        // All arrays must be equal
        require(
            contracts.length == amounts.length &&
            contracts.length == token_ids.length,
            "all arrays must be equal length"
        );

        // Loop through the contracts and mint
        for (uint i=0; i<contracts.length; i++) {
            MintInterface1155 underlying_contract = MintInterface1155(contracts[i]);
            try underlying_contract.mint(destinations[i], amounts[i], token_ids[i]) {
                emit batchMint1155Response(true, "", "", contracts[i], amounts[i], token_ids[i], destinations[i]);
            } catch Error(string memory _err) {
                emit batchMint1155Response(false, "", _err, contracts[i], amounts[i], token_ids[i], destinations[i]);
            } catch (bytes memory _err) {
                emit batchMint1155Response(false, _err, "", contracts[i], amounts[i], token_ids[i], destinations[i]);
            }
        }
    }
}
IMagicDirectAggregator.sol 29 lines
// contracts/IMagicAggregator.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

interface IMagicAggregator {

    /// @notice Gets the number of tokens the specified wallet is able to purchase currently.
    ///
    /// @param contracts       A list of ERC721 smart contracts that have the address allowed to mint
    /// @param amounts         A list of the quantity/amounts of each token to mint
    function batchMint721(
        address payable[] calldata contracts,
        uint256[] calldata amounts,
        address payable[] calldata destinations
    ) external payable;

    /// @notice Gets the number of tokens the specified wallet is able to purchase currently.
    ///
    /// @param contracts       A list of ERC721 smart contracts that have the address allowed to mint
    /// @param amounts         A list of the quantity/amounts of each token to mint
    /// @param token_ids       A list of token_ids to mint
    function batchMint1155(
        address payable[] calldata contracts,
        uint256[] calldata amounts,
        uint256[] calldata token_ids,
        address payable[] calldata destinations
    ) external payable;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Read Contract

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
MINTER 0xfe6d8124 → bytes32
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
supportsInterface 0x01ffc9a7 → bool

Write Contract 7 functions

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

batchMint1155 0xacf779d5
address[] contracts
uint256[] amounts
uint256[] token_ids
address[] destinations
batchMint721 0xd51089c1
address[] contracts
uint256[] amounts
address[] destinations
grantMinter 0x261707fa
address account
grantRole 0x2f2ff15d
bytes32 role
address account
renounceRole 0x36568abe
bytes32 role
address account
revokeMinter 0xcfbd4885
address account
revokeRole 0xd547741f
bytes32 role
address account

Recent Transactions

No transactions found for this address