Forkchoice Ethereum Mainnet

Address Contract Partially Verified

Address 0x67765B835659b57801cE25B1fa169393D628DF0D
Balance 0 ETH
Nonce 1
Code Size 5463 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

5463 bytes
0x608060405234801561000f575f80fd5b50600436106100a7575f3560e01c8063771602f71161006f578063771602f7146101615780638da5cb5b1461017d578063a1258e5e1461019b578063f2fde38b146101b7578063fa3908b1146101d3578063ff842a7014610206576100a7565b80631b94ca9f146100ab57806330c3ab12146100db57806330f24e79146100f75780636c6458f114610127578063715018a614610157575b5f80fd5b6100c560048036038101906100c09190610d90565b610222565b6040516100d29190610e8e565b60405180910390f35b6100f560048036038101906100f09190610f08565b6102e0565b005b610111600480360381019061010c9190610f08565b61032b565b60405161011e9190610f4d565b60405180910390f35b610141600480360381019061013c9190610d90565b610383565b60405161014e9190610fb9565b60405180910390f35b61015f6104c3565b005b61017b60048036038101906101769190610fd2565b6104d6565b005b61018561054b565b604051610192919061101f565b60405180910390f35b6101b560048036038101906101b09190611038565b610572565b005b6101d160048036038101906101cc9190610f08565b610614565b005b6101ed60048036038101906101e891906110ae565b610698565b6040516101fd94939291906110e8565b60405180910390f35b610220600480360381019061021b919061112b565b6106c4565b005b60605f825167ffffffffffffffff8111156102405761023f610c21565b5b60405190808252806020026020018201604052801561026e5781602001602082028036833780820191505090505b5090505f5b83518110156102d65760045f8583815181106102925761029161117b565b5b602002602001015181526020019081526020015f205f01548282815181106102bd576102bc61117b565b5b6020026020010181815250508080600101915050610273565b5080915050919050565b6102e86106e6565b8060055f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b5f60055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b61038b610bd8565b5f5b82518110156104bd5760045f8483815181106103ac576103ab61117b565b5b602002602001015181526020019081526020015f205f0154825f018181516103d491906111d5565b9150818152505060045f8483815181106103f1576103f061117b565b5b602002602001015181526020019081526020015f20600101548260200181815161041b91906111d5565b9150818152505060045f8483815181106104385761043761117b565b5b602002602001015181526020019081526020015f20600201548260400181815161046291906111d5565b9150818152505060045f84838151811061047f5761047e61117b565b5b602002602001015181526020019081526020015f2060030154826060018181516104a991906111d5565b91508181525050808060010191505061038d565b50919050565b6104cb6106e6565b6104d45f61076d565b565b6104df3361032b565b61051e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161051590611262565b60405180910390fd5b8060045f8481526020019081526020015f205f015f82825461054091906111d5565b925050819055505050565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61057a61082e565b5f5b82518110156105d0576105c383828151811061059b5761059a61117b565b5b60200260200101518383815181106105b6576105b561117b565b5b602002602001015161087d565b808060010191505061057c565b507f190625d72108398fc64b6e4be02e909da1ed59f0880c10898b9bfbaaa7b86ae733604051610600919061101f565b60405180910390a1610610610bc8565b5050565b61061c6106e6565b5f73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff160361068c575f6040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600401610683919061101f565b60405180910390fd5b6106958161076d565b50565b6004602052805f5260405f205f91509050805f0154908060010154908060020154908060030154905084565b6106cc6106e6565b826006819055508160078190555080600881905550505050565b6106ee610bd1565b73ffffffffffffffffffffffffffffffffffffffff1661070c61054b565b73ffffffffffffffffffffffffffffffffffffffff161461076b5761072f610bd1565b6040517f118cdaa7000000000000000000000000000000000000000000000000000000008152600401610762919061101f565b60405180910390fd5b565b5f805f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050815f806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600260015403610873576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161086a906112ca565b60405180910390fd5b6002600181905550565b3373ffffffffffffffffffffffffffffffffffffffff1660025f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16636352211e846040518263ffffffff1660e01b81526004016108ee91906112e8565b602060405180830381865afa158015610909573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061092d9190611315565b73ffffffffffffffffffffffffffffffffffffffff161480610a1257503373ffffffffffffffffffffffffffffffffffffffff1660055f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16639870dce0846040518263ffffffff1660e01b81526004016109bb91906112e8565b602060405180830381865afa1580156109d6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109fa9190611315565b73ffffffffffffffffffffffffffffffffffffffff16145b610a51576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a489061138a565b60405180910390fd5b8060045f8481526020019081526020015f205f01541015610aa7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a9e906113f2565b60405180910390fd5b8060045f8481526020019081526020015f205f015f828254610ac99190611410565b925050819055505f4290505f5b82811015610bc25781604051602001610aef9190611463565b604051602081830303815290604052805190602001205f1c91505f606483610b1791906114aa565b9050600654811015610b515760045f8681526020019081526020015f206001015f815480929190610b47906114da565b9190505550610bb4565b600754811015610b895760045f8681526020019081526020015f206002015f815480929190610b7f906114da565b9190505550610bb3565b60045f8681526020019081526020015f206003015f815480929190610bad906114da565b91905055505b5b508080600101915050610ad6565b50505050565b60018081905550565b5f33905090565b60405180608001604052805f81526020015f81526020015f81526020015f81525090565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610c5782610c11565b810181811067ffffffffffffffff82111715610c7657610c75610c21565b5b80604052505050565b5f610c88610bfc565b9050610c948282610c4e565b919050565b5f67ffffffffffffffff821115610cb357610cb2610c21565b5b602082029050602081019050919050565b5f80fd5b5f819050919050565b610cda81610cc8565b8114610ce4575f80fd5b50565b5f81359050610cf581610cd1565b92915050565b5f610d0d610d0884610c99565b610c7f565b90508083825260208201905060208402830185811115610d3057610d2f610cc4565b5b835b81811015610d595780610d458882610ce7565b845260208401935050602081019050610d32565b5050509392505050565b5f82601f830112610d7757610d76610c0d565b5b8135610d87848260208601610cfb565b91505092915050565b5f60208284031215610da557610da4610c05565b5b5f82013567ffffffffffffffff811115610dc257610dc1610c09565b5b610dce84828501610d63565b91505092915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b610e0981610cc8565b82525050565b5f610e1a8383610e00565b60208301905092915050565b5f602082019050919050565b5f610e3c82610dd7565b610e468185610de1565b9350610e5183610df1565b805f5b83811015610e81578151610e688882610e0f565b9750610e7383610e26565b925050600181019050610e54565b5085935050505092915050565b5f6020820190508181035f830152610ea68184610e32565b905092915050565b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f610ed782610eae565b9050919050565b610ee781610ecd565b8114610ef1575f80fd5b50565b5f81359050610f0281610ede565b92915050565b5f60208284031215610f1d57610f1c610c05565b5b5f610f2a84828501610ef4565b91505092915050565b5f8115159050919050565b610f4781610f33565b82525050565b5f602082019050610f605f830184610f3e565b92915050565b608082015f820151610f7a5f850182610e00565b506020820151610f8d6020850182610e00565b506040820151610fa06040850182610e00565b506060820151610fb36060850182610e00565b50505050565b5f608082019050610fcc5f830184610f66565b92915050565b5f8060408385031215610fe857610fe7610c05565b5b5f610ff585828601610ce7565b925050602061100685828601610ce7565b9150509250929050565b61101981610ecd565b82525050565b5f6020820190506110325f830184611010565b92915050565b5f806040838503121561104e5761104d610c05565b5b5f83013567ffffffffffffffff81111561106b5761106a610c09565b5b61107785828601610d63565b925050602083013567ffffffffffffffff81111561109857611097610c09565b5b6110a485828601610d63565b9150509250929050565b5f602082840312156110c3576110c2610c05565b5b5f6110d084828501610ce7565b91505092915050565b6110e281610cc8565b82525050565b5f6080820190506110fb5f8301876110d9565b61110860208301866110d9565b61111560408301856110d9565b61112260608301846110d9565b95945050505050565b5f805f6060848603121561114257611141610c05565b5b5f61114f86828701610ce7565b935050602061116086828701610ce7565b925050604061117186828701610ce7565b9150509250925092565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f6111df82610cc8565b91506111ea83610cc8565b9250828201905080821115611202576112016111a8565b5b92915050565b5f82825260208201905092915050565b7f4e4f545f4a4f55524e45595f434f4e54524143540000000000000000000000005f82015250565b5f61124c601483611208565b915061125782611218565b602082019050919050565b5f6020820190508181035f83015261127981611240565b9050919050565b7f5265656e7472616e637947756172643a207265656e7472616e742063616c6c005f82015250565b5f6112b4601f83611208565b91506112bf82611280565b602082019050919050565b5f6020820190508181035f8301526112e1816112a8565b9050919050565b5f6020820190506112fb5f8301846110d9565b92915050565b5f8151905061130f81610ede565b92915050565b5f6020828403121561132a57611329610c05565b5b5f61133784828501611301565b91505092915050565b7f4e4f545f4f574e455200000000000000000000000000000000000000000000005f82015250565b5f611374600983611208565b915061137f82611340565b602082019050919050565b5f6020820190508181035f8301526113a181611368565b9050919050565b7f4e4f545f454e4f554748000000000000000000000000000000000000000000005f82015250565b5f6113dc600a83611208565b91506113e7826113a8565b602082019050919050565b5f6020820190508181035f830152611409816113d0565b9050919050565b5f61141a82610cc8565b915061142583610cc8565b925082820390508181111561143d5761143c6111a8565b5b92915050565b5f819050919050565b61145d61145882610cc8565b611443565b82525050565b5f61146e828461144c565b60208201915081905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b5f6114b482610cc8565b91506114bf83610cc8565b9250826114cf576114ce61147d565b5b828206905092915050565b5f6114e482610cc8565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611516576115156111a8565b5b60018201905091905056fea264697066735822122050097797a573f0bb8616b22547b13c91d45bb457b66df8443a089c17237313ce64736f6c63430008160033

