APE Price: $0.56 (-2.77%)

Contract

0x138ef8d011DdDD319F977Dc59ac0e01d1B41211C

Overview

APE Balance

Apechain LogoApechain LogoApechain Logo0.081697101399999999 APE

APE Value

$0.05 (@ $0.56/APE)

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Transfer110156582025-03-06 6:06:3614 hrs ago1741241196IN
0x138ef8d0...d1B41211C
0.1 APE0.0005355825.42069

Latest 1 internal transaction

Parent Transaction Hash Block From To
110156712025-03-06 6:06:5914 hrs ago1741241219
0x138ef8d0...d1B41211C
0.01830289 APE

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
DungeonGame

Compiler Version
v0.8.23+commit.f704f362

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 15 : DungeonGame.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "./interfaces/IDungeonGame.sol";
import "./interfaces/IDungeonEntry.sol";
import "./interfaces/INFTStats.sol";
import "./interfaces/IPrizePool.sol";
import "./libraries/EncounterLibrary.sol";

import {IEntropy} from "@pythnetwork/entropy-sdk-solidity/IEntropy.sol";
import {IEntropyConsumer} from "@pythnetwork/entropy-sdk-solidity/IEntropyConsumer.sol";

/// @title DungeonGame
/// @notice Core game logic for dungeon runs and encounters
contract DungeonGame is IDungeonGame, IEntropyConsumer, Ownable, ReentrancyGuard {
    // Events
    event EntropyRequested(uint256 indexed requestId, uint256 fee);
    event EntropyFulfilled(uint256 indexed requestId);
    event FeesWithdrawn(address indexed owner, uint256 amount);
    
    // Allow contract to receive native currency (for Pyth refunds)
    receive() external payable {}
    
    // Constants
    uint256 private constant ROOMS = 16;
    uint256 private constant BASE_XP = 100;
    uint256 private constant COMPLETION_BONUS = 500;

    address public constant ENTROPY_PROVIDER = 0x52DeaA1c84233F7bb8C8A45baeDE41091c616506; // ApeChain Pyth Entropy
    
    IEntropy public immutable entropy;
    
    // Mapping to store pending encounters
    mapping(uint64 => PendingEncounter) private pendingEncounters;
    
    // Struct to store encounter data while waiting for randomness
    struct PendingEncounter {
        uint256 roomNumber;
        address collection;
        uint256 tokenId;
        bool isValid;
        bytes32 randomSeed;
    }

    // Struct to store character state
    struct Character {
        uint256 currentHp;
        uint256 currentAttack;
        uint256 currentSpeed;
        uint256 roomNumber;
        uint256 entryTime;
        bool isActive;
    }
    
    // Core contract references
    address public immutable dungeonEntry;
    address public immutable nftStats;
    address public immutable prizePool;

    // Room state
    mapping(uint256 => RoomState) private rooms;
    uint256 private currentRoom;

    // Character state
    mapping(address => mapping(uint256 => Character)) private characters;
    mapping(uint256 => address) private roomToCharacter;
    mapping(address => mapping(uint256 => uint256)) private characterToRoom;
    mapping(address => mapping(uint256 => bool)) private completedRuns;

    constructor(
        address _dungeonEntry,
        address _nftStats,
        address _prizePool,
        address _entropy
    ) {
        require(_dungeonEntry != address(0), "Invalid DungeonEntry address");
        require(_nftStats != address(0), "Invalid NFTStats address");
        require(_prizePool != address(0), "Invalid PrizePool address");
        require(_entropy != address(0), "Invalid entropy address");

        dungeonEntry = _dungeonEntry;
        nftStats = _nftStats;
        prizePool = _prizePool;
        entropy = IEntropy(_entropy);
    }

    /// @notice Progress all characters in the dungeon by one room
    function progressAllCharacters() external returns (EncounterResult[] memory) {
        // Count active characters to size our return array
        uint256 activeCount = 0;
        for (uint256 i = 1; i <= ROOMS; i++) {
            if (rooms[i].isOccupied) activeCount++;
        }
        
        EncounterResult[] memory results = new EncounterResult[](activeCount);
        uint256 resultIndex = 0;
        
        // Process rooms from last to first to avoid overwriting
        for (uint256 i = ROOMS; i >= 1; i--) {
            if (!rooms[i].isOccupied) continue;
            
            address collection = rooms[i].collection;
            uint256 tokenId = rooms[i].tokenId;
            
            // Process encounter for current room
            EncounterResult memory result = _processEncounter(i, collection, tokenId);
            results[resultIndex] = result;
            resultIndex++;
            
            // If character survived, move them forward
            if (result.survived) {
                if (i == ROOMS) {
                    // Character completed the dungeon
                    _handleDungeonCompletion(collection, tokenId);
                } else {
                    // Move character to next room
                    _moveCharacter(i, i + 1, collection, tokenId);
                }
            } else {
                // Remove failed character
                _removeCharacter(i, collection, tokenId, false);
            }
        }
        
        return results;
    }

    /// @notice Add a new character to the dungeon queue
    function addCharacterToDungeon(
        address collection,
        uint256 tokenId
    ) external {
        require(msg.sender == address(dungeonEntry), "Only DungeonEntry can add characters");
        
        // Get NFT stats
        INFTStats.NFTStatsData memory stats = INFTStats(nftStats).getStats(collection, tokenId);
        
        // Push all characters forward one room, starting from the last room
        for (uint256 i = ROOMS; i > 1; i--) {
            if (rooms[i-1].isOccupied) {
                address prevCollection = rooms[i-1].collection;
                uint256 prevTokenId = rooms[i-1].tokenId;
                
                // Process encounter for the character being moved
                EncounterResult memory result = _processEncounter(i, prevCollection, prevTokenId);
                
                // Only move if they survived the encounter
                if (result.survived) {
                    if (i == ROOMS) {
                        // Character completed the dungeon
                        _handleDungeonCompletion(prevCollection, prevTokenId);
                    } else {
                        // Move character to next room
                        _moveCharacter(i-1, i, prevCollection, prevTokenId);
                    }
                } else {
                    // Remove failed character
                    _removeCharacter(i-1, prevCollection, prevTokenId, false);
                }
            }
        }
        
        // Place new character in room 1
        rooms[1] = RoomState({
            collection: collection,
            tokenId: tokenId,
            entryIndex: block.timestamp,
            currentHp: stats.hp,
            currentAttack: stats.attack,
            currentSpeed: stats.speed,
            isOccupied: true
        });
        
        characterToRoom[collection][tokenId] = 1;
    }

    /// @notice Claim rewards for a successful dungeon run
    function claimRewards(address collection, uint256 tokenId) external {
        require(completedRuns[collection][tokenId], "No completed run found");
        require(msg.sender == IERC721(collection).ownerOf(tokenId), "Not token owner");
        
        // Reset completion status and let prize pool handle the reward
        completedRuns[collection][tokenId] = false;
        IPrizePool(prizePool).claimPrize(collection, tokenId);
    }

    /// @notice Get the state of a specific room
    function getRoomState(uint256 roomNumber) external view returns (RoomState memory) {
        require(roomNumber > 0 && roomNumber <= ROOMS, "Invalid room number");
        return rooms[roomNumber];
    }

    /// @notice Get all active room states
    function getAllRoomStates() external view returns (RoomState[] memory) {
        RoomState[] memory allRooms = new RoomState[](ROOMS);
        for (uint256 i = 1; i <= ROOMS; i++) {
            allRooms[i-1] = rooms[i];
        }
        return allRooms;
    }

    /// @notice Get the room number where a character is located
    function getCharacterRoom(
        address collection,
        uint256 tokenId
    ) external view returns (uint256) {
        return characterToRoom[collection][tokenId];
    }

    /// @notice Get the total number of rooms in the dungeon
    function getTotalRooms() external pure returns (uint256) {
        return ROOMS;
    }

    /// @notice Check if a character has completed the dungeon
    function isDungeonCompleted(
        address collection,
        uint256 tokenId
    ) external view returns (bool) {
        return completedRuns[collection][tokenId];
    }

    // Internal helper functions

    function _processEncounter(
        uint256 roomNumber,
        address collection,
        uint256 tokenId
    ) internal returns (EncounterResult memory) {
        // Generate user seed from encounter data
        bytes32 userSeed = keccak256(abi.encodePacked(roomNumber, collection, tokenId, block.timestamp));
        
        // Get fee from entropy provider
        uint256 fee = entropy.getFee(ENTROPY_PROVIDER);
        
        // Request entropy with callback
        uint64 sequenceNumber = entropy.requestWithCallback{value: fee}(
            ENTROPY_PROVIDER,
            userSeed
        );
        
        // Store pending encounter
        pendingEncounters[sequenceNumber] = PendingEncounter({
            roomNumber: roomNumber,
            collection: collection,
            tokenId: tokenId,
            isValid: true,
            randomSeed: userSeed
        });
        
        emit EntropyRequested(sequenceNumber, fee);
        
        // Return placeholder result while waiting for entropy
        return EncounterResult({
            roomNumber: roomNumber,
            survived: true,
            hpChange: 0,
            attackChange: 0,
            speedChange: 0,
            xpGained: 0,
            encounterDescription: ""
        });
    }

    /// @notice Callback function for Pyth entropy
    function entropyCallback(
        uint64 sequenceNumber,
        address provider,
        bytes32 randomNumber
    ) internal override {
        require(msg.sender == address(entropy), "Only entropy contract");
        require(provider == ENTROPY_PROVIDER, "Invalid provider");
        
        PendingEncounter memory pending = pendingEncounters[sequenceNumber];
        require(pending.isValid, "Invalid sequence number");
        
        // Process encounter with received entropy
        _processEncounterWithEntropy(
            pending.roomNumber,
            pending.collection,
            pending.tokenId,
            randomNumber
        );
        
        // Clean up
        delete pendingEncounters[sequenceNumber];
        emit EntropyFulfilled(sequenceNumber);
    }

    /// @notice Process encounter with received entropy
    function _processEncounterWithEntropy(
        uint256 roomNumber,
        address collection,
        uint256 tokenId,
        bytes32 randomNumber
    ) internal returns (EncounterResult memory) {
        RoomState storage room = rooms[roomNumber];
        require(room.isOccupied, "Room not occupied");
        require(room.collection == collection && room.tokenId == tokenId, "Character mismatch");

        // Generate encounter using entropy
        EncounterLibrary.Encounter memory encounter = EncounterLibrary.generateEncounter(
            roomNumber,
            uint256(randomNumber)
        );

        // Process encounter
        IDungeonGame.RoomState memory characterStats = IDungeonGame.RoomState({
            collection: collection,
            tokenId: tokenId,
            entryIndex: room.entryIndex,
            currentHp: room.currentHp,
            currentAttack: room.currentAttack,
            currentSpeed: room.currentSpeed,
            isOccupied: true
        });
        
        EncounterResult memory result = EncounterLibrary.processEncounter(
            encounter,
            characterStats
        );

        // Update character stats
        if (result.survived) {
            room.currentHp = uint256(int256(room.currentHp) + result.hpChange);
            room.currentAttack = uint256(int256(room.currentAttack) + result.attackChange);
            room.currentSpeed = uint256(int256(room.currentSpeed) + result.speedChange);
            INFTStats(nftStats).awardXP(collection, tokenId, result.xpGained, 1); // 1 room cleared
        }

        return result;
    }

    /// @notice Required interface implementation
    function getEntropy() internal view override returns (address) {
        return address(entropy);
    }
   
    function _moveCharacter(
        uint256 fromRoom,
        uint256 toRoom,
        address collection,
        uint256 tokenId
    ) internal {
        require(toRoom <= ROOMS, "Invalid room number");
        require(!rooms[toRoom].isOccupied, "Destination room occupied");
        
        // Copy character state to new room
        rooms[toRoom] = rooms[fromRoom];
        rooms[toRoom].entryIndex = block.timestamp;
        
        // Clear old room
        delete rooms[fromRoom];
        
        // Update character location
        characterToRoom[collection][tokenId] = toRoom;
    }

    function _removeCharacter(
        uint256 roomNumber,
        address collection,
        uint256 tokenId,
        bool success
    ) internal {
        // Clear room state
        delete rooms[roomNumber];
        
        // Clear character location
        delete characterToRoom[collection][tokenId];
        
        // End the run in DungeonEntry
        IDungeonEntry(dungeonEntry).endDungeonRun(collection, tokenId, success);
    }

    function _handleDungeonCompletion(address collection, uint256 tokenId) internal {
        // Award completion bonus XP
        INFTStats(nftStats).awardXP(collection, tokenId, COMPLETION_BONUS, ROOMS);
        
        // Mark run as completed for reward claiming
        completedRuns[collection][tokenId] = true;
        
        // Remove character from dungeon
        _removeCharacter(ROOMS, collection, tokenId, true);
        
        // Calculate total XP gained (completion bonus only, room XP already awarded)
        emit DungeonCompleted(
            collection,
            tokenId,
            true,
            ROOMS,
            COMPLETION_BONUS,
            0 // Actual reward amount will be determined by PrizePool
        );
    }
    
    /// @notice Withdraw accumulated fees from Pyth refunds
    /// @dev Only callable by contract owner
    function withdrawFees() external onlyOwner {
        uint256 balance = address(this).balance;
        require(balance > 0, "No fees to withdraw");
        
        (bool success, ) = msg.sender.call{value: balance}("");
        require(success, "Withdrawal failed");
        
        emit FeesWithdrawn(msg.sender, balance);
    }
}

