ETH Price: $3,348.06 (+0.38%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00
Transaction Hash
Method
Block
From
To
Withdraw211455242024-11-08 21:10:5953 days ago1731100259IN
0x7498C606...4c32E326a
0 ETH0.0006796514.57934649
Mint211449702024-11-08 19:19:3553 days ago1731093575IN
0x7498C606...4c32E326a
0.0377 ETH0.0023480716.67973615
Withdraw211033872024-11-02 23:58:5959 days ago1730591939IN
0x7498C606...4c32E326a
0 ETH0.000265675.69904867
Mint211029322024-11-02 22:27:2359 days ago1730586443IN
0x7498C606...4c32E326a
0.0377 ETH0.000787185.61844882
Withdraw210862732024-10-31 14:39:3561 days ago1730385575IN
0x7498C606...4c32E326a
0 ETH0.0014254122.37065814
Mint210859462024-10-31 13:33:5961 days ago1730381639IN
0x7498C606...4c32E326a
0.0377 ETH0.0024646615.67773449

Latest 7 internal transactions

Advanced mode:
Parent Transaction Hash Block
From
To
211455242024-11-08 21:10:5953 days ago1731100259
0x7498C606...4c32E326a
0.0369 ETH
211449702024-11-08 19:19:3553 days ago1731093575
0x7498C606...4c32E326a
0.0008 ETH
211033872024-11-02 23:58:5959 days ago1730591939
0x7498C606...4c32E326a
0.0369 ETH
211029322024-11-02 22:27:2359 days ago1730586443
0x7498C606...4c32E326a
0.0008 ETH
210862732024-10-31 14:39:3561 days ago1730385575
0x7498C606...4c32E326a
0.0369 ETH
210859462024-10-31 13:33:5961 days ago1730381639
0x7498C606...4c32E326a
0.0008 ETH
210464042024-10-26 1:05:4767 days ago1729904747  Contract Creation0 ETH
Loading...
Loading

Minimal Proxy Contract for 0x97866d75d7053e61557e2584f2c263defcefba88

Contract Name:
RandomMint1155

Compiler Version
v0.8.24+commit.e11b9ed9

Optimization Enabled:
No with 200 runs

Other Settings:
paris EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 15 : RandomMint1155.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

import {IERC1155Mintable} from "./../interfaces/IERC1155Mintable.sol";
import {Payable} from "./../libraries/Payable.sol";
import {SupplyControl1155} from "./../libraries/SupplyControl1155.sol";
import {LimitPerWallet} from "./../libraries/LimitPerWallet.sol";
import {SignatureProtected} from "./../libraries/SignatureProtected.sol";
import {DTOs} from "./../libraries/dtos.sol";
import {RandomGenerator} from "./../libraries/RandomGenerator.sol";

contract RandomMint1155 is
    Payable,
    SupplyControl1155,
    LimitPerWallet,
    SignatureProtected,
    RandomGenerator
{
    string public constant contractType = "RANDOM-MINTER-1155";
    string public constant version = "1.0.0";

    IERC1155Mintable public erc1155Contract;

    bool private _isInitialized;

    function init(
        address owner,
        address signerAddress,
        address feeRecipient,
        uint256[] memory availableTokens,
        DTOs.Recipient[] memory recipients,
        address erc1155Address
    ) external {
        require(_isInitialized == false, "Contract already initialized.");
        _transferOwnership(owner);
        initSupplyControl(availableTokens);
        initSignatureProtected(signerAddress);
        initPayable(feeRecipient, recipients);

        erc1155Contract = IERC1155Mintable(erc1155Address);
        _isInitialized = true;
    }

    function mint(
        uint256 _amount,
        uint256 _maxPerWallet,
        uint256 _pricePerToken,
        uint256 _feePerToken,
        bytes calldata _signature
    ) external payable {
        validateSignature(
            abi.encodePacked(_maxPerWallet, _pricePerToken, _feePerToken),
            _signature
        );

        _amount = _getAvailableTokens(_amount);
        _amount = getAvailableForWallet(_amount, _maxPerWallet);

        checkSentEther(_amount, _pricePerToken, _feePerToken);

        uint256[] memory amountsPerToken = new uint256[](
            availableTokens.length
        );

        uint256 diffCount = 0;
        for (uint256 i; i < _amount; i++) {
            uint256 tokenId = getRandomTokenId(i);
            if (amountsPerToken[tokenId] == 0) {
                diffCount++;
            }

            amountsPerToken[tokenId]++;
        }

        uint256[] memory ids = new uint256[](diffCount);
        uint256[] memory amounts = new uint256[](diffCount);

        uint256 found = 0;
        for (uint256 i; i < amountsPerToken.length; i++) {
            if (amountsPerToken[i] == 0) {
                continue;
            }

            ids[found] = i;
            amounts[found] = amountsPerToken[i];
            found++;
        }

        erc1155Contract.mint(msg.sender, ids, amounts);
    }

    function getRandomTokenId(
        uint256 _randomVariable
    ) internal returns (uint256) {
        uint256 random = getRandomNumber(getAvailableTokens(), _randomVariable);

        uint256 total;
        for (uint256 i; i < availableTokens.length; i++) {
            total += availableTokens[i];
            if (random < total) {
                availableTokens[i]--;
                return i;
            }
        }

        revert("Invalid random value generated");
    }
}

File 2 of 15 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../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:
 *
 * ```solidity
 * 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}:
 *
 * ```solidity
 * 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. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    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 returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @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 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 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 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 `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @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 Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 3 of 15 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @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.
     */
    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 `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

File 4 of 15 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 5 of 15 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

File 6 of 15 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.20;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS
    }

    /**
     * @dev The signature derives the `address(0)`.
     */
    error ECDSAInvalidSignature();

    /**
     * @dev The signature has an invalid length.
     */
    error ECDSAInvalidSignatureLength(uint256 length);

    /**
     * @dev The signature has an S value that is in the upper half order.
     */
    error ECDSAInvalidSignatureS(bytes32 s);

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with `signature` or an error. This will not
     * return address(0) without also returning an error description. Errors are documented using an enum (error type)
     * and a bytes32 providing additional information about the error.
     *
     * If no error is returned, then the address can be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length));
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     */
    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) {
        unchecked {
            bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
            // We do not check for an overflow here since the shift operation results in 0 or 1.
            uint8 v = uint8((uint256(vs) >> 255) + 27);
            return tryRecover(hash, v, r, s);
        }
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     */
    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError, bytes32) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS, s);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature, bytes32(0));
        }

        return (signer, RecoverError.NoError, bytes32(0));
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {
        (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s);
        _throwError(error, errorArg);
        return recovered;
    }

    /**
     * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided.
     */
    function _throwError(RecoverError error, bytes32 errorArg) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert ECDSAInvalidSignature();
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert ECDSAInvalidSignatureLength(uint256(errorArg));
        } else if (error == RecoverError.InvalidSignatureS) {
            revert ECDSAInvalidSignatureS(errorArg);
        }
    }
}

