账户
0x08...06e8
0x08...06E8

0x08...06E8

US$0.00
此合同的源代码已经过验证!
合同元数据
编译器
0.8.24+commit.e11b9ed9
语言
Solidity
合同源代码
文件 1 的 6:Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

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

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}
合同源代码
文件 2 的 6:Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
合同源代码
文件 3 的 6:DotGameChain.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";

// ::::::::::::::::         :::::::::::::::::::::    :::::::::::::::::::::
// ::::::::::::::::         :::::::::::::::::::::    :::::::::::::::::::::
// :::::::::::::::::::::    :::::::::::::::::::::    :::::::::::::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::    ::::::::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::    ::::::::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::     :::::::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::         :::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::         :::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::         :::::::::::
// :::::::::::    ::::::    :::::::::::    ::::::         :::::::::::
// :::::::::::::::::::::    :::::::::::::::::::::         :::::::::::
// ::::::::::::::::         :::::::::::::::::::::         :::::::::::
// ::::::::::::::::         :::::::::::::::::::::         :::::::::::

contract DotGameChain is ReentrancyGuard, Ownable, Pausable {
    // State Variables
    bool private _initialized;
    uint256 private _reserved;
    uint256 private _moveCount;
    uint256 private _spellCount;

    // Structs
    struct Move {
        address player;
        uint256 moveTime;
        string team;
        string gameId;
        uint256 placement;
    }
    
    struct Spell {
        address player;
        uint256 spellTime;
        string team;
        string gameId;
        uint256 placement;
        string spellType;
    }

    // Mappings
    mapping(string => string) private _spellURIs;
    mapping(address => bool) public flaggedPlayers;
    mapping(uint256 => Move) private _moves;
    mapping(uint256 => Spell) private _spells;
    mapping(address => uint256) private _sharePerWallet;

    // Events
    event MoveStored(string indexed gameId, address indexed player, uint256 moveTime, string team, uint256 placement);
    event SpellStored(string indexed gameId, address indexed player, uint256 spellTime, string team, uint256 placement, string spellType);
    event AmountReserved(address indexed player, uint256 amount);
    event Withdrawal(address indexed player, uint256 amount);
    event WithdrawalDot(uint256 amount);
    event AmountUnreserved(address indexed player, uint256 amount);

    // Constructor
    constructor(address initialOwner) Ownable(initialOwner) {
        require(!_initialized, "Already initialized");
        _initialized = true;
    }

    // Receive function
    receive() external payable {}

    // External functions
    /// Withdraw Reserved
    /// @dev Withdraws the reserved balance from the contract
    function withdraw() public nonReentrant() whenNotPaused() returns (uint256) {
        address payable player = payable(msg.sender);
        uint256 amount = _sharePerWallet[player];

        require(amount > 0, "User has no balance to withdraw");
        require(amount <= address(this).balance, "Insufficient balance on contract");

        _sharePerWallet[player] = 0;
        _reserved -= amount;

        Address.sendValue(player, amount);

        emit Withdrawal(player, amount);

        return amount;
    }

    /// Withdraw For Player
    /// @param player player address
    /// @dev Withdraws the reserved balance for a player
    function withdrawForPlayer(
        address payable player
    ) public onlyOwner() nonReentrant() whenNotPaused() returns (uint256) {
        uint256 amount = _sharePerWallet[player];

        require(amount > 0, "User has no balance to withdraw");
        require(amount <= address(this).balance, "Insufficient balance on contract");

        _sharePerWallet[player] = 0;
        _reserved -= amount;

        Address.sendValue(player, amount);

        emit Withdrawal(player, amount);

        return amount;
    }

    /// Withdraw
    /// @dev Withdraws the entire balance from the contract
    function withdrawDot() public onlyOwner() nonReentrant() whenNotPaused() returns (uint256) {
        uint256 amount = address(this).balance - _reserved;

        require(amount > 0, "Insufficient balance on contract");

        Address.sendValue(payable(owner()), amount);

        emit WithdrawalDot(amount);

        return amount;
    }
    
    /// Withdraw Partial
    /// @param amount amount to withdraw
    /// @dev Withdraws a specific amount from the contract
    function withdrawDotPartial(
        uint256 amount
    ) public onlyOwner() nonReentrant() whenNotPaused() returns (uint256) {
        require(amount <= address(this).balance - _reserved, "Insufficient balance on contract");

        Address.sendValue(payable(owner()), amount);

        emit WithdrawalDot(amount);

        return amount;
    }

    /// Set Spell URI
    /// @param spellId spell id
    /// @param uri spell uri
    /// @dev Set the URI of a spell card
    function setSpellURI(string memory spellId, string memory uri) public onlyOwner() nonReentrant() whenNotPaused() {
        _spellURIs[spellId] = uri;
    }

    /// Flag Player
    /// @param player player address
    /// @dev Flag a player
    function flagPlayer(address player) public onlyOwner() nonReentrant() whenNotPaused() {
        flaggedPlayers[player] = true;
    }

    /// Unflag Player
    /// @param player player address
    /// @dev Unflag a player
    function unflagPlayer(address player) public onlyOwner() nonReentrant() whenNotPaused() {
        flaggedPlayers[player] = false;
    }

    /// Store Move
    /// @param gameId game id
    /// @param moveTime move time
    /// @param team team slug
    /// @param placement placement on the board
    /// @param player player address
    /// @dev Store a move
    function storeMove(
        string memory gameId,
        uint256 moveTime,
        string memory team,
        uint256 placement,
        address player
    ) public onlyOwner() nonReentrant() whenNotPaused() {
        require(bytes(gameId).length > 0, "Game ID cannot be empty");
        require(bytes(team).length > 0, "Team cannot be empty");
        require(player != address(0), "Invalid player address");

        _moves[_moveCount].team = team;
        _moves[_moveCount].moveTime = moveTime;
        _moves[_moveCount].gameId = gameId;
        _moves[_moveCount].player = player;
        _moves[_moveCount].placement = placement;
        _moveCount++;

        emit MoveStored(gameId, player, moveTime, team, placement);
    }

    /// Store Spell
    /// @param gameId game id
    /// @param spellTime spell time
    /// @param team team slug
    /// @param placement placement on the board
    /// @param spellType spell type
    /// @param player player address
    /// @dev Store a move
    function storeSpell(
        string memory gameId,
        uint256 spellTime,
        string memory team,
        uint256 placement,
        string memory spellType,
        address player
    ) public onlyOwner() nonReentrant() whenNotPaused() {
        require(bytes(gameId).length > 0, "Game ID cannot be empty");
        require(bytes(team).length > 0, "Team cannot be empty");
        require(bytes(spellType).length > 0, "Spell type cannot be empty");
        require(player != address(0), "Invalid player address");

        _spells[_spellCount].team = team;
        _spells[_spellCount].spellTime = spellTime;
        _spells[_spellCount].gameId = gameId;
        _spells[_spellCount].player = player;
        _spells[_spellCount].placement = placement;
        _spells[_spellCount].spellType = spellType;
        _spellCount++;

        emit SpellStored(gameId, player, spellTime, team, placement, spellType);
    }

    // Reserve an amount for player
    /// @param player player address
    /// @param amount amount to pay
    /// @dev Reserve an amount for a player
    function reserveForPlayer(address player, uint256 amount) public onlyOwner() nonReentrant() whenNotPaused() {
        require(amount > 0, "Amount must be greater than 0");
        require(!flaggedPlayers[player], "Player is flagged");
        
        if(_sharePerWallet[player] > 0) {
            _sharePerWallet[player] += amount;
        } else {
            _sharePerWallet[player] = amount;
        }

        _reserved += amount;

        emit AmountReserved(player, amount);
    }

    /// Unreserve an amount for player
    /// @param player player address
    /// @param amount amount to unreserve
    /// @dev Unreserve an amount for a player
    function unreserveForPlayer(address player, uint256 amount) public onlyOwner() nonReentrant() whenNotPaused() {
        require(amount > 0, "Amount must be greater than 0");
        require(_sharePerWallet[player] >= amount, "Insufficient reserved balance for player");
        
        _sharePerWallet[player] -= amount;
        _reserved -= amount;

        emit AmountUnreserved(player, amount);
    }

    /// Get Reserved Balance 
    /// @return reserved balance
    /// @dev Get the reserved balance
    function reservedForDot() public view returns (uint256) {
        return address(this).balance - _reserved;
    }

    /// Get Reserved Balance for Players
    /// @return reserved balance for players
    /// @dev Get the reserved balance for players
    function reservedForPlayers() public view returns (uint256) {
        return _reserved;
    }

    /// Get Reserved Balance for Player
    /// @param player player address
    /// @return reserved balance for player
    /// @dev Get the reserved balance for a player
    function reservedForPlayer(
        address player
    ) public view returns (uint256) {
        return _sharePerWallet[player];
    }

    /// Get Move Count
    /// @return move count
    /// @dev Get the total number of moves
    function getMoveCount() public view returns (uint256) {
        return _moveCount;
    }

    /// Get Spell Count
    /// @return spell count
    /// @dev Get the total number of spells
    function getSpellCount() public view returns (uint256) {
        return _spellCount;
    }

    /// Get All Moves
    /// @return all moves
    /// @dev Get all moves
    function getAllMoves() public view returns (Move[] memory) {
        Move[] memory result = new Move[](_moveCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _moveCount; i++) {
            result[count] = _moves[i];
            count++;
        }

        return result;
    }

    /// Get All Spells
    /// @return all spells
    /// @dev Get all spells
    function getAllSpells() public view returns (Spell[] memory) {
        Spell[] memory result = new Spell[](_spellCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _spellCount; i++) {
            result[count] = _spells[i];
            count++;
        }

        return result;
    }

    /// Get Moves by player
    /// @param player player address
    /// @return moves by player
    /// @dev Get moves by player
    function getMovesByPlayer(address player) public view returns (Move[] memory) {
        Move[] memory getMoves = new Move[](_moveCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _moveCount; i++) {
            if(_moves[i].player == player) {
                getMoves[count] = _moves[i];
                count++;
            }
        }

        Move[] memory result = new Move[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getMoves[i];
        }

        return result;
    }

    /// Get Spells by player
    /// @param player player address
    /// @return spells by player
    /// @dev Get spells by player
    function getSpellsByPlayer(address player) public view returns (Spell[] memory) {
        Spell[] memory getSpells = new Spell[](_spellCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _spellCount; i++) {
            if(_spells[i].player == player) {
                getSpells[count] = _spells[i];
                count++;
            }
        }

        Spell[] memory result = new Spell[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getSpells[i];
        }

        return result;
    }

    /// Get Moves by game
    /// @param gameId game id
    /// @return moves by game
    /// @dev Get moves by game
    function getMovesByGame(string memory gameId) public view returns (Move[] memory) {
        Move[] memory getMoves = new Move[](_moveCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _moveCount; i++){
            if(compareStrings(_moves[i].gameId, gameId)) {
                getMoves[count] = _moves[i];
                count++;
            }
        }

        Move[] memory result = new Move[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getMoves[i];
        }

        return result;
    }

    /// Get Spells by game
    /// @param gameId game id
    /// @return spells by game
    /// @dev Get spells by game
    function getSpellsByGame(string memory gameId) public view returns (Spell[] memory) {
        Spell[] memory getSpells = new Spell[](_spellCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _spellCount; i++){
            if(compareStrings(_spells[i].gameId, gameId)) {
                getSpells[count] = _spells[i];
                count++;
            }
        }

        Spell[] memory result = new Spell[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getSpells[i];
        }

        return result;
    }

    /// Get Player Moves by game
    /// @param player player address
    /// @param gameId game id
    /// @return moves by game and player
    /// @dev Get player moves by game
    function getUserMovesByGame(address player, string memory gameId) public view returns (Move[] memory) {
        Move[] memory getMoves = new Move[](_moveCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _moveCount; i++){
            if(compareStrings(_moves[i].gameId, gameId) && _moves[i].player == player) {
                getMoves[count] = _moves[i];
                count++;
            }
        }

        Move[] memory result = new Move[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getMoves[i];
        }

        return result;
    }

    /// Get Player Spells by game
    /// @param player player address
    /// @param gameId game id
    /// @return spells by game and player
    /// @dev Get player spells by game
    function getUserSpellsByGame(address player, string memory gameId) public view returns (Spell[] memory) {
        Spell[] memory getSpells = new Spell[](_spellCount);
        uint256 count = 0;

        for(uint256 i = 0; i < _spellCount; i++){
            if(compareStrings(_spells[i].gameId, gameId) && _spells[i].player == player) {
                getSpells[count] = _spells[i];
                count++;
            }
        }

        Spell[] memory result = new Spell[](count);

        for (uint256 i = 0; i < count; i++) {
            result[i] = getSpells[i];
        }

        return result;
    }

    // Private functions
    function compareStrings(string memory a, string memory b) private pure returns (bool) {
        return (keccak256(abi.encodePacked((a))) == keccak256(abi.encodePacked((b))));
    }

    /// Pause
    /// @dev Pauses the contract
    function pause() public onlyOwner {
        _pause();
    }

    /// Unpause
    /// @dev Unpauses the contract
    function unpause() public onlyOwner {
        _unpause();
    }
}
合同源代码
文件 4 的 6:Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
合同源代码
文件 5 的 6:Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

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

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

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

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

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

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

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

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

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}
合同源代码
文件 6 的 6:ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

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

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    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
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // 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;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
设置
{
  "compilationTarget": {
    "contracts/DotGameChain.sol": "DotGameChain"
  },
  "evmVersion": "paris",
  "libraries": {},
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "optimizer": {
    "enabled": false,
    "runs": 200
  },
  "remappings": []
}
ABI
[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AmountReserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AmountUnreserved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"gameId","type":"string"},{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"moveTime","type":"uint256"},{"indexed":false,"internalType":"string","name":"team","type":"string"},{"indexed":false,"internalType":"uint256","name":"placement","type":"uint256"}],"name":"MoveStored","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"string","name":"gameId","type":"string"},{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"spellTime","type":"uint256"},{"indexed":false,"internalType":"string","name":"team","type":"string"},{"indexed":false,"internalType":"uint256","name":"placement","type":"uint256"},{"indexed":false,"internalType":"string","name":"spellType","type":"string"}],"name":"SpellStored","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawalDot","type":"event"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"flagPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"flaggedPlayers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllMoves","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"moveTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"}],"internalType":"struct DotGameChain.Move[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAllSpells","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"spellTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"string","name":"spellType","type":"string"}],"internalType":"struct DotGameChain.Spell[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMoveCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"gameId","type":"string"}],"name":"getMovesByGame","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"moveTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"}],"internalType":"struct DotGameChain.Move[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"getMovesByPlayer","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"moveTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"}],"internalType":"struct DotGameChain.Move[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getSpellCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"gameId","type":"string"}],"name":"getSpellsByGame","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"spellTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"string","name":"spellType","type":"string"}],"internalType":"struct DotGameChain.Spell[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"getSpellsByPlayer","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"spellTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"string","name":"spellType","type":"string"}],"internalType":"struct DotGameChain.Spell[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"},{"internalType":"string","name":"gameId","type":"string"}],"name":"getUserMovesByGame","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"moveTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"}],"internalType":"struct DotGameChain.Move[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"},{"internalType":"string","name":"gameId","type":"string"}],"name":"getUserSpellsByGame","outputs":[{"components":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"spellTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"string","name":"spellType","type":"string"}],"internalType":"struct DotGameChain.Spell[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"reserveForPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reservedForDot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"reservedForPlayer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reservedForPlayers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"spellId","type":"string"},{"internalType":"string","name":"uri","type":"string"}],"name":"setSpellURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"moveTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"address","name":"player","type":"address"}],"name":"storeMove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"gameId","type":"string"},{"internalType":"uint256","name":"spellTime","type":"uint256"},{"internalType":"string","name":"team","type":"string"},{"internalType":"uint256","name":"placement","type":"uint256"},{"internalType":"string","name":"spellType","type":"string"},{"internalType":"address","name":"player","type":"address"}],"name":"storeSpell","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"}],"name":"unflagPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"player","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unreserveForPlayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawDot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawDotPartial","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"player","type":"address"}],"name":"withdrawForPlayer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]