Overview
APE Balance
APE Value
$0.00More Info
Private Name Tags
ContractCreator
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
NFTStats
Compiler Version
v0.8.23+commit.f704f362
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "./interfaces/INFTStats.sol"; import "./interfaces/ICollectionRegistry.sol"; /// @title NFTStats /// @notice Manages individual NFT stats, experience, and leveling contract NFTStats is INFTStats, Ownable { // Reference to the collection registry ICollectionRegistry public immutable collectionRegistry; // Mapping from collection address and token ID to its stats mapping(address => mapping(uint256 => NFTStatsData)) private nftStats; // Constants for XP and leveling uint256 private constant BASE_XP_PER_LEVEL = 100; uint256 private constant XP_MULTIPLIER = 150; // 150% increase per level uint256 private constant BASE_STAT_INCREASE_PERCENT = 5; // 5% increase per level uint256 private constant STARTING_LEVEL = 1; // Authorized contracts that can modify stats mapping(address => bool) private authorizedContracts; modifier onlyAuthorized() { require(msg.sender == owner() || authorizedContracts[msg.sender], "Not authorized"); _; } constructor(address _collectionRegistry) Ownable() { require(_collectionRegistry != address(0), "Invalid registry address"); collectionRegistry = ICollectionRegistry(_collectionRegistry); } /// @notice Set authorization for a contract to modify stats /// @param contract_ Address of the contract /// @param authorized Whether the contract should be authorized function setContractAuthorization(address contract_, bool authorized) external onlyOwner { require(contract_ != address(0), "Invalid contract address"); authorizedContracts[contract_] = authorized; } /// @notice Initialize stats for an NFT based on its collection's base stats /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT function initializeStats(address collection, uint256 tokenId) external onlyAuthorized { require(!nftStats[collection][tokenId].initialized, "Stats already initialized"); require(collectionRegistry.isWhitelisted(collection), "Collection not whitelisted"); // Verify NFT ownership try IERC721(collection).ownerOf(tokenId) returns (address) { // NFT exists, proceed with initialization } catch { revert("NFT does not exist"); } // Get base stats from collection registry ICollectionRegistry.CollectionStats memory baseStats = collectionRegistry.getCollectionStats(collection); // Initialize NFT stats nftStats[collection][tokenId] = NFTStatsData({ hp: baseStats.baseHp, attack: baseStats.baseAttack, speed: baseStats.baseSpeed, level: STARTING_LEVEL, currentXP: 0, xpToNextLevel: getXPForNextLevel(STARTING_LEVEL), dungeonRuns: 0, successfulRuns: 0, roomsCleared: 0, initialized: true }); emit StatsInitialized(collection, tokenId, baseStats.baseHp, baseStats.baseAttack, baseStats.baseSpeed); } /// @notice Award XP for dungeon progress /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @param xpAmount Amount of XP to award /// @param roomsCleared Number of rooms cleared in this run function awardXP( address collection, uint256 tokenId, uint256 xpAmount, uint256 roomsCleared ) external onlyAuthorized { require(nftStats[collection][tokenId].initialized, "Stats not initialized"); NFTStatsData storage stats = nftStats[collection][tokenId]; // Single storage update for XP uint256 newXP = stats.currentXP + xpAmount; stats.currentXP = newXP; stats.roomsCleared += roomsCleared; emit XPGained(collection, tokenId, xpAmount, newXP); } /// @notice Process pending level ups for a character /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT function levelUp( address collection, uint256 tokenId ) external { require(nftStats[collection][tokenId].initialized, "Stats not initialized"); NFTStatsData storage stats = nftStats[collection][tokenId]; uint256 currentXP = stats.currentXP; uint256 xpToNextLevel = stats.xpToNextLevel; uint256 currentLevel = stats.level; require(currentXP >= xpToNextLevel, "Insufficient XP"); // Calculate all level ups at once uint256 statMultiplier = 0; while (currentXP >= xpToNextLevel) { currentXP -= xpToNextLevel; currentLevel++; statMultiplier++; xpToNextLevel = getXPForNextLevel(currentLevel); } // Get base stats once uint256 baseHP = stats.hp; uint256 baseAttack = stats.attack; uint256 baseSpeed = stats.speed; // Calculate total stat increases uint256 totalHPIncrease = (baseHP * BASE_STAT_INCREASE_PERCENT * statMultiplier) / 100; uint256 totalAttackIncrease = (baseAttack * BASE_STAT_INCREASE_PERCENT * statMultiplier) / 100; uint256 totalSpeedIncrease = (baseSpeed * BASE_STAT_INCREASE_PERCENT * statMultiplier) / 100; // Apply all updates in one SSTORE each stats.hp = baseHP + totalHPIncrease; stats.attack = baseAttack + totalAttackIncrease; stats.speed = baseSpeed + totalSpeedIncrease; stats.level = currentLevel; stats.xpToNextLevel = xpToNextLevel; stats.currentXP = currentXP; emit LevelUp(collection, tokenId, stats.level); } /// @notice Record a dungeon run attempt /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @param success Whether the run was successful function recordRun( address collection, uint256 tokenId, bool success ) external onlyAuthorized { require(nftStats[collection][tokenId].initialized, "Stats not initialized"); NFTStatsData storage stats = nftStats[collection][tokenId]; stats.dungeonRuns += 1; if (success) { stats.successfulRuns += 1; } emit RunRecorded(collection, tokenId, success, stats.roomsCleared, stats.currentXP); } /// @notice Calculate XP required for next level /// @param currentLevel Current level of the NFT /// @return uint256 XP required for next level function getXPForNextLevel(uint256 currentLevel) public pure returns (uint256) { return BASE_XP_PER_LEVEL * (currentLevel * XP_MULTIPLIER / 100); } /// @notice Get the stat increases for a level up /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return hpIncrease Amount HP increases /// @return attackIncrease Amount Attack increases /// @return speedIncrease Amount Speed increases function getLevelUpStats( address collection, uint256 tokenId ) external view returns ( uint256 hpIncrease, uint256 attackIncrease, uint256 speedIncrease ) { require(nftStats[collection][tokenId].initialized, "Stats not initialized"); return _calculateStatIncreases(nftStats[collection][tokenId]); } /// @notice Get current stats for an NFT /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return NFTStatsData struct containing current stats function getStats( address collection, uint256 tokenId ) external view returns (NFTStatsData memory) { return nftStats[collection][tokenId]; } /// @notice Check if an NFT has been initialized /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return bool True if NFT has been initialized function isInitialized( address collection, uint256 tokenId ) external view returns (bool) { return nftStats[collection][tokenId].initialized; } /// @notice Calculate stat increases for a level up /// @param stats Current stats of the NFT /// @return hpIncrease Amount HP increases /// @return attackIncrease Amount Attack increases /// @return speedIncrease Amount Speed increases function _calculateStatIncreases( NFTStatsData memory stats ) internal pure returns ( uint256 hpIncrease, uint256 attackIncrease, uint256 speedIncrease ) { hpIncrease = (stats.hp * BASE_STAT_INCREASE_PERCENT) / 100; attackIncrease = (stats.attack * BASE_STAT_INCREASE_PERCENT) / 100; speedIncrease = (stats.speed * BASE_STAT_INCREASE_PERCENT) / 100; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @title INFTStats /// @notice Interface for managing individual NFT stats and progression interface INFTStats { /// @notice Structure for NFT permanent stats struct NFTStatsData { uint256 hp; uint256 attack; uint256 speed; uint256 level; uint256 currentXP; uint256 xpToNextLevel; uint256 dungeonRuns; uint256 successfulRuns; uint256 roomsCleared; bool initialized; } /// @notice Event emitted when an NFT's stats are initialized event StatsInitialized(address indexed collection, uint256 indexed tokenId, uint256 hp, uint256 attack, uint256 speed); /// @notice Event emitted when an NFT's stats are boosted event StatsBoosted(address indexed collection, uint256 indexed tokenId, uint256 newHp, uint256 newAttack, uint256 newSpeed); /// @notice Event emitted when XP is gained event XPGained(address indexed collection, uint256 indexed tokenId, uint256 xpGained, uint256 newTotalXP); /// @notice Event emitted when a level up occurs event LevelUp(address indexed collection, uint256 indexed tokenId, uint256 newLevel); /// @notice Event emitted when a run is recorded event RunRecorded(address indexed collection, uint256 indexed tokenId, bool success, uint256 roomsCleared, uint256 xpGained); /// @notice Initialize stats for an NFT based on its collection's base stats /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT function initializeStats(address collection, uint256 tokenId) external; /// @notice Award XP for dungeon progress /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @param xpAmount Amount of XP to award /// @param roomsCleared Number of rooms cleared in this run function awardXP( address collection, uint256 tokenId, uint256 xpAmount, uint256 roomsCleared ) external; /// @notice Calculate XP required for next level /// @param currentLevel Current level of the NFT /// @return uint256 XP required for next level function getXPForNextLevel(uint256 currentLevel) external pure returns (uint256); /// @notice Get the stat increases for a level up /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return hpIncrease Amount HP increases /// @return attackIncrease Amount Attack increases /// @return speedIncrease Amount Speed increases function getLevelUpStats( address collection, uint256 tokenId ) external view returns ( uint256 hpIncrease, uint256 attackIncrease, uint256 speedIncrease ); /// @notice Record a dungeon run attempt /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @param success Whether the run was successful function recordRun(address collection, uint256 tokenId, bool success) external; /// @notice Get current stats for an NFT /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return NFTStatsData struct containing current stats function getStats(address collection, uint256 tokenId) external view returns (NFTStatsData memory); /// @notice Check if an NFT has been initialized /// @param collection Address of the NFT collection /// @param tokenId Token ID of the NFT /// @return bool True if NFT has been initialized function isInitialized(address collection, uint256 tokenId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.23; /// @title ICollectionRegistry /// @notice Interface for managing whitelisted NFT collections and their base stats interface ICollectionRegistry { /// @notice Stats structure for NFT collections struct CollectionStats { uint256 baseHp; uint256 baseAttack; uint256 baseSpeed; bool isWhitelisted; } /// @notice Event emitted when a collection is whitelisted event CollectionWhitelisted(address indexed collection, uint256 baseHp, uint256 baseAttack, uint256 baseSpeed); /// @notice Event emitted when a collection's stats are updated event CollectionStatsUpdated(address indexed collection, uint256 baseHp, uint256 baseAttack, uint256 baseSpeed); /// @notice Event emitted when a collection is removed from whitelist event CollectionRemoved(address indexed collection); /// @notice Whitelist a new NFT collection with base stats /// @param collection Address of the NFT collection /// @param baseHp Initial HP for NFTs from this collection /// @param baseAttack Initial Attack for NFTs from this collection /// @param baseSpeed Initial Speed for NFTs from this collection function whitelistCollection( address collection, uint256 baseHp, uint256 baseAttack, uint256 baseSpeed ) external; /// @notice Update base stats for a whitelisted collection /// @param collection Address of the NFT collection /// @param baseHp New base HP /// @param baseAttack New base Attack /// @param baseSpeed New base Speed function updateCollectionStats( address collection, uint256 baseHp, uint256 baseAttack, uint256 baseSpeed ) external; /// @notice Remove a collection from the whitelist /// @param collection Address of the NFT collection to remove function removeCollection(address collection) external; /// @notice Check if a collection is whitelisted /// @param collection Address of the NFT collection to check /// @return bool True if collection is whitelisted function isWhitelisted(address collection) external view returns (bool); /// @notice Get base stats for a collection /// @param collection Address of the NFT collection /// @return CollectionStats struct containing base stats function getCollectionStats(address collection) external view returns (CollectionStats memory); }
// 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/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); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "forge-std/=lib/forge-std/src/", "@pythnetwork/=lib/@pythnetwork/", "pyth-sdk-solidity/=lib/pyth-sdk-solidity/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_collectionRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newLevel","type":"uint256"}],"name":"LevelUp","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"uint256","name":"roomsCleared","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"xpGained","type":"uint256"}],"name":"RunRecorded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newHp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newAttack","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newSpeed","type":"uint256"}],"name":"StatsBoosted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"hp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"attack","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"speed","type":"uint256"}],"name":"StatsInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"xpGained","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalXP","type":"uint256"}],"name":"XPGained","type":"event"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"xpAmount","type":"uint256"},{"internalType":"uint256","name":"roomsCleared","type":"uint256"}],"name":"awardXP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectionRegistry","outputs":[{"internalType":"contract ICollectionRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getLevelUpStats","outputs":[{"internalType":"uint256","name":"hpIncrease","type":"uint256"},{"internalType":"uint256","name":"attackIncrease","type":"uint256"},{"internalType":"uint256","name":"speedIncrease","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getStats","outputs":[{"components":[{"internalType":"uint256","name":"hp","type":"uint256"},{"internalType":"uint256","name":"attack","type":"uint256"},{"internalType":"uint256","name":"speed","type":"uint256"},{"internalType":"uint256","name":"level","type":"uint256"},{"internalType":"uint256","name":"currentXP","type":"uint256"},{"internalType":"uint256","name":"xpToNextLevel","type":"uint256"},{"internalType":"uint256","name":"dungeonRuns","type":"uint256"},{"internalType":"uint256","name":"successfulRuns","type":"uint256"},{"internalType":"uint256","name":"roomsCleared","type":"uint256"},{"internalType":"bool","name":"initialized","type":"bool"}],"internalType":"struct INFTStats.NFTStatsData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"currentLevel","type":"uint256"}],"name":"getXPForNextLevel","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"initializeStats","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"levelUp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bool","name":"success","type":"bool"}],"name":"recordRun","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contract_","type":"address"},{"internalType":"bool","name":"authorized","type":"bool"}],"name":"setContractAuthorization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a060405234801561001057600080fd5b506040516113ff3803806113ff83398101604081905261002f916100f3565b610038336100a3565b6001600160a01b0381166100925760405162461bcd60e51b815260206004820152601860248201527f496e76616c696420726567697374727920616464726573730000000000000000604482015260640160405180910390fd5b6001600160a01b0316608052610123565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006020828403121561010557600080fd5b81516001600160a01b038116811461011c57600080fd5b9392505050565b6080516112b361014c60003960008181610153015281816109ea0152610b6601526112b36000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063b339311511610066578063b3393115146101fd578063ea682d801461022b578063f2fde38b1461023e578063f60ccc861461025157600080fd5b80638da5cb5b1461018d57806391f6c6581461019e578063994e4a19146101b157600080fd5b806303685169146100d45780630954c478146100fd5780634220be2314610112578063546ef39514610133578063715018a6146101465780638c7cc5e31461014e575b600080fd5b6100e76100e2366004610f3c565b610264565b6040516100f49190610f68565b60405180910390f35b61011061010b366004610fe3565b61035a565b005b61012561012036600461101e565b610495565b6040519081526020016100f4565b610110610141366004610f3c565b6104b9565b6101106106c0565b6101757f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020016100f4565b6000546001600160a01b0316610175565b6101106101ac366004611045565b6106d4565b6101ed6101bf366004610f3c565b6001600160a01b03919091166000908152600160209081526040808320938352929052206009015460ff1690565b60405190151581526020016100f4565b61021061020b366004610f3c565b61081a565b604080519384526020840192909252908201526060016100f4565b610110610239366004610f3c565b610910565b61011061024c366004611087565b610d13565b61011061025f3660046110ab565b610d8c565b6102bc6040518061014001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b506001600160a01b03821660009081526001602081815260408084208585528252928390208351610140810185528154815292810154918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e0820152600882015461010082015260099091015460ff1615156101208201525b92915050565b6000546001600160a01b031633148061038257503360009081526002602052604090205460ff165b6103a75760405162461bcd60e51b815260040161039e906110e4565b60405180910390fd5b6001600160a01b038416600090815260016020908152604080832086845290915290206009015460ff166103ed5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b038416600090815260016020908152604080832086845290915281206004810154909190610423908590611151565b9050808260040181905550828260080160008282546104429190611151565b9091555050604080518581526020810183905286916001600160a01b038916917f1cfcc60a52168386067c020abab02289b7dee02c9a7e9690aeff3c3aa53e24a8910160405180910390a3505050505050565b600060646104a4609684611164565b6104ae919061117b565b610354906064611164565b6001600160a01b038216600090815260016020908152604080832084845290915290206009015460ff166104ff5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b03821660009081526001602090815260408083208484529091529020600481015460058201546003830154818310156105735760405162461bcd60e51b815260206004820152600f60248201526e0496e73756666696369656e7420585608c1b604482015260640161039e565b60005b8284106105b457610587838561119d565b935081610593816111b0565b92505080806105a1906111b0565b9150506105ad82610495565b9250610576565b84546001860154600287015460006064856105d0600587611164565b6105da9190611164565b6105e4919061117b565b905060006064866105f6600587611164565b6106009190611164565b61060a919061117b565b9050600060648761061c600587611164565b6106269190611164565b610630919061117b565b905061063c8387611151565b8b556106488286611151565b60018c01556106578185611151565b60028c015560038b0188905560058b0189905560048b018a90556040518881528c906001600160a01b038f16907feec61667dd6eeecdccfef3c906e0fd047cca672804901ac4254d8545e9a426d49060200160405180910390a350505050505050505050505050565b6106c8610e15565b6106d26000610e6f565b565b6000546001600160a01b03163314806106fc57503360009081526002602052604090205460ff165b6107185760405162461bcd60e51b815260040161039e906110e4565b6001600160a01b038316600090815260016020908152604080832085845290915290206009015460ff1661075e5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b0383166000908152600160208181526040808420868552909152822060068101805491939091610796908490611151565b909155505081156107bc5760018160070160008282546107b69190611151565b90915550505b60088101546004820154604080518515158152602081019390935282015283906001600160a01b038616907fe6ce2da96a964985bd161cb1f6b383b07d1f2fed13aef14028de4503dfeb81d29060600160405180910390a350505050565b6001600160a01b03821660009081526001602090815260408083208484529091528120600901548190819060ff166108645760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b03851660009081526001602081815260408084208885528252928390208351610140810185528154815292810154918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e0820152600882015461010082015260099091015460ff16151561012082015261090390610ebf565b9250925092509250925092565b6000546001600160a01b031633148061093857503360009081526002602052604090205460ff165b6109545760405162461bcd60e51b815260040161039e906110e4565b6001600160a01b038216600090815260016020908152604080832084845290915290206009015460ff16156109cb5760405162461bcd60e51b815260206004820152601960248201527f537461747320616c726561647920696e697469616c697a656400000000000000604482015260640161039e565b604051633af32abf60e01b81526001600160a01b0383811660048301527f00000000000000000000000000000000000000000000000000000000000000001690633af32abf90602401602060405180830381865afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5591906111c9565b610aa15760405162461bcd60e51b815260206004820152601a60248201527f436f6c6c656374696f6e206e6f742077686974656c6973746564000000000000604482015260640161039e565b6040516331a9108f60e11b8152600481018290526001600160a01b03831690636352211e90602401602060405180830381865afa925050508015610b02575060408051601f3d908101601f19168201909252610aff918101906111e6565b60015b610b435760405162461bcd60e51b815260206004820152601260248201527113919508191bd95cc81b9bdd08195e1a5cdd60721b604482015260640161039e565b50604051631cc6f28360e31b81526001600160a01b0383811660048301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063e637941890602401608060405180830381865afa158015610baf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd39190611203565b90506040518061014001604052808260000151815260200182602001518152602001826040015181526020016001815260200160008152602001610c176001610495565b81526000602080830182905260408084018390526060808501849052600160809586018190526001600160a01b038a168086528185528386208a875285529483902087518155878501519181019190915586830151600282015586820151600382015594860151600486015560a0860151600586015560c0860151600686015560e086015160078601556101008601516008860155610120909501516009909401805460ff1916941515949094179093558451858201518685015185519283529282015292830152849290917f32c0a0e7ad6c4e9521aaa8ec2a134505ae98bfb6b39a618b287ae78b7aa22dd1910160405180910390a3505050565b610d1b610e15565b6001600160a01b038116610d805760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161039e565b610d8981610e6f565b50565b610d94610e15565b6001600160a01b038216610dea5760405162461bcd60e51b815260206004820152601860248201527f496e76616c696420636f6e747261637420616464726573730000000000000000604482015260640161039e565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146106d25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000606460058560000151610ed79190611164565b610ee1919061117b565b9250606460058560200151610ef69190611164565b610f00919061117b565b9150606460058560400151610f159190611164565b610f1f919061117b565b929491935050565b6001600160a01b0381168114610d8957600080fd5b60008060408385031215610f4f57600080fd5b8235610f5a81610f27565b946020939093013593505050565b600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151610fdb8285018215159052565b505092915050565b60008060008060808587031215610ff957600080fd5b843561100481610f27565b966020860135965060408601359560600135945092505050565b60006020828403121561103057600080fd5b5035919050565b8015158114610d8957600080fd5b60008060006060848603121561105a57600080fd5b833561106581610f27565b925060208401359150604084013561107c81611037565b809150509250925092565b60006020828403121561109957600080fd5b81356110a481610f27565b9392505050565b600080604083850312156110be57600080fd5b82356110c981610f27565b915060208301356110d981611037565b809150509250929050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526015908201527414dd185d1cc81b9bdd081a5b9a5d1a585b1a5e9959605a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808201808211156103545761035461113b565b80820281158282048414176103545761035461113b565b60008261119857634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156103545761035461113b565b6000600182016111c2576111c261113b565b5060010190565b6000602082840312156111db57600080fd5b81516110a481611037565b6000602082840312156111f857600080fd5b81516110a481610f27565b60006080828403121561121557600080fd5b6040516080810181811067ffffffffffffffff8211171561124657634e487b7160e01b600052604160045260246000fd5b8060405250825181526020830151602082015260408301516040820152606083015161127181611037565b6060820152939250505056fea2646970667358221220df295371c34bf062200b1a91ff15f1cf8a4d4d58ec60f114028a4e3d467b273664736f6c63430008170033000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638da5cb5b1161008c578063b339311511610066578063b3393115146101fd578063ea682d801461022b578063f2fde38b1461023e578063f60ccc861461025157600080fd5b80638da5cb5b1461018d57806391f6c6581461019e578063994e4a19146101b157600080fd5b806303685169146100d45780630954c478146100fd5780634220be2314610112578063546ef39514610133578063715018a6146101465780638c7cc5e31461014e575b600080fd5b6100e76100e2366004610f3c565b610264565b6040516100f49190610f68565b60405180910390f35b61011061010b366004610fe3565b61035a565b005b61012561012036600461101e565b610495565b6040519081526020016100f4565b610110610141366004610f3c565b6104b9565b6101106106c0565b6101757f000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c81565b6040516001600160a01b0390911681526020016100f4565b6000546001600160a01b0316610175565b6101106101ac366004611045565b6106d4565b6101ed6101bf366004610f3c565b6001600160a01b03919091166000908152600160209081526040808320938352929052206009015460ff1690565b60405190151581526020016100f4565b61021061020b366004610f3c565b61081a565b604080519384526020840192909252908201526060016100f4565b610110610239366004610f3c565b610910565b61011061024c366004611087565b610d13565b61011061025f3660046110ab565b610d8c565b6102bc6040518061014001604052806000815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b506001600160a01b03821660009081526001602081815260408084208585528252928390208351610140810185528154815292810154918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e0820152600882015461010082015260099091015460ff1615156101208201525b92915050565b6000546001600160a01b031633148061038257503360009081526002602052604090205460ff165b6103a75760405162461bcd60e51b815260040161039e906110e4565b60405180910390fd5b6001600160a01b038416600090815260016020908152604080832086845290915290206009015460ff166103ed5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b038416600090815260016020908152604080832086845290915281206004810154909190610423908590611151565b9050808260040181905550828260080160008282546104429190611151565b9091555050604080518581526020810183905286916001600160a01b038916917f1cfcc60a52168386067c020abab02289b7dee02c9a7e9690aeff3c3aa53e24a8910160405180910390a3505050505050565b600060646104a4609684611164565b6104ae919061117b565b610354906064611164565b6001600160a01b038216600090815260016020908152604080832084845290915290206009015460ff166104ff5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b03821660009081526001602090815260408083208484529091529020600481015460058201546003830154818310156105735760405162461bcd60e51b815260206004820152600f60248201526e0496e73756666696369656e7420585608c1b604482015260640161039e565b60005b8284106105b457610587838561119d565b935081610593816111b0565b92505080806105a1906111b0565b9150506105ad82610495565b9250610576565b84546001860154600287015460006064856105d0600587611164565b6105da9190611164565b6105e4919061117b565b905060006064866105f6600587611164565b6106009190611164565b61060a919061117b565b9050600060648761061c600587611164565b6106269190611164565b610630919061117b565b905061063c8387611151565b8b556106488286611151565b60018c01556106578185611151565b60028c015560038b0188905560058b0189905560048b018a90556040518881528c906001600160a01b038f16907feec61667dd6eeecdccfef3c906e0fd047cca672804901ac4254d8545e9a426d49060200160405180910390a350505050505050505050505050565b6106c8610e15565b6106d26000610e6f565b565b6000546001600160a01b03163314806106fc57503360009081526002602052604090205460ff165b6107185760405162461bcd60e51b815260040161039e906110e4565b6001600160a01b038316600090815260016020908152604080832085845290915290206009015460ff1661075e5760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b0383166000908152600160208181526040808420868552909152822060068101805491939091610796908490611151565b909155505081156107bc5760018160070160008282546107b69190611151565b90915550505b60088101546004820154604080518515158152602081019390935282015283906001600160a01b038616907fe6ce2da96a964985bd161cb1f6b383b07d1f2fed13aef14028de4503dfeb81d29060600160405180910390a350505050565b6001600160a01b03821660009081526001602090815260408083208484529091528120600901548190819060ff166108645760405162461bcd60e51b815260040161039e9061110c565b6001600160a01b03851660009081526001602081815260408084208885528252928390208351610140810185528154815292810154918301919091526002810154928201929092526003820154606082015260048201546080820152600582015460a0820152600682015460c0820152600782015460e0820152600882015461010082015260099091015460ff16151561012082015261090390610ebf565b9250925092509250925092565b6000546001600160a01b031633148061093857503360009081526002602052604090205460ff165b6109545760405162461bcd60e51b815260040161039e906110e4565b6001600160a01b038216600090815260016020908152604080832084845290915290206009015460ff16156109cb5760405162461bcd60e51b815260206004820152601960248201527f537461747320616c726561647920696e697469616c697a656400000000000000604482015260640161039e565b604051633af32abf60e01b81526001600160a01b0383811660048301527f000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c1690633af32abf90602401602060405180830381865afa158015610a31573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a5591906111c9565b610aa15760405162461bcd60e51b815260206004820152601a60248201527f436f6c6c656374696f6e206e6f742077686974656c6973746564000000000000604482015260640161039e565b6040516331a9108f60e11b8152600481018290526001600160a01b03831690636352211e90602401602060405180830381865afa925050508015610b02575060408051601f3d908101601f19168201909252610aff918101906111e6565b60015b610b435760405162461bcd60e51b815260206004820152601260248201527113919508191bd95cc81b9bdd08195e1a5cdd60721b604482015260640161039e565b50604051631cc6f28360e31b81526001600160a01b0383811660048301526000917f000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c9091169063e637941890602401608060405180830381865afa158015610baf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bd39190611203565b90506040518061014001604052808260000151815260200182602001518152602001826040015181526020016001815260200160008152602001610c176001610495565b81526000602080830182905260408084018390526060808501849052600160809586018190526001600160a01b038a168086528185528386208a875285529483902087518155878501519181019190915586830151600282015586820151600382015594860151600486015560a0860151600586015560c0860151600686015560e086015160078601556101008601516008860155610120909501516009909401805460ff1916941515949094179093558451858201518685015185519283529282015292830152849290917f32c0a0e7ad6c4e9521aaa8ec2a134505ae98bfb6b39a618b287ae78b7aa22dd1910160405180910390a3505050565b610d1b610e15565b6001600160a01b038116610d805760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b606482015260840161039e565b610d8981610e6f565b50565b610d94610e15565b6001600160a01b038216610dea5760405162461bcd60e51b815260206004820152601860248201527f496e76616c696420636f6e747261637420616464726573730000000000000000604482015260640161039e565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146106d25760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161039e565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000806000606460058560000151610ed79190611164565b610ee1919061117b565b9250606460058560200151610ef69190611164565b610f00919061117b565b9150606460058560400151610f159190611164565b610f1f919061117b565b929491935050565b6001600160a01b0381168114610d8957600080fd5b60008060408385031215610f4f57600080fd5b8235610f5a81610f27565b946020939093013593505050565b600061014082019050825182526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151610fdb8285018215159052565b505092915050565b60008060008060808587031215610ff957600080fd5b843561100481610f27565b966020860135965060408601359560600135945092505050565b60006020828403121561103057600080fd5b5035919050565b8015158114610d8957600080fd5b60008060006060848603121561105a57600080fd5b833561106581610f27565b925060208401359150604084013561107c81611037565b809150509250925092565b60006020828403121561109957600080fd5b81356110a481610f27565b9392505050565b600080604083850312156110be57600080fd5b82356110c981610f27565b915060208301356110d981611037565b809150509250929050565b6020808252600e908201526d139bdd08185d5d1a1bdc9a5e995960921b604082015260600190565b60208082526015908201527414dd185d1cc81b9bdd081a5b9a5d1a585b1a5e9959605a1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b808201808211156103545761035461113b565b80820281158282048414176103545761035461113b565b60008261119857634e487b7160e01b600052601260045260246000fd5b500490565b818103818111156103545761035461113b565b6000600182016111c2576111c261113b565b5060010190565b6000602082840312156111db57600080fd5b81516110a481611037565b6000602082840312156111f857600080fd5b81516110a481610f27565b60006080828403121561121557600080fd5b6040516080810181811067ffffffffffffffff8211171561124657634e487b7160e01b600052604160045260246000fd5b8060405250825181526020830151602082015260408301516040820152606083015161127181611037565b6060820152939250505056fea2646970667358221220df295371c34bf062200b1a91ff15f1cf8a4d4d58ec60f114028a4e3d467b273664736f6c63430008170033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c
-----Decoded View---------------
Arg [0] : _collectionRegistry (address): 0xd6D3CAf3E4917f74f0D03F1483a4eD26e4476f4C
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000d6d3caf3e4917f74f0d03f1483a4ed26e4476f4c
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 31 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.