File 7 of 15 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

File 8 of 15 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @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);
}

File 9 of 15 : IERC1155Mintable.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

interface IERC1155Mintable {
    function mint(
        address _to,
        uint256[] memory _ids,
        uint256[] memory _values
    ) external;

    function totalMinted() external returns (uint256);
}

File 10 of 15 : dtos.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library DTOs {
    struct Recipient {
        address addr;
        uint256 percentage;
    }

    struct Create721ContractDto {
        address owner;
        string uuid;
        string name;
        string symbol;
        bool transferLocked;
        uint96 royaltyPercentage;
        uint256 maxSupply;
        address signer;
        Recipient[] recipients;
        uint256 paymentAmount;
        uint256[] extras;
        bytes signature;
    }

    struct Create1155ContractDto {
        address owner;
        string uuid;
        string name;
        string symbol;
        bool transferLocked;
        uint96 royaltyPercentage;
        uint256[] availableTokens;
        address signer;
        Recipient[] recipients;
        uint256 paymentAmount;
        uint256[] extras;
        bytes signature;
    }
}

File 11 of 15 : LimitPerWallet.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

abstract contract LimitPerWallet {
    mapping(address => uint256) public mintsPerWallet;

    /**
     * @dev Checks if the given wallet address can mint more tokens.
     * If the desired amount to be minted exceeds the amount of tokens left allowed to be minted by the given address
     * it will return the maximum amount of tokens that address can mint.
     *
     * If the given address can not mint more tokens it will revert the transaction.
     */
    function getAvailableForWallet(
        uint256 _amount,
        uint256 _maxPerWallet
    ) internal returns (uint256) {
        // If maxPerWallet is 0 it means that there is no limit per wallet.
        if (_maxPerWallet == 0) {
            return _amount;
        }

        if (mintsPerWallet[msg.sender] + _amount > _maxPerWallet) {
            _amount = _maxPerWallet - mintsPerWallet[msg.sender];
        }

        require(
            _amount > 0,
            "LimitPerWallet: The caller address can not mint more tokens"
        );

        mintsPerWallet[msg.sender] += _amount;

        return _amount;
    }
}

File 12 of 15 : Payable.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

import {DTOs} from "./../libraries/dtos.sol";