File 2 of 15 : Ownable.sol
// 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);
    }
}

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

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

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

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

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

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

File 4 of 15 : IERC721.sol
// 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);
}

File 5 of 15 : IDungeonGame.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/// @title IDungeonGame
/// @notice Interface for core dungeon game mechanics and progression
interface IDungeonGame {
    /// @notice Structure for dungeon room state
    struct RoomState {
        address collection;
        uint256 tokenId;
        uint256 entryIndex;      // Used for ordering characters
        uint256 currentHp;
        uint256 currentAttack;
        uint256 currentSpeed;
        bool isOccupied;
    }

    /// @notice Structure for encounter results
    struct EncounterResult {
        int256 hpChange;
        int256 attackChange;
        int256 speedChange;
        uint256 xpGained;
        bool survived;
        string encounterDescription;
        uint256 roomNumber;
    }

    /// @notice Event emitted when an encounter is completed
    event EncounterCompleted(
        address indexed collection,
        uint256 indexed tokenId,
        uint256 roomNumber,
        uint256 xpGained,
        bool survived,
        string encounterDescription
    );
    
    /// @notice Event emitted when a dungeon run is completed
    event DungeonCompleted(
        address indexed collection,
        uint256 indexed tokenId,
        bool success,
        uint256 roomsCleared,
        uint256 totalXpGained,
        uint256 reward
    );

    /// @notice Progress all characters in the dungeon by one room
    /// @return EncounterResult[] Array of encounter results for each character that moved
    function progressAllCharacters() external returns (EncounterResult[] memory);

    /// @notice Add a new character to the dungeon queue
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    function addCharacterToDungeon(address collection, uint256 tokenId) external;

    /// @notice Claim rewards for a successful dungeon run
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    function claimRewards(address collection, uint256 tokenId) external;

    /// @notice Get the state of a specific room
    /// @param roomNumber Room number to query
    /// @return RoomState Current state of the room
    function getRoomState(uint256 roomNumber) external view returns (RoomState memory);

    /// @notice Get all active room states
    /// @return RoomState[] Array of all room states
    function getAllRoomStates() external view returns (RoomState[] memory);

    /// @notice Get the room number where a character is located
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return uint256 Room number, 0 if not in dungeon
    function getCharacterRoom(address collection, uint256 tokenId) external view returns (uint256);

    /// @notice Get the total number of rooms in the dungeon
    /// @return uint256 Number of rooms (16)
    function getTotalRooms() external pure returns (uint256);

    /// @notice Check if a character has completed the dungeon
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return bool True if character has completed all rooms
    function isDungeonCompleted(address collection, uint256 tokenId) external view returns (bool);
}

File 6 of 15 : IDungeonEntry.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/// @title IDungeonEntry
/// @notice Interface for managing dungeon entry and run initialization
interface IDungeonEntry {
    /// @notice Structure for active dungeon run state
    struct DungeonRun {
        uint256 currentHp;
        uint256 currentAttack;
        uint256 currentSpeed;
        uint256 currentRoom;
        uint256 startTime;
        bool isActive;
    }

    /// @notice Event emitted when a dungeon run is started
    event DungeonRunStarted(
        address indexed collection,
        uint256 indexed tokenId,
        address indexed player,
        uint256 entryFee
    );
    
    /// @notice Event emitted when a dungeon run is ended
    event DungeonRunEnded(
        address indexed collection,
        uint256 indexed tokenId,
        bool success
    );

    /// @notice Start a new dungeon run for an NFT
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    function startDungeonRun(address collection, uint256 tokenId) external payable;

    /// @notice End an active dungeon run (called by DungeonGame)
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @param success Whether the run was successful
    function endDungeonRun(address collection, uint256 tokenId, bool success) external;

    /// @notice Get the current dungeon run state for an NFT
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return DungeonRun struct containing current run state
    function getCurrentRun(address collection, uint256 tokenId) external view returns (DungeonRun memory);

    /// @notice Check if an NFT has an active dungeon run
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return bool True if NFT has an active run
    function hasActiveRun(address collection, uint256 tokenId) external view returns (bool);

    /// @notice Get the current entry fee for dungeon runs
    /// @return uint256 Current entry fee in wei
    function getEntryFee() external view returns (uint256);
}

File 7 of 15 : INFTStats.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/// @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, uint256 newHp, uint256 newAttack, uint256 newSpeed);
    
    /// @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);
}

File 8 of 15 : IPrizePool.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

/// @title IPrizePool
/// @notice Interface for managing dungeon rewards and prize distribution
interface IPrizePool {
    /// @notice Event emitted when entry fee is deposited
    event EntryFeeDeposited(address indexed collection, uint256 indexed tokenId, uint256 amount);
    
    /// @notice Event emitted when reward is claimed
    event RewardClaimed(address indexed collection, uint256 indexed tokenId, address indexed recipient, uint256 amount);
    
    /// @notice Event emitted when prize pool parameters are updated
    event PrizePoolParametersUpdated(uint256 entryFee, uint256 winnerShare);

    /// @notice Deposit entry fee for a dungeon run
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    function depositEntryFee(address collection, uint256 tokenId) external payable;

    /// @notice Register a winner for prize claiming
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @param amount Amount to be claimed
    function registerWinner(address collection, uint256 tokenId, uint256 amount) external;

    /// @notice Claim prize for a winning NFT
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    function claimPrize(address collection, uint256 tokenId) external;

    /// @notice Get claimable prize amount for a winning NFT
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return uint256 Claimable amount
    function getClaimablePrize(address collection, uint256 tokenId) external view returns (uint256);

    /// @notice Get current prize pool balance
    /// @return uint256 Current balance
    function getCurrentPrizePool() external view returns (uint256);

    /// @notice Check if an NFT has an unclaimed prize
    /// @param collection Address of the NFT collection
    /// @param tokenId Token ID of the NFT
    /// @return bool True if NFT has unclaimed prize
    function hasUnclaimedPrize(address collection, uint256 tokenId) external view returns (bool);
}

File 9 of 15 : EncounterLibrary.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import "../interfaces/IDungeonGame.sol";

