Polygon Sponsored slots available. Book your slot here!
More Info
Private Name Tags
ContractCreator
Latest 19 from a total of 19 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Enroll Initial A... | 62878292 | 60 days ago | IN | 0 POL | 0.00361515 | ||||
Enroll Initial A... | 60196916 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196897 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196895 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196893 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196891 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196889 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196883 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196881 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196879 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196874 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196857 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196854 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196852 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196849 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196847 | 127 days ago | IN | 0 POL | 0.00103524 | ||||
Enroll Initial A... | 60196843 | 127 days ago | IN | 0 POL | 0.00310143 | ||||
Enroll Initial A... | 57752903 | 189 days ago | IN | 0 POL | 0.00464043 | ||||
Grant Role | 54583310 | 272 days ago | IN | 0 POL | 0.00483757 |
Loading...
Loading
Contract Name:
Affiliates
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import './types.sol'; import "../tickets/registry.sol"; /* The contract supports rank progression based on the number of direct referrals and the sales volume generated by each referrer. The `RankCriteria` struct is used to define the criteria for each rank, and the `rankCriterias` array stores these structs. The contract has been updated to include the following new functions: 1. `updateSalesVolume(address referrer, uint256 amount)` - Updates the sales volume for a referrer. 2. `checkEligibilityForRankUp(address referrer)` - Checks if a referrer is eligible for a rank up based on the rank criteria. 3. `rankUp(address referrer)` - Performs a rank up for a referrer if they are eligible. Additionally, the `handleAffiliateProgram` function has been updated to update the sales volume for each referrer in the hierarchy when processing rewards. */ /// @custom:security-contact [email protected] contract Affiliates is AccessControl { using SafeMath for uint256; /* ///////////////////////////////// 1. Role Declarations ///////////////////////////////// - Define a constant role for the booth role - Define a constant role for the affiliates role */ bytes32 public constant BOOTH_ROLE = keccak256("BOOTH_ROLE"); /* ///////////////////////////// 2. Structs and State Variables ///////////////////////////// - referralRewardBasisPoints: The percentage of the reward to be given to referrers at each level and rank (in basis points, e.g., 1000 = 10%) - referrers: The mapping to store referrer addresses - referrerRanks: The mapping to store the rank of each referrer - directReferrals: The mapping to store the number of direct referrals for each referrer - salesVolume: The mapping to store the sales volume for each referrer - rankCriterias: The mapping to store RankCriteria structs defining the criteria for each rank - rankCriteriasCount: The total number of rank criterias - maxDepth: The maximum depth of the MLM hierarchy - affiliates: Array to store all affiliate addresses - nftAffiliates: Map each NFT token ID to a mapping of addresses to their affiliate data - nftAffiliateCounts: - nftReferralRewards: */ TicketRegistry private ticketRegistry; uint256 public maxDepth; uint256[][] public referralRewardBasisPoints; uint256 public rankCriteriasCount; mapping(uint256 => SharedTypes.RankCriteria) public rankCriterias; mapping(address => SharedTypes.AffiliateData) public affiliates; mapping(uint256 => uint256) public nftAffiliateCounts; uint256 public affiliatesCount; address[] public affiliateAddresses; /* ///////////////////////////// 3. Constructor and events ///////////////////////////// The constructor initializes the contract's state. With this structure, affiliates are incentivized to improve their rank and work on their direct referrals as they receive higher rewards for higher ranks and closer relationships. At the same time, the maximum reward an affiliate can get from a single sale is capped at 25 %, ensuring a balance in the reward distribution. Level 1: Bronze 8%, Silver 10%, Gold 12%, Platinum 14%, Diamond 16% Level 2: Bronze 6%, Silver 8%, Gold 10%, Platinum 12%, Diamond 14% Level 3: Bronze 4%, Silver 6%, Gold 8%, Platinum 10%, Diamond 12% Level 4: Bronze 2%, Silver 4%, Gold 6%, Platinum 8%, Diamond 10% Level 5: Bronze 1%, Silver 2%, Gold 4%, Platinum 6%, Diamond 8% // Define the rewrd bsis points array const referralRewardBasisPointsArray = [ [1000, 1100, 1200, 1300, 1400], Level 1: Bronze 10%, Silver 11%, Gold 12%, Platinum 13%, Diamond 14% [700, 850, 1000, 1150, 1300], Level 2: Increase by a factor that reduces the gap slightly but still provides incentive for higher ranks [500, 650, 800, 950, 1100], Level 3: Same as above, continue reducing the gap [300, 450, 600, 750, 900], Level 4: Continue the trend [150, 300, 450, 600, 750] Level 5: By this level, the difference between ranks narrows as the depth increases ]; // Define the rank criteria const rankCriteriasArray = [ {requiredDirectReferrals: 5, requiredSalesVolume: ethers.utils.parseEther("1")}, {requiredDirectReferrals: 10, requiredSalesVolume: ethers.utils.parseEther("5")}, {requiredDirectReferrals: 20, requiredSalesVolume: ethers.utils.parseEther("10")}, {requiredDirectReferrals: 50, requiredSalesVolume: ethers.utils.parseEther("20")}, {requiredDirectReferrals: 100, requiredSalesVolume: ethers.utils.parseEther("50")} ]; maxDepth is the number of referrers an affiliate can have in their chain */ // Constructor constructor(uint256[][] memory _referralRewardBasisPoints, SharedTypes.RankCriteria[] memory _rankCriterias, uint256 _maxDepth, address _ticketRegistryAddress) { referralRewardBasisPoints = _referralRewardBasisPoints; for (uint256 i = 0; i < _rankCriterias.length; i++) { rankCriterias[i] = _rankCriterias[i]; } rankCriteriasCount = _rankCriterias.length; maxDepth = _maxDepth; ticketRegistry = TicketRegistry(_ticketRegistryAddress); _grantRole(DEFAULT_ADMIN_ROLE, msg.sender); } event AffiliateEnrolledForNFT(uint256 indexed tokenId, address indexed affiliateAddress, address referrerAddress); event SalesVolumeUpdated(address indexed referrer, uint256 newSalesVolume); event RankUp(address indexed referrer, uint256 newRank); event ReferralRewardUpdated(uint256 level, uint256 rank, uint256 reward); event ReferrerRankUpdated(address indexed referrer, uint256 rank); event RankCriteriaUpdated(uint256 indexed rank, SharedTypes.RankCriteria newCriteria); /* ///////////////////////////// 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 Updates the maximum depth of the affiliate referral hierarchy. * @param newMaxDepth The new maximum depth to set. */ function setMaxDepth(uint256 newMaxDepth) public onlyRole(BOOTH_ROLE) { maxDepth = newMaxDepth; } /** * @notice Modifier to ensure an affiliate is not already enrolled for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliateAddress The address of the affiliate. */ modifier notAlreadyEnrolled(uint256 tokenId, address affiliateAddress) { require(!affiliates[affiliateAddress].nftAffiliations[tokenId].isAffiliated, "Already an affiliate for this NFT"); _; } /** * @notice Enrolls the initial affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param sellerAddress The address of the seller to be enrolled as an affiliate. */ function enrollInitialAffiliateForNFT(uint256 tokenId, address sellerAddress) public onlyRole(BOOTH_ROLE) onlyRegisteredToken(tokenId) notAlreadyEnrolled(tokenId, sellerAddress) { // Enrolling seller as their own referrer for this NFT affiliates[sellerAddress].nftAffiliations[tokenId] = SharedTypes.AffiliateNFTData({ isAffiliated: true, referrer: sellerAddress, networkDepth: 0, totalRewards: 0, pendingRewards: 0, referredUsers: new address[](0) }); // Updating affiliate counts and addresses nftAffiliateCounts[tokenId]++; affiliatesCount++; affiliateAddresses.push(sellerAddress); emit AffiliateEnrolledForNFT(tokenId, sellerAddress, sellerAddress); } /** * @notice Enrolls an affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliateAddress The address of the affiliate to enroll. * @param referrerAddress The address of the affiliate's referrer. */ function enrollAffiliateForNFT(uint256 tokenId, address affiliateAddress, address referrerAddress) public onlyRole(BOOTH_ROLE) onlyRegisteredToken(tokenId) notAlreadyEnrolled(tokenId, affiliateAddress) isReferrerAffiliate(tokenId, referrerAddress) { // Initializing general affiliate data for new affiliates SharedTypes.AffiliateData storage affiliate = affiliates[affiliateAddress]; if (affiliate.generalReferrer == address(0)) { affiliate.generalReferrer = referrerAddress; affiliate.rank = 0; affiliate.directReferrals = 0; affiliate.salesVolume = 0; } // Calculating new affiliate level based on referrer's level uint256 referrerLevel = affiliates[referrerAddress].nftAffiliations[tokenId].networkDepth; uint256 newLevel = referrerLevel + 1; // Handling max depth limit if (newLevel >= maxDepth) { newLevel = 0; referrerAddress = referrerAddress; } // Enrolling affiliate and updating relevant data affiliate.nftAffiliations[tokenId] = SharedTypes.AffiliateNFTData({ isAffiliated: true, referrer: referrerAddress, networkDepth: newLevel, totalRewards: 0, pendingRewards: 0, referredUsers: new address[](0) }); affiliates[referrerAddress].nftAffiliations[tokenId].referredUsers.push(affiliateAddress); affiliates[referrerAddress].directReferrals = affiliates[referrerAddress].directReferrals.add(1); nftAffiliateCounts[tokenId]++; affiliatesCount++; affiliateAddresses.push(affiliateAddress); emit AffiliateEnrolledForNFT(tokenId, affiliateAddress, referrerAddress); } /** * @notice Checks if an affiliate is eligible for a rank upgrade. * @param affiliateAddress The address of the affiliate. * @return eligible Boolean indicating if the affiliate is eligible for a rank up. * @return currentRank The current rank of the affiliate. * @return requiredDirectReferrals The required direct referrals for the next rank. * @return requiredSalesVolume The required sales volume for the next rank. */ function checkEligibilityForRankUp(address affiliateAddress) public view returns (bool eligible, uint256 currentRank, uint256 requiredDirectReferrals, uint256 requiredSalesVolume) { SharedTypes.AffiliateData storage affiliate = affiliates[affiliateAddress]; currentRank = affiliate.rank; // Handling the highest rank limit if (currentRank >= rankCriteriasCount - 1) { return (false, currentRank, 0, 0); } // Fetching next rank criteria SharedTypes.RankCriteria memory nextRankCriteria = rankCriterias[currentRank + 1]; requiredDirectReferrals = nextRankCriteria.requiredDirectReferrals; requiredSalesVolume = nextRankCriteria.requiredSalesVolume; // Checking eligibility eligible = (affiliate.directReferrals >= requiredDirectReferrals) && (affiliate.salesVolume >= requiredSalesVolume); return (eligible, currentRank, requiredDirectReferrals, requiredSalesVolume); } /** * @notice Sets new referral reward basis points for a specific level and rank. * @param level The level for which to set the new reward basis points. * @param rank The rank for which to set the new reward basis points. * @param newRewardBasisPoints The new reward basis points to set. */ function setReferralRewardBasisPoints(uint256 level, uint256 rank, uint256 newRewardBasisPoints) public onlyRole(BOOTH_ROLE) { referralRewardBasisPoints[level][rank] = newRewardBasisPoints; emit ReferralRewardUpdated(level, rank, newRewardBasisPoints); } /** * @notice Update the criteria for a specific rank. * @param rank The rank to update. * @param newCriteria The new criteria for the rank. */ function setRankCriteria(uint256 rank, SharedTypes.RankCriteria memory newCriteria) public onlyRole(BOOTH_ROLE) { require(rank < rankCriteriasCount, "Invalid rank"); rankCriterias[rank] = newCriteria; emit RankCriteriaUpdated(rank, newCriteria); } /** * @notice Set the rank of a referrer. * @param affiliateAddress The address of the referrer. * @param rank The new rank to be set. */ function setReferrerRank(address affiliateAddress, uint256 rank, uint256 tokenId) external onlyRole(BOOTH_ROLE) onlyRegisteredToken(tokenId) { require(affiliateAddress != address(0), "Invalid referrer address"); require(rank < rankCriteriasCount, "Invalid rank"); require(affiliates[affiliateAddress].nftAffiliations[tokenId].isAffiliated, "Referrer not enrolled for NFT"); SharedTypes.AffiliateData storage affiliate = affiliates[affiliateAddress]; affiliate.rank = rank; emit ReferrerRankUpdated(affiliateAddress, rank); } /** * @notice Updates the sales volume for a specific affiliate. * @param affiliateAddress The address of the affiliate whose sales volume is to be updated. * @param amount The amount to add to the affiliate's sales volume. * @dev This function should only be called by roles with the BOOTH_ROLE permission. */ function updateSalesVolume(address affiliateAddress, uint256 amount) external onlyRole(BOOTH_ROLE) { require(affiliates[affiliateAddress].generalReferrer != address(0), "Affiliate does not exist"); SharedTypes.AffiliateData storage affiliate = affiliates[affiliateAddress]; affiliate.salesVolume = affiliates[affiliateAddress].salesVolume.add(amount); emit SalesVolumeUpdated(affiliateAddress, affiliates[affiliateAddress].salesVolume); } /** * @notice Increments the rank of an affiliate if they are eligible for a rank up. * @param affiliateAddress The address of the affiliate to rank up. * @dev This function checks the affiliate's eligibility before increasing their rank. * Only callable by roles with the BOOTH_ROLE permission. */ function rankUp(address affiliateAddress) external onlyRole(BOOTH_ROLE) { require(affiliates[affiliateAddress].generalReferrer != address(0), "Affiliate does not exist"); (bool eligible, uint256 currentRank, , ) = checkEligibilityForRankUp(affiliateAddress); require(eligible, "Affiliate is not eligible for rank up"); affiliates[affiliateAddress].rank = currentRank + 1; emit RankUp(affiliateAddress, currentRank + 1); } /** * @notice Handles the distribution of referral rewards for an NFT purchase. * @param tokenId The token ID of the NFT involved in the transaction. * @param buyer The address of the buyer. * @param referrer The address of the referrer. * @return remainingRewards The amount of funds remaining after distributing the rewards. * @dev Distributes referral rewards up the referral chain and updates sales volumes. * Only callable by roles with the BOOTH_ROLE permission and for registered tokens. */ function handleAffiliateProgram(uint256 tokenId, address buyer, address referrer) external payable onlyRole(BOOTH_ROLE) onlyRegisteredToken(tokenId) returns (uint256) { if(!(affiliates[buyer].nftAffiliations[tokenId].isAffiliated)){ enrollAffiliateForNFT(tokenId, buyer, referrer); } uint256 remainingRewards = msg.value; address currentAffiliate = referrer; uint256 currentDepth = 0; while (currentAffiliate != address(0) && currentDepth < maxDepth) { SharedTypes.AffiliateData storage affiliate = affiliates[currentAffiliate]; SharedTypes.AffiliateNFTData storage nftAffiliateData = affiliate.nftAffiliations[tokenId]; if (nftAffiliateData.isAffiliated) { uint256 referralReward = calculateReward(tokenId, currentAffiliate, msg.value); // Using msg.value instead of remainingRewards payable(currentAffiliate).transfer(referralReward); remainingRewards -= referralReward; affiliate.salesVolume = affiliate.salesVolume.add(referralReward); nftAffiliateData.totalRewards = nftAffiliateData.totalRewards.add(referralReward); emit SalesVolumeUpdated(currentAffiliate, affiliate.salesVolume); } currentAffiliate = nftAffiliateData.referrer; currentDepth++; } return remainingRewards; } /** * @notice Calculates the referral reward for an affiliate based on the purchase price. * @param tokenId The token ID of the NFT involved in the transaction. * @param affiliate The address of the affiliate for whom the reward is being calculated. * @param purchasePrice The price of the NFT purchase. * @return referralReward The calculated referral reward for the affiliate. * @dev This calculation is based on the affiliate's rank and level within the referral system. * Only callable for registered tokens. */ function calculateReward(uint256 tokenId, address affiliate, uint256 purchasePrice) public view onlyRegisteredToken(tokenId) returns (uint256) { SharedTypes.AffiliateData storage affiliateData = affiliates[affiliate]; SharedTypes.AffiliateNFTData storage nftAffiliateData = affiliateData.nftAffiliations[tokenId]; require(nftAffiliateData.isAffiliated, "Affiliate not enrolled for this NFT"); uint256 affiliateRank = affiliateData.rank; uint256 affiliateLevel = nftAffiliateData.networkDepth; uint256 referralRewardBasisPoint = referralRewardBasisPoints[affiliateLevel][affiliateRank]; uint256 referralReward = (purchasePrice * referralRewardBasisPoint) / 10000; return referralReward; } /* ///////////////////////////// 5. Helper Functions ///////////////////////////// Include helper functions. */ /** * @notice Retrieves the general referrer of an affiliate. * @param affiliate The address of the affiliate. * @return The address of the general referrer of the specified affiliate. */ function getAffiliateReferrer(address affiliate) public view returns (address) { return affiliates[affiliate].generalReferrer; } /** * @notice Returns the number of direct referrals made by an affiliate. * @param affiliate The address of the affiliate. * @return The number of direct referrals made by the affiliate. */ function getAffiliateDirectReferrals(address affiliate) public view returns (uint256) { return affiliates[affiliate].directReferrals; } /** * @notice Retrieves NFT-specific affiliate data. * @param tokenId The ID of the NFT. * @param affiliate The address of the affiliate. * @return NFT-specific affiliate data for the specified affiliate and NFT. */ function getAffiliateNFTData(uint256 tokenId, address affiliate) public view onlyRegisteredToken(tokenId) returns (SharedTypes.AffiliateNFTData memory) { return affiliates[affiliate].nftAffiliations[tokenId]; } /** * @notice Retrieves the rank of an affiliate. * @param affiliate The address of the affiliate. * @return The rank of the specified affiliate. */ function getAffiliateRank(address affiliate) public view returns (uint256) { return affiliates[affiliate].rank; } /** * @notice Retrieves the total sales volume generated by an affiliate. * @param affiliate The address of the affiliate. * @return The total sales volume of the affiliate. */ function getAffiliateSalesVolume(address affiliate) public view returns (uint256) { return affiliates[affiliate].salesVolume; } /** * @notice Retrieves the total rewards earned by an affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliate The address of the affiliate. * @return Total rewards earned by the affiliate for the specified NFT. */ function getAffiliateTotalRewards(uint256 tokenId, address affiliate) public view onlyRegisteredToken(tokenId) returns (uint256) { return affiliates[affiliate].nftAffiliations[tokenId].totalRewards; } /** * @notice Retrieves the list of users referred by an affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliate The address of the affiliate. * @return List of users referred by the affiliate for the specified NFT. */ function getNFTAffiliateReferredUsers(uint256 tokenId, address affiliate) public view onlyRegisteredToken(tokenId) returns (address[] memory) { return affiliates[affiliate].nftAffiliations[tokenId].referredUsers; } /** * @notice Retrieves the level of an affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliateAddress The address of the affiliate. * @return The level of the affiliate for the specified NFT. */ function getAffiliateLevel(uint256 tokenId, address affiliateAddress) public view onlyRegisteredToken(tokenId) returns (uint256) { // Ensure the affiliate is enrolled for the specified NFT require(affiliates[affiliateAddress].nftAffiliations[tokenId].isAffiliated, "Affiliate not enrolled for this NFT"); // Return the level of the affiliate for the specific NFT return affiliates[affiliateAddress].nftAffiliations[tokenId].networkDepth; } /** * @notice Retrieves the referral reward basis points for all levels and ranks. * @return A two-dimensional array containing the referral reward basis points. */ function getReferralRewardBasisPoints() public view returns (uint256[][] memory) { return referralRewardBasisPoints; } /** * @notice Retrieves the maximum depth allowed in the affiliate hierarchy. * @return The maximum depth of the affiliate hierarchy. */ function getMaxDepth() public view returns (uint256) { return maxDepth; } /** * @notice Retrieves the referral reward basis points for a specific level and rank. * @param level The affiliate level. * @param rank The affiliate rank. * @return The referral reward basis points for the specified level and rank. */ function getReferralRewardBasisPointsForLevelAndRank(uint256 level, uint256 rank) public view returns (uint256) { // Ensure the level and rank are within the bounds of the referralRewardBasisPoints array require(level < referralRewardBasisPoints.length, "Level out of range"); require(rank < referralRewardBasisPoints[level].length, "Rank out of range"); // Return the basis points for the given level and rank return referralRewardBasisPoints[level][rank]; } /** * @notice Retrieves the criteria for a specific rank. * @param rank The rank number. * @return The criteria for the specified rank. */ function getRankCriteria(uint256 rank) public view returns (SharedTypes.RankCriteria memory) { require(rank < rankCriteriasCount, "Rank number out of range"); return rankCriterias[rank]; } /** * @notice Retrieves the total number of affiliates. * @return The total number of affiliates. */ function getTotalAffiliates() public view returns (uint256) { return affiliatesCount; } /** * @notice Retrieves the total number of affiliates for a specific NFT. * @param tokenId The token ID of the NFT. * @return The total number of affiliates for the specified NFT. */ function getTotalNFTAffiliates(uint256 tokenId) public view onlyRegisteredToken(tokenId) returns (uint256) { return nftAffiliateCounts[tokenId]; } /** * @notice Checks if a given address is an affiliate for a specific NFT. * @param tokenId The token ID of the NFT. * @param affiliateAddress The address to check. * @return True if the address is an affiliate for the NFT, otherwise false. */ function isAffiliateForNFT(uint256 tokenId, address affiliateAddress) public view onlyRegisteredToken(tokenId) returns (bool) { // Access the affiliate's data for the specific NFT SharedTypes.AffiliateNFTData storage nftAffiliateData = affiliates[affiliateAddress].nftAffiliations[tokenId]; // Check if the affiliate is affiliated with the specified NFT return nftAffiliateData.isAffiliated; } /** * @notice Retrieves the affiliate address at a given index in the affiliate list. * @param index The index in the affiliate list. * @return The address of the affiliate at the specified index. */ function getAffiliateAtIndex(uint256 index) public view returns (address) { require(index < affiliateAddresses.length, "Index out of bounds"); return affiliateAddresses[index]; } /** * @notice Ensures that the specified token ID is registered. * @param _tokenId The token ID to check. */ modifier onlyRegisteredToken(uint256 _tokenId) { require(ticketRegistry.isObjectRegistered(_tokenId), "Object is not registered"); _; } /** * @notice Ensures that the specified referrer is an affiliate for the given token ID. * @param _tokenId The token ID. * @param referrer The address of the referrer. */ modifier isReferrerAffiliate(uint256 _tokenId, address referrer) { require(affiliates[referrer].nftAffiliations[_tokenId].isAffiliated, "Referrer is not an affiliate for this tokenId"); _; } }
// 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()); } } }
// 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; }
// 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_); } }
// 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); }
// 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; } }
// 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; } } } } }
// 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); }
// 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; }
// 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); }
// 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); }
// 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); }
// 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"); } } }
// 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); } } }
// 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; } }
// 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; } }
// 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); }
// 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); } } }
// 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; } } }
// 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); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; contract SharedTypes { struct RankCriteria { uint256 requiredDirectReferrals; uint256 requiredSalesVolume; } struct AffiliateNFTData { bool isAffiliated; address referrer; // Referrer for this specific NFT uint256 networkDepth; // The depth of the affiliate's network for this NFT uint256 totalRewards; uint256 pendingRewards; address[] referredUsers; // Users directly referred by this affiliate for this NFT } struct AffiliateData { address generalReferrer; // General referrer (across all NFTs) uint256 rank; uint256 directReferrals; uint256 salesVolume; mapping(uint256 => AffiliateNFTData) nftAffiliations; // NFT specific data // mapping(address => uint256) recruitsNetworkDepth; // General network depth of each recruit } }
// 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); }
// 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; } }
// 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); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"uint256[][]","name":"_referralRewardBasisPoints","type":"uint256[][]"},{"components":[{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"internalType":"struct SharedTypes.RankCriteria[]","name":"_rankCriterias","type":"tuple[]"},{"internalType":"uint256","name":"_maxDepth","type":"uint256"},{"internalType":"address","name":"_ticketRegistryAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"affiliateAddress","type":"address"},{"indexed":false,"internalType":"address","name":"referrerAddress","type":"address"}],"name":"AffiliateEnrolledForNFT","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"rank","type":"uint256"},{"components":[{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"indexed":false,"internalType":"struct SharedTypes.RankCriteria","name":"newCriteria","type":"tuple"}],"name":"RankCriteriaUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"newRank","type":"uint256"}],"name":"RankUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"level","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rank","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"ReferralRewardUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"rank","type":"uint256"}],"name":"ReferrerRankUpdated","type":"event"},{"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"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"referrer","type":"address"},{"indexed":false,"internalType":"uint256","name":"newSalesVolume","type":"uint256"}],"name":"SalesVolumeUpdated","type":"event"},{"inputs":[],"name":"BOOTH_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":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"affiliateAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"affiliates","outputs":[{"internalType":"address","name":"generalReferrer","type":"address"},{"internalType":"uint256","name":"rank","type":"uint256"},{"internalType":"uint256","name":"directReferrals","type":"uint256"},{"internalType":"uint256","name":"salesVolume","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"affiliatesCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliate","type":"address"},{"internalType":"uint256","name":"purchasePrice","type":"uint256"}],"name":"calculateReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliateAddress","type":"address"}],"name":"checkEligibilityForRankUp","outputs":[{"internalType":"bool","name":"eligible","type":"bool"},{"internalType":"uint256","name":"currentRank","type":"uint256"},{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliateAddress","type":"address"},{"internalType":"address","name":"referrerAddress","type":"address"}],"name":"enrollAffiliateForNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"sellerAddress","type":"address"}],"name":"enrollInitialAffiliateForNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getAffiliateAtIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateDirectReferrals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliateAddress","type":"address"}],"name":"getAffiliateLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateNFTData","outputs":[{"components":[{"internalType":"bool","name":"isAffiliated","type":"bool"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint256","name":"networkDepth","type":"uint256"},{"internalType":"uint256","name":"totalRewards","type":"uint256"},{"internalType":"uint256","name":"pendingRewards","type":"uint256"},{"internalType":"address[]","name":"referredUsers","type":"address[]"}],"internalType":"struct SharedTypes.AffiliateNFTData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateRank","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateReferrer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateSalesVolume","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliate","type":"address"}],"name":"getAffiliateTotalRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMaxDepth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliate","type":"address"}],"name":"getNFTAffiliateReferredUsers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rank","type":"uint256"}],"name":"getRankCriteria","outputs":[{"components":[{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"internalType":"struct SharedTypes.RankCriteria","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReferralRewardBasisPoints","outputs":[{"internalType":"uint256[][]","name":"","type":"uint256[][]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"uint256","name":"rank","type":"uint256"}],"name":"getReferralRewardBasisPointsForLevelAndRank","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":[],"name":"getTotalAffiliates","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTotalNFTAffiliates","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":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"buyer","type":"address"},{"internalType":"address","name":"referrer","type":"address"}],"name":"handleAffiliateProgram","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"payable","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":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"affiliateAddress","type":"address"}],"name":"isAffiliateForNFT","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDepth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"nftAffiliateCounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rankCriterias","outputs":[{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rankCriteriasCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliateAddress","type":"address"}],"name":"rankUp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"referralRewardBasisPoints","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":"newMaxDepth","type":"uint256"}],"name":"setMaxDepth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rank","type":"uint256"},{"components":[{"internalType":"uint256","name":"requiredDirectReferrals","type":"uint256"},{"internalType":"uint256","name":"requiredSalesVolume","type":"uint256"}],"internalType":"struct SharedTypes.RankCriteria","name":"newCriteria","type":"tuple"}],"name":"setRankCriteria","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"uint256","name":"rank","type":"uint256"},{"internalType":"uint256","name":"newRewardBasisPoints","type":"uint256"}],"name":"setReferralRewardBasisPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"affiliateAddress","type":"address"},{"internalType":"uint256","name":"rank","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"setReferrerRank","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"affiliateAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"updateSalesVolume","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b506040516200347c3803806200347c8339810160408190526200003491620003e1565b83516200004990600390602087019062000185565b5060005b8351811015620000a7578381815181106200006c576200006c62000546565b6020908102919091018101516000838152600583526040902081518155910151600190910155806200009e816200055c565b9150506200004d565b5082516004556002829055600180546001600160a01b0319166001600160a01b038316179055620000da600033620000e4565b5050505062000586565b6000828152602081815260408083206001600160a01b038516845290915290205460ff1662000181576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001403390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b828054828255906000526020600020908101928215620001d7579160200282015b82811115620001d75782518051620001c6918491602090910190620001e9565b5091602001919060010190620001a6565b50620001e592915062000235565b5090565b82805482825590600052602060002090810192821562000227579160200282015b82811115620002275782518255916020019190600101906200020a565b50620001e592915062000256565b80821115620001e55760006200024c82826200026d565b5060010162000235565b5b80821115620001e5576000815560010162000257565b50805460008255906000526020600020908101906200028d919062000256565b50565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715620002cb57620002cb62000290565b60405290565b604051601f8201601f191681016001600160401b0381118282101715620002fc57620002fc62000290565b604052919050565b60006001600160401b0382111562000320576200032062000290565b5060051b60200190565b600082601f8301126200033c57600080fd5b81516020620003556200034f8362000304565b620002d1565b82815260069290921b840181019181810190868411156200037557600080fd5b8286015b84811015620003b95760408189031215620003945760008081fd5b6200039e620002a6565b81518152848201518582015283529183019160400162000379565b509695505050505050565b80516001600160a01b0381168114620003dc57600080fd5b919050565b60008060008060808587031215620003f857600080fd5b84516001600160401b03808211156200041057600080fd5b818701915087601f8301126200042557600080fd5b8151620004366200034f8262000304565b8082825260208201915060208360051b86010192508a8311156200045957600080fd5b602085015b83811015620004f9578051858111156200047757600080fd5b8601603f81018d136200048957600080fd5b60208101516200049d6200034f8262000304565b81815260059190911b82016040019060208101908f831115620004bf57600080fd5b6040840193505b82841015620004e3578351825260209384019390910190620004c6565b865250506020938401939190910190506200045e565b5060208a015190985093505050808211156200051457600080fd5b5062000523878288016200032a565b935050604085015191506200053b60608601620003c4565b905092959194509250565b634e487b7160e01b600052603260045260246000fd5b60006000198214156200057f57634e487b7160e01b600052601160045260246000fd5b5060010190565b612ee680620005966000396000f3fe60806040526004361061025c5760003560e01c8063695b299a1161014457806395d0ca54116100b6578063d33bcc4a1161007a578063d33bcc4a14610836578063d547741f14610856578063d9c7221c14610876578063db5568b614610896578063e031471f146108d8578063fd1c98cd146108ed57600080fd5b806395d0ca541461079f578063a217fddf146107bf578063a68e5659146107d4578063ad6473de146107f4578063b94063131461082157600080fd5b80637df15655116101085780637df15655146106b957806387007c60146106d95780638b6863fb146107125780638fa44dc11461073257806391d148541461075f5780639356d6671461077f57600080fd5b8063695b299a146105c85780636f8bd036146105e857806375d779721461060857806376290905146106435780637ab35a6d1461068c57600080fd5b80633b7c362c116101dd578063468f9fd1116101a1578063468f9fd1146104a157806348f4fcd8146104c15780634f51e294146104e357806357eddb8814610559578063609a233d14610592578063647bea4f146105a857600080fd5b80633b7c362c146104095780633ca78f84146104295780633eb3b9d7146104495780633fb8b6921461045f578063409749111461047f57600080fd5b80632771fc1a116102245780632771fc1a1461033657806328777e49146103875780632f2ff15d146103a957806331a50227146103c957806336568abe146103e957600080fd5b806301ffc9a71461026157806305c32cbf14610296578063143117e1146102b7578063248a9ca3146102cd578063272e974f146102fd575b600080fd5b34801561026d57600080fd5b5061028161027c36600461287b565b61090d565b60405190151581526020015b60405180910390f35b6102a96102a43660046128c1565b610944565b60405190815260200161028d565b3480156102c357600080fd5b506102a960025481565b3480156102d957600080fd5b506102a96102e83660046128fd565b60009081526020819052604090206001015490565b34801561030957600080fd5b506102a9610318366004612916565b6001600160a01b031660009081526006602052604090206003015490565b34801561034257600080fd5b5061036f610351366004612916565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b03909116815260200161028d565b34801561039357600080fd5b506103a76103a2366004612931565b610b81565b005b3480156103b557600080fd5b506103a76103c4366004612964565b610d9b565b3480156103d557600080fd5b506102a96103e4366004612990565b610dc5565b3480156103f557600080fd5b506103a7610404366004612964565b610e02565b34801561041557600080fd5b506102a9610424366004612964565b610e80565b34801561043557600080fd5b506102a96104443660046129b2565b610f91565b34801561045557600080fd5b506102a960085481565b34801561046b57600080fd5b5061036f61047a3660046128fd565b6110e7565b34801561048b57600080fd5b506102a9600080516020612e9183398151915281565b3480156104ad57600080fd5b506103a76104bc366004612964565b611111565b3480156104cd57600080fd5b506104d66113de565b60405161028d91906129e7565b3480156104ef57600080fd5b5061052f6104fe366004612916565b60066020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909184565b604080516001600160a01b039095168552602085019390935291830152606082015260800161028d565b34801561056557600080fd5b506102a9610574366004612916565b6001600160a01b031660009081526006602052604090206001015490565b34801561059e57600080fd5b506102a960045481565b3480156105b457600080fd5b506102a96105c3366004612990565b611477565b3480156105d457600080fd5b506102816105e3366004612964565b611562565b3480156105f457600080fd5b506103a7610603366004612916565b61162d565b34801561061457600080fd5b506106286106233660046128fd565b611786565b6040805182518152602092830151928101929092520161028d565b34801561064f57600080fd5b5061067761065e3660046128fd565b6005602052600090815260409020805460019091015482565b6040805192835260208301919091520161028d565b34801561069857600080fd5b506106ac6106a7366004612964565b611815565b60405161028d9190612ab5565b3480156106c557600080fd5b506103a76106d43660046128c1565b611938565b3480156106e557600080fd5b506102a96106f4366004612916565b6001600160a01b031660009081526006602052604090206002015490565b34801561071e57600080fd5b506103a761072d3660046128fd565b611dea565b34801561073e57600080fd5b5061075261074d366004612964565b611e08565b60405161028d9190612ac8565b34801561076b57600080fd5b5061028161077a366004612964565b611fad565b34801561078b57600080fd5b506103a761079a366004612b3d565b611fd6565b3480156107ab57600080fd5b506103a76107ba366004612bb7565b612093565b3480156107cb57600080fd5b506102a9600081565b3480156107e057600080fd5b506102a96107ef366004612964565b61212f565b34801561080057600080fd5b506102a961080f3660046128fd565b60076020526000908152604090205481565b34801561082d57600080fd5b506008546102a9565b34801561084257600080fd5b506103a7610851366004612be3565b6121fa565b34801561086257600080fd5b506103a7610871366004612964565b6122f4565b34801561088257600080fd5b5061036f6108913660046128fd565b612319565b3480156108a257600080fd5b506108b66108b1366004612916565b612391565b604080519415158552602085019390935291830152606082015260800161028d565b3480156108e457600080fd5b506002546102a9565b3480156108f957600080fd5b506102a96109083660046128fd565b612440565b60006001600160e01b03198216637965db0b60e01b148061093e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000600080516020612e9183398151915261095e816124f1565b600154604051630d4fc8b760e41b81526004810187905286916001600160a01b03169063d4fc8b709060240160206040518083038186803b1580156109a257600080fd5b505afa1580156109b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109da9190612c0d565b6109ff5760405162461bcd60e51b81526004016109f690612c2f565b60405180910390fd5b6001600160a01b038516600090815260066020908152604080832089845260040190915290205460ff16610a3857610a38868686611938565b348460005b6001600160a01b03821615801590610a56575060025481105b15610b74576001600160a01b03821660009081526006602090815260408083208c845260048101909252909120805460ff1615610b4e576000610a9a8c8634610f91565b6040519091506001600160a01b0386169082156108fc029083906000818181858888f19350505050158015610ad3573d6000803e3d6000fd5b50610ade8187612c7c565b6003840154909650610af090826124fe565b60038401556002820154610b0490826124fe565b600283015560038301546040519081526001600160a01b038616907f1885940a4fbe7f8ff305dc3bf0cec95b9fa33e6cc8254f35445509da9b6ca66e9060200160405180910390a2505b805461010090046001600160a01b0316935082610b6a81612c93565b9350505050610a3d565b5090979650505050505050565b600080516020612e91833981519152610b99816124f1565b600154604051630d4fc8b760e41b81526004810184905283916001600160a01b03169063d4fc8b709060240160206040518083038186803b158015610bdd57600080fd5b505afa158015610bf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c159190612c0d565b610c315760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038516610c875760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642072656665727265722061646472657373000000000000000060448201526064016109f6565b6004548410610cc75760405162461bcd60e51b815260206004820152600c60248201526b496e76616c69642072616e6b60a01b60448201526064016109f6565b6001600160a01b038516600090815260066020908152604080832086845260040190915290205460ff16610d3d5760405162461bcd60e51b815260206004820152601d60248201527f5265666572726572206e6f7420656e726f6c6c656420666f72204e465400000060448201526064016109f6565b6001600160a01b0385166000818152600660209081526040918290206001810188905591518781529192917f6d50a587edaa47fc975bbee0241bc331d0e00a6978f53e2e82fdf4b44ef54709910160405180910390a2505050505050565b600082815260208190526040902060010154610db6816124f1565b610dc08383612511565b505050565b60038281548110610dd557600080fd5b906000526020600020018181548110610ded57600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381163314610e725760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109f6565b610e7c8282612595565b5050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b158015610ec957600080fd5b505afa158015610edd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f019190612c0d565b610f1d5760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038316600090815260066020908152604080832087845260040190915290205460ff16610f635760405162461bcd60e51b81526004016109f690612cae565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052206001015490565b600154604051630d4fc8b760e41b81526004810185905260009185916001600160a01b039091169063d4fc8b709060240160206040518083038186803b158015610fda57600080fd5b505afa158015610fee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110129190612c0d565b61102e5760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038416600090815260066020908152604080832088845260048101909252909120805460ff166110775760405162461bcd60e51b81526004016109f690612cae565b6001808301549082015460038054600091908390811061109957611099612cf1565b9060005260206000200183815481106110b4576110b4612cf1565b600091825260208220015491506127106110ce838b612d07565b6110d89190612d26565b9b9a5050505050505050505050565b600981815481106110f757600080fd5b6000918252602090912001546001600160a01b0316905081565b600080516020612e91833981519152611129816124f1565b600154604051630d4fc8b760e41b81526004810185905284916001600160a01b03169063d4fc8b709060240160206040518083038186803b15801561116d57600080fd5b505afa158015611181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a59190612c0d565b6111c15760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b03831660009081526006602090815260408083208784526004019091529020548490849060ff161561120c5760405162461bcd60e51b81526004016109f690612d48565b6040518060c00160405280600115158152602001866001600160a01b03168152602001600081526020016000815260200160008152602001600067ffffffffffffffff81111561125e5761125e612b27565b604051908082528060200260200182016040528015611287578160200160208202803683370190505b5090526001600160a01b0386811660009081526006602090815260408083208b8452600490810183529281902085518154878501516001600160a81b0319909116911515610100600160a81b0319169190911761010091909616029490941784558401516001840155606084015160028401556080840151600384015560a0840151805161131c938501929190910190612801565b505050600086815260076020526040812080549161133983612c93565b90915550506008805490600061134e83612c93565b9091555050600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b03871690811790915560405181815287907f37f3f879b4204a02e8857f0cae55a12a21e3b64920ed77254cc283beab3960619060200160405180910390a3505050505050565b60606003805480602002602001604051908101604052809291908181526020016000905b8282101561146e5760008481526020908190208301805460408051828502810185019091528181529283018282801561145a57602002820191906000526020600020905b815481526020019060010190808311611446575b505050505081526020019060010190611402565b50505050905090565b60035460009083106114c05760405162461bcd60e51b81526020600482015260126024820152714c6576656c206f7574206f662072616e676560701b60448201526064016109f6565b600383815481106114d3576114d3612cf1565b60009182526020909120015482106115215760405162461bcd60e51b815260206004820152601160248201527052616e6b206f7574206f662072616e676560781b60448201526064016109f6565b6003838154811061153457611534612cf1565b90600052602060002001828154811061154f5761154f612cf1565b9060005260206000200154905092915050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b1580156115ab57600080fd5b505afa1580156115bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e39190612c0d565b6115ff5760405162461bcd60e51b81526004016109f690612c2f565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052205460ff1690565b600080516020612e91833981519152611645816124f1565b6001600160a01b03828116600090815260066020526040902054166116a75760405162461bcd60e51b81526020600482015260186024820152771059999a5b1a585d1948191bd95cc81b9bdd08195e1a5cdd60421b60448201526064016109f6565b6000806116b384612391565b505091509150816117145760405162461bcd60e51b815260206004820152602560248201527f416666696c69617465206973206e6f7420656c696769626c6520666f7220726160448201526406e6b2075760dc1b60648201526084016109f6565b61171f816001612d89565b6001600160a01b0385166000818152600660205260409020600190810192909255907f8faaf8a740886b7256ae887161e50e41b4d5c5969e5d0712d3cdb7464af5f54c9061176e908490612d89565b6040519081526020015b60405180910390a250505050565b604080518082019091526000808252602082015260045482106117eb5760405162461bcd60e51b815260206004820152601860248201527f52616e6b206e756d626572206f7574206f662072616e6765000000000000000060448201526064016109f6565b50600090815260056020908152604091829020825180840190935280548352600101549082015290565b600154604051630d4fc8b760e41b81526004810184905260609184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561185e57600080fd5b505afa158015611872573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118969190612c0d565b6118b25760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038316600090815260066020908152604080832087845260049081018352928190209092018054835181840281018401909452808452909183018282801561192a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161190c575b505050505091505092915050565b600080516020612e91833981519152611950816124f1565b600154604051630d4fc8b760e41b81526004810186905285916001600160a01b03169063d4fc8b709060240160206040518083038186803b15801561199457600080fd5b505afa1580156119a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cc9190612c0d565b6119e85760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b03841660009081526006602090815260408083208884526004019091529020548590859060ff1615611a335760405162461bcd60e51b81526004016109f690612d48565b6001600160a01b03851660009081526006602090815260408083208a84526004019091529020548790869060ff16611ac35760405162461bcd60e51b815260206004820152602d60248201527f5265666572726572206973206e6f7420616e20616666696c6961746520666f7260448201526c081d1a1a5cc81d1bdad95b9259609a1b60648201526084016109f6565b6001600160a01b0380891660009081526006602052604090208054909116611b145780546001600160a01b0319166001600160a01b0389161781556000600182018190556002820181905560038201555b6001600160a01b03881660009081526006602090815260408083208d845260040190915281206001908101549190611b4d908390612d89565b90506002548110611b5c575060005b6040805160c081018252600181526001600160a01b038c1660208201529081018290526000606082018190526080820181905260a0820190604051908082528060200260200182016040528015611bbd578160200160208202803683370190505b50905260008d81526004808601602090815260409283902084518154868401516001600160a01b031661010002610100600160a81b0319921515929092166001600160a81b031990911617178155928401516001840155606084015160028401556080840151600384015560a08401518051611c40938501929190910190612801565b50905050600660008b6001600160a01b03166001600160a01b0316815260200190815260200160002060040160008d81526020019081526020016000206004018b9080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b03160217905550611d036001600660008d6001600160a01b03166001600160a01b03168152602001908152602001600020600201546124fe90919063ffffffff16565b6001600160a01b038b166000908152600660209081526040808320600201939093558e825260079052908120805491611d3b83612c93565b909155505060088054906000611d5083612c93565b9091555050600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b038d8116918217909255604051918c168252908d907f37f3f879b4204a02e8857f0cae55a12a21e3b64920ed77254cc283beab3960619060200160405180910390a3505050505050505050505050565b600080516020612e91833981519152611e02816124f1565b50600255565b611e4c6040518060c0016040528060001515815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001606081525090565b600154604051630d4fc8b760e41b81526004810185905284916001600160a01b03169063d4fc8b709060240160206040518083038186803b158015611e9057600080fd5b505afa158015611ea4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec89190612c0d565b611ee45760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b0380841660009081526006602090815260408083208884526004908101835292819020815160c081018352815460ff8116151582526101009004909516858401526001810154858301526002810154606086015260038101546080860152928301805482518185028101850190935280835260a0860193830182828015611f9b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f7d575b50505050508152505091505092915050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020612e91833981519152611fee816124f1565b600454831061202e5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c69642072616e6b60a01b60448201526064016109f6565b60008381526005602090815260409182902084518082558583018051600190930192909255835190815290519181019190915284917f3c9a73a8ca75e074f16686cc978b200c7e30c347404e32c409379d9d7bdc057d910160405180910390a2505050565b600080516020612e918339815191526120ab816124f1565b81600385815481106120bf576120bf612cf1565b9060005260206000200184815481106120da576120da612cf1565b600091825260209182902001919091556040805186815291820185905281018390527faf77d62ba2ee4bf3fd0163a9867b75dca12d0eb5a6084a779a7224c02e7a26239060600160405180910390a150505050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b09190612c0d565b6121cc5760405162461bcd60e51b81526004016109f690612c2f565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052206002015490565b600080516020612e91833981519152612212816124f1565b6001600160a01b03838116600090815260066020526040902054166122745760405162461bcd60e51b81526020600482015260186024820152771059999a5b1a585d1948191bd95cc81b9bdd08195e1a5cdd60421b60448201526064016109f6565b6001600160a01b0383166000908152600660205260409020600381015461229b90846124fe565b6003808301919091556001600160a01b0385166000818152600660205260409081902090920154915190917f1885940a4fbe7f8ff305dc3bf0cec95b9fa33e6cc8254f35445509da9b6ca66e9161177891815260200190565b60008281526020819052604090206001015461230f816124f1565b610dc08383612595565b60095460009082106123635760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b60448201526064016109f6565b6009828154811061237657612376612cf1565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b03811660009081526006602052604081206001808201546004549092849283926123c29190612c7c565b84106123d8575060009350839150819050612439565b60006005816123e8876001612d89565b8152602080820192909252604090810160002081518083019092528054808352600190910154928201839052600285015490965091945091508411801590612434575082826003015410155b955050505b9193509193565b600154604051630d4fc8b760e41b81526004810183905260009183916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561248957600080fd5b505afa15801561249d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c19190612c0d565b6124dd5760405162461bcd60e51b81526004016109f690612c2f565b505060009081526007602052604090205490565b6124fb81336125fa565b50565b600061250a8284612d89565b9392505050565b61251b8282611fad565b610e7c576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556125513390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61259f8282611fad565b15610e7c576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6126048282611fad565b610e7c5761261181612653565b61261c836020612665565b60405160200161262d929190612dd1565b60408051601f198184030181529082905262461bcd60e51b82526109f691600401612e46565b606061093e6001600160a01b03831660145b60606000612674836002612d07565b61267f906002612d89565b67ffffffffffffffff81111561269757612697612b27565b6040519080825280601f01601f1916602001820160405280156126c1576020820181803683370190505b509050600360fc1b816000815181106126dc576126dc612cf1565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061270b5761270b612cf1565b60200101906001600160f81b031916908160001a905350600061272f846002612d07565b61273a906001612d89565b90505b60018111156127b2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061276e5761276e612cf1565b1a60f81b82828151811061278457612784612cf1565b60200101906001600160f81b031916908160001a90535060049490941c936127ab81612e79565b905061273d565b50831561250a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109f6565b828054828255906000526020600020908101928215612856579160200282015b8281111561285657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612821565b50612862929150612866565b5090565b5b808211156128625760008155600101612867565b60006020828403121561288d57600080fd5b81356001600160e01b03198116811461250a57600080fd5b80356001600160a01b03811681146128bc57600080fd5b919050565b6000806000606084860312156128d657600080fd5b833592506128e6602085016128a5565b91506128f4604085016128a5565b90509250925092565b60006020828403121561290f57600080fd5b5035919050565b60006020828403121561292857600080fd5b61250a826128a5565b60008060006060848603121561294657600080fd5b61294f846128a5565b95602085013595506040909401359392505050565b6000806040838503121561297757600080fd5b82359150612987602084016128a5565b90509250929050565b600080604083850312156129a357600080fd5b50508035926020909101359150565b6000806000606084860312156129c757600080fd5b833592506129d7602085016128a5565b9150604084013590509250925092565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b83811015612a6357888603603f19018552825180518088529088019088880190845b81811015612a4d5783518352928a0192918a0191600101612a31565b5090975050509386019391860191600101612a0f565b509398975050505050505050565b600081518084526020808501945080840160005b83811015612aaa5781516001600160a01b031687529582019590820190600101612a85565b509495945050505050565b60208152600061250a6020830184612a71565b6020815281511515602082015260018060a01b0360208301511660408201526040820151606082015260608201516080820152608082015160a0820152600060a083015160c080840152612b1f60e0840182612a71565b949350505050565b634e487b7160e01b600052604160045260246000fd5b6000808284036060811215612b5157600080fd5b833592506040601f1982011215612b6757600080fd5b506040516040810181811067ffffffffffffffff82111715612b9957634e487b7160e01b600052604160045260246000fd5b60409081526020858101358352940135938101939093525092909150565b600080600060608486031215612bcc57600080fd5b505081359360208301359350604090920135919050565b60008060408385031215612bf657600080fd5b612bff836128a5565b946020939093013593505050565b600060208284031215612c1f57600080fd5b8151801515811461250a57600080fd5b60208082526018908201527f4f626a656374206973206e6f7420726567697374657265640000000000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015612c8e57612c8e612c66565b500390565b6000600019821415612ca757612ca7612c66565b5060010190565b60208082526023908201527f416666696c69617465206e6f7420656e726f6c6c656420666f7220746869732060408201526213919560ea1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000816000190483118215151615612d2157612d21612c66565b500290565b600082612d4357634e487b7160e01b600052601260045260246000fd5b500490565b60208082526021908201527f416c726561647920616e20616666696c6961746520666f722074686973204e466040820152601560fa1b606082015260800190565b60008219821115612d9c57612d9c612c66565b500190565b60005b83811015612dbc578181015183820152602001612da4565b83811115612dcb576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612e09816017850160208801612da1565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612e3a816028840160208801612da1565b01602801949350505050565b6020815260008251806020840152612e65816040850160208701612da1565b601f01601f19169190910160400192915050565b600081612e8857612e88612c66565b50600019019056fe435269160f073040285d1afaa3d9dbd1dbcaa4ff2aa674d3b9d65359d97fa414a264697066735822122096686bf0197b3a5d12096162ce7a195257156a666bb3a5ceee5ac2dcc292b39764736f6c6343000809003300000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000500000000000000000000000011ba0f6a6fd2b7fe3cb953262c55e44af96c8ded000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000041a000000000000000000000000000000000000000000000000000000000000044c000000000000000000000000000000000000000000000000000000000000047e00000000000000000000000000000000000000000000000000000000000004b0000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000352000000000000000000000000000000000000000000000000000000000000038400000000000000000000000000000000000000000000000000000000000003b600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000258000000000000000000000000000000000000000000000000000000000000028a00000000000000000000000000000000000000000000000000000000000002bc00000000000000000000000000000000000000000000000000000000000002ee00000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000002260000000000000000000000000000000000000000000000000000000000000258000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000015e0000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000015af1d78b58c40000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000340aad21b3b700000000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000068155a43676e00000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000d8d726b7177a800000000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000015af1d78b58c400000
Deployed Bytecode
0x60806040526004361061025c5760003560e01c8063695b299a1161014457806395d0ca54116100b6578063d33bcc4a1161007a578063d33bcc4a14610836578063d547741f14610856578063d9c7221c14610876578063db5568b614610896578063e031471f146108d8578063fd1c98cd146108ed57600080fd5b806395d0ca541461079f578063a217fddf146107bf578063a68e5659146107d4578063ad6473de146107f4578063b94063131461082157600080fd5b80637df15655116101085780637df15655146106b957806387007c60146106d95780638b6863fb146107125780638fa44dc11461073257806391d148541461075f5780639356d6671461077f57600080fd5b8063695b299a146105c85780636f8bd036146105e857806375d779721461060857806376290905146106435780637ab35a6d1461068c57600080fd5b80633b7c362c116101dd578063468f9fd1116101a1578063468f9fd1146104a157806348f4fcd8146104c15780634f51e294146104e357806357eddb8814610559578063609a233d14610592578063647bea4f146105a857600080fd5b80633b7c362c146104095780633ca78f84146104295780633eb3b9d7146104495780633fb8b6921461045f578063409749111461047f57600080fd5b80632771fc1a116102245780632771fc1a1461033657806328777e49146103875780632f2ff15d146103a957806331a50227146103c957806336568abe146103e957600080fd5b806301ffc9a71461026157806305c32cbf14610296578063143117e1146102b7578063248a9ca3146102cd578063272e974f146102fd575b600080fd5b34801561026d57600080fd5b5061028161027c36600461287b565b61090d565b60405190151581526020015b60405180910390f35b6102a96102a43660046128c1565b610944565b60405190815260200161028d565b3480156102c357600080fd5b506102a960025481565b3480156102d957600080fd5b506102a96102e83660046128fd565b60009081526020819052604090206001015490565b34801561030957600080fd5b506102a9610318366004612916565b6001600160a01b031660009081526006602052604090206003015490565b34801561034257600080fd5b5061036f610351366004612916565b6001600160a01b039081166000908152600660205260409020541690565b6040516001600160a01b03909116815260200161028d565b34801561039357600080fd5b506103a76103a2366004612931565b610b81565b005b3480156103b557600080fd5b506103a76103c4366004612964565b610d9b565b3480156103d557600080fd5b506102a96103e4366004612990565b610dc5565b3480156103f557600080fd5b506103a7610404366004612964565b610e02565b34801561041557600080fd5b506102a9610424366004612964565b610e80565b34801561043557600080fd5b506102a96104443660046129b2565b610f91565b34801561045557600080fd5b506102a960085481565b34801561046b57600080fd5b5061036f61047a3660046128fd565b6110e7565b34801561048b57600080fd5b506102a9600080516020612e9183398151915281565b3480156104ad57600080fd5b506103a76104bc366004612964565b611111565b3480156104cd57600080fd5b506104d66113de565b60405161028d91906129e7565b3480156104ef57600080fd5b5061052f6104fe366004612916565b60066020526000908152604090208054600182015460028301546003909301546001600160a01b0390921692909184565b604080516001600160a01b039095168552602085019390935291830152606082015260800161028d565b34801561056557600080fd5b506102a9610574366004612916565b6001600160a01b031660009081526006602052604090206001015490565b34801561059e57600080fd5b506102a960045481565b3480156105b457600080fd5b506102a96105c3366004612990565b611477565b3480156105d457600080fd5b506102816105e3366004612964565b611562565b3480156105f457600080fd5b506103a7610603366004612916565b61162d565b34801561061457600080fd5b506106286106233660046128fd565b611786565b6040805182518152602092830151928101929092520161028d565b34801561064f57600080fd5b5061067761065e3660046128fd565b6005602052600090815260409020805460019091015482565b6040805192835260208301919091520161028d565b34801561069857600080fd5b506106ac6106a7366004612964565b611815565b60405161028d9190612ab5565b3480156106c557600080fd5b506103a76106d43660046128c1565b611938565b3480156106e557600080fd5b506102a96106f4366004612916565b6001600160a01b031660009081526006602052604090206002015490565b34801561071e57600080fd5b506103a761072d3660046128fd565b611dea565b34801561073e57600080fd5b5061075261074d366004612964565b611e08565b60405161028d9190612ac8565b34801561076b57600080fd5b5061028161077a366004612964565b611fad565b34801561078b57600080fd5b506103a761079a366004612b3d565b611fd6565b3480156107ab57600080fd5b506103a76107ba366004612bb7565b612093565b3480156107cb57600080fd5b506102a9600081565b3480156107e057600080fd5b506102a96107ef366004612964565b61212f565b34801561080057600080fd5b506102a961080f3660046128fd565b60076020526000908152604090205481565b34801561082d57600080fd5b506008546102a9565b34801561084257600080fd5b506103a7610851366004612be3565b6121fa565b34801561086257600080fd5b506103a7610871366004612964565b6122f4565b34801561088257600080fd5b5061036f6108913660046128fd565b612319565b3480156108a257600080fd5b506108b66108b1366004612916565b612391565b604080519415158552602085019390935291830152606082015260800161028d565b3480156108e457600080fd5b506002546102a9565b3480156108f957600080fd5b506102a96109083660046128fd565b612440565b60006001600160e01b03198216637965db0b60e01b148061093e57506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000600080516020612e9183398151915261095e816124f1565b600154604051630d4fc8b760e41b81526004810187905286916001600160a01b03169063d4fc8b709060240160206040518083038186803b1580156109a257600080fd5b505afa1580156109b6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109da9190612c0d565b6109ff5760405162461bcd60e51b81526004016109f690612c2f565b60405180910390fd5b6001600160a01b038516600090815260066020908152604080832089845260040190915290205460ff16610a3857610a38868686611938565b348460005b6001600160a01b03821615801590610a56575060025481105b15610b74576001600160a01b03821660009081526006602090815260408083208c845260048101909252909120805460ff1615610b4e576000610a9a8c8634610f91565b6040519091506001600160a01b0386169082156108fc029083906000818181858888f19350505050158015610ad3573d6000803e3d6000fd5b50610ade8187612c7c565b6003840154909650610af090826124fe565b60038401556002820154610b0490826124fe565b600283015560038301546040519081526001600160a01b038616907f1885940a4fbe7f8ff305dc3bf0cec95b9fa33e6cc8254f35445509da9b6ca66e9060200160405180910390a2505b805461010090046001600160a01b0316935082610b6a81612c93565b9350505050610a3d565b5090979650505050505050565b600080516020612e91833981519152610b99816124f1565b600154604051630d4fc8b760e41b81526004810184905283916001600160a01b03169063d4fc8b709060240160206040518083038186803b158015610bdd57600080fd5b505afa158015610bf1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c159190612c0d565b610c315760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038516610c875760405162461bcd60e51b815260206004820152601860248201527f496e76616c69642072656665727265722061646472657373000000000000000060448201526064016109f6565b6004548410610cc75760405162461bcd60e51b815260206004820152600c60248201526b496e76616c69642072616e6b60a01b60448201526064016109f6565b6001600160a01b038516600090815260066020908152604080832086845260040190915290205460ff16610d3d5760405162461bcd60e51b815260206004820152601d60248201527f5265666572726572206e6f7420656e726f6c6c656420666f72204e465400000060448201526064016109f6565b6001600160a01b0385166000818152600660209081526040918290206001810188905591518781529192917f6d50a587edaa47fc975bbee0241bc331d0e00a6978f53e2e82fdf4b44ef54709910160405180910390a2505050505050565b600082815260208190526040902060010154610db6816124f1565b610dc08383612511565b505050565b60038281548110610dd557600080fd5b906000526020600020018181548110610ded57600080fd5b90600052602060002001600091509150505481565b6001600160a01b0381163314610e725760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016109f6565b610e7c8282612595565b5050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b158015610ec957600080fd5b505afa158015610edd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f019190612c0d565b610f1d5760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038316600090815260066020908152604080832087845260040190915290205460ff16610f635760405162461bcd60e51b81526004016109f690612cae565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052206001015490565b600154604051630d4fc8b760e41b81526004810185905260009185916001600160a01b039091169063d4fc8b709060240160206040518083038186803b158015610fda57600080fd5b505afa158015610fee573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110129190612c0d565b61102e5760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038416600090815260066020908152604080832088845260048101909252909120805460ff166110775760405162461bcd60e51b81526004016109f690612cae565b6001808301549082015460038054600091908390811061109957611099612cf1565b9060005260206000200183815481106110b4576110b4612cf1565b600091825260208220015491506127106110ce838b612d07565b6110d89190612d26565b9b9a5050505050505050505050565b600981815481106110f757600080fd5b6000918252602090912001546001600160a01b0316905081565b600080516020612e91833981519152611129816124f1565b600154604051630d4fc8b760e41b81526004810185905284916001600160a01b03169063d4fc8b709060240160206040518083038186803b15801561116d57600080fd5b505afa158015611181573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111a59190612c0d565b6111c15760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b03831660009081526006602090815260408083208784526004019091529020548490849060ff161561120c5760405162461bcd60e51b81526004016109f690612d48565b6040518060c00160405280600115158152602001866001600160a01b03168152602001600081526020016000815260200160008152602001600067ffffffffffffffff81111561125e5761125e612b27565b604051908082528060200260200182016040528015611287578160200160208202803683370190505b5090526001600160a01b0386811660009081526006602090815260408083208b8452600490810183529281902085518154878501516001600160a81b0319909116911515610100600160a81b0319169190911761010091909616029490941784558401516001840155606084015160028401556080840151600384015560a0840151805161131c938501929190910190612801565b505050600086815260076020526040812080549161133983612c93565b90915550506008805490600061134e83612c93565b9091555050600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b03871690811790915560405181815287907f37f3f879b4204a02e8857f0cae55a12a21e3b64920ed77254cc283beab3960619060200160405180910390a3505050505050565b60606003805480602002602001604051908101604052809291908181526020016000905b8282101561146e5760008481526020908190208301805460408051828502810185019091528181529283018282801561145a57602002820191906000526020600020905b815481526020019060010190808311611446575b505050505081526020019060010190611402565b50505050905090565b60035460009083106114c05760405162461bcd60e51b81526020600482015260126024820152714c6576656c206f7574206f662072616e676560701b60448201526064016109f6565b600383815481106114d3576114d3612cf1565b60009182526020909120015482106115215760405162461bcd60e51b815260206004820152601160248201527052616e6b206f7574206f662072616e676560781b60448201526064016109f6565b6003838154811061153457611534612cf1565b90600052602060002001828154811061154f5761154f612cf1565b9060005260206000200154905092915050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b1580156115ab57600080fd5b505afa1580156115bf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e39190612c0d565b6115ff5760405162461bcd60e51b81526004016109f690612c2f565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052205460ff1690565b600080516020612e91833981519152611645816124f1565b6001600160a01b03828116600090815260066020526040902054166116a75760405162461bcd60e51b81526020600482015260186024820152771059999a5b1a585d1948191bd95cc81b9bdd08195e1a5cdd60421b60448201526064016109f6565b6000806116b384612391565b505091509150816117145760405162461bcd60e51b815260206004820152602560248201527f416666696c69617465206973206e6f7420656c696769626c6520666f7220726160448201526406e6b2075760dc1b60648201526084016109f6565b61171f816001612d89565b6001600160a01b0385166000818152600660205260409020600190810192909255907f8faaf8a740886b7256ae887161e50e41b4d5c5969e5d0712d3cdb7464af5f54c9061176e908490612d89565b6040519081526020015b60405180910390a250505050565b604080518082019091526000808252602082015260045482106117eb5760405162461bcd60e51b815260206004820152601860248201527f52616e6b206e756d626572206f7574206f662072616e6765000000000000000060448201526064016109f6565b50600090815260056020908152604091829020825180840190935280548352600101549082015290565b600154604051630d4fc8b760e41b81526004810184905260609184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561185e57600080fd5b505afa158015611872573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118969190612c0d565b6118b25760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b038316600090815260066020908152604080832087845260049081018352928190209092018054835181840281018401909452808452909183018282801561192a57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161190c575b505050505091505092915050565b600080516020612e91833981519152611950816124f1565b600154604051630d4fc8b760e41b81526004810186905285916001600160a01b03169063d4fc8b709060240160206040518083038186803b15801561199457600080fd5b505afa1580156119a8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119cc9190612c0d565b6119e85760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b03841660009081526006602090815260408083208884526004019091529020548590859060ff1615611a335760405162461bcd60e51b81526004016109f690612d48565b6001600160a01b03851660009081526006602090815260408083208a84526004019091529020548790869060ff16611ac35760405162461bcd60e51b815260206004820152602d60248201527f5265666572726572206973206e6f7420616e20616666696c6961746520666f7260448201526c081d1a1a5cc81d1bdad95b9259609a1b60648201526084016109f6565b6001600160a01b0380891660009081526006602052604090208054909116611b145780546001600160a01b0319166001600160a01b0389161781556000600182018190556002820181905560038201555b6001600160a01b03881660009081526006602090815260408083208d845260040190915281206001908101549190611b4d908390612d89565b90506002548110611b5c575060005b6040805160c081018252600181526001600160a01b038c1660208201529081018290526000606082018190526080820181905260a0820190604051908082528060200260200182016040528015611bbd578160200160208202803683370190505b50905260008d81526004808601602090815260409283902084518154868401516001600160a01b031661010002610100600160a81b0319921515929092166001600160a81b031990911617178155928401516001840155606084015160028401556080840151600384015560a08401518051611c40938501929190910190612801565b50905050600660008b6001600160a01b03166001600160a01b0316815260200190815260200160002060040160008d81526020019081526020016000206004018b9080600181540180825580915050600190039060005260206000200160009091909190916101000a8154816001600160a01b0302191690836001600160a01b03160217905550611d036001600660008d6001600160a01b03166001600160a01b03168152602001908152602001600020600201546124fe90919063ffffffff16565b6001600160a01b038b166000908152600660209081526040808320600201939093558e825260079052908120805491611d3b83612c93565b909155505060088054906000611d5083612c93565b9091555050600980546001810182556000919091527f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0180546001600160a01b0319166001600160a01b038d8116918217909255604051918c168252908d907f37f3f879b4204a02e8857f0cae55a12a21e3b64920ed77254cc283beab3960619060200160405180910390a3505050505050505050505050565b600080516020612e91833981519152611e02816124f1565b50600255565b611e4c6040518060c0016040528060001515815260200160006001600160a01b03168152602001600081526020016000815260200160008152602001606081525090565b600154604051630d4fc8b760e41b81526004810185905284916001600160a01b03169063d4fc8b709060240160206040518083038186803b158015611e9057600080fd5b505afa158015611ea4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ec89190612c0d565b611ee45760405162461bcd60e51b81526004016109f690612c2f565b6001600160a01b0380841660009081526006602090815260408083208884526004908101835292819020815160c081018352815460ff8116151582526101009004909516858401526001810154858301526002810154606086015260038101546080860152928301805482518185028101850190935280835260a0860193830182828015611f9b57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611f7d575b50505050508152505091505092915050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b600080516020612e91833981519152611fee816124f1565b600454831061202e5760405162461bcd60e51b815260206004820152600c60248201526b496e76616c69642072616e6b60a01b60448201526064016109f6565b60008381526005602090815260409182902084518082558583018051600190930192909255835190815290519181019190915284917f3c9a73a8ca75e074f16686cc978b200c7e30c347404e32c409379d9d7bdc057d910160405180910390a2505050565b600080516020612e918339815191526120ab816124f1565b81600385815481106120bf576120bf612cf1565b9060005260206000200184815481106120da576120da612cf1565b600091825260209182902001919091556040805186815291820185905281018390527faf77d62ba2ee4bf3fd0163a9867b75dca12d0eb5a6084a779a7224c02e7a26239060600160405180910390a150505050565b600154604051630d4fc8b760e41b81526004810184905260009184916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561217857600080fd5b505afa15801561218c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121b09190612c0d565b6121cc5760405162461bcd60e51b81526004016109f690612c2f565b50506001600160a01b0316600090815260066020908152604080832093835260049093019052206002015490565b600080516020612e91833981519152612212816124f1565b6001600160a01b03838116600090815260066020526040902054166122745760405162461bcd60e51b81526020600482015260186024820152771059999a5b1a585d1948191bd95cc81b9bdd08195e1a5cdd60421b60448201526064016109f6565b6001600160a01b0383166000908152600660205260409020600381015461229b90846124fe565b6003808301919091556001600160a01b0385166000818152600660205260409081902090920154915190917f1885940a4fbe7f8ff305dc3bf0cec95b9fa33e6cc8254f35445509da9b6ca66e9161177891815260200190565b60008281526020819052604090206001015461230f816124f1565b610dc08383612595565b60095460009082106123635760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b60448201526064016109f6565b6009828154811061237657612376612cf1565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b03811660009081526006602052604081206001808201546004549092849283926123c29190612c7c565b84106123d8575060009350839150819050612439565b60006005816123e8876001612d89565b8152602080820192909252604090810160002081518083019092528054808352600190910154928201839052600285015490965091945091508411801590612434575082826003015410155b955050505b9193509193565b600154604051630d4fc8b760e41b81526004810183905260009183916001600160a01b039091169063d4fc8b709060240160206040518083038186803b15801561248957600080fd5b505afa15801561249d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c19190612c0d565b6124dd5760405162461bcd60e51b81526004016109f690612c2f565b505060009081526007602052604090205490565b6124fb81336125fa565b50565b600061250a8284612d89565b9392505050565b61251b8282611fad565b610e7c576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556125513390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b61259f8282611fad565b15610e7c576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6126048282611fad565b610e7c5761261181612653565b61261c836020612665565b60405160200161262d929190612dd1565b60408051601f198184030181529082905262461bcd60e51b82526109f691600401612e46565b606061093e6001600160a01b03831660145b60606000612674836002612d07565b61267f906002612d89565b67ffffffffffffffff81111561269757612697612b27565b6040519080825280601f01601f1916602001820160405280156126c1576020820181803683370190505b509050600360fc1b816000815181106126dc576126dc612cf1565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061270b5761270b612cf1565b60200101906001600160f81b031916908160001a905350600061272f846002612d07565b61273a906001612d89565b90505b60018111156127b2576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061276e5761276e612cf1565b1a60f81b82828151811061278457612784612cf1565b60200101906001600160f81b031916908160001a90535060049490941c936127ab81612e79565b905061273d565b50831561250a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016109f6565b828054828255906000526020600020908101928215612856579160200282015b8281111561285657825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190612821565b50612862929150612866565b5090565b5b808211156128625760008155600101612867565b60006020828403121561288d57600080fd5b81356001600160e01b03198116811461250a57600080fd5b80356001600160a01b03811681146128bc57600080fd5b919050565b6000806000606084860312156128d657600080fd5b833592506128e6602085016128a5565b91506128f4604085016128a5565b90509250925092565b60006020828403121561290f57600080fd5b5035919050565b60006020828403121561292857600080fd5b61250a826128a5565b60008060006060848603121561294657600080fd5b61294f846128a5565b95602085013595506040909401359392505050565b6000806040838503121561297757600080fd5b82359150612987602084016128a5565b90509250929050565b600080604083850312156129a357600080fd5b50508035926020909101359150565b6000806000606084860312156129c757600080fd5b833592506129d7602085016128a5565b9150604084013590509250925092565b6000602080830181845280855180835260408601915060408160051b87010192508387016000805b83811015612a6357888603603f19018552825180518088529088019088880190845b81811015612a4d5783518352928a0192918a0191600101612a31565b5090975050509386019391860191600101612a0f565b509398975050505050505050565b600081518084526020808501945080840160005b83811015612aaa5781516001600160a01b031687529582019590820190600101612a85565b509495945050505050565b60208152600061250a6020830184612a71565b6020815281511515602082015260018060a01b0360208301511660408201526040820151606082015260608201516080820152608082015160a0820152600060a083015160c080840152612b1f60e0840182612a71565b949350505050565b634e487b7160e01b600052604160045260246000fd5b6000808284036060811215612b5157600080fd5b833592506040601f1982011215612b6757600080fd5b506040516040810181811067ffffffffffffffff82111715612b9957634e487b7160e01b600052604160045260246000fd5b60409081526020858101358352940135938101939093525092909150565b600080600060608486031215612bcc57600080fd5b505081359360208301359350604090920135919050565b60008060408385031215612bf657600080fd5b612bff836128a5565b946020939093013593505050565b600060208284031215612c1f57600080fd5b8151801515811461250a57600080fd5b60208082526018908201527f4f626a656374206973206e6f7420726567697374657265640000000000000000604082015260600190565b634e487b7160e01b600052601160045260246000fd5b600082821015612c8e57612c8e612c66565b500390565b6000600019821415612ca757612ca7612c66565b5060010190565b60208082526023908201527f416666696c69617465206e6f7420656e726f6c6c656420666f7220746869732060408201526213919560ea1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b6000816000190483118215151615612d2157612d21612c66565b500290565b600082612d4357634e487b7160e01b600052601260045260246000fd5b500490565b60208082526021908201527f416c726561647920616e20616666696c6961746520666f722074686973204e466040820152601560fa1b606082015260800190565b60008219821115612d9c57612d9c612c66565b500190565b60005b83811015612dbc578181015183820152602001612da4565b83811115612dcb576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351612e09816017850160208801612da1565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612e3a816028840160208801612da1565b01602801949350505050565b6020815260008251806020840152612e65816040850160208701612da1565b601f01601f19169190910160400192915050565b600081612e8857612e88612c66565b50600019019056fe435269160f073040285d1afaa3d9dbd1dbcaa4ff2aa674d3b9d65359d97fa414a264697066735822122096686bf0197b3a5d12096162ce7a195257156a666bb3a5ceee5ac2dcc292b39764736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000000500000000000000000000000011ba0f6a6fd2b7fe3cb953262c55e44af96c8ded000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000041a000000000000000000000000000000000000000000000000000000000000044c000000000000000000000000000000000000000000000000000000000000047e00000000000000000000000000000000000000000000000000000000000004b0000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000352000000000000000000000000000000000000000000000000000000000000038400000000000000000000000000000000000000000000000000000000000003b600000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000258000000000000000000000000000000000000000000000000000000000000028a00000000000000000000000000000000000000000000000000000000000002bc00000000000000000000000000000000000000000000000000000000000002ee00000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000005000000000000000000000000000000000000000000000000000000000000019000000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000000000000000000002260000000000000000000000000000000000000000000000000000000000000258000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000c800000000000000000000000000000000000000000000000000000000000000fa000000000000000000000000000000000000000000000000000000000000012c000000000000000000000000000000000000000000000000000000000000015e0000000000000000000000000000000000000000000000000000000000000190000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000015af1d78b58c40000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000340aad21b3b700000000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000068155a43676e00000000000000000000000000000000000000000000000000000000000000000001e00000000000000000000000000000000000000000000000d8d726b7177a800000000000000000000000000000000000000000000000000000000000000000032000000000000000000000000000000000000000000000015af1d78b58c400000
-----Decoded View---------------
Arg [0] : _referralRewardBasisPoints (uint256[][]): System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger],System.Collections.Generic.List`1[System.Numerics.BigInteger]
Arg [1] : _rankCriterias (tuple[]): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput],System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [2] : _maxDepth (uint256): 5
Arg [3] : _ticketRegistryAddress (address): 0x11Ba0f6A6Fd2b7FE3Cb953262C55e44af96C8deD
-----Encoded View---------------
51 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000500
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [3] : 00000000000000000000000011ba0f6a6fd2b7fe3cb953262c55e44af96c8ded
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [5] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [6] : 0000000000000000000000000000000000000000000000000000000000000160
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000220
Arg [8] : 00000000000000000000000000000000000000000000000000000000000002e0
Arg [9] : 00000000000000000000000000000000000000000000000000000000000003a0
Arg [10] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [11] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [12] : 000000000000000000000000000000000000000000000000000000000000041a
Arg [13] : 000000000000000000000000000000000000000000000000000000000000044c
Arg [14] : 000000000000000000000000000000000000000000000000000000000000047e
Arg [15] : 00000000000000000000000000000000000000000000000000000000000004b0
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [18] : 0000000000000000000000000000000000000000000000000000000000000352
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000384
Arg [20] : 00000000000000000000000000000000000000000000000000000000000003b6
Arg [21] : 00000000000000000000000000000000000000000000000000000000000003e8
Arg [22] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [23] : 0000000000000000000000000000000000000000000000000000000000000258
Arg [24] : 000000000000000000000000000000000000000000000000000000000000028a
Arg [25] : 00000000000000000000000000000000000000000000000000000000000002bc
Arg [26] : 00000000000000000000000000000000000000000000000000000000000002ee
Arg [27] : 0000000000000000000000000000000000000000000000000000000000000320
Arg [28] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [29] : 0000000000000000000000000000000000000000000000000000000000000190
Arg [30] : 00000000000000000000000000000000000000000000000000000000000001c2
Arg [31] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [32] : 0000000000000000000000000000000000000000000000000000000000000226
Arg [33] : 0000000000000000000000000000000000000000000000000000000000000258
Arg [34] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [35] : 00000000000000000000000000000000000000000000000000000000000000c8
Arg [36] : 00000000000000000000000000000000000000000000000000000000000000fa
Arg [37] : 000000000000000000000000000000000000000000000000000000000000012c
Arg [38] : 000000000000000000000000000000000000000000000000000000000000015e
Arg [39] : 0000000000000000000000000000000000000000000000000000000000000190
Arg [40] : 0000000000000000000000000000000000000000000000000000000000000005
Arg [41] : 0000000000000000000000000000000000000000000000000000000000000003
Arg [42] : 0000000000000000000000000000000000000000000000015af1d78b58c40000
Arg [43] : 0000000000000000000000000000000000000000000000000000000000000007
Arg [44] : 00000000000000000000000000000000000000000000000340aad21b3b700000
Arg [45] : 000000000000000000000000000000000000000000000000000000000000000f
Arg [46] : 0000000000000000000000000000000000000000000000068155a43676e00000
Arg [47] : 000000000000000000000000000000000000000000000000000000000000001e
Arg [48] : 00000000000000000000000000000000000000000000000d8d726b7177a80000
Arg [49] : 0000000000000000000000000000000000000000000000000000000000000032
Arg [50] : 000000000000000000000000000000000000000000000015af1d78b58c400000
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.