POL Price: $0.575558 (-10.01%)
 

Overview

POL Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 POL

POL Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AuctionUtils

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 27 : utils.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

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

import "./auctions.sol";
import "./types.sol";

contract AuctionUtils is AccessControl {
    bytes32 public constant ADMIN_ROLE = keccak256("ADMIN_ROLE");

    Auctions public auctionsContract;
    uint256 public maxPageSize = 100; // Default value

    constructor(Auctions _auctionsContract) {
        auctionsContract = _auctionsContract;
        _setupRole(ADMIN_ROLE, msg.sender);
    }

    function setMaxPageSize(uint256 _maxPageSize) public onlyRole(ADMIN_ROLE) {
        maxPageSize = _maxPageSize;
    }

    /* 
    /////////////////////////////
    Utility Functions
    /////////////////////////////

        Include utility functions like getRemainingTime and getActiveAuctions.
    */ 
    
    // Function to get remaining time for an auction
    function getRemainingTime(uint256 _auctionId) public view returns (uint256) {
        SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(_auctionId);
        
        // Check if the auction has already ended
        if(block.timestamp >= auction.endTime) {
            return 0;
        } else {
            // Calculate and return the remaining time
            return auction.endTime - block.timestamp;
        }
    }

    // Function to get active auctions for a specific user
    function getUserActiveAuctions(address user, uint256 page, uint256 pageSize) 
    public view 
    returns (uint256[] memory, uint256) 
    {
        uint256[] memory allActiveAuctions = auctionsContract.getUserActiveAuctions(user);
        uint256 totalActive = allActiveAuctions.length;

        if (pageSize > maxPageSize) {
            pageSize = maxPageSize;
        }

        uint256 startIndex = (page - 1) * pageSize;
        require(startIndex < totalActive, "Start index out of range");

        uint256 endIndex = startIndex + pageSize > totalActive ? totalActive : startIndex + pageSize;
        uint256[] memory paginatedActiveAuctions = new uint256[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            paginatedActiveAuctions[i - startIndex] = allActiveAuctions[i];
        }

        return (paginatedActiveAuctions, totalActive);
    }

    // Function to get user bidding history for an auction
    function getUserBiddingHistory(address user, uint256 auctionId) public view returns (uint256) {
        return auctionsContract.biddingHistory(user, auctionId);
    }

    // Function to get the auction bid history
    function getAuctionBidHistory(uint256 _auctionId) public view returns (SharedTypes.Bid[] memory) {
        return auctionsContract.getAuctionBids(_auctionId);
    }

    // Function to get the active auctions
    function getActiveAuctions(uint256 page, uint256 pageSize) 
        public view 
        returns (SharedTypes.AuctionInfo[] memory, uint256)  
    {
        uint256 totalAuctions = auctionsContract.getTotalActiveAuctions();
        uint256 startIndex = (page - 1) * pageSize;
        require(startIndex < totalAuctions, "Start index out of range");

        if (pageSize > maxPageSize) {
            pageSize = maxPageSize;
        }

        uint256 endIndex = startIndex + pageSize > totalAuctions ? totalAuctions : startIndex + pageSize;
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            paginatedAuctions[i - startIndex] = auctionsContract.getAuctionInfo(i);
        }

        return (paginatedAuctions, totalAuctions);
    }

    // Function to get the ended auctions
    function getEndedAuctions(uint256 page, uint256 pageSize) 
        public 
        view 
        returns (SharedTypes.AuctionInfo[] memory, uint256)  
    {
        uint256 totalAuctions = auctionsContract.getTotalEndedAuctions();
        uint256 startIndex = (page - 1) * pageSize;
        require(startIndex < totalAuctions, "Start index out of range");

        if (pageSize > maxPageSize) {
            pageSize = maxPageSize;
        }

        uint256 endIndex = startIndex + pageSize > totalAuctions ? totalAuctions : startIndex + pageSize;
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            paginatedAuctions[i - startIndex] = auctionsContract.getAuctionInfo(i);
        }

        return (paginatedAuctions, totalAuctions);
    }

    // Function to get a limited list of auctions by NFT ID with pagination
    function getAuctionsByTokenId(uint256 _tokenId, uint256 page, uint256 pageSize) 
        public view 
        returns (SharedTypes.AuctionInfo[] memory, uint256) 
    {
        uint256 totalAuctions = auctionsContract.getTotalAuctions();
        uint256 count = 0;

        // First pass: count auctions with the matching NFT ID
        for (uint256 i = 0; i < totalAuctions; i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.tokenId == _tokenId) {
                count++;
            }
        }

        // Apply pagination
        uint256 startIndex = (page - 1) * pageSize;
        if (startIndex > count) {
            startIndex = count;
        }
        uint256 endIndex = startIndex + pageSize;
        if (endIndex > count) {
            endIndex = count;
        }

        // Second pass: populate the paginated array with matching auctions
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);
        uint256 arrayIndex = 0;
        for (uint256 i = 0; i < totalAuctions && arrayIndex < (endIndex - startIndex); i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.tokenId == _tokenId) {
                if (i >= startIndex && i < endIndex) {
                    paginatedAuctions[arrayIndex] = auction;
                    arrayIndex++;
                }
            }
        }

        return (paginatedAuctions, count);
    }

    // Function to get a limited list of auctions without bids with pagination
    function getAuctionsWithoutBids(uint256 page, uint256 pageSize) 
        public view 
        returns (SharedTypes.AuctionInfo[] memory, uint256) 
    {
        uint256 totalAuctions = auctionsContract.getTotalAuctions();
        uint256 count = 0;

        // First pass: count auctions with no bids and not ended
        for (uint256 i = 0; i < totalAuctions; i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.highestBid == 0 && !auction.ended) {
                count++;
            }
        }

        // Apply pagination
        uint256 startIndex = (page - 1) * pageSize;
        if (startIndex > count) {
            startIndex = count;
        }
        uint256 endIndex = startIndex + pageSize;
        if (endIndex > count) {
            endIndex = count;
        }

        // Second pass: populate the paginated array with matching auctions
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);
        uint256 arrayIndex = 0;
        for (uint256 i = 0; i < totalAuctions && arrayIndex < (endIndex - startIndex); i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.highestBid == 0 && !auction.ended) {
                if (i >= startIndex && i < endIndex) {
                    paginatedAuctions[arrayIndex] = auction;
                    arrayIndex++;
                }
            }
        }

        return (paginatedAuctions, count);
    }

    // Function to get a limited list of auctions close to ending with pagination
    function getAuctionsCloseToEnding(uint256 page, uint256 pageSize) 
    public view 
    returns (SharedTypes.AuctionInfo[] memory, uint256) 
    {
        uint256 totalAuctions = auctionsContract.getTotalAuctions();
        uint256 threshold = block.timestamp + auctionsContract.getTimeExtensionThreshold();
        uint256 count = 0;

        // First pass: count auctions close to ending and not ended
        for (uint256 i = 0; i < totalAuctions; i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.endTime <= threshold && !auction.ended) {
                count++;
            }
        }

        // Apply pagination
        uint256 startIndex = (page - 1) * pageSize;
        if (startIndex > count) {
            startIndex = count;
        }
        uint256 endIndex = startIndex + pageSize;
        if (endIndex > count) {
            endIndex = count;
        }

        // Second pass: populate the paginated array with matching auctions
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);
        uint256 arrayIndex = 0;
        for (uint256 i = 0; i < totalAuctions && arrayIndex < (endIndex - startIndex); i++) {
            SharedTypes.AuctionInfo memory auction = auctionsContract.getAuctionInfo(i);
            if (auction.endTime <= threshold && !auction.ended) {
                if (i >= startIndex && i < endIndex) {
                    paginatedAuctions[arrayIndex] = auction;
                    arrayIndex++;
                }
            }
        }

        return (paginatedAuctions, count);
    }

    // new methods
    function getAuctions(uint256 page, uint256 pageSize) public view returns (SharedTypes.AuctionInfo[] memory, uint256) {
        uint256 totalAuctions = auctionsContract.getTotalAuctions();
        uint256 startIndex = (page - 1) * pageSize;
        require(startIndex < totalAuctions, "Start index out of range");

        if (pageSize > maxPageSize) {
            pageSize = maxPageSize;
        }

        uint256 endIndex = startIndex + pageSize > totalAuctions ? totalAuctions : startIndex + pageSize;
        SharedTypes.AuctionInfo[] memory paginatedAuctions = new SharedTypes.AuctionInfo[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            paginatedAuctions[i - startIndex] = auctionsContract.getAuctionInfo(i);
        }

        return (paginatedAuctions, totalAuctions);
    }
}

File 2 of 27 : AccessControl.sol
// 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());
        }
    }
}

File 3 of 27 : IAccessControl.sol
// 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;
}

File 4 of 27 : PaymentSplitter.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (finance/PaymentSplitter.sol)

pragma solidity ^0.8.0;

import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";

/**
 * @title PaymentSplitter
 * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
 * that the Ether will be split in this way, since it is handled transparently by the contract.
 *
 * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
 * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
 * an amount proportional to the percentage of total shares they were assigned. The distribution of shares is set at the
 * time of contract deployment and can't be updated thereafter.
 *
 * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
 * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
 * function.
 *
 * NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
 * tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
 * to run tests before sending real value to this contract.
 */
contract PaymentSplitter is Context {
    event PayeeAdded(address account, uint256 shares);
    event PaymentReleased(address to, uint256 amount);
    event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
    event PaymentReceived(address from, uint256 amount);

    uint256 private _totalShares;
    uint256 private _totalReleased;

    mapping(address => uint256) private _shares;
    mapping(address => uint256) private _released;
    address[] private _payees;

    mapping(IERC20 => uint256) private _erc20TotalReleased;
    mapping(IERC20 => mapping(address => uint256)) private _erc20Released;

    /**
     * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
     * the matching position in the `shares` array.
     *
     * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
     * duplicates in `payees`.
     */
    constructor(address[] memory payees, uint256[] memory shares_) payable {
        require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
        require(payees.length > 0, "PaymentSplitter: no payees");

        for (uint256 i = 0; i < payees.length; i++) {
            _addPayee(payees[i], shares_[i]);
        }
    }

    /**
     * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
     * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
     * reliability of the events, and not the actual splitting of Ether.
     *
     * To learn more about this see the Solidity documentation for
     * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
     * functions].
     */
    receive() external payable virtual {
        emit PaymentReceived(_msgSender(), msg.value);
    }

    /**
     * @dev Getter for the total shares held by payees.
     */
    function totalShares() public view returns (uint256) {
        return _totalShares;
    }

    /**
     * @dev Getter for the total amount of Ether already released.
     */
    function totalReleased() public view returns (uint256) {
        return _totalReleased;
    }

    /**
     * @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
     * contract.
     */
    function totalReleased(IERC20 token) public view returns (uint256) {
        return _erc20TotalReleased[token];
    }

    /**
     * @dev Getter for the amount of shares held by an account.
     */
    function shares(address account) public view returns (uint256) {
        return _shares[account];
    }

    /**
     * @dev Getter for the amount of Ether already released to a payee.
     */
    function released(address account) public view returns (uint256) {
        return _released[account];
    }

    /**
     * @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
     * IERC20 contract.
     */
    function released(IERC20 token, address account) public view returns (uint256) {
        return _erc20Released[token][account];
    }

    /**
     * @dev Getter for the address of the payee number `index`.
     */
    function payee(uint256 index) public view returns (address) {
        return _payees[index];
    }

    /**
     * @dev Getter for the amount of payee's releasable Ether.
     */
    function releasable(address account) public view returns (uint256) {
        uint256 totalReceived = address(this).balance + totalReleased();
        return _pendingPayment(account, totalReceived, released(account));
    }

    /**
     * @dev Getter for the amount of payee's releasable `token` tokens. `token` should be the address of an
     * IERC20 contract.
     */
    function releasable(IERC20 token, address account) public view returns (uint256) {
        uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token);
        return _pendingPayment(account, totalReceived, released(token, account));
    }

    /**
     * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
     * total shares and their previous withdrawals.
     */
    function release(address payable account) public virtual {
        require(_shares[account] > 0, "PaymentSplitter: account has no shares");

        uint256 payment = releasable(account);

        require(payment != 0, "PaymentSplitter: account is not due payment");

        // _totalReleased is the sum of all values in _released.
        // If "_totalReleased += payment" does not overflow, then "_released[account] += payment" cannot overflow.
        _totalReleased += payment;
        unchecked {
            _released[account] += payment;
        }

        Address.sendValue(account, payment);
        emit PaymentReleased(account, payment);
    }

    /**
     * @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
     * percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
     * contract.
     */
    function release(IERC20 token, address account) public virtual {
        require(_shares[account] > 0, "PaymentSplitter: account has no shares");

        uint256 payment = releasable(token, account);

        require(payment != 0, "PaymentSplitter: account is not due payment");

        // _erc20TotalReleased[token] is the sum of all values in _erc20Released[token].
        // If "_erc20TotalReleased[token] += payment" does not overflow, then "_erc20Released[token][account] += payment"
        // cannot overflow.
        _erc20TotalReleased[token] += payment;
        unchecked {
            _erc20Released[token][account] += payment;
        }

        SafeERC20.safeTransfer(token, account, payment);
        emit ERC20PaymentReleased(token, account, payment);
    }

    /**
     * @dev internal logic for computing the pending payment of an `account` given the token historical balances and
     * already released amounts.
     */
    function _pendingPayment(
        address account,
        uint256 totalReceived,
        uint256 alreadyReleased
    ) private view returns (uint256) {
        return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
    }

    /**
     * @dev Add a new payee to the contract.
     * @param account The address of the payee to add.
     * @param shares_ The number of shares owned by the payee.
     */
    function _addPayee(address account, uint256 shares_) private {
        require(account != address(0), "PaymentSplitter: account is the zero address");
        require(shares_ > 0, "PaymentSplitter: shares are 0");
        require(_shares[account] == 0, "PaymentSplitter: account already has shares");

        _payees.push(account);
        _shares[account] = shares_;
        _totalShares = _totalShares + shares_;
        emit PayeeAdded(account, shares_);
    }
}