/// @title EncounterLibrary
/// @notice Library for generating and processing dungeon encounters
library EncounterLibrary {
    // Encounter types
    enum EncounterType {
        Combat,      // Standard combat encounter
        Trap,       // Environmental hazard
        Blessing,   // Positive encounter
        Elite,      // Stronger combat encounter
        Boss        // Room 16 boss encounter
    }

    // Encounter definition
    struct Encounter {
        EncounterType encounterType;
        uint256 difficulty;       // 1-100 scale
        int256 baseHpChange;     // Base HP modification
        int256 baseAttackMod;    // Temporary attack modification
        int256 baseSpeedMod;     // Temporary speed modification
        uint256 baseXp;          // Base XP reward
        string description;       // Encounter description
    }

    // Constants for encounter generation
    uint256 private constant BASE_DIFFICULTY_PER_ROOM = 6; // ~100 difficulty by room 16
    uint256 private constant ELITE_CHANCE = 15;           // 15% chance for elite encounter
    uint256 private constant BLESSING_CHANCE = 10;        // 10% chance for blessing
    uint256 private constant TRAP_CHANCE = 20;           // 20% chance for trap
    
    // Constants for encounter effects
    uint256 private constant BASE_DAMAGE = 20;
    uint256 private constant ELITE_DAMAGE_MULTIPLIER = 2;
    uint256 private constant BOSS_DAMAGE_MULTIPLIER = 3;
    int256 private constant MAX_STAT_MODIFICATION = 50;   // Maximum temporary stat change

    /// @notice Generate an encounter for a specific room
    /// @param roomNumber Current room number (1-16)
    /// @param randomness Random number for encounter generation
    /// @return Encounter struct with encounter details
    function generateEncounter(
        uint256 roomNumber,
        uint256 randomness
    ) internal pure returns (Encounter memory) {
        require(roomNumber > 0 && roomNumber <= 16, "Invalid room number");

        // Room 16 is always a boss encounter
        if (roomNumber == 16) {
            return _generateBossEncounter();
        }

        // Use randomness to determine encounter type
        uint256 encounterRoll = randomness % 100;
        
        // Scale difficulty with room number
        uint256 difficulty = BASE_DIFFICULTY_PER_ROOM * roomNumber;
        
        // Select encounter type based on roll
        if (encounterRoll < BLESSING_CHANCE) {
            return _generateBlessing(roomNumber, difficulty);
        } else if (encounterRoll < BLESSING_CHANCE + TRAP_CHANCE) {
            return _generateTrap(roomNumber, difficulty);
        } else if (encounterRoll < BLESSING_CHANCE + TRAP_CHANCE + ELITE_CHANCE) {
            return _generateEliteEncounter(roomNumber, difficulty);
        } else {
            return _generateCombatEncounter(roomNumber, difficulty);
        }
    }

    /// @notice Process an encounter for a character
    /// @param encounter The encounter to process
    /// @param characterStats Current character stats
    /// @return IDungeonGame.EncounterResult Result of the encounter
    function processEncounter(
        Encounter memory encounter,
        IDungeonGame.RoomState memory characterStats
    ) internal pure returns (IDungeonGame.EncounterResult memory) {
        // Calculate final HP change based on character stats
        int256 hpChange = _calculateHpChange(encounter, characterStats);
        
        // Determine if character survived
        bool survived = (int256(characterStats.currentHp) + hpChange) > 0;
        
        // Calculate XP (partial XP if failed)
        uint256 xpGained = survived ? encounter.baseXp : encounter.baseXp / 2;
        
        return IDungeonGame.EncounterResult({
            hpChange: hpChange,
            attackChange: encounter.baseAttackMod,
            speedChange: encounter.baseSpeedMod,
            xpGained: xpGained,
            survived: survived,
            encounterDescription: encounter.description,
            roomNumber: 0 // Set by DungeonGame
        });
    }

    // Internal encounter generation functions

    function _generateCombatEncounter(
        uint256 roomNumber,
        uint256 difficulty
    ) private pure returns (Encounter memory) {
        int256 damage = -int256(BASE_DAMAGE + (difficulty / 2));
        return Encounter({
            encounterType: EncounterType.Combat,
            difficulty: difficulty,
            baseHpChange: damage,
            baseAttackMod: 0,
            baseSpeedMod: 0,
            baseXp: 100 + (roomNumber * 10),
            description: "A hostile enemy appears!"
        });
    }

    function _generateEliteEncounter(
        uint256 roomNumber,
        uint256 difficulty
    ) private pure returns (Encounter memory) {
        int256 damage = -int256((BASE_DAMAGE + (difficulty / 2)) * ELITE_DAMAGE_MULTIPLIER);
        return Encounter({
            encounterType: EncounterType.Elite,
            difficulty: difficulty,
            baseHpChange: damage,
            baseAttackMod: int256(MAX_STAT_MODIFICATION / 2),
            baseSpeedMod: -int256(MAX_STAT_MODIFICATION / 4),
            baseXp: (150 + (roomNumber * 15)),
            description: "An elite enemy blocks your path!"
        });
    }

    function _generateBossEncounter() private pure returns (Encounter memory) {
        return Encounter({
            encounterType: EncounterType.Boss,
            difficulty: 100,
            baseHpChange: -int256(BASE_DAMAGE * BOSS_DAMAGE_MULTIPLIER),
            baseAttackMod: -int256(MAX_STAT_MODIFICATION),
            baseSpeedMod: -int256(MAX_STAT_MODIFICATION / 2),
            baseXp: 1000,
            description: "The dungeon boss emerges!"
        });
    }

    function _generateBlessing(
        uint256 roomNumber,
        uint256 difficulty
    ) private pure returns (Encounter memory) {
        return Encounter({
            encounterType: EncounterType.Blessing,
            difficulty: difficulty,
            baseHpChange: int256(BASE_DAMAGE),
            baseAttackMod: int256(MAX_STAT_MODIFICATION / 2),
            baseSpeedMod: int256(MAX_STAT_MODIFICATION / 2),
            baseXp: 50 + (roomNumber * 5),
            description: "You discover a magical blessing!"
        });
    }

    function _generateTrap(
        uint256 roomNumber,
        uint256 difficulty
    ) private pure returns (Encounter memory) {
        return Encounter({
            encounterType: EncounterType.Trap,
            difficulty: difficulty,
            baseHpChange: -int256(BASE_DAMAGE / 2),
            baseAttackMod: -int256(MAX_STAT_MODIFICATION / 4),
            baseSpeedMod: -int256(MAX_STAT_MODIFICATION / 4),
            baseXp: 75 + (roomNumber * 7),
            description: "You triggered a trap!"
        });
    }

    // Internal helper functions

    function _calculateHpChange(
        Encounter memory encounter,
        IDungeonGame.RoomState memory characterStats
    ) private pure returns (int256) {
        // Base damage
        int256 hpChange = encounter.baseHpChange;
        
        // Modify based on character stats
        if (encounter.encounterType == EncounterType.Combat || 
            encounter.encounterType == EncounterType.Elite ||
            encounter.encounterType == EncounterType.Boss) {
            // Higher attack reduces damage taken
            uint256 attackMitigation = characterStats.currentAttack / 10;
            // Higher speed increases chance to dodge
            uint256 speedMitigation = characterStats.currentSpeed / 20;
            
            hpChange += int256(attackMitigation + speedMitigation);
        }
        
        return hpChange;
    }
}

File 10 of 15 : IEntropy.sol
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;

import "./EntropyEvents.sol";

interface IEntropy is EntropyEvents {
    // Register msg.sender as a randomness provider. The arguments are the provider's configuration parameters
    // and initial commitment. Re-registering the same provider rotates the provider's commitment (and updates
    // the feeInWei).
    //
    // chainLength is the number of values in the hash chain *including* the commitment, that is, chainLength >= 1.
    function register(
        uint128 feeInWei,
        bytes32 commitment,
        bytes calldata commitmentMetadata,
        uint64 chainLength,
        bytes calldata uri
    ) external;

    // Withdraw a portion of the accumulated fees for the provider msg.sender.
    // Calling this function will transfer `amount` wei to the caller (provided that they have accrued a sufficient
    // balance of fees in the contract).
    function withdraw(uint128 amount) external;

    // Withdraw a portion of the accumulated fees for provider. The msg.sender must be the fee manager for this provider.
    // Calling this function will transfer `amount` wei to the caller (provided that they have accrued a sufficient
    // balance of fees in the contract).
    function withdrawAsFeeManager(address provider, uint128 amount) external;

    // As a user, request a random number from `provider`. Prior to calling this method, the user should
    // generate a random number x and keep it secret. The user should then compute hash(x) and pass that
    // as the userCommitment argument. (You may call the constructUserCommitment method to compute the hash.)
    //
    // This method returns a sequence number. The user should pass this sequence number to
    // their chosen provider (the exact method for doing so will depend on the provider) to retrieve the provider's
    // number. The user should then call fulfillRequest to construct the final random number.
    //
    // This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
    // Note that excess value is *not* refunded to the caller.
    function request(
        address provider,
        bytes32 userCommitment,
        bool useBlockHash
    ) external payable returns (uint64 assignedSequenceNumber);

    // Request a random number. The method expects the provider address and a secret random number
    // in the arguments. It returns a sequence number.
    //
    // The address calling this function should be a contract that inherits from the IEntropyConsumer interface.
    // The `entropyCallback` method on that interface will receive a callback with the generated random number.
    //
    // This method will revert unless the caller provides a sufficient fee (at least getFee(provider)) as msg.value.
    // Note that excess value is *not* refunded to the caller.
    function requestWithCallback(
        address provider,
        bytes32 userRandomNumber
    ) external payable returns (uint64 assignedSequenceNumber);

    // Fulfill a request for a random number. This method validates the provided userRandomness and provider's proof
    // against the corresponding commitments in the in-flight request. If both values are validated, this function returns
    // the corresponding random number.
    //
    // Note that this function can only be called once per in-flight request. Calling this function deletes the stored
    // request information (so that the contract doesn't use a linear amount of storage in the number of requests).
    // If you need to use the returned random number more than once, you are responsible for storing it.
    function reveal(
        address provider,
        uint64 sequenceNumber,
        bytes32 userRevelation,
        bytes32 providerRevelation
    ) external returns (bytes32 randomNumber);

