编译器
0.8.17+commit.8df45f5f
文件 1 的 32:AccountWhitelist.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
abstract contract AccountWhitelist is Ownable {
bytes32 public whitelistMerkleRoot;
string public whitelistURI;
function verifyAccount(address account, bytes32[] memory proof)
public
view
returns (bool)
{
return _verify(proof, _hash(account));
}
function _verify(bytes32[] memory proof, bytes32 addressHash)
internal
view
returns (bool)
{
return MerkleProof.verify(proof, whitelistMerkleRoot, addressHash);
}
function _hash(address _address) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(_address));
}
function setWhitelist(bytes32 root, string calldata uri)
external
onlyOwner
{
whitelistMerkleRoot = root;
whitelistURI = uri;
}
modifier onlyWhitelisted(address account, bytes32[] memory proof) {
require(verifyAccount(account, proof), "Not whitelisted");
_;
}
}
文件 2 的 32:AccountWhitelistManager.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "./AccountWhitelist.sol";
import "../utils/Bitmap.sol";
contract AccountWhitelistManager is AccountWhitelist, Initializable {
using Bitmap for mapping(uint256 => uint256);
address public approvedCaller;
mapping(address => bool) public claimed;
function initialize(bytes32 root, string calldata uri)
external
initializer
{
_transferOwnership(msg.sender);
whitelistMerkleRoot = root;
whitelistURI = uri;
}
function _setClaimed(address account) internal {
claimed[account] = true;
}
function claim(address account, bytes32[] calldata proof)
external
onlyApprovedCaller
onlyWhitelisted(account, proof)
onlyNotClaimed(account)
{
_setClaimed(account);
}
function setApprovedCaller(address _approvedCaller) external onlyOwner {
approvedCaller = _approvedCaller;
}
modifier onlyNotClaimed(address account) {
require(!claimed[account], "Already claimed");
_;
}
modifier onlyApprovedCaller() {
require(
msg.sender == approvedCaller,
"AccountWhitelist: not approved caller"
);
_;
}
}
文件 3 的 32:Address.sol
pragma solidity ^0.8.1;
library Address {
function isContract(address account) internal view returns (bool) {
return account.code.length > 0;
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
文件 4 的 32:Bitmap.sol
pragma solidity ^0.8.0;
library Bitmap {
uint256 internal constant BITS_PER_SLOT = 256;
function set(
mapping(uint256 => uint256) storage map,
uint256 key,
bool value
) internal {
uint256 index = _getIndex(key);
uint256 bitMask = _getBitMask(key);
if (value) {
map[index] |= bitMask;
} else {
map[index] ^= bitMask;
}
}
function multiSet(
mapping(uint256 => uint256) storage map,
uint256[] memory keys,
bool value
) internal {
uint256 index = _getIndex(keys[0]);
uint256 bitMask = _getBitMask(keys[0]);
for (uint256 i = 1; i < keys.length; i++) {
uint256 newIndex = _getIndex(keys[i]);
uint256 newBitMask = _getBitMask(keys[i]);
if (newIndex == index) {
bitMask += newBitMask;
} else {
if (value) {
map[index] |= bitMask;
} else {
map[index] ^= bitMask;
}
index = newIndex;
bitMask = newBitMask;
}
}
if (value) {
map[index] |= bitMask;
} else {
map[index] ^= bitMask;
}
}
function get(mapping(uint256 => uint256) storage map, uint256 key)
internal
view
returns (bool)
{
uint256 index = _getIndex(key);
uint256 bitMask = _getBitMask(key);
return (map[index] & bitMask) != 0;
}
function _getIndex(uint256 key) private pure returns (uint256) {
return key / BITS_PER_SLOT;
}
function _getBitMask(uint256 key) private pure returns (uint256) {
return 1 << (key % BITS_PER_SLOT);
}
}
文件 5 的 32:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 6 的 32:ERC165.sol
pragma solidity ^0.8.0;
import "./IERC165.sol";
abstract contract ERC165 is IERC165 {
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
文件 7 的 32:ERC721.sol
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
string private _name;
string private _symbol;
mapping(uint256 => address) private _owners;
mapping(address => uint256) private _balances;
mapping(uint256 => address) private _tokenApprovals;
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
return _balances[owner];
}
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
_requireMinted(tokenId);
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
function _baseURI() internal view virtual returns (string memory) {
return "";
}
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner or approved for all"
);
_approve(to, tokenId);
}
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_transfer(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_safeTransfer(from, to, tokenId, data);
}
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer");
}
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _ownerOf(tokenId) != address(0);
}
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);
}
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
function _safeMint(
address to,
uint256 tokenId,
bytes memory data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId, 1);
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
owner = ERC721.ownerOf(tokenId);
delete _tokenApprovals[tokenId];
unchecked {
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId, 1);
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
delete _tokenApprovals[tokenId];
unchecked {
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
function _beforeTokenTransfer(
address from,
address to,
uint256,
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
}
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
}
文件 8 的 32:EntityUtils.sol
pragma solidity ^0.8.17;
function tokenToEntity(address token, uint256 id) pure returns (uint256) {
return (uint256(uint160(token)) << 96) | id;
}
function entityToToken(uint256 entity)
pure
returns (address token, uint256 id)
{
token = address(uint160(entity >> 96));
id = entity & 0xffffffffffffffffffffffff;
}
function accountToEntity(address account) pure returns (uint256) {
return (uint256(uint160(account)));
}
function entityToAccount(uint256 entity) pure returns (address account) {
account = address(uint160(entity));
}
function entityIsAccount(uint256 entity) pure returns (bool) {
return entity >> 160 == 0;
}
文件 9 的 32:IERC1363.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC165.sol";
interface IERC1363 is IERC165, IERC20 {
function transferAndCall(address to, uint256 value) external returns (bool);
function transferAndCall(
address to,
uint256 value,
bytes memory data
) external returns (bool);
function transferFromAndCall(
address from,
address to,
uint256 value
) external returns (bool);
function transferFromAndCall(
address from,
address to,
uint256 value,
bytes memory data
) external returns (bool);
function approveAndCall(address spender, uint256 value) external returns (bool);
function approveAndCall(
address spender,
uint256 value,
bytes memory data
) external returns (bool);
}
文件 10 的 32:IERC165.sol
pragma solidity ^0.8.0;
interface IERC165 {
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
文件 11 的 32:IERC20.sol
pragma solidity ^0.8.0;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
文件 12 的 32:IERC20Entity.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/Interfaces/IERC1363.sol";
interface IERC20Entity is IERC1363 {
event EntityTransfer(
uint256 indexed from,
uint256 indexed to,
uint256 value
);
event EntityApproval(
uint256 indexed owner,
uint256 indexed spender,
uint256 value
);
function balanceOf(uint256 entity) external view returns (uint256);
function transfer(uint256 to, uint256 amount) external returns (bool);
function allowance(uint256 owner, uint256 spender)
external
view
returns (uint256);
function approve(uint256 spender, uint256 amount) external returns (bool);
function transferFrom(
uint256 from,
uint256 to,
uint256 amount
) external returns (bool);
}
文件 13 的 32:IERC20EntityBurnable.sol
pragma solidity ^0.8.17;
import "./IERC20Entity.sol";
interface IERC20EntityBurnable is IERC20Entity {
function burn(uint256 amount) external;
function burnFrom(uint256 entity, uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
}
文件 14 的 32:IERC20Resource.sol
pragma solidity ^0.8.17;
import "./extensions/IERC20EntityBurnable.sol";
interface IERC20Resource is IERC20EntityBurnable {
function mint(address to, uint256 amount) external;
function mint(uint256 to, uint256 amount) external;
function mintAndCall(address to, uint256 amount) external;
}
文件 15 的 32:IERC721.sol
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
interface IERC721 is IERC165 {
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
function balanceOf(address owner) external view returns (uint256 balance);
function ownerOf(uint256 tokenId) external view returns (address owner);
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
function approve(address to, uint256 tokenId) external;
function setApprovalForAll(address operator, bool _approved) external;
function getApproved(uint256 tokenId) external view returns (address operator);
function isApprovedForAll(address owner, address operator) external view returns (bool);
}
文件 16 的 32:IERC721Metadata.sol
pragma solidity ^0.8.0;
import "../IERC721.sol";
interface IERC721Metadata is IERC721 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function tokenURI(uint256 tokenId) external view returns (string memory);
}
文件 17 的 32:IERC721Receiver.sol
pragma solidity ^0.8.0;
interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
文件 18 的 32:IMetadata.sol
pragma solidity ^0.8.17;
interface IMetadata {
function getMetadata(uint256 tokenId) external view returns (string memory);
}
文件 19 的 32:IMiaocraft.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
struct ShipInfo {
uint96 spins;
uint96 spinsBurned;
uint40 lastServiceTime;
string name;
}
interface IMiaocraft is IERC721 {
event Build(
address indexed owner,
uint256 indexed id,
uint256 spins,
string name
);
event Upgrade(address indexed owner, uint256 indexed id, uint256 spins);
event Merge(
address indexed owner,
uint256 indexed id1,
uint256 indexed id2,
uint256 spins
);
event Scrap(
address indexed scavengerOwner,
uint256 indexed scavengerId,
uint256 indexed targetId
);
event Service(
address indexed owner,
uint256 indexed id,
uint256 spins,
uint256 cost
);
event Rename(address indexed owner, uint256 indexed id, string name);
function spinsOf(uint256 id) external view returns (uint256);
function spinsDecayOf(uint256 id) external view returns (uint256);
function buildCost(uint256 spins_) external view returns (uint256);
function serviceCostOf(uint256 id) external view returns (uint256);
function getShipInfo(uint256 id) external view returns (ShipInfo memory);
function build(uint256 spins_, string calldata name_) external;
function upgrade(uint256 id, uint256 spins_) external;
function merge(uint256 id1, uint256 id2) external;
function scrap(uint256 scavengerId, uint256 targetId) external;
function service(uint256 id) external;
function rename(uint256 id, string calldata name_) external;
function isApprovedOrOwner(address spender, uint256 id)
external
view
returns (bool);
}
文件 20 的 32:ISpatialSystem.sol
pragma solidity ^0.8.17;
struct LocationInfo {
int40 xOrigin;
int40 yOrigin;
int40 xDest;
int40 yDest;
uint40 speed;
uint40 departureTime;
bool locked;
}
interface ISpatialSystem {
event UpdateLocation(
uint256 indexed entityId,
int256 xOrigin,
int256 yOrigin,
int256 xDest,
int256 yDest,
uint256 speed,
uint256 departureTime
);
event Move(
uint256 indexed entityId,
int256 xOrigin,
int256 yOrigin,
int256 xDest,
int256 yDest,
uint256 speed,
uint256 departureTime
);
event SetLocation(
uint256 indexed entityId,
int256 xOrigin,
int256 yOrigin,
int256 xDest,
int256 yDest,
uint256 speed,
uint256 departureTime
);
event SetCoordinate(uint256 indexed entityId, int256 x, int256 y);
event Locked(uint256 indexed entityId);
event Unlocked(uint256 indexed entityId);
function coordinate(uint256 entityId)
external
view
returns (int256 x, int256 y);
function collocated(uint256 entityId1, uint256 entityId2)
external
view
returns (bool);
function collocated(
uint256 entityId1,
uint256 entityId2,
uint256 radius
) external view returns (bool);
function getLocationInfo(uint256 entityId)
external
view
returns (LocationInfo memory);
function locked(uint256 entityId) external view returns (bool);
function updateLocation(uint256 entityId) external;
}
文件 21 的 32:Initializable.sol
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
abstract contract Initializable {
uint8 private _initialized;
bool private _initializing;
event Initialized(uint8 version);
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
文件 22 的 32:Math.sol
pragma solidity ^0.8.0;
library Math {
enum Rounding {
Down,
Up,
Zero
}
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function average(uint256 a, uint256 b) internal pure returns (uint256) {
return (a & b) + (a ^ b) / 2;
}
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
return a == 0 ? 0 : (a - 1) / b + 1;
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
uint256 prod0;
uint256 prod1;
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
if (prod1 == 0) {
return prod0 / denominator;
}
require(denominator > prod1);
uint256 remainder;
assembly {
remainder := mulmod(x, y, denominator)
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
uint256 twos = denominator & (~denominator + 1);
assembly {
denominator := div(denominator, twos)
prod0 := div(prod0, twos)
twos := add(div(sub(0, twos), twos), 1)
}
prod0 |= prod1 * twos;
uint256 inverse = (3 * denominator) ^ 2;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
inverse *= 2 - denominator * inverse;
result = prod0 * inverse;
return result;
}
}
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator,
Rounding rounding
) internal pure returns (uint256) {
uint256 result = mulDiv(x, y, denominator);
if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
result += 1;
}
return result;
}
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 result = 1 << (log2(a) >> 1);
unchecked {
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
result = (result + a / result) >> 1;
return min(result, a / result);
}
}
function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = sqrt(a);
return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
}
}
function log2(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 128;
}
if (value >> 64 > 0) {
value >>= 64;
result += 64;
}
if (value >> 32 > 0) {
value >>= 32;
result += 32;
}
if (value >> 16 > 0) {
value >>= 16;
result += 16;
}
if (value >> 8 > 0) {
value >>= 8;
result += 8;
}
if (value >> 4 > 0) {
value >>= 4;
result += 4;
}
if (value >> 2 > 0) {
value >>= 2;
result += 2;
}
if (value >> 1 > 0) {
result += 1;
}
}
return result;
}
function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log2(value);
return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
}
}
function log10(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >= 10**64) {
value /= 10**64;
result += 64;
}
if (value >= 10**32) {
value /= 10**32;
result += 32;
}
if (value >= 10**16) {
value /= 10**16;
result += 16;
}
if (value >= 10**8) {
value /= 10**8;
result += 8;
}
if (value >= 10**4) {
value /= 10**4;
result += 4;
}
if (value >= 10**2) {
value /= 10**2;
result += 2;
}
if (value >= 10**1) {
result += 1;
}
}
return result;
}
function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log10(value);
return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
}
}
function log256(uint256 value) internal pure returns (uint256) {
uint256 result = 0;
unchecked {
if (value >> 128 > 0) {
value >>= 128;
result += 16;
}
if (value >> 64 > 0) {
value >>= 64;
result += 8;
}
if (value >> 32 > 0) {
value >>= 32;
result += 4;
}
if (value >> 16 > 0) {
value >>= 16;
result += 2;
}
if (value >> 8 > 0) {
result += 1;
}
}
return result;
}
function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
unchecked {
uint256 result = log256(value);
return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
}
}
}
文件 23 的 32:MerkleProof.sol
pragma solidity ^0.8.0;
library MerkleProof {
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = _hashPair(computedHash, proof[i]);
}
return computedHash;
}
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
for (uint256 i = 0; i < totalHashes; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i] ? leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++] : proof[proofPos++];
hashes[i] = _hashPair(a, b);
}
if (totalHashes > 0) {
return hashes[totalHashes - 1];
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {
return a < b ? _efficientHash(a, b) : _efficientHash(b, a);
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
文件 24 的 32:Miaocraft.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/math/SignedMath.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";
import "solmate/utils/SignedWadMath.sol";
import "./systems/ISpatialSystem.sol";
import "./utils/EntityUtils.sol";
import "./whitelist/NFTWhitelistManager.sol";
import "./whitelist/AccountWhitelistManager.sol";
import "./IERC20Resource.sol";
import "./IMetadata.sol";
import "./IMiaocraft.sol";
import "./constants.sol";
struct ShipInfoExtended {
uint256 id;
address owner;
uint256 balance;
ShipInfo shipInfo;
LocationInfo locationInfo;
}
contract Miaocraft is IMiaocraft, ERC721, Initializable, Ownable, Multicall {
using Address for address;
uint256 public immutable BUILD_COST;
uint256 public immutable SINGLE_SPINS_DECAY_PER_SEC;
bool public commissionWlOpen;
bool public commissionPublicOpen;
uint256 public scrapReward;
uint256 public scrapRadius;
uint256 public transferBurnRate;
IERC20Resource public butter;
ISpatialSystem public spatialSystem;
IMetadata public metadata;
address public sbh;
NFTWhitelistManager public nftWlManager;
AccountWhitelistManager public accountWlManager;
mapping(uint256 => ShipInfo) private _shipInfos;
mapping(address => bool) private _commissioned;
uint256 public nextId;
constructor(uint256 buildCost_, uint256 unitDecayInterval)
ERC721("Miaocraft", "MC")
{
BUILD_COST = buildCost_;
SINGLE_SPINS_DECAY_PER_SEC = SPINS_PRECISION / unitDecayInterval;
}
function initialize(
address butter_,
address spatialSystem_,
address metadata_,
address sbh_,
uint256 scrapReward_,
uint256 scrapRadius_,
uint256 transferBurnRate_,
address nftWlManager_,
address accountWlManager_
) public initializer {
butter = IERC20Resource(butter_);
spatialSystem = ISpatialSystem(spatialSystem_);
metadata = IMetadata(metadata_);
sbh = sbh_;
scrapReward = scrapReward_;
scrapRadius = scrapRadius_;
transferBurnRate = transferBurnRate_;
nftWlManager = NFTWhitelistManager(nftWlManager_);
accountWlManager = AccountWhitelistManager(accountWlManager_);
_transferOwnership(msg.sender);
}
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
return metadata.getMetadata(tokenId);
}
function spinsOf(uint256 id) public view override returns (uint256) {
return _shipInfos[id].spins;
}
function spinsDecayOf(uint256 id) public view returns (uint256) {
uint256 spins = _shipInfos[id].spins;
return
Math.min(
spins,
(spinsDecayPerSec(spins) *
(block.timestamp - _shipInfos[id].lastServiceTime) +
_shipInfos[id].spinsBurned)
);
}
function spinsDecayPerSec(uint256 spins) public view returns (uint256) {
return (SINGLE_SPINS_DECAY_PER_SEC * spins) / SPINS_PRECISION;
}
function buildCost(uint256 spins) public view returns (uint256) {
return (BUILD_COST * spins) / SPINS_PRECISION;
}
function serviceCostOf(uint256 id) public view returns (uint256) {
return (BUILD_COST * spinsDecayOf(id)) / SPINS_PRECISION;
}
function isApprovedOrOwner(address spender, uint256 tokenId)
public
view
returns (bool)
{
return _isApprovedOrOwner(spender, tokenId);
}
function getShipInfo(uint256 id)
public
view
override
returns (ShipInfo memory)
{
return _shipInfos[id];
}
function toEntity(uint256 id) public view returns (uint256) {
return tokenToEntity(address(this), id);
}
function commissionNftWl(
address token,
uint256[] calldata ids,
string[] calldata names
) public {
require(commissionWlOpen, "Not open yet");
require(nextId < GENESIS_SUPPLY, "No more");
require(ids.length == names.length, "Length mismatch");
nftWlManager.claim(_msgSender(), token, ids);
for (uint256 i = 0; i < ids.length; i++) {
_buildShip(_msgSender(), SPINS_PRECISION, names[i]);
}
}
function commissionWl(string calldata name, bytes32[] calldata proof)
public
{
require(commissionWlOpen, "Not open yet");
require(nextId < GENESIS_SUPPLY, "No more");
accountWlManager.claim(_msgSender(), proof);
_buildShip(_msgSender(), SPINS_PRECISION, name);
}
function commissionPublic(string calldata name) public {
require(commissionPublicOpen, "Not open yet");
require(nextId < GENESIS_SUPPLY, "No more");
address sender = _msgSender();
require(!_commissioned[sender], "Already commissioned");
_commissioned[sender] = true;
_buildShip(sender, SPINS_PRECISION, name);
}
function buildAndLoad(
uint256 spins,
string calldata name,
uint256 amount
) public virtual {
require(spins >= SPINS_PRECISION, "Less than 1 spin");
address sender = _msgSender();
butter.burnFrom(sender, buildCost(spins));
uint256 id = _buildShip(sender, spins, name);
butter.transferFrom(accountToEntity(sender), toEntity(id), amount);
}
function build(uint256 spins, string calldata name) public virtual {
require(spins >= SPINS_PRECISION, "Less than 1 spin");
address sender = _msgSender();
butter.burnFrom(sender, buildCost(spins));
_buildShip(sender, spins, name);
}
function loadAndUpgrade(
uint256 id,
uint256 amount,
uint256 spins
) public virtual onlyApprovedOrOwner(id) {
require(spins >= SPINS_PRECISION, "Less than 1 spin");
uint256 shipEntityId = toEntity(id);
butter.transferFrom(
accountToEntity(_msgSender()),
shipEntityId,
amount
);
_service(id);
_shipInfos[id].spins += uint96(spins);
butter.burnFrom(shipEntityId, buildCost(spins));
emit Upgrade(ownerOf(id), id, spins);
}
function upgrade(uint256 id, uint256 spins)
public
virtual
override
onlyApprovedOrOwner(id)
{
_service(id);
_shipInfos[id].spins += uint96(spins);
butter.burnFrom(toEntity(id), buildCost(spins));
emit Upgrade(ownerOf(id), id, spins);
}
function merge(uint256 id1, uint256 id2)
public
virtual
override
onlyApprovedOrOwner(id1)
onlyApprovedOrOwner(id2)
{
uint256 entityId1 = toEntity(id1);
uint256 entityId2 = toEntity(id2);
require(spatialSystem.collocated(entityId1, entityId2));
_service(id1);
_service(id2);
_shipInfos[id1].spins += _shipInfos[id2].spins;
delete _shipInfos[id2];
butter.transferFrom(entityId2, entityId1, butter.balanceOf(entityId2));
_burn(id2);
emit Merge(ownerOf(id1), id1, id2, _shipInfos[id1].spins);
}
function scrap(uint256 scavengerId, uint256 targetId)
public
virtual
override
onlyApprovedOrOwner(scavengerId)
{
uint256 scavengerEntityId = toEntity(scavengerId);
uint256 targetEntityId = toEntity(targetId);
require(spinsOf(targetId) == spinsDecayOf(targetId), "Not scrappable");
require(
spatialSystem.collocated(
scavengerEntityId,
targetEntityId,
scrapRadius
),
"Too far away"
);
delete _shipInfos[targetId];
butter.burnFrom(targetEntityId, butter.balanceOf(targetEntityId));
_burn(targetId);
butter.mint(scavengerEntityId, scrapReward);
emit Scrap(ownerOf(scavengerId), scavengerId, targetId);
}
function service(uint256 id)
public
virtual
override
onlyApprovedOrOwner(id)
{
_service(id);
}
function rename(uint256 id, string calldata name) public virtual override {
require(_msgSender() == ownerOf(id), "Unauthorized");
_shipInfos[id].name = name;
emit Rename(ownerOf(id), id, name);
}
function _service(uint256 id) internal {
uint256 cost = serviceCostOf(id);
uint256 entityId = toEntity(id);
uint256 butterBalance = butter.balanceOf(entityId);
_shipInfos[id].lastServiceTime = uint40(block.timestamp);
if (cost > butterBalance) {
butter.burnFrom(entityId, butterBalance);
_shipInfos[id].spins -= uint96(
((cost - butterBalance) * SPINS_PRECISION) / BUILD_COST
);
_shipInfos[id].spinsBurned = 0;
} else {
butter.burnFrom(entityId, cost);
}
emit Service(ownerOf(id), id, _shipInfos[id].spins, cost);
}
function _buildShip(
address account,
uint256 spins,
string calldata name
) internal returns (uint256 id) {
id = nextId++;
_shipInfos[id] = ShipInfo({
spins: uint96(spins),
spinsBurned: 0,
lastServiceTime: uint40(block.timestamp),
name: name
});
_mint(account, id);
emit Build(account, id, spins, name);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 id,
uint256 batchSize
) internal virtual override {
if (from != address(0) && to != address(0)) {
for (uint256 currId = id; currId < id + batchSize; currId++) {
uint256 remainingSpins = spinsOf(currId) - spinsDecayOf(currId);
if (remainingSpins > 0) {
uint256 spinsBurn = (remainingSpins * transferBurnRate) /
1e18;
_shipInfos[currId].spinsBurned += uint96(spinsBurn);
butter.mint(
sbh,
(2 * (spinsBurn * BUILD_COST)) / SPINS_PRECISION
);
}
}
}
super._beforeTokenTransfer(from, to, id, batchSize);
}
modifier onlyApprovedOrOwner(uint256 id) {
require(_isApprovedOrOwner(_msgSender(), id), "Only approved or owner");
_;
}
function paginateShips(uint256 offset, uint256 limit)
public
view
returns (ShipInfoExtended[] memory shipInfos)
{
uint256 total = nextId;
if (offset >= total) {
return shipInfos;
}
uint256 end = offset + limit;
if (end > total) {
end = total;
}
shipInfos = new ShipInfoExtended[](end - offset);
for (uint256 id = offset; id < end; id++) {
shipInfos[id] = ShipInfoExtended({
id: id,
owner: ownerOf(id),
balance: butter.balanceOf(toEntity(id)),
shipInfo: _shipInfos[id],
locationInfo: spatialSystem.getLocationInfo(toEntity(id))
});
}
}
function setCommissionWlOpen(bool open) public onlyOwner {
commissionWlOpen = open;
}
function setCommissionPublicOpen(bool open) public onlyOwner {
commissionPublicOpen = open;
}
function setTransferBurnRate(uint256 rate) public onlyOwner {
require(rate <= 0.1e18, "Rate must be <= 0.1e18");
transferBurnRate = rate;
}
function setScrapRadius(uint256 radius) public onlyOwner {
scrapRadius = radius;
}
function setScrapReward(uint256 reward) public onlyOwner {
require(reward <= BUILD_COST, "Reward must be <= build cost");
scrapReward = reward;
}
function setButter(IERC20Resource butter_) public onlyOwner {
butter = butter_;
}
function setSpatialSystem(ISpatialSystem spatialSystem_) public onlyOwner {
spatialSystem = spatialSystem_;
}
function setSbh(address sbh_) public onlyOwner {
sbh = sbh_;
}
function setMetadata(IMetadata metadata_) public onlyOwner {
metadata = metadata_;
}
}
文件 25 的 32:Multicall.sol
pragma solidity ^0.8.0;
import "./Address.sol";
abstract contract Multicall {
function multicall(bytes[] calldata data) external virtual returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
}
文件 26 的 32:NFTWhitelist.sol
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "../utils/Bitmap.sol";
abstract contract NFTWhitelist is Ownable, Initializable {
uint256 public immutable SEED;
mapping(address => uint256) public whitelistRates;
constructor(uint256 seed) {
SEED = seed;
}
function initialize() external initializer {
_transferOwnership(msg.sender);
}
function isWhitelisted(address token, uint256 id)
public
view
virtual
returns (bool)
{
return
uint256(keccak256(abi.encodePacked(token, id, SEED))) % 1e18 <
whitelistRates[token];
}
function isOwner(
address account,
address token,
uint256 id
) public view virtual returns (bool) {
return IERC721(token).ownerOf(id) == account;
}
function paginateWhitelisted(
address token,
uint256 start,
uint256 count
) external view virtual returns (uint256[] memory) {
uint256[] memory ids = new uint256[](count);
uint256 index = 0;
for (uint256 i = start; i < start + count; i++) {
if (isWhitelisted(token, i)) {
ids[index] = i;
index++;
}
}
return ids;
}
function paginateOwnerWhitelisted(
address account,
address token,
uint256 start,
uint256 count
) external view virtual returns (uint256[] memory) {
uint256[] memory ids = new uint256[](count);
uint256 index = 0;
for (uint256 i = start; i < start + count; i++) {
if (isWhitelisted(token, i) && isOwner(account, token, i)) {
ids[index] = i;
index++;
}
}
return ids;
}
function _addWhitelist(address token, uint256 whitelistRate)
internal
virtual
{
require(whitelistRate <= 1e18, "NFTWhitelist: whitelist rate too high");
whitelistRates[token] = whitelistRate;
}
function addWhitelist(address token, uint256 whitelistRate)
external
onlyOwner
{
_addWhitelist(token, whitelistRate);
}
modifier onlyWhitelisted(
address account,
address token,
uint256 id
) {
require(isWhitelisted(token, id), "Not whitelisted");
require(isOwner(account, token, id), "Not owner");
_;
}
}
文件 27 的 32:NFTWhitelistManager.sol
pragma solidity ^0.8.17;
import "./NFTWhitelist.sol";
import "../utils/Bitmap.sol";
contract NFTWhitelistManager is NFTWhitelist {
using Bitmap for mapping(uint256 => uint256);
address public approvedCaller;
mapping(address => mapping(uint256 => uint256)) public claimed;
constructor(uint256 seed) NFTWhitelist(seed) {}
function isClaimed(address token, uint256 id) public view returns (bool) {
return claimed[token].get(id);
}
function filterUnclaimed(address token, uint256[] calldata ids)
external
view
returns (uint256[] memory)
{
uint256[] memory unclaimedIds = new uint256[](ids.length);
uint256 index = 0;
for (uint256 i = 0; i < ids.length; i++) {
if (isWhitelisted(token, ids[i]) && !isClaimed(token, ids[i])) {
unclaimedIds[index] = ids[i];
index++;
}
}
return slice(unclaimedIds, 0, index);
}
function paginateUnclaimed(
address token,
uint256 start,
uint256 count
) external view returns (uint256[] memory) {
uint256[] memory ids = new uint256[](count);
uint256 index = 0;
for (uint256 i = start; i < start + count; i++) {
if (isWhitelisted(token, i) && !isClaimed(token, i)) {
ids[index] = i;
index++;
}
}
return slice(ids, 0, index);
}
function paginateOwnerUnclaimed(
address account,
address token,
uint256 start,
uint256 count
) external view returns (uint256[] memory) {
uint256[] memory ids = new uint256[](count);
uint256 index = 0;
for (uint256 i = start; i < start + count; i++) {
if (
isWhitelisted(token, i) &&
!isClaimed(token, i) &&
isOwner(account, token, i)
) {
ids[index] = i;
index++;
}
}
return slice(ids, 0, index);
}
function claim(
address account,
address token,
uint256 id
) external onlyApprovedCaller {
_claim(account, token, id);
}
function claim(
address account,
address token,
uint256[] calldata ids
) external onlyApprovedCaller {
for (uint256 i = 0; i < ids.length; i++) {
_claim(account, token, ids[i]);
}
}
function _claim(
address account,
address token,
uint256 id
) internal onlyWhitelisted(account, token, id) onlyNotClaimed(token, id) {
_setClaimed(token, id);
}
function _setClaimed(address token, uint256 id) internal {
claimed[token].set(id, true);
}
function setApprovedCaller(address _approvedCaller) external onlyOwner {
approvedCaller = _approvedCaller;
}
modifier onlyNotClaimed(address token, uint256 id) {
require(!claimed[token].get(id), "Already claimed");
_;
}
modifier onlyApprovedCaller() {
require(
msg.sender == approvedCaller,
"NFTWhitelist: not approved caller"
);
_;
}
}
function slice(
uint256[] memory array,
uint256 start,
uint256 end
) pure returns (uint256[] memory) {
uint256[] memory result = new uint256[](end - start);
for (uint256 i = start; i < end; i++) {
result[i - start] = array[i];
}
return result;
}
文件 28 的 32:Ownable.sol
pragma solidity ^0.8.0;
import "../utils/Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 29 的 32:SignedMath.sol
pragma solidity ^0.8.0;
library SignedMath {
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
function average(int256 a, int256 b) internal pure returns (int256) {
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
function abs(int256 n) internal pure returns (uint256) {
unchecked {
return uint256(n >= 0 ? n : -n);
}
}
}
文件 30 的 32:SignedWadMath.sol
pragma solidity >=0.8.0;
function toWadUnsafe(uint256 x) pure returns (int256 r) {
assembly {
r := mul(x, 1000000000000000000)
}
}
function toDaysWadUnsafe(uint256 x) pure returns (int256 r) {
assembly {
r := div(mul(x, 1000000000000000000), 86400)
}
}
function fromDaysWadUnsafe(int256 x) pure returns (uint256 r) {
assembly {
r := div(mul(x, 86400), 1000000000000000000)
}
}
function unsafeWadMul(int256 x, int256 y) pure returns (int256 r) {
assembly {
r := sdiv(mul(x, y), 1000000000000000000)
}
}
function unsafeWadDiv(int256 x, int256 y) pure returns (int256 r) {
assembly {
r := sdiv(mul(x, 1000000000000000000), y)
}
}
function wadMul(int256 x, int256 y) pure returns (int256 r) {
assembly {
r := mul(x, y)
if iszero(or(iszero(x), eq(sdiv(r, x), y))) {
revert(0, 0)
}
r := sdiv(r, 1000000000000000000)
}
}
function wadDiv(int256 x, int256 y) pure returns (int256 r) {
assembly {
r := mul(x, 1000000000000000000)
if iszero(and(iszero(iszero(y)), eq(sdiv(r, 1000000000000000000), x))) {
revert(0, 0)
}
r := sdiv(r, y)
}
}
function wadPow(int256 x, int256 y) pure returns (int256) {
return wadExp((wadLn(x) * y) / 1e18);
}
function wadExp(int256 x) pure returns (int256 r) {
unchecked {
if (x <= -42139678854452767551) return 0;
if (x >= 135305999368893231589) revert("EXP_OVERFLOW");
x = (x << 78) / 5**18;
int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;
x = x - k * 54916777467707473351141471128;
int256 y = x + 1346386616545796478920950773328;
y = ((y * x) >> 96) + 57155421227552351082224309758442;
int256 p = y + x - 94201549194550492254356042504812;
p = ((p * y) >> 96) + 28719021644029726153956944680412240;
p = p * x + (4385272521454847904659076985693276 << 96);
int256 q = x - 2855989394907223263936484059900;
q = ((q * x) >> 96) + 50020603652535783019961831881945;
q = ((q * x) >> 96) - 533845033583426703283633433725380;
q = ((q * x) >> 96) + 3604857256930695427073651918091429;
q = ((q * x) >> 96) - 14423608567350463180887372962807573;
q = ((q * x) >> 96) + 26449188498355588339934803723976023;
assembly {
r := sdiv(p, q)
}
r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
}
}
function wadLn(int256 x) pure returns (int256 r) {
unchecked {
require(x > 0, "UNDEFINED");
assembly {
r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffff, shr(r, x))))
r := or(r, shl(3, lt(0xff, shr(r, x))))
r := or(r, shl(2, lt(0xf, shr(r, x))))
r := or(r, shl(1, lt(0x3, shr(r, x))))
r := or(r, lt(0x1, shr(r, x)))
}
int256 k = r - 96;
x <<= uint256(159 - k);
x = int256(uint256(x) >> 159);
int256 p = x + 3273285459638523848632254066296;
p = ((p * x) >> 96) + 24828157081833163892658089445524;
p = ((p * x) >> 96) + 43456485725739037958740375743393;
p = ((p * x) >> 96) - 11111509109440967052023855526967;
p = ((p * x) >> 96) - 45023709667254063763336534515857;
p = ((p * x) >> 96) - 14706773417378608786704636184526;
p = p * x - (795164235651350426258249787498 << 96);
int256 q = x + 5573035233440673466300451813936;
q = ((q * x) >> 96) + 71694874799317883764090561454958;
q = ((q * x) >> 96) + 283447036172924575727196451306956;
q = ((q * x) >> 96) + 401686690394027663651624208769553;
q = ((q * x) >> 96) + 204048457590392012362485061816622;
q = ((q * x) >> 96) + 31853899698501571402653359427138;
q = ((q * x) >> 96) + 909429971244387300277376558375;
assembly {
r := sdiv(p, q)
}
r *= 1677202110996718588342820967067443963516166;
r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
r += 600920179829731861736702779321621459595472258049074101567377883020018308;
r >>= 174;
}
}
function unsafeDiv(int256 x, int256 y) pure returns (int256 r) {
assembly {
r := sdiv(x, y)
}
}
文件 31 的 32:Strings.sol
pragma solidity ^0.8.0;
import "./math/Math.sol";
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
文件 32 的 32:constants.sol
pragma solidity ^0.8.17;
uint16 constant VRF_MIN_BLOCKS = 3;
uint32 constant VRF_GAS_LIMIT = 300000;
uint256 constant SPINS_PRECISION = 1e18;
uint256 constant GENESIS_SUPPLY = 2000;
uint256 constant ASTEROID_COORD_PRECISION = 1e3;
int256 constant ASTEROID_COORD_NEG_FLAG = 1e3;
{
"compilationTarget": {
"src/Miaocraft.sol": "Miaocraft"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@chainlink/=lib/chainlink/contracts/src/",
":@openzeppelin/=lib/openzeppelin-contracts/",
":chainlink/=lib/chainlink/integration-tests/contracts/ethereum/src/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":forge-std/=lib/forge-std/src/",
":miaocraft/=src/",
":solmate/=lib/solmate/src/"
]
}
[{"inputs":[{"internalType":"uint256","name":"buildCost_","type":"uint256"},{"internalType":"uint256","name":"unitDecayInterval","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"spins","type":"uint256"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"Build","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id1","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"id2","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"spins","type":"uint256"}],"name":"Merge","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"Rename","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"scavengerOwner","type":"address"},{"indexed":true,"internalType":"uint256","name":"scavengerId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"targetId","type":"uint256"}],"name":"Scrap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"spins","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"}],"name":"Service","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"spins","type":"uint256"}],"name":"Upgrade","type":"event"},{"inputs":[],"name":"BUILD_COST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SINGLE_SPINS_DECAY_PER_SEC","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"accountWlManager","outputs":[{"internalType":"contract AccountWhitelistManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"spins","type":"uint256"},{"internalType":"string","name":"name","type":"string"}],"name":"build","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"spins","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"buildAndLoad","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"spins","type":"uint256"}],"name":"buildCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"butter","outputs":[{"internalType":"contract IERC20Resource","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"string[]","name":"names","type":"string[]"}],"name":"commissionNftWl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"commissionPublic","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commissionPublicOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"name":"commissionWl","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commissionWlOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getShipInfo","outputs":[{"components":[{"internalType":"uint96","name":"spins","type":"uint96"},{"internalType":"uint96","name":"spinsBurned","type":"uint96"},{"internalType":"uint40","name":"lastServiceTime","type":"uint40"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct ShipInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"butter_","type":"address"},{"internalType":"address","name":"spatialSystem_","type":"address"},{"internalType":"address","name":"metadata_","type":"address"},{"internalType":"address","name":"sbh_","type":"address"},{"internalType":"uint256","name":"scrapReward_","type":"uint256"},{"internalType":"uint256","name":"scrapRadius_","type":"uint256"},{"internalType":"uint256","name":"transferBurnRate_","type":"uint256"},{"internalType":"address","name":"nftWlManager_","type":"address"},{"internalType":"address","name":"accountWlManager_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isApprovedOrOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"spins","type":"uint256"}],"name":"loadAndUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id1","type":"uint256"},{"internalType":"uint256","name":"id2","type":"uint256"}],"name":"merge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"metadata","outputs":[{"internalType":"contract IMetadata","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftWlManager","outputs":[{"internalType":"contract NFTWhitelistManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"paginateShips","outputs":[{"components":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"components":[{"internalType":"uint96","name":"spins","type":"uint96"},{"internalType":"uint96","name":"spinsBurned","type":"uint96"},{"internalType":"uint40","name":"lastServiceTime","type":"uint40"},{"internalType":"string","name":"name","type":"string"}],"internalType":"struct ShipInfo","name":"shipInfo","type":"tuple"},{"components":[{"internalType":"int40","name":"xOrigin","type":"int40"},{"internalType":"int40","name":"yOrigin","type":"int40"},{"internalType":"int40","name":"xDest","type":"int40"},{"internalType":"int40","name":"yDest","type":"int40"},{"internalType":"uint40","name":"speed","type":"uint40"},{"internalType":"uint40","name":"departureTime","type":"uint40"},{"internalType":"bool","name":"locked","type":"bool"}],"internalType":"struct LocationInfo","name":"locationInfo","type":"tuple"}],"internalType":"struct ShipInfoExtended[]","name":"shipInfos","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"string","name":"name","type":"string"}],"name":"rename","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sbh","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"scavengerId","type":"uint256"},{"internalType":"uint256","name":"targetId","type":"uint256"}],"name":"scrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"scrapRadius","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scrapReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"service","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"serviceCostOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Resource","name":"butter_","type":"address"}],"name":"setButter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"open","type":"bool"}],"name":"setCommissionPublicOpen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"open","type":"bool"}],"name":"setCommissionWlOpen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMetadata","name":"metadata_","type":"address"}],"name":"setMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sbh_","type":"address"}],"name":"setSbh","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"radius","type":"uint256"}],"name":"setScrapRadius","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"setScrapReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ISpatialSystem","name":"spatialSystem_","type":"address"}],"name":"setSpatialSystem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"rate","type":"uint256"}],"name":"setTransferBurnRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spatialSystem","outputs":[{"internalType":"contract ISpatialSystem","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"spinsDecayOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"spins","type":"uint256"}],"name":"spinsDecayPerSec","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"spinsOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"toEntity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"transferBurnRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"spins","type":"uint256"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"}]