File 5 of 27 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

import "../utils/introspection/IERC165.sol";

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}

File 6 of 27 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    constructor() {
        _paused = false;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        require(paused(), "Pausable: not paused");
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

File 7 of 27 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 8 of 27 : ERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol)

pragma solidity ^0.8.0;

import "./IERC1155.sol";
import "./IERC1155Receiver.sol";
import "./extensions/IERC1155MetadataURI.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the basic standard multi-token.
 * See https://eips.ethereum.org/EIPS/eip-1155
 * Originally based on code by Enjin: https://github.com/enjin/erc-1155
 *
 * _Available since v3.1._
 */
contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI {
    using Address for address;

    // Mapping from token ID to account balances
    mapping(uint256 => mapping(address => uint256)) private _balances;

    // Mapping from account to operator approvals
    mapping(address => mapping(address => bool)) private _operatorApprovals;

    // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json
    string private _uri;

    /**
     * @dev See {_setURI}.
     */
    constructor(string memory uri_) {
        _setURI(uri_);
    }

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

    /**
     * @dev See {IERC1155MetadataURI-uri}.
     *
     * This implementation returns the same URI for *all* token types. It relies
     * on the token type ID substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * Clients calling this function must replace the `\{id\}` substring with the
     * actual token type ID.
     */
    function uri(uint256) public view virtual override returns (string memory) {
        return _uri;
    }

    /**
     * @dev See {IERC1155-balanceOf}.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) public view virtual override returns (uint256) {
        require(account != address(0), "ERC1155: address zero is not a valid owner");
        return _balances[id][account];
    }

    /**
     * @dev See {IERC1155-balanceOfBatch}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] memory accounts, uint256[] memory ids)
        public
        view
        virtual
        override
        returns (uint256[] memory)
    {
        require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch");

        uint256[] memory batchBalances = new uint256[](accounts.length);

        for (uint256 i = 0; i < accounts.length; ++i) {
            batchBalances[i] = balanceOf(accounts[i], ids[i]);
        }

        return batchBalances;
    }

    /**
     * @dev See {IERC1155-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        _setApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC1155-isApprovedForAll}.
     */
    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[account][operator];
    }

    /**
     * @dev See {IERC1155-safeTransferFrom}.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeTransferFrom(from, to, id, amount, data);
    }

    /**
     * @dev See {IERC1155-safeBatchTransferFrom}.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) public virtual override {
        require(
            from == _msgSender() || isApprovedForAll(from, _msgSender()),
            "ERC1155: caller is not token owner or approved"
        );
        _safeBatchTransferFrom(from, to, ids, amounts, data);
    }

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }
        _balances[id][to] += amount;

        emit TransferSingle(operator, from, to, id, amount);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _safeBatchTransferFrom(
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
        require(to != address(0), "ERC1155: transfer to the zero address");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; ++i) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: insufficient balance for transfer");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
            _balances[id][to] += amount;
        }

        emit TransferBatch(operator, from, to, ids, amounts);

        _afterTokenTransfer(operator, from, to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data);
    }

    /**
     * @dev Sets a new URI for all token types, by relying on the token type ID
     * substitution mechanism
     * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP].
     *
     * By this mechanism, any occurrence of the `\{id\}` substring in either the
     * URI or any of the amounts in the JSON file at said URI will be replaced by
     * clients with the token type ID.
     *
     * For example, the `https://token-cdn-domain/\{id\}.json` URI would be
     * interpreted by clients as
     * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json`
     * for token type ID 0x4cce0.
     *
     * See {uri}.
     *
     * Because these URIs cannot be meaningfully represented by the {URI} event,
     * this function emits no events.
     */
    function _setURI(string memory newuri) internal virtual {
        _uri = newuri;
    }

    /**
     * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function _mint(
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        _balances[id][to] += amount;
        emit TransferSingle(operator, address(0), to, id, amount);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data);
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function _mintBatch(
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {
        require(to != address(0), "ERC1155: mint to the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, address(0), to, ids, amounts, data);

        for (uint256 i = 0; i < ids.length; i++) {
            _balances[ids[i]][to] += amounts[i];
        }

        emit TransferBatch(operator, address(0), to, ids, amounts);

        _afterTokenTransfer(operator, address(0), to, ids, amounts, data);

        _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data);
    }

    /**
     * @dev Destroys `amount` tokens of token type `id` from `from`
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `from` must have at least `amount` tokens of token type `id`.
     */
    function _burn(
        address from,
        uint256 id,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");

        address operator = _msgSender();
        uint256[] memory ids = _asSingletonArray(id);
        uint256[] memory amounts = _asSingletonArray(amount);

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        uint256 fromBalance = _balances[id][from];
        require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
        unchecked {
            _balances[id][from] = fromBalance - amount;
        }

        emit TransferSingle(operator, from, address(0), id, amount);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     */
    function _burnBatch(
        address from,
        uint256[] memory ids,
        uint256[] memory amounts
    ) internal virtual {
        require(from != address(0), "ERC1155: burn from the zero address");
        require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

        address operator = _msgSender();

        _beforeTokenTransfer(operator, from, address(0), ids, amounts, "");

        for (uint256 i = 0; i < ids.length; i++) {
            uint256 id = ids[i];
            uint256 amount = amounts[i];

            uint256 fromBalance = _balances[id][from];
            require(fromBalance >= amount, "ERC1155: burn amount exceeds balance");
            unchecked {
                _balances[id][from] = fromBalance - amount;
            }
        }

        emit TransferBatch(operator, from, address(0), ids, amounts);

        _afterTokenTransfer(operator, from, address(0), ids, amounts, "");
    }

    /**
     * @dev Approve `operator` to operate on all of `owner` tokens
     *
     * Emits an {ApprovalForAll} event.
     */
    function _setApprovalForAll(
        address owner,
        address operator,
        bool approved
    ) internal virtual {
        require(owner != operator, "ERC1155: setting approval status for self");
        _operatorApprovals[owner][operator] = approved;
        emit ApprovalForAll(owner, operator, approved);
    }

    /**
     * @dev Hook that is called before any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `ids` and `amounts` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    /**
     * @dev Hook that is called after any token transfer. This includes minting
     * and burning, as well as batched variants.
     *
     * The same hook is called on both single and batched variants. For single
     * transfers, the length of the `id` and `amount` arrays will be 1.
     *
     * Calling conditions (for each `id` and `amount` pair):
     *
     * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * of token type `id` will be  transferred to `to`.
     * - When `from` is zero, `amount` tokens of token type `id` will be minted
     * for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens of token type `id`
     * will be burned.
     * - `from` and `to` are never both zero.
     * - `ids` and `amounts` have the same, non-zero length.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual {}

    function _doSafeTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) {
                if (response != IERC1155Receiver.onERC1155Received.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _doSafeBatchTransferAcceptanceCheck(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) private {
        if (to.isContract()) {
            try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns (
                bytes4 response
            ) {
                if (response != IERC1155Receiver.onERC1155BatchReceived.selector) {
                    revert("ERC1155: ERC1155Receiver rejected tokens");
                }
            } catch Error(string memory reason) {
                revert(reason);
            } catch {
                revert("ERC1155: transfer to non-ERC1155Receiver implementer");
            }
        }
    }

    function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) {
        uint256[] memory array = new uint256[](1);
        array[0] = element;

        return array;
    }
}

File 9 of 27 : ERC1155Supply.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC1155/extensions/ERC1155Supply.sol)

pragma solidity ^0.8.0;

import "../ERC1155.sol";

/**
 * @dev Extension of ERC1155 that adds tracking of total supply per id.
 *
 * Useful for scenarios where Fungible and Non-fungible tokens have to be
 * clearly identified. Note: While a totalSupply of 1 might mean the
 * corresponding is an NFT, there is no guarantees that no other token with the
 * same id are not going to be minted.
 */
abstract contract ERC1155Supply is ERC1155 {
    mapping(uint256 => uint256) private _totalSupply;

    /**
     * @dev Total amount of tokens in with a given id.
     */
    function totalSupply(uint256 id) public view virtual returns (uint256) {
        return _totalSupply[id];
    }

    /**
     * @dev Indicates whether any token exist with a given id, or not.
     */
    function exists(uint256 id) public view virtual returns (bool) {
        return ERC1155Supply.totalSupply(id) > 0;
    }

    /**
     * @dev See {ERC1155-_beforeTokenTransfer}.
     */
    function _beforeTokenTransfer(
        address operator,
        address from,
        address to,
        uint256[] memory ids,
        uint256[] memory amounts,
        bytes memory data
    ) internal virtual override {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        if (from == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                _totalSupply[ids[i]] += amounts[i];
            }
        }

        if (to == address(0)) {
            for (uint256 i = 0; i < ids.length; ++i) {
                uint256 id = ids[i];
                uint256 amount = amounts[i];
                uint256 supply = _totalSupply[id];
                require(supply >= amount, "ERC1155: burn amount exceeds totalSupply");
                unchecked {
                    _totalSupply[id] = supply - amount;
                }
            }
        }
    }
}

File 10 of 27 : IERC1155MetadataURI.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol)

pragma solidity ^0.8.0;

import "../IERC1155.sol";

/**
 * @dev Interface of the optional ERC1155MetadataExtension interface, as defined
 * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155MetadataURI is IERC1155 {
    /**
     * @dev Returns the URI for token type `id`.
     *
     * If the `\{id\}` substring is present in the URI, it must be replaced by
     * clients with the actual token type ID.
     */
    function uri(uint256 id) external view returns (string memory);
}

File 11 of 27 : IERC1155.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 12 of 27 : IERC1155Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.sol";