    // Fulfill a request for a random number. This method validates the provided userRandomness
    // and provider's revelation against the corresponding commitment in the in-flight request. If both values are validated
    // and the requestor address is a contract address, this function calls the requester's entropyCallback method with the
    // sequence number, provider address and the random number as arguments. Else if the requestor is an EOA, it won't call it.
    //
    // Note that this function can only be called once per in-flight request. Calling this function deletes the stored
    // request information (so that the contract doesn't use a linear amount of storage in the number of requests).
    // If you need to use the returned random number more than once, you are responsible for storing it.
    //
    // Anyone can call this method to fulfill a request, but the callback will only be made to the original requester.
    function revealWithCallback(
        address provider,
        uint64 sequenceNumber,
        bytes32 userRandomNumber,
        bytes32 providerRevelation
    ) external;

    function getProviderInfo(
        address provider
    ) external view returns (EntropyStructs.ProviderInfo memory info);

    function getDefaultProvider() external view returns (address provider);

    function getRequest(
        address provider,
        uint64 sequenceNumber
    ) external view returns (EntropyStructs.Request memory req);

    function getFee(address provider) external view returns (uint128 feeAmount);

    function getAccruedPythFees()
        external
        view
        returns (uint128 accruedPythFeesInWei);

    function setProviderFee(uint128 newFeeInWei) external;

    function setProviderFeeAsFeeManager(
        address provider,
        uint128 newFeeInWei
    ) external;

    function setProviderUri(bytes calldata newUri) external;

    // Set manager as the fee manager for the provider msg.sender.
    // After calling this function, manager will be able to set the provider's fees and withdraw them.
    // Only one address can be the fee manager for a provider at a time -- calling this function again with a new value
    // will override the previous value. Call this function with the all-zero address to disable the fee manager role.
    function setFeeManager(address manager) external;

    function constructUserCommitment(
        bytes32 userRandomness
    ) external pure returns (bytes32 userCommitment);

    function combineRandomValues(
        bytes32 userRandomness,
        bytes32 providerRandomness,
        bytes32 blockHash
    ) external pure returns (bytes32 combinedRandomness);
}

File 11 of 15 : IEntropyConsumer.sol
// SPDX-License-Identifier: Apache 2
pragma solidity ^0.8.0;

abstract contract IEntropyConsumer {
    // This method is called by Entropy to provide the random number to the consumer.
    // It asserts that the msg.sender is the Entropy contract. It is not meant to be
    // override by the consumer.
    function _entropyCallback(
        uint64 sequence,
        address provider,
        bytes32 randomNumber
    ) external {
        address entropy = getEntropy();
        require(entropy != address(0), "Entropy address not set");
        require(msg.sender == entropy, "Only Entropy can call this function");

        entropyCallback(sequence, provider, randomNumber);
    }

    // getEntropy returns Entropy contract address. The method is being used to check that the
    // callback is indeed from Entropy contract. The consumer is expected to implement this method.
    // Entropy address can be found here - https://docs.pyth.network/entropy/contract-addresses
    function getEntropy() internal view virtual returns (address);

    // This method is expected to be implemented by the consumer to handle the random number.
    // It will be called by _entropyCallback after _entropyCallback ensures that the call is
    // indeed from Entropy contract.
    function entropyCallback(
        uint64 sequence,
        address provider,
        bytes32 randomNumber
    ) internal virtual;
}

File 12 of 15 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

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

File 13 of 15 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

File 14 of 15 : EntropyEvents.sol
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;

import "./EntropyStructs.sol";

interface EntropyEvents {
    event Registered(EntropyStructs.ProviderInfo provider);

    event Requested(EntropyStructs.Request request);
    event RequestedWithCallback(
        address indexed provider,
        address indexed requestor,
        uint64 indexed sequenceNumber,
        bytes32 userRandomNumber,
        EntropyStructs.Request request
    );

    event Revealed(
        EntropyStructs.Request request,
        bytes32 userRevelation,
        bytes32 providerRevelation,
        bytes32 blockHash,
        bytes32 randomNumber
    );
    event RevealedWithCallback(
        EntropyStructs.Request request,
        bytes32 userRandomNumber,
        bytes32 providerRevelation,
        bytes32 randomNumber
    );

    event ProviderFeeUpdated(address provider, uint128 oldFee, uint128 newFee);

    event ProviderUriUpdated(address provider, bytes oldUri, bytes newUri);

    event ProviderFeeManagerUpdated(
        address provider,
        address oldFeeManager,
        address newFeeManager
    );

    event Withdrawal(
        address provider,
        address recipient,
        uint128 withdrawnAmount
    );
}

File 15 of 15 : EntropyStructs.sol
// SPDX-License-Identifier: Apache 2

pragma solidity ^0.8.0;

contract EntropyStructs {
    struct ProviderInfo {
        uint128 feeInWei;
        uint128 accruedFeesInWei;
        // The commitment that the provider posted to the blockchain, and the sequence number
        // where they committed to this. This value is not advanced after the provider commits,
        // and instead is stored to help providers track where they are in the hash chain.
        bytes32 originalCommitment;
        uint64 originalCommitmentSequenceNumber;
        // Metadata for the current commitment. Providers may optionally use this field to help
        // manage rotations (i.e., to pick the sequence number from the correct hash chain).
        bytes commitmentMetadata;
        // Optional URI where clients can retrieve revelations for the provider.
        // Client SDKs can use this field to automatically determine how to retrieve random values for each provider.
        // TODO: specify the API that must be implemented at this URI
        bytes uri;
        // The first sequence number that is *not* included in the current commitment (i.e., an exclusive end index).
        // The contract maintains the invariant that sequenceNumber <= endSequenceNumber.
        // If sequenceNumber == endSequenceNumber, the provider must rotate their commitment to add additional random values.
        uint64 endSequenceNumber;
        // The sequence number that will be assigned to the next inbound user request.
        uint64 sequenceNumber;
        // The current commitment represents an index/value in the provider's hash chain.
        // These values are used to verify requests for future sequence numbers. Note that
        // currentCommitmentSequenceNumber < sequenceNumber.
        //
        // The currentCommitment advances forward through the provider's hash chain as values
        // are revealed on-chain.
        bytes32 currentCommitment;
        uint64 currentCommitmentSequenceNumber;
        // An address that is authorized to set / withdraw fees on behalf of this provider.
        address feeManager;
    }

    struct Request {
        // Storage slot 1 //
        address provider;
        uint64 sequenceNumber;
        // The number of hashes required to verify the provider revelation.
        uint32 numHashes;
        // Storage slot 2 //
        // The commitment is keccak256(userCommitment, providerCommitment). Storing the hash instead of both saves 20k gas by
        // eliminating 1 store.
        bytes32 commitment;
        // Storage slot 3 //
        // The number of the block where this request was created.
        // Note that we're using a uint64 such that we have an additional space for an address and other fields in
        // this storage slot. Although block.number returns a uint256, 64 bits should be plenty to index all of the
        // blocks ever generated.
        uint64 blockNumber;
        // The address that requested this random number.
        address requester;
        // If true, incorporate the blockhash of blockNumber into the generated random value.
        bool useBlockhash;
        // If true, the requester will be called back with the generated random value.
        bool isRequestWithCallback;
        // There are 2 remaining bytes of free space in this slot.
    }
}