abstract contract Payable {
    address public feeRecipient;
    uint256 private _totalEarnings;

    modifier onlyRecipient() {
        bool isRecipient = false;
        for (uint256 i = 0; i < recipients.length; i++) {
            if (recipients[i].addr == msg.sender) {
                isRecipient = true;
                break;
            }
        }

        require(
            isRecipient,
            "Payable: The caller is not an allowed withdrawer"
        );

        _;
    }

    uint256 constant BASIS_POINTS = 10000;

    DTOs.Recipient[] public recipients;

    function initPayable(
        address _feeRecipient,
        DTOs.Recipient[] memory _recipients
    ) internal {
        feeRecipient = _feeRecipient;

        for (uint256 i = 0; i < _recipients.length; i++) {
            recipients.push(_recipients[i]);
        }
    }

    function checkSentEther(
        uint256 _amount,
        uint256 _pricePerToken,
        uint256 _feePerToken
    ) internal {
        uint totalPrice = _amount * _pricePerToken;
        uint totalFee = _amount * _feePerToken;
        uint total = totalPrice + totalFee;

        require(
            msg.value >= total,
            "Payable: Not enough Ether provided to mint"
        );

        if (msg.value > total) {
            payable(msg.sender).transfer(msg.value - total);
        }

        if (totalFee > 0) {
            (bool success, ) = address(feeRecipient).call{value: totalFee}("");
            require(success, "Payable: Transfer failed");
        }
    }

    function withdraw() external onlyRecipient {
        uint256 totalBalance = address(this).balance;
        _totalEarnings += totalBalance;

        for (uint256 i; i < recipients.length; i++) {
            (bool success, ) = address(recipients[i].addr).call{
                value: mulScale(
                    totalBalance,
                    recipients[i].percentage,
                    BASIS_POINTS
                )
            }("");

            require(success, "Payable: Transfer failed");
        }
    }

    function totalEarnings() external view returns (uint256) {
        return _totalEarnings + address(this).balance;
    }

    function mulScale(
        uint256 x,
        uint256 y,
        uint256 scale
    ) internal pure returns (uint256) {
        uint256 a = x / scale;
        uint256 b = x % scale;
        uint256 c = y / scale;
        uint256 d = y % scale;

        return a * c * scale + a * d + b * c + (b * d) / scale;
    }
}

File 13 of 15 : RandomGenerator.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

abstract contract RandomGenerator {
    /**
     * @dev Generates a pseudo-random number.
     */
    function getRandomNumber(
        uint256 _upper,
        uint256 _variable // This value should change in between calls to this function within the same block to avoid generating the same number.
    ) internal view returns (uint256) {
        uint256 random = uint256(
            keccak256(
                abi.encodePacked(
                    _variable,
                    blockhash(block.number - 1),
                    block.coinbase,
                    block.prevrandao,
                    msg.sender
                )
            )
        );

        return (random % _upper);
    }
}

File 14 of 15 : SignatureProtected.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";

abstract contract SignatureProtected is Ownable {
    address public signerAddress;

    constructor() Ownable(msg.sender) {}

    function initSignatureProtected(address _signerAddress) internal {
        signerAddress = _signerAddress;
    }

    function setSignerAddress(address _signerAddress) external onlyOwner {
        signerAddress = _signerAddress;
    }

    function validateSignature(
        bytes memory packedParams,
        bytes calldata signature
    ) internal view {
        require(
            ECDSA.recover(generateHash(packedParams), signature) ==
                signerAddress,
            "SignatureProtected: Invalid signature for the caller"
        );
    }

    function generateHash(
        bytes memory packedParams
    ) private view returns (bytes32) {
        bytes32 _hash = keccak256(
            bytes.concat(
                abi.encodePacked(address(this), msg.sender),
                packedParams
            )
        );

        bytes memory result = abi.encodePacked(
            "\x19Ethereum Signed Message:\n32",
            _hash
        );

        return keccak256(result);
    }
}

File 15 of 15 : SupplyControl1155.sol
// SPDX-License-Identifier: MIT
// @author: NFT Studios

pragma solidity ^0.8.18;

abstract contract SupplyControl1155 {
    uint256[] internal availableTokens;
    uint256 public maxSupply;

    function initSupplyControl(uint256[] memory _availableTokens) internal {
        availableTokens = _availableTokens;
        for (uint256 i; i < _availableTokens.length; i++) {
            maxSupply += _availableTokens[i];
        }
    }

    /**
     * @dev Checks if there are tokens left to be minted.
     * If there are not enough tokens for the given amount to mint, it will return whatever is left.
     *
     * If there are no tokens left to be minted it will revert the transaction.
     */
    function _getAvailableTokens(
        uint256 _amountToMint
    ) internal view returns (uint256) {
        uint256 _availableTokens = getAvailableTokens();

        require(_availableTokens > 0, "SupplyControl: No tokens left to mint");
        if (_availableTokens < _amountToMint) {
            return _availableTokens;
        }

        return _amountToMint;
    }

    function getAvailableTokens() public view returns (uint256) {
        uint256 _availableTokens;
        for (uint256 i; i < availableTokens.length; i++) {
            _availableTokens += availableTokens[i];
        }

        return _availableTokens;
    }
}

Settings
{
  "evmVersion": "paris",
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  }
}

Contract ABI

[{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"contractType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"erc1155Contract","outputs":[{"internalType":"contract IERC1155Mintable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeRecipient","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAvailableTokens","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"signerAddress","type":"address"},{"internalType":"address","name":"feeRecipient","type":"address"},{"internalType":"uint256[]","name":"availableTokens","type":"uint256[]"},{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"internalType":"struct DTOs.Recipient[]","name":"recipients","type":"tuple[]"},{"internalType":"address","name":"erc1155Address","type":"address"}],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_maxPerWallet","type":"uint256"},{"internalType":"uint256","name":"_pricePerToken","type":"uint256"},{"internalType":"uint256","name":"_feePerToken","type":"uint256"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mintsPerWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"recipients","outputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint256","name":"percentage","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_signerAddress","type":"address"}],"name":"setSignerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"signerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalEarnings","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.