/**
 * @dev _Available since v3.1._
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 13 of 27 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-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);
}

File 14 of 27 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.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);
}

File 15 of 27 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    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");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 16 of 27 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return 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);
        }
    }
}

File 17 of 27 : Context.sol
// 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;
    }
}

File 18 of 27 : ERC165.sol
// 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;
    }
}

File 19 of 27 : IERC165.sol
// 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);
}

File 20 of 27 : Math.sol
// 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);
        }
    }
}

File 21 of 27 : SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)

pragma solidity ^0.8.0;

// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.

/**
 * @dev Wrappers over Solidity's arithmetic operations.
 *
 * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
 * now has built in overflow checking.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b <= a, errorMessage);
            return a - b;
        }
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a / b;
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(
        uint256 a,
        uint256 b,
        string memory errorMessage
    ) internal pure returns (uint256) {
        unchecked {
            require(b > 0, errorMessage);
            return a % b;
        }
    }
}

File 22 of 27 : Strings.sol
// 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);
    }
}

File 23 of 27 : auctions.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/security/Pausable.sol";

import "../tickets/ticket.sol";
import "../tickets/registry.sol";
import "./types.sol";

/// @custom:security-contact [email protected]
contract Auctions is IERC165, IERC1155Receiver, AccessControl, ReentrancyGuard, Pausable {
    using SafeMath for uint256;

    /* 
    /////////////////////////////////
    1. Contract and Role Declarations 
    /////////////////////////////////

        - Define a constant role for the booth role
    */ 

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

    /* 
    /////////////////////////////
    2. Structs and State Variables
    /////////////////////////////
        
        This section declares the state variables and data structures used in the contract.

        - struct Auction: This structure represents an auction. It includes the seller's address, the ticket ID and NFT ID being auctioned, the starting price, the end time of the auction, the highest bid and bidder, and a boolean to indicate if the auction has ended.

        - ticketContract: This is the address of the Ticket contract used in the auctions.

        - auctions: This is a mapping from auction ID to the corresponding Auction struct.

        - userAuctions: This is a mapping from a user's address to an array of auction IDs they have participated in.

        - biddingHistory: This is a mapping from a user's address and an auction ID to the amount they have bid in that auction.

        - nextAuctionId: This is a counter for generating unique IDs for new auctions.

        - depositPercentage: Percentage of bid amount to be deposited

        - bidLockPeriod: Lock period in seconds

        - platformCommission: Represented in basis points (500 is 5%)
    */

    Ticket public ticketContract;
    TicketRegistry public ticketRegistryContract;
    mapping(uint256 => SharedTypes.Auction) public auctions;
    mapping(address => uint256[]) public userAuctions;
    mapping(address => mapping(uint256 => uint256)) public biddingHistory;
    mapping(uint256 => SharedTypes.Bid[]) public auctionBids;

    // New index mappings for efficient lookup
    mapping(uint256 => uint256) private auctionIndex; // Maps auction ID to its index in the activeAuctions array
    mapping(address => mapping(uint256 => uint256)) private userAuctionIndex; // Maps user address and auction ID to index in userActiveAuctions

    // User's active auctions
    mapping(address => uint256[]) public userActiveAuctions;
    mapping(uint256 => uint256) private activeAuctionIndex; // Maps auction ID to its index in activeAuctionIds array
    uint256[] private activeAuctionIds; // Dynamic array of active auction IDs

    // Counters for total, active, and ended auctions
    uint256 public totalAuctions;
    uint256 public totalActiveAuctions;
    uint256 public totalEndedAuctions;

    // Auction Parameters
    uint256 public nextAuctionId;
    uint256 public timeExtensionThreshold;
    uint256 public minBidIncrement;
    uint256 public depositPercentage;
    uint256 public bidLockPeriod;
    uint256 public platformCommission;
    address public platformOwnerAddress;

    /* 
    /////////////////////////////
    3. Constructor and Events
    /////////////////////////////

        The constructor initializes the state of the contract with the following parameters:

        - Ticket _ticketContract: This is the ERC20 contract address of the Ticket.sol contract

        - timeExtensionThreshold: This variable will hold the number of seconds for the time extension. 
            e.g: 300; // 5 minutes in seconds
        
        - uint256 _initialMinBidIncrement: The minimum bid increment in an auction contract can be specified in wei, which is the smallest denomination of ether. One ether is equivalent to 
            e.g: 10**16; // 0.01 ether in wei

        - uint256 _depositPercentage: Percentage of bid amount to be deposited. The platform will keep this in case of an early withdrawal.
        
        - uint256 _bidLockPeriod: Lock period in seconds
            e.g; 300 is 5 minutes in seconds
        
        - uint256 _platformCommission: Percentage comission for platform, represented in basis points.
            e.g; 500 is 5%

    */

    constructor(
        Ticket _ticketContract,
        TicketRegistry _ticketRegistryContract,
        uint256 _timeExtensionThreshold,
        uint256 _initialMinBidIncrement,
        uint256 _depositPercentage,
        uint256 _bidLockPeriod,
        uint256 _platformCommission
    ) 
    {
        ticketContract = _ticketContract;
        ticketRegistryContract = _ticketRegistryContract;
        timeExtensionThreshold = _timeExtensionThreshold;
        minBidIncrement = _initialMinBidIncrement;
        depositPercentage = _depositPercentage;
        bidLockPeriod = _bidLockPeriod;
        platformCommission = _platformCommission;
        platformOwnerAddress = msg.sender;

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(BOOTH_ROLE, msg.sender);
    }

    event AuctionCreated(uint256 indexed auctionId, address indexed seller, uint256 ticketId, uint256 nftId, uint256 startingPrice, uint256 endTime);
    event BidPlaced(uint256 indexed auctionId, address indexed bidder, uint256 amount);
    event BidRefunded(uint256 indexed auctionId, address indexed bidder, uint256 amount);
    event AuctionEnded(uint256 indexed auctionId, address indexed seller, address indexed winner, uint256 amount);
    event AuctionEndedWithoutSale(uint256 indexed auctionId, address indexed seller);
    event AuctionCancelled(uint256 indexed auctionId);
    event BidWithdrawn(uint256 indexed auctionId, address indexed bidder, uint256 amount);
    event BidOutbid(uint256 indexed auctionId, address indexed outbidBidder, uint256 amount);
    event TimeExtended(uint256 indexed auctionId, uint256 newEndTime);
    event MinBidIncrementChanged(uint256 newMinBidIncrement);

    /* 
    /////////////////////////////
    4. Role-Based Functionality
    /////////////////////////////

        Group functions by the roles that can call them. 
        For example, all functions that require BOOTH_ROLE should be together.
    */ 

    /**
     * @notice Ends an ongoing auction.
     * @param _auctionId The ID of the auction to end.
     * @dev This method handles the auction closure, transfers the NFT to the highest bidder, and distributes the bid amount between the seller and the platform based on the commission rate.
     *      Can only be called by an account with the BOOTH_ROLE.
     */
    function endAuction(uint256 _auctionId) public nonReentrant onlyRole(BOOTH_ROLE) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(!auction.ended, "Auction has already ended");
        require(block.timestamp >= auction.endTime, "Auction is still ongoing");

        IERC1155 ticketContractInstance = IERC1155(auction.ticketContractAddress);

        auction.ended = true;

        if (auction.highestBid >= auction.reservePrice) {
            // Calculate and transfer royalty payment
            uint256 salePriceAfterRoyalty = handleRoyaltyPayment(auction.tokenId, _auctionId, auction.highestBid);

            // Ensure commission is within valid range
            require(platformCommission <= 10000, "Invalid platform commission");
            uint256 commissionAmount = salePriceAfterRoyalty.mul(platformCommission).div(10000);
            require(salePriceAfterRoyalty >= commissionAmount, "Commission exceeds sale price after royalty");

            uint256 sellerAmount = salePriceAfterRoyalty.sub(commissionAmount);

            // Transfer the commission to the platform owner
            payable(platformOwnerAddress).transfer(commissionAmount);
            // Transfer the remaining funds to the seller
            (bool success, ) = auction.seller.call{value: sellerAmount}("");
            require(success, "Failed to transfer funds to the seller");

            ticketContractInstance.safeTransferFrom(address(this), auction.highestBidder, auction.nftId, 1, "");
            emit AuctionEnded(_auctionId, auction.seller, auction.highestBidder, auction.highestBid);
        } else {
            ticketContractInstance.safeTransferFrom(address(this), auction.seller, auction.nftId, 1, "");
            emit AuctionEndedWithoutSale(_auctionId, auction.seller);
        }

        totalEndedAuctions++;
        updateAuctionStatus(auction.seller, _auctionId);
    }

    /**
     * @notice Withdraws funds from the Auctions contract.
     * @dev This method allows the withdrawal of accumulated funds in the contract. Can only be called by an account with the BOOTH_ROLE.
     */
    function withdraw() public onlyRole(BOOTH_ROLE) {
        uint256 amount = address(this).balance;
        require(amount > 0, "No funds to withdraw");
        payable(msg.sender).transfer(amount);
    }

    /**
     * @notice Sets a new time extension threshold for auction bids.
     * @param _newThreshold The new time threshold in seconds.
     * @dev This method updates the time extension threshold, which is used to extend the auction end time if a bid is placed near the closing time. Can only be called by an account with the BOOTH_ROLE.
     */
    function setTimeExtensionThreshold(uint256 _newThreshold) public onlyRole(BOOTH_ROLE) {
        require(_newThreshold > 0, "Invalid threshold");
        timeExtensionThreshold = _newThreshold;
    }
    
    /**
     * @notice Sets the minimum bid increment for auctions.
     * @param _minBidIncrement The new minimum bid increment.
     * @dev This method updates the minimum amount by which each new bid must exceed the previous one. Can only be called by an account with the BOOTH_ROLE.
     */
    function setMinBidIncrement(uint256 _minBidIncrement) public onlyRole(BOOTH_ROLE) {
        require(_minBidIncrement > 0, "Minimum bid increment must be greater than 0");
        minBidIncrement = _minBidIncrement;
        emit MinBidIncrementChanged(_minBidIncrement);
    }
    
    /**
     * @notice Updates the deposit percentage required for placing bids.
     * @param _newPercentage The new deposit percentage.
     * @dev This method sets the percentage of the bid amount that must be deposited by bidders. Can only be called by an account with the BOOTH_ROLE.
     */
    function setDepositPercentage(uint256 _newPercentage) public onlyRole(BOOTH_ROLE) {
        depositPercentage = _newPercentage;
    }
    
    /**
     * @notice Sets a new lock period for bids.
     * @param _newPeriod The new bid lock period in seconds.
     * @dev This method updates the period during which a bid cannot be withdrawn after being placed. Can only be called by an account with the BOOTH_ROLE.
     */
    function setBidLockPeriod(uint256 _newPeriod) public onlyRole(BOOTH_ROLE) {
        bidLockPeriod = _newPeriod;
    }
    
    /**
     * @notice Updates the platform commission rate for auctions.
     * @param _newCommission The new commission rate in basis points.
     * @dev This method sets the percentage of the final bid amount that will be taken as a commission by the platform. Can only be called by an account with the BOOTH_ROLE.
     */
    function setPlatformCommission(uint256 _newCommission) public onlyRole(BOOTH_ROLE) {
        require(_newCommission >= 0 && _newCommission <= 10000, "Invalid commission rate");
        platformCommission = _newCommission;
    }
    
    /**
     * @notice Pauses all auction activities.
     * @dev This emergency method halts all auction-related actions in case a bug or security issue is detected. Can only be called by an account with the BOOTH_ROLE.
     */
    function pause() public onlyRole(BOOTH_ROLE) {
        _pause();
    }
    
    /**
     * @notice Resumes all auction activities.
     * @dev This method is used to un-halt auction activities after a bug or security issue has been resolved. Can only be called by an account with the BOOTH_ROLE.
     */
    function unpause() public onlyRole(BOOTH_ROLE) {
        _unpause();
    }

    /* 
    /////////////////////////////
    5. Auction methods
    /////////////////////////////
        
        Group together all functions related to creating auctions. 
    */ 

    /**
     * @notice Creates a new auction for an NFT.
     * @param _ticketContractAddress The erc20 address of the ticket contract to interact with.
     * @param _tokenId The ID of the ticket contract.
     * @param _nftId The ID of the NFT to be auctioned.
     * @param _startingPrice The starting price of the auction.
     * @param _duration The duration of the auction in seconds.
     * @param _reservePrice The reserve price for the auction.
     * @dev Transfers the NFT to the auction contract and initializes the auction. Can only be called when the contract is not paused.
     */
    function createAuction(
        address _ticketContractAddress,
        uint256 _tokenId,
        uint256 _nftId,
        uint256 _startingPrice,
        uint256 _duration,
        uint256 _reservePrice
    ) public whenNotPaused nonReentrant isValidAuctionDuration(_duration) isNftOwner(msg.sender, _tokenId) {
        uint256 auctionId = nextAuctionId;
        nextAuctionId++;

        // Transfer NFT to auction contract
        IERC1155(_ticketContractAddress).safeTransferFrom(msg.sender, address(this), _nftId, 1, "");

        // Initialize the Auction struct
        SharedTypes.Auction storage newAuction = auctions[auctionId];
        newAuction.seller = msg.sender;
        newAuction.tokenId = _tokenId;
        newAuction.nftId = _nftId;
        newAuction.startingPrice = _startingPrice;
        newAuction.endTime = block.timestamp.add(_duration);
        newAuction.highestBid = 0;
        newAuction.highestBidder = address(0);
        newAuction.ended = false;
        newAuction.isOpen = true;
        newAuction.reservePrice = _reservePrice;
        newAuction.ticketContractAddress = _ticketContractAddress;

        // Add the new auction to the user's list of auctions
        userAuctions[msg.sender].push(auctionId);

        // Add the new auction ID to the user's active auctions
        userActiveAuctions[msg.sender].push(auctionId);

        // Add to active auctions
        activeAuctionIds.push(auctionId);
        activeAuctionIndex[auctionId] = activeAuctionIds.length - 1;

        totalAuctions++;
        totalActiveAuctions++;
        // Emit the AuctionCreated event
        emit AuctionCreated(auctionId, msg.sender, _tokenId, _nftId, _startingPrice, newAuction.endTime);
    }
    
    /**
     * @notice Cancels an ongoing auction.
     * @param _auctionId The ID of the auction to cancel.
     * @dev Can only be called by the auction creator and when no bids have been placed. The NFT is returned to the seller.
     */
    function cancelAuction(uint256 _auctionId) 
      public 
      whenNotPaused
      nonReentrant
      isAuctionSeller(_auctionId)
      ifNoBidsArePlaced(_auctionId)
      isAuctionNotClosed(_auctionId)
    {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        auction.isOpen = false;
        IERC1155 ticketContractInstance = IERC1155(auction.ticketContractAddress);
        // Return NFT to seller
        ticketContractInstance.safeTransferFrom(address(this), msg.sender, auction.nftId, 1, "");
        totalActiveAuctions--;
        emit AuctionCancelled(_auctionId);
    }
    
    /**
     * @notice Places a bid on an ongoing auction.
     * @param _auctionId The ID of the auction to bid on.
     * @dev Refunds the previous highest bidder and updates the auction's highest bid. Extends the auction time if the bid is placed near the auction end time. Ensures the bid is higher than the current highest bid and meets the minimum bid increment.
     */
    function placeBid(uint256 _auctionId) 
        public
        payable
        whenNotPaused
        nonReentrant
        isOngoingAuction(_auctionId)
        isBidHigherThanCurrent(_auctionId)
        isBidHigherThanMinimum(_auctionId)
        isBidAboveMinRequired(_auctionId)
    {
        SharedTypes.Auction storage auction = auctions[_auctionId];

        // Update state before refunding to prevent reentrancy
        address previousHighestBidder = auction.highestBidder;
        uint256 previousHighestBid = auction.highestBid;

        auction.highestBid = msg.value;
        auction.highestBidder = msg.sender;

        // Refund previous highest bidder
        if (previousHighestBidder != address(0)) {
            payable(previousHighestBidder).transfer(previousHighestBid);
            emit BidRefunded(_auctionId, previousHighestBidder, previousHighestBid);
            emit BidOutbid(_auctionId, previousHighestBidder, previousHighestBid);
        }

        // Record the bid in the auction's bid history
        auctionBids[_auctionId].push(SharedTypes.Bid({
            bidder: msg.sender,
            amount: msg.value,
            timestamp: block.timestamp
        }));

        // Extend auction time if bid is placed in the last X minutes
        if(auction.endTime.sub(block.timestamp) < timeExtensionThreshold) {
            auction.endTime = block.timestamp.add(timeExtensionThreshold);
            emit TimeExtended(_auctionId, auction.endTime);
        }

        // Update bidding history (simplified to avoid 'Stack too deep' error)
        biddingHistory[msg.sender][_auctionId] += msg.value;

        // Remove from active auctions
        removeActiveAuction(_auctionId);

        emit BidPlaced(_auctionId, msg.sender, msg.value);
    }
    
    /**
     * @notice Withdraws a bid from an auction.
     * @param _auctionId The ID of the auction to withdraw the bid from.
     * @dev Allows a bidder to withdraw their bid if they are not the current highest bidder. The lock period must have elapsed for the withdrawal to be successful.
     */
    function withdrawBid(uint256 _auctionId) 
      public
      whenNotPaused
      nonReentrant
      isNotLeadingBid(_auctionId)
      ifUserHasBid(_auctionId)
    {
        // Ensure the lock period has elapsed
        require(
            block.timestamp >= auctions[_auctionId].bidTimestamps[msg.sender] + bidLockPeriod,
            "Bid lock period has not elapsed"
        );

        uint256 bidAmount = biddingHistory[msg.sender][_auctionId];
        uint256 refundAmount = bidAmount - auctions[_auctionId].deposits[msg.sender];
        payable(msg.sender).transfer(refundAmount);

        // Emit BidWithdrawn event
        emit BidWithdrawn(_auctionId, msg.sender, refundAmount);

        // Reset the deposit for the bidder
        auctions[_auctionId].deposits[msg.sender] = 0;
    }

    /* 
    /////////////////////////////
    6. Utility Functions
    /////////////////////////////

        Include utility functions like getRemainingTime and getActiveAuctions.
    */ 


    function handleRoyaltyPayment(uint256 _tokenId, uint256 _auctionId, uint256 _salePrice) internal returns (uint256) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        uint256 nftId = auction.nftId;
        Ticket ticketContractInstance = ticketRegistryContract.getRegisteredNFT(_tokenId);
        (address royaltyReceiver, uint256 royaltyAmount) = ticketContractInstance.royaltyInfo(nftId, _salePrice);
        if (royaltyAmount > 0 && royaltyReceiver != address(0)) {
            require(_salePrice >= royaltyAmount, "Insufficient funds to pay royalties");
            payable(royaltyReceiver).transfer(royaltyAmount);
        }

        return _salePrice - royaltyAmount; // Return the remaining amount after deducting royalty
    }

    /**
     * @notice Retrieves detailed information about a specific auction.
     * @param _auctionId The ID of the auction to retrieve information for.
     * @return AuctionInfo The detailed information about the auction.
     * @dev Returns various details about the auction such as seller, ticket ID, NFT ID, prices, bids, and auction status.
     */
    function getAuctionInfo(uint256 _auctionId) public view returns (SharedTypes.AuctionInfo memory) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        return SharedTypes.AuctionInfo({
            seller: auction.seller,
            tokenId: auction.tokenId,
            nftId: auction.nftId,
            startingPrice: auction.startingPrice,
            endTime: auction.endTime,
            highestBid: auction.highestBid,
            highestBidder: auction.highestBidder,
            ended: auction.ended,
            isOpen: auction.isOpen,
            reservePrice: auction.reservePrice
        });
    }

    /**
     * @notice Retrieves a list of auction IDs created by a specific user.
     * @param user The address of the user whose auctions are being queried.
     * @return uint256[] The list of auction IDs created by the user.
     * @dev Returns the IDs of all auctions that the specified user has created.
     */
    function getUserAuctions(address user) public view returns (uint256[] memory) {
        return userAuctions[user];
    }

    /**
     * @notice Retrieves a list of active auction IDs for a specific user.
     * @param user The address of the user whose active auctions are being queried.
     * @return uint256[] The list of active auction IDs for the user.
     * @dev Returns the IDs of all ongoing auctions that the specified user has created.
     */
    function getUserActiveAuctions(address user) public view returns (uint256[] memory) {
        return userActiveAuctions[user];
    }

    /**
     * @notice Retrieves a list of all bids placed in a specific auction.
     * @param _auctionId The ID of the auction.
     * @return Bid[] The list of bids made in the auction.
     * @dev Returns all bids placed in the specified auction, including bidder addresses, bid amounts, and timestamps.
     */
    function getAuctionBids(uint256 _auctionId) public view returns (SharedTypes.Bid[] memory) {
        return auctionBids[_auctionId];
    }

    /**
     * @notice Retrieves the total amount bid by a user in a specific auction.
     * @param user The address of the user.
     * @param auctionId The ID of the auction.
     * @return uint256 The total amount bid by the user in the auction.
     * @dev Returns the cumulative amount that the specified user has bid in the given auction.
     */
    function getUserBiddingHistory(address user, uint256 auctionId) public view returns (uint256) {
        return biddingHistory[user][auctionId];
    }

    /**
     * @notice Retrieves the total number/count of auctions, active auction IDs, total active auctions, total ended auctions, or the time extension threshold.
     * @return uint256 or uint256[] The requested number/count or list of IDs.
     * @dev These methods provide various aggregate statistics about the auctions, including totals and specific IDs.
     */
    function getTotalAuctions() public view returns (uint256) {
        return nextAuctionId;
    }
    function getActiveAuctionIds() public view returns (uint256[] memory) {
        return activeAuctionIds;
    }
    function getTotalActiveAuctions() public view returns (uint256) {
        return totalActiveAuctions;
    }
    function getTotalEndedAuctions() public view returns (uint256) {
        return totalEndedAuctions;
    }
    function getTimeExtensionThreshold() public view returns (uint256) {
        return timeExtensionThreshold;
    }

    /**
     * @notice Removes an auction from the active auctions list or updates the status of an auction.
     * @param _auctionId The ID of the auction to be updated.
     * @dev These methods handle the internal management of active auctions, including removing or updating auction statuses based on specific criteria.
     */
    function removeActiveAuction(uint256 _auctionId) private {
        address seller = auctions[_auctionId].seller;

        // Ensure the seller has active auctions
        if (userActiveAuctions[seller].length == 0) {
            return;
        }

        // Ensure the auction ID exists in the userActiveAuctions list
        if (userAuctionIndex[seller][_auctionId] >= userActiveAuctions[seller].length || 
            (userAuctionIndex[seller][_auctionId] == 0 && userActiveAuctions[seller][0] != _auctionId)) {
            // Auction ID not found in userActiveAuctions
            return;
        }

        uint256 indexToRemove = userAuctionIndex[seller][_auctionId];
        uint256 lastIndex = userActiveAuctions[seller].length - 1;

        if (indexToRemove != lastIndex) {
            uint256 lastAuctionId = userActiveAuctions[seller][lastIndex];

            userActiveAuctions[seller][indexToRemove] = lastAuctionId;
            userAuctionIndex[seller][lastAuctionId] = indexToRemove;
        }

        userActiveAuctions[seller].pop();
        delete userAuctionIndex[seller][_auctionId];
    }

    /**
     * @notice Updates the status of an auction, including its presence in active auctions lists.
     * @param seller The address of the auction seller.
     * @param _auctionId The ID of the auction to update.
     * @dev Removes the auction from both the seller's and global active auctions lists and updates indexes.
     */
    function updateAuctionStatus(address seller, uint256 _auctionId) private {
        // Ensure the seller has active auctions
        if (userActiveAuctions[seller].length == 0) {
            return;
        }

        // Ensure the auction ID exists in the userActiveAuctions list
        if (userAuctionIndex[seller][_auctionId] >= userActiveAuctions[seller].length || 
            (userAuctionIndex[seller][_auctionId] == 0 && userActiveAuctions[seller][0] != _auctionId)) {
            // Auction ID not found in userActiveAuctions
            return;
        }

        // Remove the auction from the active auctions of the seller
        uint256 userAuctionIdx = userAuctionIndex[seller][_auctionId];
        uint256 lastUserAuctionId = userActiveAuctions[seller][userActiveAuctions[seller].length - 1];
        userActiveAuctions[seller][userAuctionIdx] = lastUserAuctionId;
        userActiveAuctions[seller].pop();
        userAuctionIndex[seller][lastUserAuctionId] = userAuctionIdx;

        // Remove the auction from the global active auctions
        uint256 auctionIdx = activeAuctionIndex[_auctionId];
        uint256 lastAuctionId = activeAuctionIds[activeAuctionIds.length - 1];
        activeAuctionIds[auctionIdx] = lastAuctionId;
        activeAuctionIds.pop();
        activeAuctionIndex[lastAuctionId] = auctionIdx;

        // Decrement the count of total active auctions
        totalActiveAuctions--;
    }


    /* 
    /////////////////////////////
    7. Modifiers
    ////////////////////////////

        Include any require statements you might want to reuse later.
    */ 

    /**
     * @notice Ensures that the provided auction duration is within a valid range.
     * @param _duration The duration of the auction in seconds.
     * @dev Requires that the auction duration is at least 1 hour and no more than 4 weeks. 1 hours or 1 minutes
     */
    modifier isValidAuctionDuration(uint256 _duration) {
        require(_duration >= 1 minutes && _duration <= 4 weeks, "Invalid auction duration");
        _;
    }

    /**
     * @notice Checks if the auction is still ongoing (not ended).
     * @param _auctionId The ID of the auction.
     * @dev Requires that the current timestamp is less than the auction's end time.
     */
    modifier isOngoingAuction(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(block.timestamp < auction.endTime, "Auction has ended");
        _;
    }

    /**
     * @notice Ensures that the new bid is higher than the current highest bid in the auction.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the sent value (msg.value) is greater than the highest bid of the auction.
     */
    modifier isBidHigherThanCurrent(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(msg.value > auction.highestBid, "Bid must be higher than current highest bid");
        _;
    }

    /**
     * @notice Checks if the caller is the seller of the auction.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the caller (msg.sender) is the seller of the specified auction.
     */
    modifier isAuctionSeller(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(msg.sender == auction.seller, "Only seller can cancel");
        _;
    }

    /**
     * @notice Ensures that no bids have been placed in the auction.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the highest bid in the auction is zero (no bids placed).
     */
    modifier ifNoBidsArePlaced(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(auction.highestBid == 0, "Cannot cancel after bids are placed");
        _;
    }

    /**
     * @notice Checks if the auction is not already closed.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the auction is still open.
     */
    modifier isAuctionNotClosed(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(auction.isOpen, "Auction is already closed");
        _;
    }

    /**
     * @notice Ensures that the caller is not the current leading bidder in the auction.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the caller (msg.sender) is not the highest bidder of the specified auction.
     */
    modifier isNotLeadingBid(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(auction.highestBidder != msg.sender, "Cannot withdraw leading bid");
        _;
    }

    /**
     * @notice Checks if the caller has placed a bid in the auction.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the caller (msg.sender) has a non-zero bid amount in the auction's bidding history.
     */
    modifier ifUserHasBid(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(biddingHistory[msg.sender][_auctionId] > 0, "No bid to withdraw");
        _;
    }

    /**
     * @notice Ensures that the caller owns the specified NFT and has approved the contract to transfer it.
     * @param _guy The address of the auction creator.
     * @param _tokenId The ID of the Course Original Token.
     * @dev Requires that the caller has a balance of the specified NFT and has set approval for the contract to manage their NFTs.
     */
    modifier isNftOwner(address _guy, uint256 _tokenId) {
            require(ticketRegistryContract.doesUserOwnNFT(msg.sender, _tokenId), "Sender does not own the NFT");
        _;
    }

    /**
     * @notice Ensures that the bid is higher than the current highest bid by at least the minimum bid increment.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the bid (msg.value) is at least higher than the highest bid plus the minimum bid increment.
     */
    modifier isBidHigherThanMinimum(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        require(msg.value >= auction.highestBid + minBidIncrement, "Bid must be higher than current highest bid by the minimum increment");
        _;
    }

    /**
     * @notice Checks if the bid is above the minimum required bid amount.
     * @param _auctionId The ID of the auction.
     * @dev Requires that the bid (msg.value) meets or exceeds the minimum required bid, calculated as the highest bid plus the minimum bid increment.
     */
    modifier isBidAboveMinRequired(uint256 _auctionId) {
        SharedTypes.Auction storage auction = auctions[_auctionId];
        uint256 minRequiredBid = auction.highestBid.add(minBidIncrement);
        require(msg.value >= minRequiredBid, "Bid not high enough");
        _;
    }

    /* 
    /////////////////////////////
    8. ERC1155 and Interface Implementations
    /////////////////////////////

        Place the ERC1155 token reception and interface support functions at the end.
    */ 

    // Interface to allow receiving ERC1155 tokens.
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes calldata
    ) external pure override returns (bytes4) {
        return this.onERC1155Received.selector;
    }
    // Interface to allow receiving batch ERC1155 tokens.
    function onERC1155BatchReceived(
        address,
        address,
        uint256[] calldata,
        uint256[] calldata,
        bytes calldata
    ) external pure override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {
        return
            interfaceId == type(IERC1155Receiver).interfaceId ||
            interfaceId == type(IERC165).interfaceId;
    }
}