Settings
{
  "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

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_dungeonEntry","type":"address"},{"internalType":"address","name":"_nftStats","type":"address"},{"internalType":"address","name":"_prizePool","type":"address"},{"internalType":"address","name":"_entropy","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":"bool","name":"success","type":"bool"},{"indexed":false,"internalType":"uint256","name":"roomsCleared","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalXpGained","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"DungeonCompleted","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":"roomNumber","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"xpGained","type":"uint256"},{"indexed":false,"internalType":"bool","name":"survived","type":"bool"},{"indexed":false,"internalType":"string","name":"encounterDescription","type":"string"}],"name":"EncounterCompleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"}],"name":"EntropyFulfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"requestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fee","type":"uint256"}],"name":"EntropyRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FeesWithdrawn","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"},{"inputs":[],"name":"ENTROPY_PROVIDER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint64","name":"sequence","type":"uint64"},{"internalType":"address","name":"provider","type":"address"},{"internalType":"bytes32","name":"randomNumber","type":"bytes32"}],"name":"_entropyCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"addCharacterToDungeon","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dungeonEntry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entropy","outputs":[{"internalType":"contract IEntropy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllRoomStates","outputs":[{"components":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"entryIndex","type":"uint256"},{"internalType":"uint256","name":"currentHp","type":"uint256"},{"internalType":"uint256","name":"currentAttack","type":"uint256"},{"internalType":"uint256","name":"currentSpeed","type":"uint256"},{"internalType":"bool","name":"isOccupied","type":"bool"}],"internalType":"struct IDungeonGame.RoomState[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getCharacterRoom","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"roomNumber","type":"uint256"}],"name":"getRoomState","outputs":[{"components":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"entryIndex","type":"uint256"},{"internalType":"uint256","name":"currentHp","type":"uint256"},{"internalType":"uint256","name":"currentAttack","type":"uint256"},{"internalType":"uint256","name":"currentSpeed","type":"uint256"},{"internalType":"bool","name":"isOccupied","type":"bool"}],"internalType":"struct IDungeonGame.RoomState","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalRooms","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isDungeonCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftStats","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"prizePool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"progressAllCharacters","outputs":[{"components":[{"internalType":"int256","name":"hpChange","type":"int256"},{"internalType":"int256","name":"attackChange","type":"int256"},{"internalType":"int256","name":"speedChange","type":"int256"},{"internalType":"uint256","name":"xpGained","type":"uint256"},{"internalType":"bool","name":"survived","type":"bool"},{"internalType":"string","name":"encounterDescription","type":"string"},{"internalType":"uint256","name":"roomNumber","type":"uint256"}],"internalType":"struct IDungeonGame.EncounterResult[]","name":"","type":"tuple[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

6101006040523480156200001257600080fd5b506040516200297238038062002972833981016040819052620000359162000238565b6200004033620001cb565b600180556001600160a01b038416620000a05760405162461bcd60e51b815260206004820152601c60248201527f496e76616c69642044756e67656f6e456e74727920616464726573730000000060448201526064015b60405180910390fd5b6001600160a01b038316620000f85760405162461bcd60e51b815260206004820152601860248201527f496e76616c6964204e4654537461747320616464726573730000000000000000604482015260640162000097565b6001600160a01b038216620001505760405162461bcd60e51b815260206004820152601960248201527f496e76616c6964205072697a65506f6f6c206164647265737300000000000000604482015260640162000097565b6001600160a01b038116620001a85760405162461bcd60e51b815260206004820152601760248201527f496e76616c696420656e74726f70792061646472657373000000000000000000604482015260640162000097565b6001600160a01b0393841660a05291831660c052821660e0521660805262000295565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b03811681146200023357600080fd5b919050565b600080600080608085870312156200024f57600080fd5b6200025a856200021b565b93506200026a602086016200021b565b92506200027a604086016200021b565b91506200028a606086016200021b565b905092959194509250565b60805160a05160c05160e05161265d620003156000396000818161029b0152610e760152600081816103bf015281816109d1015281816112560152611a0701526000818161038b0152818161092f01526115350152600081816101da0152818161083a01528181610fde0152818161109201526115fe015261265d6000f3fe60806040526004361061010d5760003560e01c8063715018a6116100955780638da5cb5b116100645780638da5cb5b1461033b5780639a99b4f014610359578063b996e27d14610379578063e602ef36146103ad578063f2fde38b146103e157600080fd5b8063715018a614610274578063719ce73e14610289578063848e332d146102bd57806386297da61461031357600080fd5b8063476343ee116100dc578063476343ee146101b157806347ce07cc146101c857806352a5f1f81461021457806353a7543514610234578063627f6aaa1461025457600080fd5b8063026bf2b71461011957806308f28b8f146101445780632ed5f28a146101665780633dd591111461018457600080fd5b3661011457005b600080fd5b34801561012557600080fd5b5061012e610401565b60405161013b91906120f7565b60405180910390f35b34801561015057600080fd5b50610159610587565b60405161013b9190612229565b34801561017257600080fd5b5060105b60405190815260200161013b565b34801561019057600080fd5b506101a461019f366004612277565b610679565b60405161013b9190612290565b3480156101bd57600080fd5b506101c6610727565b005b3480156101d457600080fd5b506101fc7f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b03909116815260200161013b565b34801561022057600080fd5b506101c661022f3660046122c9565b610838565b34801561024057600080fd5b506101c661024f36600461230a565b610924565b34801561026057600080fd5b5061017661026f36600461230a565b610cc6565b34801561028057600080fd5b506101c6610cf1565b34801561029557600080fd5b506101fc7f000000000000000000000000000000000000000000000000000000000000000081565b3480156102c957600080fd5b506103036102d836600461230a565b6001600160a01b03919091166000908152600860209081526040808320938352929052205460ff1690565b604051901515815260200161013b565b34801561031f57600080fd5b506101fc7352deaa1c84233f7bb8c8a45baede41091c61650681565b34801561034757600080fd5b506000546001600160a01b03166101fc565b34801561036557600080fd5b506101c661037436600461230a565b610d05565b34801561038557600080fd5b506101fc7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103b957600080fd5b506101fc7f000000000000000000000000000000000000000000000000000000000000000081565b3480156103ed57600080fd5b506101c66103fc366004612336565b610ed8565b6060600060015b6010811161044a5760008181526003602052604090206006015460ff1615610438578161043481612369565b9250505b8061044281612369565b915050610408565b5060008167ffffffffffffffff81111561046657610466612382565b60405190808252806020026020018201604052801561049f57816020015b61048c612032565b8152602001906001900390816104845790505b509050600060105b6001811061057e5760008181526003602052604090206006015460ff161561056c57600081815260036020526040812080546001909101546001600160a01b03909116916104f6848484610f51565b90508086868151811061050b5761050b612398565b6020026020010181905250848061052190612369565b95505080608001511561055b5760108403610545576105408383611221565b610568565b610540846105548160016123ae565b858561134d565b61056884848460006114a4565b5050505b80610576816123c1565b9150506104a7565b50909392505050565b604080516010808252610220820190925260609160009190816020015b6105ac612071565b8152602001906001900390816105a457905050905060015b6010811161067357600081815260036020818152604092839020835160e08101855281546001600160a01b031681526001808301549382019390935260028201549481019490945291820154606084015260048201546080840152600582015460a084015260069091015460ff16151560c0830152839061064590846123d8565b8151811061065557610655612398565b6020026020010181905250808061066b90612369565b9150506105c4565b50919050565b610681612071565b600082118015610692575060108211155b6106b75760405162461bcd60e51b81526004016106ae906123eb565b60405180910390fd5b50600090815260036020818152604092839020835160e08101855281546001600160a01b0316815260018201549281019290925260028101549382019390935290820154606082015260048201546080820152600582015460a082015260069091015460ff16151560c082015290565b61072f611599565b47806107735760405162461bcd60e51b81526020600482015260136024820152724e6f206665657320746f20776974686472617760681b60448201526064016106ae565b604051600090339083908381818185875af1925050503d80600081146107b5576040519150601f19603f3d011682016040523d82523d6000602084013e6107ba565b606091505b50509050806107ff5760405162461bcd60e51b815260206004820152601160248201527015da5d1a191c985dd85b0819985a5b1959607a1b60448201526064016106ae565b60405182815233907fc0819c13be868895eb93e40eaceb96de976442fa1d404e5c55f14bb65a8c489a9060200160405180910390a25050565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0381166108af5760405162461bcd60e51b815260206004820152601760248201527f456e74726f70792061646472657373206e6f742073657400000000000000000060448201526064016106ae565b336001600160a01b038216146109135760405162461bcd60e51b815260206004820152602360248201527f4f6e6c7920456e74726f70792063616e2063616c6c20746869732066756e637460448201526234b7b760e91b60648201526084016106ae565b61091e8484846115f3565b50505050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109a85760405162461bcd60e51b8152602060048201526024808201527f4f6e6c792044756e67656f6e456e7472792063616e20616464206368617261636044820152637465727360e01b60648201526084016106ae565b604051630368516960e01b81526001600160a01b038381166004830152602482018390526000917f00000000000000000000000000000000000000000000000000000000000000009091169063036851699060440161014060405180830381865afa158015610a1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3f9190612465565b905060105b6001811115610b3b5760036000610a5c6001846123d8565b815260208101919091526040016000206006015460ff1615610b29576000600381610a886001856123d8565b815260208101919091526040016000908120546001600160a01b03169150600381610ab46001866123d8565b81526020019081526020016000206001015490506000610ad5848484610f51565b9050806080015115610b0e5760108403610af857610af38383611221565b610b25565b610af3610b066001866123d8565b85858561134d565b610b25610b1c6001866123d8565b848460006114a4565b5050505b80610b33816123c1565b915050610a44565b506040805160e0810182526001600160a01b0394851680825260208083018681524284860190815286516060860190815287840151608087019081529787015160a08701908152600160c0880181815260008281526003885298517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054c80546001600160a01b03191691909e1617909c5593517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054d5591517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054e55517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054f5595517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c305505594517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c305515595517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c30552805460ff19169115159190911790558152600785528181209381529290935291902055565b6001600160a01b03821660009081526007602090815260408083208484529091529020545b92915050565b610cf9611599565b610d036000611802565b565b6001600160a01b038216600090815260086020908152604080832084845290915290205460ff16610d715760405162461bcd60e51b8152602060048201526016602482015275139bc818dbdb5c1b195d1959081c9d5b88199bdd5b9960521b60448201526064016106ae565b6040516331a9108f60e11b8152600481018290526001600160a01b03831690636352211e90602401602060405180830381865afa158015610db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dda91906124ef565b6001600160a01b0316336001600160a01b031614610e2c5760405162461bcd60e51b815260206004820152600f60248201526e2737ba103a37b5b2b71037bbb732b960891b60448201526064016106ae565b6001600160a01b03828116600081815260086020908152604080832086845290915290819020805460ff191690555163ace79f4f60e01b81526004810191909152602481018390527f00000000000000000000000000000000000000000000000000000000000000009091169063ace79f4f90604401600060405180830381600087803b158015610ebc57600080fd5b505af1158015610ed0573d6000803e3d6000fd5b505050505050565b610ee0611599565b6001600160a01b038116610f455760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106ae565b610f4e81611802565b50565b610f59612032565b60408051602081018690526bffffffffffffffffffffffff19606086901b16918101919091526054810183905242607482015260009060940160408051601f19818403018152908290528051602090910120631711922960e31b82527352deaa1c84233f7bb8c8a45baede41091c616506600483015291506000906001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b88c914890602401602060405180830381865afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611049919061250c565b6040516319cb825f60e01b81527352deaa1c84233f7bb8c8a45baede41091c6165066004820152602481018490526001600160801b039190911691506000906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906319cb825f90849060440160206040518083038185885af11580156110dc573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111019190612535565b6040805160a0810182528981526001600160a01b0389811660208084019182528385018b8152600160608601818152608087018c815267ffffffffffffffff8a1660008181526002808852908b902099518a55965193890180546001600160a01b03191694909816939093179096559151938601939093555160038501805460ff191691151591909117905591516004909301929092559151858152929350917fbdc6d9cd20b69192d98208f944398e7220245fa28933232072f237e004b9a376910160405180910390a26040518060e00160405280600081526020016000815260200160008152602001600081526020016001151581526020016040518060200160405280600081525081526020018881525093505050509392505050565b60405163012a988f60e31b81526001600160a01b038381166004830152602482018390526101f46044830152601060648301527f00000000000000000000000000000000000000000000000000000000000000001690630954c47890608401600060405180830381600087803b15801561129a57600080fd5b505af11580156112ae573d6000803e3d6000fd5b5050506001600160a01b03831660009081526008602090815260408083208584529091529020805460ff191660019081179091556112f39150601090849084906114a4565b6040805160018152601060208201526101f48183015260006060820152905182916001600160a01b038516917f1345e8a25655895952c45bc93dbf87a34f9fc824f1611f5391a08633c068a6209181900360800190a35050565b601083111561136e5760405162461bcd60e51b81526004016106ae906123eb565b60008381526003602052604090206006015460ff16156113d05760405162461bcd60e51b815260206004820152601960248201527f44657374696e6174696f6e20726f6f6d206f636375706965640000000000000060448201526064016106ae565b6000938452600360208181526040808720868852818820815481546001600160a01b03199081166001600160a01b03928316178355600180850180549185019190915560028086018054918601918255868a0180549a87019a909a55600480880180549188019190915560058089018054918901919091556006808a01805491909901805460ff909216151560ff19928316179055429094558854909516909755918d9055908c9055968b9055928a9055918990558054909416909355939091168552600781528285209185525290912055565b600084815260036020818152604080842080546001600160a01b031916815560018101859055600281018590559283018490556004808401859055600584018590556006909301805460ff191690556001600160a01b0387811680865260078452828620888752909352818520949094555163ceef46bd60e01b8152918201526024810184905282151560448201527f00000000000000000000000000000000000000000000000000000000000000009091169063ceef46bd90606401600060405180830381600087803b15801561157b57600080fd5b505af115801561158f573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b03163314610d035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ae565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146116635760405162461bcd60e51b815260206004820152601560248201527413db9b1e48195b9d1c9bdc1e4818dbdb9d1c9858dd605a1b60448201526064016106ae565b6001600160a01b0382167352deaa1c84233f7bb8c8a45baede41091c616506146116c25760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b210383937bb34b232b960811b60448201526064016106ae565b67ffffffffffffffff8316600090815260026020818152604092839020835160a0810185528154815260018201546001600160a01b0316928101929092529182015492810192909252600381015460ff1615156060830181905260049091015460808301526117735760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073657175656e6365206e756d62657200000000000000000060448201526064016106ae565b61178b81600001518260200151836040015185611852565b5067ffffffffffffffff841660008181526002602081905260408083208381556001810180546001600160a01b031916905591820183905560038201805460ff191690556004909101829055517f4ba5186b4e7e1e2ddc4bc81ec33fc45f5f4e30c2d8e4f1e422178e3eb8cfd08d9190a250505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61185a612032565b6000858152600360205260409020600681015460ff166118b05760405162461bcd60e51b8152602060048201526011602482015270149bdbdb481b9bdd081bd8d8dd5c1a5959607a1b60448201526064016106ae565b80546001600160a01b0386811691161480156118cf5750838160010154145b6119105760405162461bcd60e51b8152602060048201526012602482015271086d0c2e4c2c6e8cae440dad2e6dac2e8c6d60731b60448201526064016106ae565b600061191c8785611a72565b6040805160e0810182526001600160a01b0389168152602081018890526002850154918101919091526003840154606082015260048401546080820152600584015460a0820152600160c082015290915060006119798383611b50565b9050806080015115611a6657805160038501546119969190612552565b6003850155602081015160048501546119af9190612552565b6004850155604081015160058501546119c89190612552565b6005850155606081015160405163012a988f60e31b81526001600160a01b038a81166004830152602482018a90526044820192909252600160648201527f000000000000000000000000000000000000000000000000000000000000000090911690630954c47890608401600060405180830381600087803b158015611a4d57600080fd5b505af1158015611a61573d6000803e3d6000fd5b505050505b98975050505050505050565b611a7a6120b9565b600083118015611a8b575060108311155b611aa75760405162461bcd60e51b81526004016106ae906123eb565b82601003611abe57611ab7611bee565b9050610ceb565b6000611acb606484612588565b90506000611ada85600661259c565b9050600a821015611af857611aef8582611c97565b92505050610ceb565b611b046014600a6123ae565b821015611b1557611aef8582611d39565b600f611b236014600a6123ae565b611b2d91906123ae565b821015611b3e57611aef8582611dfb565b611aef8582611ed4565b505092915050565b611b58612032565b6000611b648484611f8c565b9050600080828560600151611b799190612552565b139050600081611b995760028660a00151611b9491906125b3565b611b9f565b8560a001515b90506040518060e00160405280848152602001876060015181526020018760800151815260200182815260200183151581526020018760c0015181526020016000815250935050505092915050565b611bf66120b9565b6040805160e0810182526004815260646020820152908101611c1a6003601461259c565b611c23906125dd565b8152602001611c3260326125dd565b8152602001611c43600260326125f9565b611c4c906125dd565b81526020016103e881526020016040518060400160405280601981526020017f5468652064756e67656f6e20626f737320656d65726765732100000000000000815250815250905090565b611c9f6120b9565b6040805160e0810190915280600281526020810184905260146040820152606001611ccc600260326125f9565b8152602001611cdd600260326125f9565b8152602001611ced85600561259c565b611cf89060326123ae565b81526040805180820190915260208082527f596f7520646973636f7665722061206d61676963616c20626c657373696e672182820152909101529392505050565b611d416120b9565b6040805160e0810182526001815260208101849052908101611d65600260146125b3565b611d6e906125dd565b8152602001611d7f600460326125f9565b611d88906125dd565b8152602001611d99600460326125f9565b611da2906125dd565b8152602001611db285600761259c565b611dbd90604b6123ae565b815260200160405180604001604052806015815260200174596f7520747269676765726564206120747261702160581b815250815250905092915050565b611e036120b9565b60006002611e1181856125b3565b611e1c9060146123ae565b611e26919061259c565b611e2f906125dd565b6040805160e081018252600381526020810186905290810182905290915060608101611e5d600260326125f9565b8152602001611e6e600460326125f9565b611e77906125dd565b8152602001611e8786600f61259c565b611e929060966123ae565b81526040805180820190915260208082527f416e20656c69746520656e656d7920626c6f636b7320796f75722070617468218282015290910152949350505050565b611edc6120b9565b6000611ee96002846125b3565b611ef49060146123ae565b611efd906125dd565b6040805160e081019091529091508060008152602001848152602001828152602001600081526020016000815260200185600a611f3a919061259c565b611f459060646123ae565b81526020016040518060400160405280601881526020017f4120686f7374696c6520656e656d79206170706561727321000000000000000081525081525091505092915050565b60408201516000908184516004811115611fa857611fa86125c7565b1480611fc65750600384516004811115611fc457611fc46125c7565b145b80611fe35750600484516004811115611fe157611fe16125c7565b145b1561202b576000600a8460800151611ffb91906125b3565b9050600060148560a0015161201091906125b3565b905061201c81836123ae565b6120269084612552565b925050505b9392505050565b6040518060e001604052806000815260200160008152602001600081526020016000815260200160001515815260200160608152602001600081525090565b6040518060e0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081525090565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b848110156121ce57898403603f19018652825180518552888101518986015287810151888601526060808201519086015260808082015115159086015260a08082015160e091870182905280519187018290528491905b81831015612197578083018c01518884016101000152918b0191612178565b5086810161010090810186905260c09384015193880193909352978a0197601f01601f191690950101935091870191600101612121565b50919998505050505050505050565b80516001600160a01b031682526020808201519083015260408082015190830152606080820151908301526080808201519083015260a0818101519083015260c0908101511515910152565b6020808252825182820181905260009190848201906040850190845b8181101561226b576122588385516121dd565b9284019260e09290920191600101612245565b50909695505050505050565b60006020828403121561228957600080fd5b5035919050565b60e08101610ceb82846121dd565b67ffffffffffffffff81168114610f4e57600080fd5b6001600160a01b0381168114610f4e57600080fd5b6000806000606084860312156122de57600080fd5b83356122e98161229e565b925060208401356122f9816122b4565b929592945050506040919091013590565b6000806040838503121561231d57600080fd5b8235612328816122b4565b946020939093013593505050565b60006020828403121561234857600080fd5b813561202b816122b4565b634e487b7160e01b600052601160045260246000fd5b60006001820161237b5761237b612353565b5060010190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b80820180821115610ceb57610ceb612353565b6000816123d0576123d0612353565b506000190190565b81810381811115610ceb57610ceb612353565b60208082526013908201527224b73b30b634b2103937b7b690373ab6b132b960691b604082015260600190565b604051610140810167ffffffffffffffff8111828210171561244a57634e487b7160e01b600052604160045260246000fd5b60405290565b8051801515811461246057600080fd5b919050565b6000610140828403121561247857600080fd5b612480612418565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101206124e4818501612450565b908201529392505050565b60006020828403121561250157600080fd5b815161202b816122b4565b60006020828403121561251e57600080fd5b81516001600160801b038116811461202b57600080fd5b60006020828403121561254757600080fd5b815161202b8161229e565b8082018281126000831280158216821582161715611b4857611b48612353565b634e487b7160e01b600052601260045260246000fd5b60008261259757612597612572565b500690565b8082028115828204841417610ceb57610ceb612353565b6000826125c2576125c2612572565b500490565b634e487b7160e01b600052602160045260246000fd5b6000600160ff1b82016125f2576125f2612353565b5060000390565b60008261260857612608612572565b600160ff1b82146000198414161561262257612622612353565b50059056fea2646970667358221220cbc8c39af4790fb30066b87a8ecde3c830ce0051b44a613a86441195eff58b6364736f6c6343000817003300000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e000000000000000000000000edc44f3953079d90ed746142b6f2aa8f9bd22d6300000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e320

Deployed Bytecode

0x60806040526004361061010d5760003560e01c8063715018a6116100955780638da5cb5b116100645780638da5cb5b1461033b5780639a99b4f014610359578063b996e27d14610379578063e602ef36146103ad578063f2fde38b146103e157600080fd5b8063715018a614610274578063719ce73e14610289578063848e332d146102bd57806386297da61461031357600080fd5b8063476343ee116100dc578063476343ee146101b157806347ce07cc146101c857806352a5f1f81461021457806353a7543514610234578063627f6aaa1461025457600080fd5b8063026bf2b71461011957806308f28b8f146101445780632ed5f28a146101665780633dd591111461018457600080fd5b3661011457005b600080fd5b34801561012557600080fd5b5061012e610401565b60405161013b91906120f7565b60405180910390f35b34801561015057600080fd5b50610159610587565b60405161013b9190612229565b34801561017257600080fd5b5060105b60405190815260200161013b565b34801561019057600080fd5b506101a461019f366004612277565b610679565b60405161013b9190612290565b3480156101bd57600080fd5b506101c6610727565b005b3480156101d457600080fd5b506101fc7f00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e32081565b6040516001600160a01b03909116815260200161013b565b34801561022057600080fd5b506101c661022f3660046122c9565b610838565b34801561024057600080fd5b506101c661024f36600461230a565b610924565b34801561026057600080fd5b5061017661026f36600461230a565b610cc6565b34801561028057600080fd5b506101c6610cf1565b34801561029557600080fd5b506101fc7f000000000000000000000000edc44f3953079d90ed746142b6f2aa8f9bd22d6381565b3480156102c957600080fd5b506103036102d836600461230a565b6001600160a01b03919091166000908152600860209081526040808320938352929052205460ff1690565b604051901515815260200161013b565b34801561031f57600080fd5b506101fc7352deaa1c84233f7bb8c8a45baede41091c61650681565b34801561034757600080fd5b506000546001600160a01b03166101fc565b34801561036557600080fd5b506101c661037436600461230a565b610d05565b34801561038557600080fd5b506101fc7f00000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a81565b3480156103b957600080fd5b506101fc7f000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e81565b3480156103ed57600080fd5b506101c66103fc366004612336565b610ed8565b6060600060015b6010811161044a5760008181526003602052604090206006015460ff1615610438578161043481612369565b9250505b8061044281612369565b915050610408565b5060008167ffffffffffffffff81111561046657610466612382565b60405190808252806020026020018201604052801561049f57816020015b61048c612032565b8152602001906001900390816104845790505b509050600060105b6001811061057e5760008181526003602052604090206006015460ff161561056c57600081815260036020526040812080546001909101546001600160a01b03909116916104f6848484610f51565b90508086868151811061050b5761050b612398565b6020026020010181905250848061052190612369565b95505080608001511561055b5760108403610545576105408383611221565b610568565b610540846105548160016123ae565b858561134d565b61056884848460006114a4565b5050505b80610576816123c1565b9150506104a7565b50909392505050565b604080516010808252610220820190925260609160009190816020015b6105ac612071565b8152602001906001900390816105a457905050905060015b6010811161067357600081815260036020818152604092839020835160e08101855281546001600160a01b031681526001808301549382019390935260028201549481019490945291820154606084015260048201546080840152600582015460a084015260069091015460ff16151560c0830152839061064590846123d8565b8151811061065557610655612398565b6020026020010181905250808061066b90612369565b9150506105c4565b50919050565b610681612071565b600082118015610692575060108211155b6106b75760405162461bcd60e51b81526004016106ae906123eb565b60405180910390fd5b50600090815260036020818152604092839020835160e08101855281546001600160a01b0316815260018201549281019290925260028101549382019390935290820154606082015260048201546080820152600582015460a082015260069091015460ff16151560c082015290565b61072f611599565b47806107735760405162461bcd60e51b81526020600482015260136024820152724e6f206665657320746f20776974686472617760681b60448201526064016106ae565b604051600090339083908381818185875af1925050503d80600081146107b5576040519150601f19603f3d011682016040523d82523d6000602084013e6107ba565b606091505b50509050806107ff5760405162461bcd60e51b815260206004820152601160248201527015da5d1a191c985dd85b0819985a5b1959607a1b60448201526064016106ae565b60405182815233907fc0819c13be868895eb93e40eaceb96de976442fa1d404e5c55f14bb65a8c489a9060200160405180910390a25050565b7f00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e3206001600160a01b0381166108af5760405162461bcd60e51b815260206004820152601760248201527f456e74726f70792061646472657373206e6f742073657400000000000000000060448201526064016106ae565b336001600160a01b038216146109135760405162461bcd60e51b815260206004820152602360248201527f4f6e6c7920456e74726f70792063616e2063616c6c20746869732066756e637460448201526234b7b760e91b60648201526084016106ae565b61091e8484846115f3565b50505050565b336001600160a01b037f00000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a16146109a85760405162461bcd60e51b8152602060048201526024808201527f4f6e6c792044756e67656f6e456e7472792063616e20616464206368617261636044820152637465727360e01b60648201526084016106ae565b604051630368516960e01b81526001600160a01b038381166004830152602482018390526000917f000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e9091169063036851699060440161014060405180830381865afa158015610a1b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a3f9190612465565b905060105b6001811115610b3b5760036000610a5c6001846123d8565b815260208101919091526040016000206006015460ff1615610b29576000600381610a886001856123d8565b815260208101919091526040016000908120546001600160a01b03169150600381610ab46001866123d8565b81526020019081526020016000206001015490506000610ad5848484610f51565b9050806080015115610b0e5760108403610af857610af38383611221565b610b25565b610af3610b066001866123d8565b85858561134d565b610b25610b1c6001866123d8565b848460006114a4565b5050505b80610b33816123c1565b915050610a44565b506040805160e0810182526001600160a01b0394851680825260208083018681524284860190815286516060860190815287840151608087019081529787015160a08701908152600160c0880181815260008281526003885298517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054c80546001600160a01b03191691909e1617909c5593517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054d5591517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054e55517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c3054f5595517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c305505594517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c305515595517fa15bc60c955c405d20d9149c709e2460f1c2d9a497496a7f46004d1772c30552805460ff19169115159190911790558152600785528181209381529290935291902055565b6001600160a01b03821660009081526007602090815260408083208484529091529020545b92915050565b610cf9611599565b610d036000611802565b565b6001600160a01b038216600090815260086020908152604080832084845290915290205460ff16610d715760405162461bcd60e51b8152602060048201526016602482015275139bc818dbdb5c1b195d1959081c9d5b88199bdd5b9960521b60448201526064016106ae565b6040516331a9108f60e11b8152600481018290526001600160a01b03831690636352211e90602401602060405180830381865afa158015610db6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dda91906124ef565b6001600160a01b0316336001600160a01b031614610e2c5760405162461bcd60e51b815260206004820152600f60248201526e2737ba103a37b5b2b71037bbb732b960891b60448201526064016106ae565b6001600160a01b03828116600081815260086020908152604080832086845290915290819020805460ff191690555163ace79f4f60e01b81526004810191909152602481018390527f000000000000000000000000edc44f3953079d90ed746142b6f2aa8f9bd22d639091169063ace79f4f90604401600060405180830381600087803b158015610ebc57600080fd5b505af1158015610ed0573d6000803e3d6000fd5b505050505050565b610ee0611599565b6001600160a01b038116610f455760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106ae565b610f4e81611802565b50565b610f59612032565b60408051602081018690526bffffffffffffffffffffffff19606086901b16918101919091526054810183905242607482015260009060940160408051601f19818403018152908290528051602090910120631711922960e31b82527352deaa1c84233f7bb8c8a45baede41091c616506600483015291506000906001600160a01b037f00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e320169063b88c914890602401602060405180830381865afa158015611025573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611049919061250c565b6040516319cb825f60e01b81527352deaa1c84233f7bb8c8a45baede41091c6165066004820152602481018490526001600160801b039190911691506000906001600160a01b037f00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e32016906319cb825f90849060440160206040518083038185885af11580156110dc573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906111019190612535565b6040805160a0810182528981526001600160a01b0389811660208084019182528385018b8152600160608601818152608087018c815267ffffffffffffffff8a1660008181526002808852908b902099518a55965193890180546001600160a01b03191694909816939093179096559151938601939093555160038501805460ff191691151591909117905591516004909301929092559151858152929350917fbdc6d9cd20b69192d98208f944398e7220245fa28933232072f237e004b9a376910160405180910390a26040518060e00160405280600081526020016000815260200160008152602001600081526020016001151581526020016040518060200160405280600081525081526020018881525093505050509392505050565b60405163012a988f60e31b81526001600160a01b038381166004830152602482018390526101f46044830152601060648301527f000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e1690630954c47890608401600060405180830381600087803b15801561129a57600080fd5b505af11580156112ae573d6000803e3d6000fd5b5050506001600160a01b03831660009081526008602090815260408083208584529091529020805460ff191660019081179091556112f39150601090849084906114a4565b6040805160018152601060208201526101f48183015260006060820152905182916001600160a01b038516917f1345e8a25655895952c45bc93dbf87a34f9fc824f1611f5391a08633c068a6209181900360800190a35050565b601083111561136e5760405162461bcd60e51b81526004016106ae906123eb565b60008381526003602052604090206006015460ff16156113d05760405162461bcd60e51b815260206004820152601960248201527f44657374696e6174696f6e20726f6f6d206f636375706965640000000000000060448201526064016106ae565b6000938452600360208181526040808720868852818820815481546001600160a01b03199081166001600160a01b03928316178355600180850180549185019190915560028086018054918601918255868a0180549a87019a909a55600480880180549188019190915560058089018054918901919091556006808a01805491909901805460ff909216151560ff19928316179055429094558854909516909755918d9055908c9055968b9055928a9055918990558054909416909355939091168552600781528285209185525290912055565b600084815260036020818152604080842080546001600160a01b031916815560018101859055600281018590559283018490556004808401859055600584018590556006909301805460ff191690556001600160a01b0387811680865260078452828620888752909352818520949094555163ceef46bd60e01b8152918201526024810184905282151560448201527f00000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a9091169063ceef46bd90606401600060405180830381600087803b15801561157b57600080fd5b505af115801561158f573d6000803e3d6000fd5b5050505050505050565b6000546001600160a01b03163314610d035760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ae565b336001600160a01b037f00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e32016146116635760405162461bcd60e51b815260206004820152601560248201527413db9b1e48195b9d1c9bdc1e4818dbdb9d1c9858dd605a1b60448201526064016106ae565b6001600160a01b0382167352deaa1c84233f7bb8c8a45baede41091c616506146116c25760405162461bcd60e51b815260206004820152601060248201526f24b73b30b634b210383937bb34b232b960811b60448201526064016106ae565b67ffffffffffffffff8316600090815260026020818152604092839020835160a0810185528154815260018201546001600160a01b0316928101929092529182015492810192909252600381015460ff1615156060830181905260049091015460808301526117735760405162461bcd60e51b815260206004820152601760248201527f496e76616c69642073657175656e6365206e756d62657200000000000000000060448201526064016106ae565b61178b81600001518260200151836040015185611852565b5067ffffffffffffffff841660008181526002602081905260408083208381556001810180546001600160a01b031916905591820183905560038201805460ff191690556004909101829055517f4ba5186b4e7e1e2ddc4bc81ec33fc45f5f4e30c2d8e4f1e422178e3eb8cfd08d9190a250505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b61185a612032565b6000858152600360205260409020600681015460ff166118b05760405162461bcd60e51b8152602060048201526011602482015270149bdbdb481b9bdd081bd8d8dd5c1a5959607a1b60448201526064016106ae565b80546001600160a01b0386811691161480156118cf5750838160010154145b6119105760405162461bcd60e51b8152602060048201526012602482015271086d0c2e4c2c6e8cae440dad2e6dac2e8c6d60731b60448201526064016106ae565b600061191c8785611a72565b6040805160e0810182526001600160a01b0389168152602081018890526002850154918101919091526003840154606082015260048401546080820152600584015460a0820152600160c082015290915060006119798383611b50565b9050806080015115611a6657805160038501546119969190612552565b6003850155602081015160048501546119af9190612552565b6004850155604081015160058501546119c89190612552565b6005850155606081015160405163012a988f60e31b81526001600160a01b038a81166004830152602482018a90526044820192909252600160648201527f000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e90911690630954c47890608401600060405180830381600087803b158015611a4d57600080fd5b505af1158015611a61573d6000803e3d6000fd5b505050505b98975050505050505050565b611a7a6120b9565b600083118015611a8b575060108311155b611aa75760405162461bcd60e51b81526004016106ae906123eb565b82601003611abe57611ab7611bee565b9050610ceb565b6000611acb606484612588565b90506000611ada85600661259c565b9050600a821015611af857611aef8582611c97565b92505050610ceb565b611b046014600a6123ae565b821015611b1557611aef8582611d39565b600f611b236014600a6123ae565b611b2d91906123ae565b821015611b3e57611aef8582611dfb565b611aef8582611ed4565b505092915050565b611b58612032565b6000611b648484611f8c565b9050600080828560600151611b799190612552565b139050600081611b995760028660a00151611b9491906125b3565b611b9f565b8560a001515b90506040518060e00160405280848152602001876060015181526020018760800151815260200182815260200183151581526020018760c0015181526020016000815250935050505092915050565b611bf66120b9565b6040805160e0810182526004815260646020820152908101611c1a6003601461259c565b611c23906125dd565b8152602001611c3260326125dd565b8152602001611c43600260326125f9565b611c4c906125dd565b81526020016103e881526020016040518060400160405280601981526020017f5468652064756e67656f6e20626f737320656d65726765732100000000000000815250815250905090565b611c9f6120b9565b6040805160e0810190915280600281526020810184905260146040820152606001611ccc600260326125f9565b8152602001611cdd600260326125f9565b8152602001611ced85600561259c565b611cf89060326123ae565b81526040805180820190915260208082527f596f7520646973636f7665722061206d61676963616c20626c657373696e672182820152909101529392505050565b611d416120b9565b6040805160e0810182526001815260208101849052908101611d65600260146125b3565b611d6e906125dd565b8152602001611d7f600460326125f9565b611d88906125dd565b8152602001611d99600460326125f9565b611da2906125dd565b8152602001611db285600761259c565b611dbd90604b6123ae565b815260200160405180604001604052806015815260200174596f7520747269676765726564206120747261702160581b815250815250905092915050565b611e036120b9565b60006002611e1181856125b3565b611e1c9060146123ae565b611e26919061259c565b611e2f906125dd565b6040805160e081018252600381526020810186905290810182905290915060608101611e5d600260326125f9565b8152602001611e6e600460326125f9565b611e77906125dd565b8152602001611e8786600f61259c565b611e929060966123ae565b81526040805180820190915260208082527f416e20656c69746520656e656d7920626c6f636b7320796f75722070617468218282015290910152949350505050565b611edc6120b9565b6000611ee96002846125b3565b611ef49060146123ae565b611efd906125dd565b6040805160e081019091529091508060008152602001848152602001828152602001600081526020016000815260200185600a611f3a919061259c565b611f459060646123ae565b81526020016040518060400160405280601881526020017f4120686f7374696c6520656e656d79206170706561727321000000000000000081525081525091505092915050565b60408201516000908184516004811115611fa857611fa86125c7565b1480611fc65750600384516004811115611fc457611fc46125c7565b145b80611fe35750600484516004811115611fe157611fe16125c7565b145b1561202b576000600a8460800151611ffb91906125b3565b9050600060148560a0015161201091906125b3565b905061201c81836123ae565b6120269084612552565b925050505b9392505050565b6040518060e001604052806000815260200160008152602001600081526020016000815260200160001515815260200160608152602001600081525090565b6040518060e0016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000151581525090565b6040805160e0810190915280600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081525090565b600060208083018184528085518083526040925060408601915060408160051b8701018488016000805b848110156121ce57898403603f19018652825180518552888101518986015287810151888601526060808201519086015260808082015115159086015260a08082015160e091870182905280519187018290528491905b81831015612197578083018c01518884016101000152918b0191612178565b5086810161010090810186905260c09384015193880193909352978a0197601f01601f191690950101935091870191600101612121565b50919998505050505050505050565b80516001600160a01b031682526020808201519083015260408082015190830152606080820151908301526080808201519083015260a0818101519083015260c0908101511515910152565b6020808252825182820181905260009190848201906040850190845b8181101561226b576122588385516121dd565b9284019260e09290920191600101612245565b50909695505050505050565b60006020828403121561228957600080fd5b5035919050565b60e08101610ceb82846121dd565b67ffffffffffffffff81168114610f4e57600080fd5b6001600160a01b0381168114610f4e57600080fd5b6000806000606084860312156122de57600080fd5b83356122e98161229e565b925060208401356122f9816122b4565b929592945050506040919091013590565b6000806040838503121561231d57600080fd5b8235612328816122b4565b946020939093013593505050565b60006020828403121561234857600080fd5b813561202b816122b4565b634e487b7160e01b600052601160045260246000fd5b60006001820161237b5761237b612353565b5060010190565b634e487b7160e01b600052604160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b80820180821115610ceb57610ceb612353565b6000816123d0576123d0612353565b506000190190565b81810381811115610ceb57610ceb612353565b60208082526013908201527224b73b30b634b2103937b7b690373ab6b132b960691b604082015260600190565b604051610140810167ffffffffffffffff8111828210171561244a57634e487b7160e01b600052604160045260246000fd5b60405290565b8051801515811461246057600080fd5b919050565b6000610140828403121561247857600080fd5b612480612418565b825181526020830151602082015260408301516040820152606083015160608201526080830151608082015260a083015160a082015260c083015160c082015260e083015160e08201526101008084015181830152506101206124e4818501612450565b908201529392505050565b60006020828403121561250157600080fd5b815161202b816122b4565b60006020828403121561251e57600080fd5b81516001600160801b038116811461202b57600080fd5b60006020828403121561254757600080fd5b815161202b8161229e565b8082018281126000831280158216821582161715611b4857611b48612353565b634e487b7160e01b600052601260045260246000fd5b60008261259757612597612572565b500690565b8082028115828204841417610ceb57610ceb612353565b6000826125c2576125c2612572565b500490565b634e487b7160e01b600052602160045260246000fd5b6000600160ff1b82016125f2576125f2612353565b5060000390565b60008261260857612608612572565b600160ff1b82146000198414161561262257612622612353565b50059056fea2646970667358221220cbc8c39af4790fb30066b87a8ecde3c830ce0051b44a613a86441195eff58b6364736f6c63430008170033

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

00000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e000000000000000000000000edc44f3953079d90ed746142b6f2aa8f9bd22d6300000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e320

-----Decoded View---------------
Arg [0] : _dungeonEntry (address): 0x36887BdBFE3d46eb1c615E1c90b727B04cCfb43A
Arg [1] : _nftStats (address): 0xc42fACfc9a6277904c8F23558d07b2F9EEC6417E
Arg [2] : _prizePool (address): 0xEDC44f3953079D90Ed746142B6f2Aa8f9Bd22d63
Arg [3] : _entropy (address): 0x36825bf3Fbdf5a29E2d5148bfe7Dcf7B5639e320

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 00000000000000000000000036887bdbfe3d46eb1c615e1c90b727b04ccfb43a
Arg [1] : 000000000000000000000000c42facfc9a6277904c8f23558d07b2f9eec6417e
Arg [2] : 000000000000000000000000edc44f3953079d90ed746142b6f2aa8f9bd22d63
Arg [3] : 00000000000000000000000036825bf3fbdf5a29e2d5148bfe7dcf7b5639e320


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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