Verified Source Code Partial Match

Compiler: v0.8.22+commit.4fc1097e EVM: shanghai Optimization: No
SkyBox.sol 459 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

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

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

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

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

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

/**
 * @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 address zero.
     *
     * 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);
}

interface ISkyJourney
{
    function checkOwner(uint256 _tokenId) external view returns (address);
}

contract SkyBox is Ownable, ReentrancyGuard{
    event openBox(address onwer);

    struct NFTAsset
    {
        uint256 boxes;
        uint256 goldChecks;
        uint256 silverChecks;
        uint256 copperChecks;
    }

    IERC721 smpToken;
    mapping(address => bool) internal _operators;
    mapping(uint256 => NFTAsset) public nftAssets;

    ISkyJourney journeyContract;

    uint256 rarity1;
    uint256 rarity2;
    uint256 rarity3;

    constructor(address _smpToken) Ownable(msg.sender)
    {
        smpToken = IERC721(_smpToken);
    }

    function add(uint256 _tokenId, uint256 _num) external 
    {
        require(isJourneyContract(msg.sender), "NOT_JOURNEY_CONTRACT");
        nftAssets[_tokenId].boxes += _num;
    }



    function getAssets(uint256[] memory _tokenIds)
        public
        view
        returns (NFTAsset memory asset)
    {
        for(uint i = 0; i<_tokenIds.length; i++)
        {
            asset.boxes += nftAssets[_tokenIds[i]].boxes;
            asset.goldChecks += nftAssets[_tokenIds[i]].goldChecks;
            asset.silverChecks += nftAssets[_tokenIds[i]].silverChecks;
            asset.copperChecks += nftAssets[_tokenIds[i]].copperChecks;
        }
    }

    function getBoxes(uint256[] memory _tokenIds)
        public
        view
        returns (uint[] memory)
    {
        uint[] memory boxes = new uint[](_tokenIds.length);
        for(uint i = 0; i<_tokenIds.length; i++)
        {
            boxes[i] = nftAssets[_tokenIds[i]].boxes;
        }
        return boxes;
    }

    function _open(uint256 _tokenId, uint256 _num) internal
    {
        require(smpToken.ownerOf(_tokenId) == msg.sender || journeyContract.checkOwner(_tokenId) == msg.sender, "NOT_OWNER");
        require(nftAssets[_tokenId].boxes >= _num, "NOT_ENOUGH");

        nftAssets[_tokenId].boxes -= _num;
        uint256 _seed = block.timestamp;
        for(uint256 i =0; i < _num; i++)
        {
            _seed = uint256(keccak256(abi.encodePacked(_seed)));
            uint256 checkType = _seed % 100;
            if(checkType < rarity1)
            {
                nftAssets[_tokenId].goldChecks ++;
            }
            else if(checkType < rarity2)
            {
                nftAssets[_tokenId].silverChecks ++;
            }
            else{
                nftAssets[_tokenId].copperChecks ++;
            }
        }
    }

    function open(uint256[] memory _tokenIds, uint256[] memory _nums) external nonReentrant
    {
        for(uint256 i = 0; i < _tokenIds.length; i++)
        {
            _open(_tokenIds[i], _nums[i]);
        }

        emit openBox(msg.sender);
    }

    function setJourneyContract(address journey) onlyOwner public {
        journeyContract = ISkyJourney(journey);
    }

     function setRarity(uint256 _rarity1, uint256 _rarity2, uint256 _rarity3) onlyOwner public {
        rarity1 = _rarity1;
        rarity2 = _rarity2;
        rarity3 = _rarity3;
    }

    function isJourneyContract(address who) public view returns (bool) {
        return who == address(journeyContract);
    }
}

Read Contract

getAssets 0x6c6458f1 → tuple
getBoxes 0x1b94ca9f → uint256[]
isJourneyContract 0x30f24e79 → bool
nftAssets 0xfa3908b1 → uint256, uint256, uint256, uint256
owner 0x8da5cb5b → address

Write Contract 6 functions

These functions modify contract state and require a wallet transaction to execute.

add 0x771602f7
uint256 _tokenId
uint256 _num
open 0xa1258e5e
uint256[] _tokenIds
uint256[] _nums
renounceOwnership 0x715018a6
No parameters
setJourneyContract 0x30c3ab12
address journey
setRarity 0xff842a70
uint256 _rarity1
uint256 _rarity2
uint256 _rarity3
transferOwnership 0xf2fde38b
address newOwner

Recent Transactions

No transactions found for this address