File 24 of 27 : types.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

contract SharedTypes {

    struct Auction {
        address seller;
        uint256 tokenId;
        uint256 nftId;
        uint256 startingPrice;
        uint256 endTime;
        uint256 highestBid;
        address highestBidder;
        bool ended;
        bool isOpen;
        uint256 reservePrice;
        mapping(address => uint256) deposits;
        mapping(address => uint256) bidTimestamps;
        address ticketContractAddress;
    }

    struct AuctionInfo {
        address seller;
        uint256 tokenId;
        uint256 nftId;
        uint256 startingPrice;
        uint256 endTime;
        uint256 highestBid;
        address highestBidder;
        bool ended;
        bool isOpen;
        uint256 reservePrice;
    }

    struct Bid {
        address bidder;
        uint256 amount;
        uint256 timestamp;
    }
}

File 25 of 27 : ITicketRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

interface ITicketRegistry {
    function specialUpdateOnMint(
        address _guy, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external;

    function specialUpdateOnTransfer(
        address _from, 
        address _to, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external;

    function isCurrentlyMinting() external view returns (bool);
}

File 26 of 27 : registry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";

import "./ticket.sol";

/// @custom:security-contact [email protected]
contract TicketRegistry is IERC165, IERC1155Receiver, AccessControl {

    /* 
    /////////////////////////////////
    1. Contract and Role Declarations 
    /////////////////////////////////
    
      - Define a constant role for the booking role
    */ 

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

    /* 
    /////////////////////////////
    2. Structs and State Variables
    /////////////////////////////
    */ 

    struct NFTTransactionDetails {
        uint256 tokenId;
        uint256 nftId;
        address owner;
        uint256 qty;
        uint256 price;
        string uri;
    }

    // Mapping to store the registered objects and their ticket contracts
    mapping(address => mapping(uint256 => NFTTransactionDetails[])) private userOwnedNFTs;
    mapping(address => mapping(uint256 => uint256)) private userTokenIdCount;
    mapping(uint256 => Ticket) public objectToTicket;
    uint256 public maxPageSize = 100;

    /* 
    /////////////////////////////
    3. Constructor and events
    /////////////////////////////
    
      The constructor initializes the contract's state.
      The deployer will be granted the Booking Role.
    */ 

    constructor() {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
        _grantRole(BOOTH_ROLE, msg.sender);
    }

    event ObjectRegistered(uint256 tokenId, address ticketContract);

    /* 
    /////////////////////////////
    4. Role-Based Functionality
    /////////////////////////////

      Group functions by the roles that can call them. 
      For example, all functions that require BOOTH_ROLE should be together.
    */ 

    /**
     * @notice Registers a new NFT object and its corresponding ticket contract.
     * @param _tokenId The ID of the NFT to register.
     * @param _address The associated Ticket contract for the NFT.
     * @dev Only callable by users with the BOOTH_ROLE.
     *      Prevents re-registering an already registered object.
     */
    function registerObject(uint256 _tokenId, Ticket _address) external onlyRole(BOOTH_ROLE) {
        // Only allow registering an object once
        require(address(objectToTicket[_tokenId]) == address(0), "Object already registered");
        objectToTicket[_tokenId] = _address;
        emit ObjectRegistered(_tokenId, address(_address));
    }

    /**
     * @notice Checks if an NFT object is registered in the system.
     * @param _tokenId The ID of the NFT to check.
     * @return True if the NFT object is registered, false otherwise.
     */
    function isObjectRegistered(uint256 _tokenId) external view returns (bool) {
        return address(objectToTicket[_tokenId]) != address(0);
    }

    /**
     * @notice Modifier to ensure an NFT object is registered.
     * @param _tokenId The ID of the NFT to check.
     * @dev Reverts if the NFT object is not registered.
     */
    modifier isRegistered(uint256 _tokenId) {
        require(address(objectToTicket[_tokenId]) != address(0), "Object is not registered");
        _;
    }

    /**
     * @notice Modifier to ensure an NFT object is registered.
     * @param _tokenId The ID of the NFT to check.
     * @dev Reverts if the NFT object is not registered.
     */
    modifier onlyAllowDuringMint(uint256 _tokenId) {
        Ticket ticketContract = objectToTicket[_tokenId];
        require(ticketContract.isCurrentlyMinting(), "Can only be called during minting");
        _;
    }
    

    /**
     * @notice Updates ownership details in the registry when a new NFT is minted.
     * @param _guy The address of the user who mints the NFT.
     * @param _tokenId The ID of the token.
     * @param _nftId The ID of the NFT.
     * @param _qty The quantity of NFTs minted.
     * @param _price The price of the NFT.
     * @param _uri The URI of the NFT.
     * @dev Only callable by users with the BOOTH_ROLE.
     */
    function updateOwnershipOnMint(
        address _guy, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external onlyRole(BOOTH_ROLE) {
        _updateOwnershipOnMint(_guy,_tokenId,_nftId, _qty, _price, _uri);
    }

    function specialUpdateOnMint(
        address _guy, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external isRegistered(_tokenId) onlyAllowDuringMint(_tokenId) {
        Ticket ticketContract = objectToTicket[_tokenId];
        require(msg.sender == address(ticketContract), "Unauthorized caller");

        _updateOwnershipOnMint(_guy,_tokenId,_nftId, _qty, _price, _uri);
    }

    function _updateOwnershipOnMint(
        address _guy, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) private {
        for (uint256 i = 0; i < _qty; ++i) {
            NFTTransactionDetails memory newNFT = NFTTransactionDetails({
                nftId: _nftId,
                tokenId: _tokenId,
                owner: _guy,
                qty: 1,
                price: _price,
                uri: _uri
            });

            userOwnedNFTs[_guy][_tokenId].push(newNFT);
            userTokenIdCount[_guy][_tokenId] += _qty;
        }
    }

    /**
     * @notice Updates ownership details in the registry when an NFT is transferred.
     * @param _from The address of the sender.
     * @param _to The address of the receiver.
     * @param _tokenId The ID of the token.
     * @param _nftId The ID of the NFT.
     * @param _qty The quantity of NFTs transferred.
     * @param _price The price of the NFT.
     * @param _uri The URI of the NFT.
     * @dev Only callable by users with the BOOTH_ROLE.
     */
    function updateOwnershipOnTransfer(
        address _from, 
        address _to, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external onlyRole(BOOTH_ROLE) {
        require(userTokenIdCount[_from][_tokenId] >= _qty, "Insufficient NFTs to transfer");

        // TODO: Verify from address owns the nft being transfered
        _updateOwnershipOnTransfer(_from, _to, _tokenId, _nftId, _qty, _price, _uri);
    }

    function specialUpdateOnTransfer(
        address _from, 
        address _to, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) external isRegistered(_tokenId){
        Ticket ticketContract = objectToTicket[_tokenId];
        require(msg.sender == address(ticketContract), "Unauthorized caller");

        // TODO: Verify from address owns the nft being transfered
        _updateOwnershipOnTransfer(_from, _to, _tokenId, _nftId, _qty, _price, _uri);
    }

    function _updateOwnershipOnTransfer(
        address _from, 
        address _to, 
        uint256 _tokenId, 
        uint256 _nftId, 
        uint256 _qty, 
        uint256 _price, 
        string memory _uri
    ) private {
        // First, reduce the quantity from the sender's account
        bool isFound = false;
        uint256 i;
        for (i = 0; i < userOwnedNFTs[_from][_tokenId].length; i++) {
            if (userOwnedNFTs[_from][_tokenId][i].nftId == _nftId) {
                require(userOwnedNFTs[_from][_tokenId][i].qty >= _qty, "Insufficient NFT quantity");
                userOwnedNFTs[_from][_tokenId][i].qty -= _qty;
                isFound = true;
                break;
            }
        }
        require(isFound, "NFT not found for transfer");

        // If the NFT quantity becomes zero, we could choose to remove it from the array
        if (userOwnedNFTs[_from][_tokenId][i].qty == 0) {
            removeNFTFromOwner(_from, _tokenId, i);
        }

        // Now, add the NFT to the receiver's account
        isFound = false;
        for (i = 0; i < userOwnedNFTs[_to][_tokenId].length; i++) {
            if (userOwnedNFTs[_to][_tokenId][i].nftId == _nftId) {
                userOwnedNFTs[_to][_tokenId][i].qty += _qty;
                isFound = true;
                break;
            }
        }

        // If the NFT does not exist in the receiver's account, create a new entry
        if (!isFound) {
            NFTTransactionDetails memory newNFT = NFTTransactionDetails({
                nftId: _nftId,
                tokenId: _tokenId,
                owner: _to,
                qty: _qty,
                price: _price,
                uri: _uri
            });
            userOwnedNFTs[_to][_tokenId].push(newNFT);
        }

        // Update the token count for both sender and receiver
        userTokenIdCount[_from][_tokenId] -= _qty;
        userTokenIdCount[_to][_tokenId] += _qty;
    }

    // Helper function to remove an NFT from an owner's list if the quantity is zero
    function removeNFTFromOwner(address _owner, uint256 _tokenId, uint256 index) private {
        require(index < userOwnedNFTs[_owner][_tokenId].length, "Index out of bounds");

        // Move the last element to the index being removed and then pop the last element
        userOwnedNFTs[_owner][_tokenId][index] = userOwnedNFTs[_owner][_tokenId][userOwnedNFTs[_owner][_tokenId].length - 1];
        userOwnedNFTs[_owner][_tokenId].pop();
    }

    /* 
    /////////////////////////////
    5. Utility Functions
    /////////////////////////////
    
      Include utility functions like getStock and getNftId.
    */ 

    /**
     * @notice Retrieves the Ticket contract associated with a registered NFT.
     * @param _tokenId The ID of the NFT.
     * @return The associated Ticket contract.
     * @dev Ensures that the NFT is registered before returning the Ticket contract.
     */
    function getRegisteredNFT(uint256 _tokenId) public view isRegistered(_tokenId) returns (Ticket) {
        Ticket nft = objectToTicket[_tokenId];
        return nft;
    }

    /**
     * @notice Checks if a user owns a specific NFT.
     * @param _guy The address of the user.
     * @param _tokenId The ID of the NFT to check.
     * @return True if the user owns the NFT, false otherwise.
     */
    function doesUserOwnNFT(address _guy, uint256 _tokenId) public view returns (bool) {
        return userTokenIdCount[_guy][_tokenId] > 0;
    }

    /**
     * @notice Gets the remaining stock of a specific NFT.
     * @param _tokenId The ID of the NFT.
     * @return The remaining stock of the NFT.
     * @dev Returns -1 if the NFT does not use stock management.
     */
    function getStock(uint256 _tokenId) public view isRegistered(_tokenId) returns (int256) {
        Ticket ticketContract = objectToTicket[_tokenId];
        int256 remainingStock = -1;
        if (ticketContract.useStock()) {
            remainingStock = int256(ticketContract.stock(_tokenId)) - int256(ticketContract.totalSupply(_tokenId));
        }
        return remainingStock;
    }

    /**
     * @notice Checks if stock management is used for a specific NFT.
     * @param _tokenId The ID of the NFT.
     * @return True if the NFT uses stock management, false otherwise.
     */
    function getUseStock(uint256 _tokenId) public view isRegistered(_tokenId) returns (bool) {
        Ticket ticketContract = objectToTicket[_tokenId];
        bool usesStock = ticketContract.useStock();
        return usesStock;
    }

    /**
     * @notice Retrieves a paginated list of NFTs owned by a user for a specific tokenId.
     * @param user The address of the user.
     * @param tokenId The ID of the token.
     * @param page The page number of the paginated results.
     * @param pageSize The number of items per page.
     * @return ownedNFTDetails The list of NFTs owned by the user for the specified tokenId and page.
     * @return totalNFTs The total number of NFTs of the specified tokenId owned by the user.
     * @dev Pagination is implemented to manage large datasets.
     */
    function getOwnedNFTs(
        address user, 
        uint256 tokenId,
        uint256 page, 
        uint256 pageSize
    ) public view returns (NFTTransactionDetails[] memory ownedNFTDetails, uint256 totalNFTs) {
        totalNFTs = userOwnedNFTs[user][tokenId].length;
        uint256 startIndex = (page - 1) * pageSize;
        if (startIndex >= totalNFTs) {
            return (new NFTTransactionDetails[](0), totalNFTs);
        }

        uint256 endIndex = startIndex + pageSize > totalNFTs ? totalNFTs : startIndex + pageSize;
        ownedNFTDetails = new NFTTransactionDetails[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            ownedNFTDetails[i - startIndex] = userOwnedNFTs[user][tokenId][i];
        }

        return (ownedNFTDetails, totalNFTs);
    }

    /**
     * @notice Retrieves the first owned NFT ID for a given tokenId.
     * @param user The address of the user.
     * @param tokenId The ID of the token.
     * @return The first NFT ID for the given tokenId owned by the user.
     */
    function getFirstOwnedNftIdForTokenId(address user, uint256 tokenId) public view returns (uint256) {
        require(userOwnedNFTs[user][tokenId].length > 0, "User does not own any NFTs for this tokenId");
        return userOwnedNFTs[user][tokenId][0].nftId;
    }

    /**
     * @notice Retrieves a paginated list of owned NFT IDs for a given tokenId.
     * @param user The address of the user.
     * @param tokenId The ID of the token.
     * @param page The page number for pagination.
     * @param pageSize The number of items per page.
     * @return ownedNftIds The paginated list of NFT IDs for the given tokenId.
     * @return totalNftCount The total count of NFTs for the given tokenId owned by the user.
     */
    function getOwnedNftIdsForTokenId(address user, uint256 tokenId, uint256 page, uint256 pageSize) public view returns (uint256[] memory ownedNftIds, uint256 totalNftCount) {
        totalNftCount = userOwnedNFTs[user][tokenId].length;
        uint256 startIndex = (page - 1) * pageSize;
        if (startIndex >= totalNftCount) {
            return (new uint256[](0), totalNftCount);
        }

        uint256 endIndex = startIndex + pageSize > totalNftCount ? totalNftCount : startIndex + pageSize;
        ownedNftIds = new uint256[](endIndex - startIndex);

        for (uint256 i = startIndex; i < endIndex; i++) {
            ownedNftIds[i - startIndex] = userOwnedNFTs[user][tokenId][i].nftId;
        }

        return (ownedNftIds, totalNftCount);
    }

    /* 
    /////////////////////////////
    6. ERC1155 and Interface Implementations
    /////////////////////////////
    
      Place the ERC1155 token reception and interface support functions at the end.
    */ 

    // Interface to allow receiving ERC1155 tokens.
    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes calldata
    ) external pure override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    // Interface to allow receiving batch ERC1155 tokens.
    function onERC1155BatchReceived(
        address,
        address,
        uint256[] calldata,
        uint256[] calldata,
        bytes calldata
    ) external pure override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }

    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {
        return
            interfaceId == type(IERC1155Receiver).interfaceId ||
            interfaceId == type(IERC165).interfaceId;
    }
}

File 27 of 27 : ticket.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/finance/PaymentSplitter.sol";
import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

import "./ITicketRegistry.sol";


/// @custom:security-contact [email protected]
contract Ticket is ERC1155, AccessControl, ERC1155Supply, PaymentSplitter,IERC2981 {
    
    /* 
    /////////////////////////////////
    1. Contract and Role Declarations 
    /////////////////////////////////

        - Define a constant role for the booth role
    */ 
   
    bytes32 public constant BOOTH_ROLE = keccak256("BOOTH_ROLE");

    /* 
    /////////////////////////////
    2. Structs and State Variables
    /////////////////////////////
        
        This section declares the state variables and data structures used in the contract.

        - price: The price of the NFT in wei.
        - tokenId: The unique identifier for each NFT.
        - stock: A mapping that associates each token ID with its stock limit. A value of 0 means there is no limit.
        - useStock: A boolean variable that indicates whether the contract should use the stock limit.
        - limitedEdition: A boolean variable that indicates whether the NFT is a limited edition.
        - userNFTs: A nested mapping that associates each user address with the number of NFTs they have minted for each token ID.
        - royaltyReceiver: The address that will receive the royalties from sales.
        - royaltyPercentage: The percentage of the sale price that will be paid as royalties. This is represented as a number out of 10000 (for example, 500 represents 5%).
    */

    ITicketRegistry private ticketRegistry;
    bool private isMintingActive = false;
    uint256 public price;
    uint256 public tokenId;
    mapping(uint256 => uint256) public stock;
    bool public useStock;
    bool public limitedEdition;
    address public royaltyReceiver;
    uint256 public royaltyPercentage;
    
    /* 
    /////////////////////////////
    3. Constructor and Events
    /////////////////////////////

        The constructor initializes the state of the contract with the following parameters:

        - uint256 _tokenId: This is the unique identifier for each NFT. For example, 8263712349.

        - uint256 _price: This is the price of the NFT in wei. The price is converted from ether to wei as follows:
            price = float(product.price)
            ticket_price = web3.to_wei(price, "ether")

        - uint256 _initialStock: This is the initial stock of the NFT. 
            For example, if _initialStock is 100, only 100 NFTs can be minted before a resupply is required.

        - bool _useStock: This boolean value indicates whether the contract should consider the stock limit. 
            If _useStock is true, the stock limit is considered; otherwise, the product is assumed to have an unlimited supply.

        - bool _limitedEdition: This boolean value restricts minting once the stock limit is reached. 
            If _limitedEdition is true, new NFTs cannot be minted once the stock limit is reached. This works in conjunction with the _useStock parameter.

        - address _royaltyReceiver: This is the address of the creator who will receive royalties. 
            Note that not all platforms enforce royalties.

        - uint256 _royaltyPercentage: This is the percentage of the sale price that will be paid as royalties, 
            represented as a number out of 10000 basis points. For example, 500 represents a 5% royalty.

        - address[] memory _payees: This is a list of addresses that will receive payments from each NFT sale. 
            Each payee must claim their profit by executing the required method. For example, [owner.address, seller.address].

        - uint256[] memory _shares: This is a list of shares corresponding to each payee. 
            The number of shares must add up to 100, and the number of items in the list must be the same as the number of payees. 
            For example, [10, 90]. In this scenario, owner.address would receive 10% of every NFT sale, and seller.address could claim the remaining 90%. Note that addresses cannot be repeated.

        - string memory _uri: This is the base URI for the NFT, which is the HTTPS address hosting the NFT metadata. 
            For example, "https://api.boomslag.com/api/courses/nft/{tokenId}".
    */
    
    constructor(
        uint256 _tokenId,
        uint256 _price,
        uint256 _initialStock,
        bool _useStock,
        bool _limitedEdition,
        address _royaltyReceiver,
        uint256 _royaltyPercentage,
        address[] memory _payees,
        uint256[] memory _shares,
        string memory _uri,
        address _ticketRegistryAddress

    )
    ERC1155(_uri) 
    PaymentSplitter(_payees, _shares)
    {
        tokenId = _tokenId;
        price = _price;
        useStock = _useStock;
        limitedEdition = _limitedEdition;
        if (limitedEdition)
            useStock = true;
        stock[tokenId] = _initialStock;
        royaltyReceiver = _royaltyReceiver;
        royaltyPercentage = _royaltyPercentage;
        ticketRegistry = ITicketRegistry(_ticketRegistryAddress);

        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
    }

    event Mint(uint256 indexed tokenId, uint256 indexed nftId, uint256 qty, uint256 price, address indexed guy, string uri);
    event Transfer(address indexed from, address indexed to, uint256 indexed nftId, uint256 tokenId, uint256 qty, string uri);
    event StockUpdated(uint256 indexed tokenId, uint256 stock);
    event UseStockUpdated(bool useStock);
    event SetUri(string newuri);

    /* 
    /////////////////////////////
    4. Role-Based Functionality
    /////////////////////////////

        Group functions by the roles that can call them. 
        For example, all functions that require BOOTH_ROLE should be together.
    */ 

    /**
     * @notice Sets the stock limit for a specific token.
     * @param _tokenId The ID of the token.
     * @param _stock The stock limit to be set.
     * @dev Only callable by users with DEFAULT_ADMIN_ROLE. Applies only if the token is not a limited edition.
     */
    function setStock(uint256 _tokenId, uint256 _stock) public onlyRole(DEFAULT_ADMIN_ROLE) {
        if (!limitedEdition){
            stock[_tokenId] = _stock;
            emit StockUpdated(_tokenId, _stock);
        }
    }
    
    /**
     * @notice Enables or disables stock management for NFTs.
     * @param _useStock True to enable stock management, false to disable it.
     * @dev Only callable by users with DEFAULT_ADMIN_ROLE. Applies only if the token is not a limited edition.
     */
    function setUseStock(bool _useStock) public onlyRole(DEFAULT_ADMIN_ROLE) {
        if (!limitedEdition){
            useStock = _useStock;
            emit UseStockUpdated(_useStock);
        }
    }
    
    /**
     * @notice Updates the base URI for all tokens.
     * @param newuri The new base URI to be set.
     * @dev Only callable by users with DEFAULT_ADMIN_ROLE. Emits an event with the new URI.
     */
    function setURI(string memory newuri) public onlyRole(DEFAULT_ADMIN_ROLE) {
        // Sets the new URI for the token
        _setURI(newuri);
        // Emits an event with the new URI
        emit SetUri(newuri);
    }
    
    /**
     * @notice Updates the price of the NFT.
     * @param newPrice The new price to be set.
     * @dev Only callable by users with DEFAULT_ADMIN_ROLE. Updates the global price of the NFT ticket.
     */
    function updatePrice(uint256 newPrice) public onlyRole(DEFAULT_ADMIN_ROLE) {
        // Updates the price of the NFT ticket
        price = newPrice;
    }
    
    /**
     * @notice Retrieves the royalty information for a token sale.
     * @param _salePrice The sale price of the NFT.
     * @return receiver The address entitled to receive the royalties.
     * @return royaltyAmount The amount of royalty to be paid.
     * @dev Assumes the royaltyPercentage is out of 10000 for percentage calculation.
     */
    function royaltyInfo(uint256 /*_tokenId*/, uint256 _salePrice) external view override returns (address receiver, uint256 royaltyAmount) {
        receiver = royaltyReceiver;
        royaltyAmount = (_salePrice * royaltyPercentage) / 10000; // assuming the royaltyPercentage is out of 10000 for a percentage calculation
    }
    
    /* 
    /////////////////////////////
    5. Purchase and Minting
    /////////////////////////////
        
        Group together all functions related to purchasing and minting.
            
    */ 
    
    /**
     * @notice Mints a specific quantity of NFTs.
     * @param _tokenId The ID of the token to mint.
     * @param _nftId The ID of the NFT.
     * @param _qty The quantity of NFTs to mint.
     * @param _guy The address to receive the minted NFTs.
     * @dev Requires the caller to pay the correct ETH amount if not having BOOTH_ROLE. Stock is checked if useStock is enabled.
     */
    function mint(uint256 _tokenId, uint256 _nftId, uint256 _qty, address _guy) public payable {
        // If the caller is not the BOOTH_ROLE, apply the requirement
        if (!hasRole(BOOTH_ROLE, msg.sender)) {
             // Price check for regular buyers
            require(msg.value >= price * _qty, "Not Enough ETH to Buy NFT");
        }

        // Check if the NFT stock limit has been reached
        if (useStock) {
            uint256 remainingStock = stock[_tokenId];
            require(remainingStock >= _qty, "NFT Out of Stock");
            // Update the stock mapping
            stock[_tokenId] = remainingStock - _qty;
        }
        
        // Mint new NFTs to the user and emit an event
        _mint(_guy, _nftId, _qty, "");

        // Call TicketRegistry to update ownership
        string memory _uri = string(abi.encodePacked(super.uri(_nftId),Strings.toString(_nftId), ".json" ));
        isMintingActive = true;
        ticketRegistry.specialUpdateOnMint(_guy, _tokenId, _nftId, _qty, msg.value, _uri);
        isMintingActive = false;
        emit Mint(_tokenId, _nftId, _qty, msg.value, _guy, _uri);
    }
    
    /**
     * @notice Mints a batch of NFTs to a specified address. (Disabled for this implementation)
     * @param _to The address to receive the minted NFTs.
     * @param _ids Array of token IDs to mint.
     * @param _amounts Array of quantities for each token ID.
     * @param _data Additional data (unused in this contract).
     * @dev Method DISABLED: Only callable by users with DEFAULT_ADMIN_ROLE. Batch minting is disabled in this contract.
     */
    function mintBatch(address _to, uint256[] memory _ids, uint256[] memory _amounts, bytes memory _data)
        public
        onlyRole(DEFAULT_ADMIN_ROLE)
    {
        // Mints a batch of NFTs to the specified address
        // _mintBatch(_to, _ids, _amounts, _data);
        // Mint Batch is Disabled in this contract
    }

    /* 
    /////////////////////////////
    6. Utility Functions
    /////////////////////////////

        Include utility functions like isObjectRegistered and hasAccess.
    */ 

    /**
     * @notice Checks if the mint method is being used.
     * @return The boolean value true or false.
     */
    function isCurrentlyMinting() external view returns (bool) {
        return isMintingActive;
    }

    /**
     * @notice Retrieves the URI for a specific token.
     * @param _id The ID of the token.
     * @return The URI associated with the token, appended with the token ID.
     * @dev Ensures that the token exists before returning the URI.
     */
    function uri(uint256 _id) public view virtual override returns (string memory) {
        // Checks if the specified token exists
        require(exists(_id),"URI: Token does not exist.");
        // Retrieves the URI for the token and appends the token ID to the end of the URI
        return string(abi.encodePacked(super.uri(_id),Strings.toString(_id), ".json" ));
    }

    /* 
    /////////////////////////////
    7. ERC1155 and Interface Implementations
    /////////////////////////////

        Place the ERC1155 token reception and interface support functions at the end.
    */
    
    function _beforeTokenTransfer(address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data)
        internal
        override(ERC1155, ERC1155Supply)
    {
        super._beforeTokenTransfer(operator, from, to, ids, amounts, data);

        // Check if this is a transfer (not minting or burning)
        if (from != address(0) && to != address(0)) {
            for (uint256 i = 0; i < ids.length; i++) { 
                // Emit the Transfer event with NFT details
                string memory _uri = string(abi.encodePacked(super.uri(ids[i]), Strings.toString(ids[i]), ".json" ));
                ticketRegistry.specialUpdateOnTransfer(from, to, tokenId, ids[i], amounts[i], 0, _uri);
                emit Transfer(from, to, ids[i], tokenId, amounts[i], _uri);
            }
        }
    }

    // The following functions are overrides required by Solidity.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(ERC1155, AccessControl, IERC165)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract Auctions","name":"_auctionsContract","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[],"name":"ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionsContract","outputs":[{"internalType":"contract Auctions","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getActiveAuctions","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionId","type":"uint256"}],"name":"getAuctionBidHistory","outputs":[{"components":[{"internalType":"address","name":"bidder","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct SharedTypes.Bid[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getAuctions","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getAuctionsByTokenId","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getAuctionsCloseToEnding","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getAuctionsWithoutBids","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getEndedAuctions","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"startingPrice","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"highestBid","type":"uint256"},{"internalType":"address","name":"highestBidder","type":"address"},{"internalType":"bool","name":"ended","type":"bool"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"reservePrice","type":"uint256"}],"internalType":"struct SharedTypes.AuctionInfo[]","name":"","type":"tuple[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionId","type":"uint256"}],"name":"getRemainingTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"page","type":"uint256"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getUserActiveAuctions","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"auctionId","type":"uint256"}],"name":"getUserBiddingHistory","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPageSize","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxPageSize","type":"uint256"}],"name":"setMaxPageSize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405260646002553480156200001657600080fd5b506040516200246338038062002463833981016040819052620000399162000137565b600180546001600160a01b0319166001600160a01b038316179055620000807fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217753362000087565b5062000169565b62000093828262000097565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000093576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000f33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000602082840312156200014a57600080fd5b81516001600160a01b03811681146200016257600080fd5b9392505050565b6122ea80620001796000396000f3fe608060405234801561001057600080fd5b50600436106101375760003560e01c80638664d7e6116100b8578063b5dd493c1161007c578063b5dd493c146102b6578063ceb6a22f146102c9578063d547741f146102dc578063dceceec5146102ef578063e8ca3bbb14610302578063f76341281461032d57600080fd5b80638664d7e61461025457806388a9e703146102755780638c4112221461028857806391d148541461029b578063a217fddf146102ae57600080fd5b80632f2ff15d116100ff5780632f2ff15d146101dc57806336568abe146101f1578063579a735e1461020457806374de55eb1461020d57806375b238fc1461022d57600080fd5b806301ffc9a71461013c5780630a1c335814610164578063181e012414610185578063248a9ca3146101a657806326dcd432146101c9575b600080fd5b61014f61014a366004611b74565b610340565b60405190151581526020015b60405180910390f35b610177610172366004611b9e565b610377565b60405161015b929190611bc0565b610198610193366004611c7c565b6105a8565b60405190815260200161015b565b6101986101b4366004611c7c565b60009081526020819052604090206001015490565b6101776101d7366004611c95565b610657565b6101ef6101ea366004611cd6565b61094d565b005b6101ef6101ff366004611cd6565b610977565b61019860025481565b61022061021b366004611c7c565b6109f5565b60405161015b9190611d06565b6101987fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b610267610262366004611d68565b610a76565b60405161015b929190611d9d565b610177610283366004611b9e565b610c2f565b6101ef610296366004611c7c565b610fc5565b61014f6102a9366004611cd6565b610ff5565b610198600081565b6101776102c4366004611b9e565b61101e565b6101776102d7366004611b9e565b611331565b6101ef6102ea366004611cd6565b61154b565b6101986102fd366004611de5565b611570565b600154610315906001600160a01b031681565b6040516001600160a01b03909116815260200161015b565b61017761033b366004611b9e565b6115f5565b60006001600160e01b03198216637965db0b60e01b148061037157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b03166301b5ec6a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156103ca57600080fd5b505afa1580156103de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104029190611e11565b9050600084610412600188611e40565b61041c9190611e57565b90508181106104465760405162461bcd60e51b815260040161043d90611e76565b60405180910390fd5b6002548511156104565760025494505b6000826104638784611ead565b11610477576104728683611ead565b610479565b825b905060006104878383611e40565b6001600160401b0381111561049e5761049e611ec5565b6040519080825280602002602001820160405280156104d757816020015b6104c4611b0b565b8152602001906001900390816104bc5790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b15801561052957600080fd5b505afa15801561053d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105619190611f76565b8261056c8684611e40565b8151811061057c5761057c612016565b602002602001018190525080806105929061202c565b9150506104dc565b509792965091945050505050565b60015460405163fc3fc4ed60e01b81526004810183905260009182916001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b1580156105f257600080fd5b505afa158015610606573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062a9190611f76565b9050806080015142106106405750600092915050565b4281608001516106509190611e40565b9392505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b1580156106aa57600080fd5b505afa1580156106be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e29190611e11565b90506000805b8281101561079d5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b15801561073657600080fd5b505afa15801561074a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076e9190611f76565b9050888160200151141561078a57826107868161202c565b9350505b50806107958161202c565b9150506106e8565b506000856107ac600189611e40565b6107b69190611e57565b9050818111156107c35750805b60006107cf8783611ead565b9050828111156107dc5750815b60006107e88383611e40565b6001600160401b038111156107ff576107ff611ec5565b60405190808252806020026020018201604052801561083857816020015b610825611b0b565b81526020019060019003908161081d5790505b5090506000805b868110801561085657506108538585611e40565b82105b1561093b5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b1580156108a157600080fd5b505afa1580156108b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d99190611f76565b90508c81602001511415610928578582101580156108f657508482105b15610928578084848151811061090e5761090e612016565b602002602001018190525082806109249061202c565b9350505b50806109338161202c565b91505061083f565b50909a93995092975050505050505050565b6000828152602081905260409020600101546109688161180f565b610972838361181c565b505050565b6001600160a01b03811633146109e75760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161043d565b6109f182826118a0565b5050565b60015460405163385a3b4760e11b8152600481018390526060916001600160a01b0316906370b4768e9060240160006040518083038186803b158015610a3a57600080fd5b505afa158015610a4e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610371919081019061206a565b60015460405162321a5160e81b81526001600160a01b03858116600483015260609260009283929091169063321a51009060240160006040518083038186803b158015610ac257600080fd5b505afa158015610ad6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610afe9190810190612135565b805160025491925090851115610b145760025494505b600085610b22600189611e40565b610b2c9190611e57565b9050818110610b4d5760405162461bcd60e51b815260040161043d90611e76565b600082610b5a8884611ead565b11610b6e57610b698783611ead565b610b70565b825b90506000610b7e8383611e40565b6001600160401b03811115610b9557610b95611ec5565b604051908082528060200260200182016040528015610bbe578160200160208202803683370190505b509050825b82811015610c1f57858181518110610bdd57610bdd612016565b6020026020010151828583610bf29190611e40565b81518110610c0257610c02612016565b602090810291909101015280610c178161202c565b915050610bc3565b5099929850919650505050505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8257600080fd5b505afa158015610c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cba9190611e11565b90506000600160009054906101000a90046001600160a01b03166001600160a01b031663254b6c486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0c57600080fd5b505afa158015610d20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d449190611e11565b610d4e9042611ead565b90506000805b83811015610e185760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dda9190611f76565b905083816080015111158015610df257508060e00151155b15610e055782610e018161202c565b9350505b5080610e108161202c565b915050610d54565b50600086610e2760018a611e40565b610e319190611e57565b905081811115610e3e5750805b6000610e4a8883611ead565b905082811115610e575750815b6000610e638383611e40565b6001600160401b03811115610e7a57610e7a611ec5565b604051908082528060200260200182016040528015610eb357816020015b610ea0611b0b565b815260200190600190039081610e985790505b5090506000805b8781108015610ed15750610ece8585611e40565b82105b1561093b5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b158015610f1c57600080fd5b505afa158015610f30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f549190611f76565b905087816080015111158015610f6c57508060e00151155b15610fb257858210158015610f8057508482105b15610fb25780848481518110610f9857610f98612016565b60200260200101819052508280610fae9061202c565b9350505b5080610fbd8161202c565b915050610eba565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610fef8161180f565b50600255565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b15801561107157600080fd5b505afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190611e11565b90506000805b828110156111735760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b1580156110fd57600080fd5b505afa158015611111573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111359190611f76565b90508060a00151600014801561114d57508060e00151155b15611160578261115c8161202c565b9350505b508061116b8161202c565b9150506110af565b50600085611182600189611e40565b61118c9190611e57565b9050818111156111995750805b60006111a58783611ead565b9050828111156111b25750815b60006111be8383611e40565b6001600160401b038111156111d5576111d5611ec5565b60405190808252806020026020018201604052801561120e57816020015b6111fb611b0b565b8152602001906001900390816111f35790505b5090506000805b868110801561122c57506112298585611e40565b82105b156113205760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b15801561127757600080fd5b505afa15801561128b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112af9190611f76565b90508060a0015160001480156112c757508060e00151155b1561130d578582101580156112db57508482105b1561130d57808484815181106112f3576112f3612016565b602002602001018190525082806113099061202c565b9350505b50806113188161202c565b915050611215565b509099939850929650505050505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b15801561138457600080fd5b505afa158015611398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bc9190611e11565b90506000846113cc600188611e40565b6113d69190611e57565b90508181106113f75760405162461bcd60e51b815260040161043d90611e76565b6002548511156114075760025494505b6000826114148784611ead565b11611428576114238683611ead565b61142a565b825b905060006114388383611e40565b6001600160401b0381111561144f5761144f611ec5565b60405190808252806020026020018201604052801561148857816020015b611475611b0b565b81526020019060019003908161146d5790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b1580156114da57600080fd5b505afa1580156114ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115129190611f76565b8261151d8684611e40565b8151811061152d5761152d612016565b602002602001018190525080806115439061202c565b91505061148d565b6000828152602081905260409020600101546115668161180f565b61097283836118a0565b600154604051638046be6560e01b81526001600160a01b038481166004830152602482018490526000921690638046be659060440160206040518083038186803b1580156115bd57600080fd5b505afa1580156115d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106509190611e11565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b031663e434e30f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561164857600080fd5b505afa15801561165c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116809190611e11565b9050600084611690600188611e40565b61169a9190611e57565b90508181106116bb5760405162461bcd60e51b815260040161043d90611e76565b6002548511156116cb5760025494505b6000826116d88784611ead565b116116ec576116e78683611ead565b6116ee565b825b905060006116fc8383611e40565b6001600160401b0381111561171357611713611ec5565b60405190808252806020026020018201604052801561174c57816020015b611739611b0b565b8152602001906001900390816117315790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b15801561179e57600080fd5b505afa1580156117b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117d69190611f76565b826117e18684611e40565b815181106117f1576117f1612016565b602002602001018190525080806118079061202c565b915050611751565b6118198133611905565b50565b6118268282610ff5565b6109f1576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561185c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6118aa8282610ff5565b156109f1576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b61190f8282610ff5565b6109f15761191c8161195e565b611927836020611970565b6040516020016119389291906121f5565b60408051601f198184030181529082905262461bcd60e51b825261043d9160040161226a565b60606103716001600160a01b03831660145b6060600061197f836002611e57565b61198a906002611ead565b6001600160401b038111156119a1576119a1611ec5565b6040519080825280601f01601f1916602001820160405280156119cb576020820181803683370190505b509050600360fc1b816000815181106119e6576119e6612016565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a1557611a15612016565b60200101906001600160f81b031916908160001a9053506000611a39846002611e57565b611a44906001611ead565b90505b6001811115611abc576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7857611a78612016565b1a60f81b828281518110611a8e57611a8e612016565b60200101906001600160f81b031916908160001a90535060049490941c93611ab58161229d565b9050611a47565b5083156106505760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161043d565b60405180610140016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b600060208284031215611b8657600080fd5b81356001600160e01b03198116811461065057600080fd5b60008060408385031215611bb157600080fd5b50508035926020909101359150565b6040808252835182820181905260009190606090818501906020808901865b83811015611c6857815180516001600160a01b0390811687528482015185880152888201518988015287820151888801526080808301519088015260a0808301519088015260c0808301519091169087015260e0808201511515908701526101008082015115159087015261012090810151908601526101409094019390820190600101611bdf565b505095909501959095525092949350505050565b600060208284031215611c8e57600080fd5b5035919050565b600080600060608486031215611caa57600080fd5b505081359360208301359350604090920135919050565b6001600160a01b038116811461181957600080fd5b60008060408385031215611ce957600080fd5b823591506020830135611cfb81611cc1565b809150509250929050565b602080825282518282018190526000919060409081850190868401855b82811015611d5b57815180516001600160a01b0316855286810151878601528501518585015260609093019290850190600101611d23565b5091979650505050505050565b600080600060608486031215611d7d57600080fd5b8335611d8881611cc1565b95602085013595506040909401359392505050565b604080825283519082018190526000906020906060840190828701845b82811015611dd657815184529284019290840190600101611dba565b50505092019290925292915050565b60008060408385031215611df857600080fd5b8235611e0381611cc1565b946020939093013593505050565b600060208284031215611e2357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015611e5257611e52611e2a565b500390565b6000816000190483118215151615611e7157611e71611e2a565b500290565b60208082526018908201527f537461727420696e646578206f7574206f662072616e67650000000000000000604082015260600190565b60008219821115611ec057611ec0611e2a565b500190565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b0381118282101715611efe57611efe611ec5565b60405290565b604051606081016001600160401b0381118282101715611efe57611efe611ec5565b604051601f8201601f191681016001600160401b0381118282101715611f4e57611f4e611ec5565b604052919050565b8051611f6181611cc1565b919050565b80518015158114611f6157600080fd5b60006101408284031215611f8957600080fd5b611f91611edb565b611f9a83611f56565b81526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a0820152611fda60c08401611f56565b60c0820152611feb60e08401611f66565b60e0820152610100611ffe818501611f66565b90820152610120928301519281019290925250919050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561204057612040611e2a565b5060010190565b60006001600160401b0382111561206057612060611ec5565b5060051b60200190565b6000602080838503121561207d57600080fd5b82516001600160401b0381111561209357600080fd5b8301601f810185136120a457600080fd5b80516120b76120b282612047565b611f26565b818152606091820283018401918482019190888411156120d657600080fd5b938501935b838510156121295780858a0312156120f35760008081fd5b6120fb611f04565b855161210681611cc1565b8152858701518782015260408087015190820152835293840193918501916120db565b50979650505050505050565b6000602080838503121561214857600080fd5b82516001600160401b0381111561215e57600080fd5b8301601f8101851361216f57600080fd5b805161217d6120b282612047565b81815260059190911b8201830190838101908783111561219c57600080fd5b928401925b828410156121ba578351825292840192908401906121a1565b979650505050505050565b60005b838110156121e05781810151838201526020016121c8565b838111156121ef576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161222d8160178501602088016121c5565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161225e8160288401602088016121c5565b01602801949350505050565b60208152600082518060208401526122898160408501602087016121c5565b601f01601f19169190910160400192915050565b6000816122ac576122ac611e2a565b50600019019056fea26469706673582212201dd648b0e89f745184fc1bdcad1e6a9485d9a76aefffe19ad0df35bf5004517364736f6c634300080900330000000000000000000000002e6c3c52a90165f2e20c7c3cc1f55f89a640fdd7

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101375760003560e01c80638664d7e6116100b8578063b5dd493c1161007c578063b5dd493c146102b6578063ceb6a22f146102c9578063d547741f146102dc578063dceceec5146102ef578063e8ca3bbb14610302578063f76341281461032d57600080fd5b80638664d7e61461025457806388a9e703146102755780638c4112221461028857806391d148541461029b578063a217fddf146102ae57600080fd5b80632f2ff15d116100ff5780632f2ff15d146101dc57806336568abe146101f1578063579a735e1461020457806374de55eb1461020d57806375b238fc1461022d57600080fd5b806301ffc9a71461013c5780630a1c335814610164578063181e012414610185578063248a9ca3146101a657806326dcd432146101c9575b600080fd5b61014f61014a366004611b74565b610340565b60405190151581526020015b60405180910390f35b610177610172366004611b9e565b610377565b60405161015b929190611bc0565b610198610193366004611c7c565b6105a8565b60405190815260200161015b565b6101986101b4366004611c7c565b60009081526020819052604090206001015490565b6101776101d7366004611c95565b610657565b6101ef6101ea366004611cd6565b61094d565b005b6101ef6101ff366004611cd6565b610977565b61019860025481565b61022061021b366004611c7c565b6109f5565b60405161015b9190611d06565b6101987fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177581565b610267610262366004611d68565b610a76565b60405161015b929190611d9d565b610177610283366004611b9e565b610c2f565b6101ef610296366004611c7c565b610fc5565b61014f6102a9366004611cd6565b610ff5565b610198600081565b6101776102c4366004611b9e565b61101e565b6101776102d7366004611b9e565b611331565b6101ef6102ea366004611cd6565b61154b565b6101986102fd366004611de5565b611570565b600154610315906001600160a01b031681565b6040516001600160a01b03909116815260200161015b565b61017761033b366004611b9e565b6115f5565b60006001600160e01b03198216637965db0b60e01b148061037157506301ffc9a760e01b6001600160e01b03198316145b92915050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b03166301b5ec6a6040518163ffffffff1660e01b815260040160206040518083038186803b1580156103ca57600080fd5b505afa1580156103de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104029190611e11565b9050600084610412600188611e40565b61041c9190611e57565b90508181106104465760405162461bcd60e51b815260040161043d90611e76565b60405180910390fd5b6002548511156104565760025494505b6000826104638784611ead565b11610477576104728683611ead565b610479565b825b905060006104878383611e40565b6001600160401b0381111561049e5761049e611ec5565b6040519080825280602002602001820160405280156104d757816020015b6104c4611b0b565b8152602001906001900390816104bc5790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b15801561052957600080fd5b505afa15801561053d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105619190611f76565b8261056c8684611e40565b8151811061057c5761057c612016565b602002602001018190525080806105929061202c565b9150506104dc565b509792965091945050505050565b60015460405163fc3fc4ed60e01b81526004810183905260009182916001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b1580156105f257600080fd5b505afa158015610606573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062a9190611f76565b9050806080015142106106405750600092915050565b4281608001516106509190611e40565b9392505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b1580156106aa57600080fd5b505afa1580156106be573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e29190611e11565b90506000805b8281101561079d5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b15801561073657600080fd5b505afa15801561074a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061076e9190611f76565b9050888160200151141561078a57826107868161202c565b9350505b50806107958161202c565b9150506106e8565b506000856107ac600189611e40565b6107b69190611e57565b9050818111156107c35750805b60006107cf8783611ead565b9050828111156107dc5750815b60006107e88383611e40565b6001600160401b038111156107ff576107ff611ec5565b60405190808252806020026020018201604052801561083857816020015b610825611b0b565b81526020019060019003908161081d5790505b5090506000805b868110801561085657506108538585611e40565b82105b1561093b5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b1580156108a157600080fd5b505afa1580156108b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108d99190611f76565b90508c81602001511415610928578582101580156108f657508482105b15610928578084848151811061090e5761090e612016565b602002602001018190525082806109249061202c565b9350505b50806109338161202c565b91505061083f565b50909a93995092975050505050505050565b6000828152602081905260409020600101546109688161180f565b610972838361181c565b505050565b6001600160a01b03811633146109e75760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b606482015260840161043d565b6109f182826118a0565b5050565b60015460405163385a3b4760e11b8152600481018390526060916001600160a01b0316906370b4768e9060240160006040518083038186803b158015610a3a57600080fd5b505afa158015610a4e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610371919081019061206a565b60015460405162321a5160e81b81526001600160a01b03858116600483015260609260009283929091169063321a51009060240160006040518083038186803b158015610ac257600080fd5b505afa158015610ad6573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610afe9190810190612135565b805160025491925090851115610b145760025494505b600085610b22600189611e40565b610b2c9190611e57565b9050818110610b4d5760405162461bcd60e51b815260040161043d90611e76565b600082610b5a8884611ead565b11610b6e57610b698783611ead565b610b70565b825b90506000610b7e8383611e40565b6001600160401b03811115610b9557610b95611ec5565b604051908082528060200260200182016040528015610bbe578160200160208202803683370190505b509050825b82811015610c1f57858181518110610bdd57610bdd612016565b6020026020010151828583610bf29190611e40565b81518110610c0257610c02612016565b602090810291909101015280610c178161202c565b915050610bc3565b5099929850919650505050505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b158015610c8257600080fd5b505afa158015610c96573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cba9190611e11565b90506000600160009054906101000a90046001600160a01b03166001600160a01b031663254b6c486040518163ffffffff1660e01b815260040160206040518083038186803b158015610d0c57600080fd5b505afa158015610d20573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d449190611e11565b610d4e9042611ead565b90506000805b83811015610e185760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b158015610da257600080fd5b505afa158015610db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dda9190611f76565b905083816080015111158015610df257508060e00151155b15610e055782610e018161202c565b9350505b5080610e108161202c565b915050610d54565b50600086610e2760018a611e40565b610e319190611e57565b905081811115610e3e5750805b6000610e4a8883611ead565b905082811115610e575750815b6000610e638383611e40565b6001600160401b03811115610e7a57610e7a611ec5565b604051908082528060200260200182016040528015610eb357816020015b610ea0611b0b565b815260200190600190039081610e985790505b5090506000805b8781108015610ed15750610ece8585611e40565b82105b1561093b5760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b158015610f1c57600080fd5b505afa158015610f30573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f549190611f76565b905087816080015111158015610f6c57508060e00151155b15610fb257858210158015610f8057508482105b15610fb25780848481518110610f9857610f98612016565b60200260200101819052508280610fae9061202c565b9350505b5080610fbd8161202c565b915050610eba565b7fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775610fef8161180f565b50600255565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b15801561107157600080fd5b505afa158015611085573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110a99190611e11565b90506000805b828110156111735760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b1580156110fd57600080fd5b505afa158015611111573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111359190611f76565b90508060a00151600014801561114d57508060e00151155b15611160578261115c8161202c565b9350505b508061116b8161202c565b9150506110af565b50600085611182600189611e40565b61118c9190611e57565b9050818111156111995750805b60006111a58783611ead565b9050828111156111b25750815b60006111be8383611e40565b6001600160401b038111156111d5576111d5611ec5565b60405190808252806020026020018201604052801561120e57816020015b6111fb611b0b565b8152602001906001900390816111f35790505b5090506000805b868110801561122c57506112298585611e40565b82105b156113205760015460405163fc3fc4ed60e01b8152600481018390526000916001600160a01b03169063fc3fc4ed906024016101406040518083038186803b15801561127757600080fd5b505afa15801561128b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112af9190611f76565b90508060a0015160001480156112c757508060e00151155b1561130d578582101580156112db57508482105b1561130d57808484815181106112f3576112f3612016565b602002602001018190525082806113099061202c565b9350505b50806113188161202c565b915050611215565b509099939850929650505050505050565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b0316633ef14cc86040518163ffffffff1660e01b815260040160206040518083038186803b15801561138457600080fd5b505afa158015611398573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113bc9190611e11565b90506000846113cc600188611e40565b6113d69190611e57565b90508181106113f75760405162461bcd60e51b815260040161043d90611e76565b6002548511156114075760025494505b6000826114148784611ead565b11611428576114238683611ead565b61142a565b825b905060006114388383611e40565b6001600160401b0381111561144f5761144f611ec5565b60405190808252806020026020018201604052801561148857816020015b611475611b0b565b81526020019060019003908161146d5790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b1580156114da57600080fd5b505afa1580156114ee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115129190611f76565b8261151d8684611e40565b8151811061152d5761152d612016565b602002602001018190525080806115439061202c565b91505061148d565b6000828152602081905260409020600101546115668161180f565b61097283836118a0565b600154604051638046be6560e01b81526001600160a01b038481166004830152602482018490526000921690638046be659060440160206040518083038186803b1580156115bd57600080fd5b505afa1580156115d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106509190611e11565b6060600080600160009054906101000a90046001600160a01b03166001600160a01b031663e434e30f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561164857600080fd5b505afa15801561165c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116809190611e11565b9050600084611690600188611e40565b61169a9190611e57565b90508181106116bb5760405162461bcd60e51b815260040161043d90611e76565b6002548511156116cb5760025494505b6000826116d88784611ead565b116116ec576116e78683611ead565b6116ee565b825b905060006116fc8383611e40565b6001600160401b0381111561171357611713611ec5565b60405190808252806020026020018201604052801561174c57816020015b611739611b0b565b8152602001906001900390816117315790505b509050825b8281101561059a5760015460405163fc3fc4ed60e01b8152600481018390526001600160a01b039091169063fc3fc4ed906024016101406040518083038186803b15801561179e57600080fd5b505afa1580156117b2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117d69190611f76565b826117e18684611e40565b815181106117f1576117f1612016565b602002602001018190525080806118079061202c565b915050611751565b6118198133611905565b50565b6118268282610ff5565b6109f1576000828152602081815260408083206001600160a01b03851684529091529020805460ff1916600117905561185c3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6118aa8282610ff5565b156109f1576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b61190f8282610ff5565b6109f15761191c8161195e565b611927836020611970565b6040516020016119389291906121f5565b60408051601f198184030181529082905262461bcd60e51b825261043d9160040161226a565b60606103716001600160a01b03831660145b6060600061197f836002611e57565b61198a906002611ead565b6001600160401b038111156119a1576119a1611ec5565b6040519080825280601f01601f1916602001820160405280156119cb576020820181803683370190505b509050600360fc1b816000815181106119e6576119e6612016565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611a1557611a15612016565b60200101906001600160f81b031916908160001a9053506000611a39846002611e57565b611a44906001611ead565b90505b6001811115611abc576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110611a7857611a78612016565b1a60f81b828281518110611a8e57611a8e612016565b60200101906001600160f81b031916908160001a90535060049490941c93611ab58161229d565b9050611a47565b5083156106505760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161043d565b60405180610140016040528060006001600160a01b03168152602001600081526020016000815260200160008152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600015158152602001600081525090565b600060208284031215611b8657600080fd5b81356001600160e01b03198116811461065057600080fd5b60008060408385031215611bb157600080fd5b50508035926020909101359150565b6040808252835182820181905260009190606090818501906020808901865b83811015611c6857815180516001600160a01b0390811687528482015185880152888201518988015287820151888801526080808301519088015260a0808301519088015260c0808301519091169087015260e0808201511515908701526101008082015115159087015261012090810151908601526101409094019390820190600101611bdf565b505095909501959095525092949350505050565b600060208284031215611c8e57600080fd5b5035919050565b600080600060608486031215611caa57600080fd5b505081359360208301359350604090920135919050565b6001600160a01b038116811461181957600080fd5b60008060408385031215611ce957600080fd5b823591506020830135611cfb81611cc1565b809150509250929050565b602080825282518282018190526000919060409081850190868401855b82811015611d5b57815180516001600160a01b0316855286810151878601528501518585015260609093019290850190600101611d23565b5091979650505050505050565b600080600060608486031215611d7d57600080fd5b8335611d8881611cc1565b95602085013595506040909401359392505050565b604080825283519082018190526000906020906060840190828701845b82811015611dd657815184529284019290840190600101611dba565b50505092019290925292915050565b60008060408385031215611df857600080fd5b8235611e0381611cc1565b946020939093013593505050565b600060208284031215611e2357600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b600082821015611e5257611e52611e2a565b500390565b6000816000190483118215151615611e7157611e71611e2a565b500290565b60208082526018908201527f537461727420696e646578206f7574206f662072616e67650000000000000000604082015260600190565b60008219821115611ec057611ec0611e2a565b500190565b634e487b7160e01b600052604160045260246000fd5b60405161014081016001600160401b0381118282101715611efe57611efe611ec5565b60405290565b604051606081016001600160401b0381118282101715611efe57611efe611ec5565b604051601f8201601f191681016001600160401b0381118282101715611f4e57611f4e611ec5565b604052919050565b8051611f6181611cc1565b919050565b80518015158114611f6157600080fd5b60006101408284031215611f8957600080fd5b611f91611edb565b611f9a83611f56565b81526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a0820152611fda60c08401611f56565b60c0820152611feb60e08401611f66565b60e0820152610100611ffe818501611f66565b90820152610120928301519281019290925250919050565b634e487b7160e01b600052603260045260246000fd5b600060001982141561204057612040611e2a565b5060010190565b60006001600160401b0382111561206057612060611ec5565b5060051b60200190565b6000602080838503121561207d57600080fd5b82516001600160401b0381111561209357600080fd5b8301601f810185136120a457600080fd5b80516120b76120b282612047565b611f26565b818152606091820283018401918482019190888411156120d657600080fd5b938501935b838510156121295780858a0312156120f35760008081fd5b6120fb611f04565b855161210681611cc1565b8152858701518782015260408087015190820152835293840193918501916120db565b50979650505050505050565b6000602080838503121561214857600080fd5b82516001600160401b0381111561215e57600080fd5b8301601f8101851361216f57600080fd5b805161217d6120b282612047565b81815260059190911b8201830190838101908783111561219c57600080fd5b928401925b828410156121ba578351825292840192908401906121a1565b979650505050505050565b60005b838110156121e05781810151838201526020016121c8565b838111156121ef576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161222d8160178501602088016121c5565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161225e8160288401602088016121c5565b01602801949350505050565b60208152600082518060208401526122898160408501602087016121c5565b601f01601f19169190910160400192915050565b6000816122ac576122ac611e2a565b50600019019056fea26469706673582212201dd648b0e89f745184fc1bdcad1e6a9485d9a76aefffe19ad0df35bf5004517364736f6c63430008090033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000002e6c3c52a90165f2e20c7c3cc1f55f89a640fdd7

-----Decoded View---------------
Arg [0] : _auctionsContract (address): 0x2E6C3C52a90165F2e20C7C3cC1F55f89a640FDD7

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000002e6c3c52a90165f2e20c7c3cc1f55f89a640fdd7


Block Transaction 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

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.