Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
TokenTracker
Latest 25 from a total of 5,941 transactions
| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
| Set Approval For... | 23515497 | 147 days ago | IN | 0 ETH | 0.00000636 | ||||
| Set Approval For... | 22186093 | 333 days ago | IN | 0 ETH | 0.00002523 | ||||
| Set Approval For... | 21995201 | 360 days ago | IN | 0 ETH | 0.00002976 | ||||
| Set Approval For... | 20891762 | 514 days ago | IN | 0 ETH | 0.00023085 | ||||
| Set Approval For... | 20217132 | 608 days ago | IN | 0 ETH | 0.00006845 | ||||
| Set Approval For... | 20149533 | 617 days ago | IN | 0 ETH | 0.00005571 | ||||
| Set Approval For... | 20149531 | 617 days ago | IN | 0 ETH | 0.0000488 | ||||
| Set Approval For... | 20149531 | 617 days ago | IN | 0 ETH | 0.00004509 | ||||
| Set Approval For... | 20149520 | 617 days ago | IN | 0 ETH | 0.00005189 | ||||
| Set Approval For... | 20149520 | 617 days ago | IN | 0 ETH | 0.00005189 | ||||
| Set Approval For... | 20149520 | 617 days ago | IN | 0 ETH | 0.00004795 | ||||
| Set Approval For... | 19340779 | 731 days ago | IN | 0 ETH | 0.00302866 | ||||
| Set Approval For... | 18831242 | 802 days ago | IN | 0 ETH | 0.00093365 | ||||
| Set Approval For... | 18047953 | 912 days ago | IN | 0 ETH | 0.00032497 | ||||
| Set Approval For... | 17949071 | 926 days ago | IN | 0 ETH | 0.00069417 | ||||
| Set Approval For... | 17712426 | 959 days ago | IN | 0 ETH | 0.00086554 | ||||
| Service | 17695979 | 961 days ago | IN | 0 ETH | 0.00064306 | ||||
| Service | 17510324 | 987 days ago | IN | 0 ETH | 0.00077432 | ||||
| Set Approval For... | 17455434 | 995 days ago | IN | 0 ETH | 0.00116155 | ||||
| Service | 17247560 | 1024 days ago | IN | 0 ETH | 0.00267186 | ||||
| Service | 17115006 | 1043 days ago | IN | 0 ETH | 0.00182685 | ||||
| Service | 17066177 | 1050 days ago | IN | 0 ETH | 0.00133449 | ||||
| Service | 17059398 | 1051 days ago | IN | 0 ETH | 0.00131344 | ||||
| Service | 17043101 | 1053 days ago | IN | 0 ETH | 0.00139342 | ||||
| Set Approval For... | 17018423 | 1057 days ago | IN | 0 ETH | 0.00087831 |
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60c06040 | 16472180 | 1133 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Name:
Miaocraft
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
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) {
// burn all existing balance and decay spins with excess cost
butter.burnFrom(entityId, butterBalance);
_shipInfos[id].spins -= uint96(
((cost - butterBalance) * SPINS_PRECISION) / BUILD_COST
);
_shipInfos[id].spinsBurned = 0;
} else {
// has enough balance to pay for service
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))
});
}
}
/*
OWNER FUNCTIONS
*/
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_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1363.sol)
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./IERC165.sol";
interface IERC1363 is IERC165, IERC20 {
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Transfer tokens from `msg.sender` to another address and then call `onTransferReceived` on receiver
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferAndCall(
address to,
uint256 value,
bytes memory data
) external returns (bool);
/**
* @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @return true unless throwing
*/
function transferFromAndCall(
address from,
address to,
uint256 value
) external returns (bool);
/**
* @dev Transfer tokens from one address to another and then call `onTransferReceived` on receiver
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 The amount of tokens to be transferred
* @param data bytes Additional data with no specified format, sent in call to `to`
* @return true unless throwing
*/
function transferFromAndCall(
address from,
address to,
uint256 value,
bytes memory data
) external returns (bool);
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender
* and then call `onApprovalReceived` on spender.
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Additional data with no specified format, sent in call to `spender`
*/
function approveAndCall(
address spender,
uint256 value,
bytes memory data
) external returns (bool);
}// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol) pragma solidity ^0.8.0; import "../token/ERC20/IERC20.sol";
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/Address.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
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);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Internal function that returns the initialized version. Returns `_initialized`
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Internal function that returns the initialized version. Returns `_initializing`
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/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";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
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];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _ownerOf(tokenId);
require(owner != address(0), "ERC721: invalid token ID");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
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())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
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);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
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);
}
/**
* @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.
*
* `data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
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");
}
/**
* @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist
*/
function _ownerOf(uint256 tokenId) internal view virtual returns (address) {
return _owners[tokenId];
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _ownerOf(tokenId) != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
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);
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
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"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
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);
// Check that tokenId was not minted by `_beforeTokenTransfer` hook
require(!_exists(tokenId), "ERC721: token already minted");
unchecked {
// Will not overflow unless all 2**256 token ids are minted to the same owner.
// Given that tokens are minted one by one, it is impossible in practice that
// this ever happens. Might change if we allow batch minting.
// The ERC fails to describe this case.
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
* This is an internal function that does not check if the sender is authorized to operate on the token.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId, 1);
// Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook
owner = ERC721.ownerOf(tokenId);
// Clear approvals
delete _tokenApprovals[tokenId];
unchecked {
// Cannot overflow, as that would require more tokens to be burned/transferred
// out than the owner initially received through minting and transferring in.
_balances[owner] -= 1;
}
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId, 1);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
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);
// Check that tokenId was not transferred by `_beforeTokenTransfer` hook
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
// Clear approvals from the previous owner
delete _tokenApprovals[tokenId];
unchecked {
// `_balances[from]` cannot overflow for the same reason as described in `_burn`:
// `from`'s balance is the number of token held, which is at least one before the current
// transfer.
// `_balances[to]` could overflow in the conditions described in `_mint`. That would require
// all 2**256 token ids to be minted, which in practice is impossible.
_balances[from] -= 1;
_balances[to] += 1;
}
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {ApprovalForAll} event.
*/
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);
}
/**
* @dev Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
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 {
/// @solidity memory-safe-assembly
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.
* - When `from` is zero, the tokens will be minted for `to`.
* - When `to` is zero, ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256, /* firstTokenId */
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
}
/**
* @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is
* used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.
* - When `from` is zero, the tokens were minted for `to`.
* - When `to` is zero, ``from``'s tokens were burned.
* - `from` and `to` are never both zero.
* - `batchSize` is non-zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual {}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
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");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
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");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
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);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
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);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
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 {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol)
pragma solidity ^0.8.0;
import "./Address.sol";
/**
* @dev Provides a function to batch together multiple calls in a single external call.
*
* _Available since v4.1._
*/
abstract contract Multicall {
/**
* @dev Receives and executes a batch of function calls on this contract.
*/
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;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
unchecked {
uint256 length = Math.log10(value) + 1;
string memory buffer = new string(length);
uint256 ptr;
/// @solidity memory-safe-assembly
assembly {
ptr := add(buffer, add(32, length))
}
while (true) {
ptr--;
/// @solidity memory-safe-assembly
assembly {
mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
}
value /= 10;
if (value == 0) break;
}
return buffer;
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
unchecked {
return toHexString(value, Math.log256(value) + 1);
}
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
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);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates merkle trees that are safe
* against this attack out of the box.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Calldata version of {verify}
*
* _Available since v4.7._
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
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;
}
/**
* @dev Calldata version of {processProof}
*
* _Available since v4.7._
*/
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;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Calldata version of {multiProofVerify}
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* _Available since v4.7._
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
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];
}
}
/**
* @dev Calldata version of {processMultiProof}.
*
* CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.
*
* _Available since v4.7._
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the merkle tree.
uint256 leavesLen = leaves.length;
uint256 totalHashes = proofFlags.length;
// Check proof validity.
require(leavesLen + proof.length - 1 == totalHashes, "MerkleProof: invalid multiproof");
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](totalHashes);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value for the "main queue" (merging branches) or an element from the
// `proof` array.
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) {
/// @solidity memory-safe-assembly
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
enum Rounding {
Down, // Toward negative infinity
Up, // Toward infinity
Zero // Toward zero
}
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow.
return (a & b) + (a ^ b) / 2;
}
/**
* @dev Returns the ceiling of the division of two numbers.
*
* This differs from standard division with `/` in that it rounds up instead
* of rounding down.
*/
function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b - 1) / b can overflow on addition, so we distribute.
return a == 0 ? 0 : (a - 1) / b + 1;
}
/**
* @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
* @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
* with further edits by Uniswap Labs also under MIT license.
*/
function mulDiv(
uint256 x,
uint256 y,
uint256 denominator
) internal pure returns (uint256 result) {
unchecked {
// 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
// use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
// variables such that product = prod1 * 2^256 + prod0.
uint256 prod0; // Least significant 256 bits of the product
uint256 prod1; // Most significant 256 bits of the product
assembly {
let mm := mulmod(x, y, not(0))
prod0 := mul(x, y)
prod1 := sub(sub(mm, prod0), lt(mm, prod0))
}
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) {
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1);
///////////////////////////////////////////////
// 512 by 256 division.
///////////////////////////////////////////////
// Make division exact by subtracting the remainder from [prod1 prod0].
uint256 remainder;
assembly {
// Compute remainder using mulmod.
remainder := mulmod(x, y, denominator)
// Subtract 256 bit number from 512 bit number.
prod1 := sub(prod1, gt(remainder, prod0))
prod0 := sub(prod0, remainder)
}
// Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
// See https://cs.stackexchange.com/q/138556/92363.
// Does not overflow because the denominator cannot be zero at this stage in the function.
uint256 twos = denominator & (~denominator + 1);
assembly {
// Divide denominator by twos.
denominator := div(denominator, twos)
// Divide [prod1 prod0] by twos.
prod0 := div(prod0, twos)
// Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
twos := add(div(sub(0, twos), twos), 1)
}
// Shift in bits from prod1 into prod0.
prod0 |= prod1 * twos;
// Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
// that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
// four bits. That is, denominator * inv = 1 mod 2^4.
uint256 inverse = (3 * denominator) ^ 2;
// Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
// in modular arithmetic, doubling the correct bits in each step.
inverse *= 2 - denominator * inverse; // inverse mod 2^8
inverse *= 2 - denominator * inverse; // inverse mod 2^16
inverse *= 2 - denominator * inverse; // inverse mod 2^32
inverse *= 2 - denominator * inverse; // inverse mod 2^64
inverse *= 2 - denominator * inverse; // inverse mod 2^128
inverse *= 2 - denominator * inverse; // inverse mod 2^256
// Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
// This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
// less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
// is no longer required.
result = prod0 * inverse;
return result;
}
}
/**
* @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
*/
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;
}
/**
* @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
*
* Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
*/
function sqrt(uint256 a) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
// For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
//
// We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
// `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
//
// This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
// → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
// → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
//
// Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
uint256 result = 1 << (log2(a) >> 1);
// At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
// since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
// every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
// into the expected uint128 result.
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);
}
}
/**
* @notice Calculates sqrt(a), following the selected rounding direction.
*/
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);
}
}
/**
* @dev Return the log in base 2, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 2, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
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);
}
}
/**
* @dev Return the log in base 10, rounded down, of a positive value.
* Returns 0 if given 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;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
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);
}
}
/**
* @dev Return the log in base 256, rounded down, of a positive value.
* Returns 0 if given 0.
*
* Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
*/
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;
}
/**
* @dev Return the log in base 10, following the selected rounding direction, of a positive value.
* Returns 0 if given 0.
*/
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);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)
pragma solidity ^0.8.0;
/**
* @dev Standard signed math utilities missing in the Solidity language.
*/
library SignedMath {
/**
* @dev Returns the largest of two signed numbers.
*/
function max(int256 a, int256 b) internal pure returns (int256) {
return a > b ? a : b;
}
/**
* @dev Returns the smallest of two signed numbers.
*/
function min(int256 a, int256 b) internal pure returns (int256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two signed numbers without overflow.
* The result is rounded towards zero.
*/
function average(int256 a, int256 b) internal pure returns (int256) {
// Formula from the book "Hacker's Delight"
int256 x = (a & b) + ((a ^ b) >> 1);
return x + (int256(uint256(x) >> 255) & (a ^ b));
}
/**
* @dev Returns the absolute unsigned value of a signed value.
*/
function abs(int256 n) internal pure returns (uint256) {
unchecked {
// must be unchecked in order to support `n = type(int256).min`
return uint256(n >= 0 ? n : -n);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/// @notice Signed 18 decimal fixed point (wad) arithmetic library.
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/SignedWadMath.sol)
/// @author Modified from Remco Bloemen (https://xn--2-umb.com/22/exp-ln/index.html)
/// @dev Will not revert on overflow, only use where overflow is not possible.
function toWadUnsafe(uint256 x) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Multiply x by 1e18.
r := mul(x, 1000000000000000000)
}
}
/// @dev Takes an integer amount of seconds and converts it to a wad amount of days.
/// @dev Will not revert on overflow, only use where overflow is not possible.
/// @dev Not meant for negative second amounts, it assumes x is positive.
function toDaysWadUnsafe(uint256 x) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Multiply x by 1e18 and then divide it by 86400.
r := div(mul(x, 1000000000000000000), 86400)
}
}
/// @dev Takes a wad amount of days and converts it to an integer amount of seconds.
/// @dev Will not revert on overflow, only use where overflow is not possible.
/// @dev Not meant for negative day amounts, it assumes x is positive.
function fromDaysWadUnsafe(int256 x) pure returns (uint256 r) {
/// @solidity memory-safe-assembly
assembly {
// Multiply x by 86400 and then divide it by 1e18.
r := div(mul(x, 86400), 1000000000000000000)
}
}
/// @dev Will not revert on overflow, only use where overflow is not possible.
function unsafeWadMul(int256 x, int256 y) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Multiply x by y and divide by 1e18.
r := sdiv(mul(x, y), 1000000000000000000)
}
}
/// @dev Will return 0 instead of reverting if y is zero and will
/// not revert on overflow, only use where overflow is not possible.
function unsafeWadDiv(int256 x, int256 y) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Multiply x by 1e18 and divide it by y.
r := sdiv(mul(x, 1000000000000000000), y)
}
}
function wadMul(int256 x, int256 y) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Store x * y in r for now.
r := mul(x, y)
// Equivalent to require(x == 0 || (x * y) / x == y)
if iszero(or(iszero(x), eq(sdiv(r, x), y))) {
revert(0, 0)
}
// Scale the result down by 1e18.
r := sdiv(r, 1000000000000000000)
}
}
function wadDiv(int256 x, int256 y) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Store x * 1e18 in r for now.
r := mul(x, 1000000000000000000)
// Equivalent to require(y != 0 && ((x * 1e18) / 1e18 == x))
if iszero(and(iszero(iszero(y)), eq(sdiv(r, 1000000000000000000), x))) {
revert(0, 0)
}
// Divide r by y.
r := sdiv(r, y)
}
}
/// @dev Will not work with negative bases, only use when x is positive.
function wadPow(int256 x, int256 y) pure returns (int256) {
// Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)
return wadExp((wadLn(x) * y) / 1e18); // Using ln(x) means x must be greater than 0.
}
function wadExp(int256 x) pure returns (int256 r) {
unchecked {
// When the result is < 0.5 we return zero. This happens when
// x <= floor(log(0.5e18) * 1e18) ~ -42e18
if (x <= -42139678854452767551) return 0;
// When the result is > (2**255 - 1) / 1e18 we can not represent it as an
// int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
if (x >= 135305999368893231589) revert("EXP_OVERFLOW");
// x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
// for more intermediate precision and a binary basis. This base conversion
// is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
x = (x << 78) / 5**18;
// Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
// of two such that exp(x) = exp(x') * 2**k, where k is an integer.
// Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;
x = x - k * 54916777467707473351141471128;
// k is in the range [-61, 195].
// Evaluate using a (6, 7)-term rational approximation.
// p is made monic, we'll multiply by a scale factor later.
int256 y = x + 1346386616545796478920950773328;
y = ((y * x) >> 96) + 57155421227552351082224309758442;
int256 p = y + x - 94201549194550492254356042504812;
p = ((p * y) >> 96) + 28719021644029726153956944680412240;
p = p * x + (4385272521454847904659076985693276 << 96);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
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;
/// @solidity memory-safe-assembly
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial won't have zeros in the domain as all its roots are complex.
// No scaling is necessary because p is already 2**96 too large.
r := sdiv(p, q)
}
// r should be in the range (0.09, 0.25) * 2**96.
// We now need to multiply r by:
// * the scale factor s = ~6.031367120.
// * the 2**k factor from the range reduction.
// * the 1e18 / 2**96 factor for base conversion.
// We do this all at once, with an intermediate result in 2**213
// basis, so the final right shift is always by a positive amount.
r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
}
}
function wadLn(int256 x) pure returns (int256 r) {
unchecked {
require(x > 0, "UNDEFINED");
// We want to convert x from 10**18 fixed point to 2**96 fixed point.
// We do this by multiplying by 2**96 / 10**18. But since
// ln(x * C) = ln(x) + ln(C), we can simply do nothing here
// and add ln(2**96 / 10**18) at the end.
/// @solidity memory-safe-assembly
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)))
}
// Reduce range of x to (1, 2) * 2**96
// ln(2^k * x) = k * ln(2) + ln(x)
int256 k = r - 96;
x <<= uint256(159 - k);
x = int256(uint256(x) >> 159);
// Evaluate using a (8, 8)-term rational approximation.
// p is made monic, we will multiply by a scale factor later.
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);
// We leave p in 2**192 basis so we don't need to scale it back up for the division.
// q is monic by convention.
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;
/// @solidity memory-safe-assembly
assembly {
// Div in assembly because solidity adds a zero check despite the unchecked.
// The q polynomial is known not to have zeros in the domain.
// No scaling required because p is already 2**96 too large.
r := sdiv(p, q)
}
// r is in the range (0, 0.125) * 2**96
// Finalization, we need to:
// * multiply by the scale factor s = 5.549…
// * add ln(2**96 / 10**18)
// * add k * ln(2)
// * multiply by 10**18 / 2**96 = 5**18 >> 78
// mul s * 5e18 * 2**96, base is now 5**18 * 2**192
r *= 1677202110996718588342820967067443963516166;
// add ln(2) * k * 5e18 * 2**192
r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
// add ln(2**96 / 10**18) * 5e18 * 2**192
r += 600920179829731861736702779321621459595472258049074101567377883020018308;
// base conversion: mul 2**18 / 2**192
r >>= 174;
}
}
/// @dev Will return 0 instead of reverting if y is zero.
function unsafeDiv(int256 x, int256 y) pure returns (int256 r) {
/// @solidity memory-safe-assembly
assembly {
// Divide x by y.
r := sdiv(x, y)
}
}// SPDX-License-Identifier: MIT
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;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
interface IMetadata {
function getMetadata(uint256 tokenId) external view returns (string memory);
}// SPDX-License-Identifier: MIT
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);
}// SPDX-License-Identifier: MIT 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;
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/Interfaces/IERC1363.sol";
/// @title ERC20 with entity-based ownership and allowances.
/// @author boffee
/// @author Modified from openzeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/IERC20.sol)
interface IERC20Entity is IERC1363 {
/**
* @dev Emitted when `value` tokens are moved from one entity (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event EntityTransfer(
uint256 indexed from,
uint256 indexed to,
uint256 value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event EntityApproval(
uint256 indexed owner,
uint256 indexed spender,
uint256 value
);
/**
* @dev Returns the amount of tokens owned by `entity`.
*/
function balanceOf(uint256 entity) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's entity to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {EntityTransfer} event.
*/
function transfer(uint256 to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(uint256 owner, uint256 spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(uint256 spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {EntityTransfer} event.
*/
function transferFrom(
uint256 from,
uint256 to,
uint256 amount
) external returns (bool);
}// SPDX-License-Identifier: MIT
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;
}// SPDX-License-Identifier: MIT
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;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title Bitmap
/// @author Boffee - Critterz
/// @notice Storage efficient index -> boolean map
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);
}
}// SPDX-License-Identifier: MIT
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;
}//SPDX-License-Identifier: MIT
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;
/*
READ FUNCTIONS
*/
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));
}
/*
OWNER FUNCTIONS
*/
function setWhitelist(bytes32 root, string calldata uri)
external
onlyOwner
{
whitelistMerkleRoot = root;
whitelistURI = uri;
}
/*
MODIFIER
*/
modifier onlyWhitelisted(address account, bytes32[] memory proof) {
require(verifyAccount(account, proof), "Not whitelisted");
_;
}
}// SPDX-License-Identifier: MIT
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;
}
/*
WRITE FUNCTIONS
*/
function _setClaimed(address account) internal {
claimed[account] = true;
}
function claim(address account, bytes32[] calldata proof)
external
onlyApprovedCaller
onlyWhitelisted(account, proof)
onlyNotClaimed(account)
{
_setClaimed(account);
}
/*
OWNER FUNCTIONS
*/
function setApprovedCaller(address _approvedCaller) external onlyOwner {
approvedCaller = _approvedCaller;
}
/*
MODIFIERS
*/
modifier onlyNotClaimed(address account) {
require(!claimed[account], "Already claimed");
_;
}
modifier onlyApprovedCaller() {
require(
msg.sender == approvedCaller,
"AccountWhitelist: not approved caller"
);
_;
}
}// SPDX-License-Identifier: MIT
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);
}
/*
READ FUNCTIONS
*/
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;
}
/*
WRITE FUNCTIONS
*/
function _addWhitelist(address token, uint256 whitelistRate)
internal
virtual
{
require(whitelistRate <= 1e18, "NFTWhitelist: whitelist rate too high");
whitelistRates[token] = whitelistRate;
}
/*
OWNER FUNCTIONS
*/
function addWhitelist(address token, uint256 whitelistRate)
external
onlyOwner
{
_addWhitelist(token, whitelistRate);
}
/*
MODIFIERS
*/
modifier onlyWhitelisted(
address account,
address token,
uint256 id
) {
require(isWhitelisted(token, id), "Not whitelisted");
require(isOwner(account, token, id), "Not owner");
_;
}
}// SPDX-License-Identifier: MIT
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) {}
/*
READ FUNCTIONS
*/
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);
}
/*
WRITE FUNCTIONS
*/
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);
}
/*
OWNER FUNCTIONS
*/
function setApprovedCaller(address _approvedCaller) external onlyOwner {
approvedCaller = _approvedCaller;
}
/*
MODIFIERS
*/
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;
}{
"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/"
],
"optimizer": {
"enabled": true,
"runs": 200
},
"metadata": {
"bytecodeHash": "ipfs"
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "london",
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"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"}]Contract Creation Code
60c06040523480156200001157600080fd5b50604051620049b6380380620049b6833981016040819052620000349162000133565b60405180604001604052806009815260200168135a585bd8dc98599d60ba1b815250604051806040016040528060028152602001614d4360f01b8152508160009081620000829190620001fd565b506001620000918282620001fd565b505050620000ae620000a8620000d360201b60201c565b620000d7565b6080829052620000c781670de0b6b3a7640000620002c9565b60a05250620002ec9050565b3390565b600680546001600160a01b038381166201000081810262010000600160b01b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600080604083850312156200014757600080fd5b505080516020909101519092909150565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200018357607f821691505b602082108103620001a457634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620001f857600081815260208120601f850160051c81016020861015620001d35750805b601f850160051c820191505b81811015620001f457828155600101620001df565b5050505b505050565b81516001600160401b0381111562000219576200021962000158565b62000231816200022a84546200016e565b84620001aa565b602080601f831160018114620002695760008415620002505750858301515b600019600386901b1c1916600185901b178555620001f4565b600085815260208120601f198616915b828110156200029a5788860151825594840194600190910190840162000279565b5085821015620002b95787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600082620002e757634e487b7160e01b600052601260045260246000fd5b500490565b60805160a05161467a6200033c600039600081816105d80152610b0601526000818161071f01528181610b7701528181611baf01528181611d8f01528181612bad015261307e015261467a6000f3fe608060405234801561001057600080fd5b50600436106103af5760003560e01c806373211164116101f4578063acd6cc851161011a578063e1801f9f116100ad578063f2fde38b1161007c578063f2fde38b14610884578063f3cb838514610897578063f8c527fc146108aa578063ffb52cfb146108bd57600080fd5b8063e1801f9f14610802578063e37a04f914610815578063e3df113014610835578063e985e9c51461084857600080fd5b8063ce87ddda116100e9578063ce87ddda146107c0578063d1c2babb146107d3578063d419c9ee146107e6578063d7282d15146107f957600080fd5b8063acd6cc8514610774578063b88d4fde14610787578063c09cd3641461079a578063c87b56dd146107ad57600080fd5b806394fa07fd116101925780639db1a133116101615780639db1a133146107075780639effb57e1461071a578063a22cb46514610741578063ac9650d81461075457600080fd5b806394fa07fd146106c657806395d89b41146106d957806396b58c7a146106e15780639bae60dd146106f457600080fd5b80638da5cb5b116101ce5780638da5cb5b146106755780638ea91f131461068c57806392071d7a146106a057806394a328fd146106b357600080fd5b8063732111641461063b57806384292e791461064e5780638577fa351461066157600080fd5b8063430c2081116102d95780635ed6a17a116102775780636352211e116102465780636352211e146105fa578063645412751461060d57806370a0823114610620578063715018a61461063357600080fd5b80635ed6a17a146105a457806360c5888e146105b757806361b8ce8c146105ca57806361e1e86d146105d357600080fd5b8063459999ef116102b3578063459999ef146105625780634c915d6d1461057557806353836e431461058857806354ec3f131461059b57600080fd5b8063430c208114610529578063451450ec1461053c578063454d6df51461054f57600080fd5b806326fe83f6116103515780633cf1ecd2116103205780633cf1ecd2146104dd5780633ec2d836146104f057806342842e0e1461050357806342fca82e1461051657600080fd5b806326fe83f61461046e5780632809967614610481578063367668d4146104aa578063392f37e9146104ca57600080fd5b8063083eb03b1161038d578063083eb03b1461041c578063095ea7b31461043357806319d071d21461044857806323b872dd1461045b57600080fd5b806301ffc9a7146103b457806306fdde03146103dc578063081812fc146103f1575b600080fd5b6103c76103c236600461366b565b6108d0565b60405190151581526020015b60405180910390f35b6103e4610922565b6040516103d391906136d8565b6104046103ff3660046136eb565b6109b4565b6040516001600160a01b0390911681526020016103d3565b61042560085481565b6040519081526020016103d3565b610446610441366004613719565b6109db565b005b6104256104563660046136eb565b610af5565b610446610469366004613745565b610b34565b61042561047c3660046136eb565b610b66565b61042561048f3660046136eb565b6000908152601060205260409020546001600160601b031690565b6104bd6104b83660046136eb565b610b9b565b6040516103d391906137cd565b600c54610404906001600160a01b031681565b6104466104eb36600461386c565b610cad565b6104466104fe3660046138d7565b610d7e565b610446610511366004613745565b610e44565b610446610524366004613922565b610e5f565b6103c7610537366004613719565b610e89565b61044661054a36600461393f565b610e9c565b61044661055d366004613961565b610fd2565b600f54610404906001600160a01b031681565b6104466105833660046136eb565b6111c8565b61044661059636600461399b565b6111fb565b61042560095481565b6104256105b23660046136eb565b611221565b600b54610404906001600160a01b031681565b61042560125481565b6104257f000000000000000000000000000000000000000000000000000000000000000081565b6104046106083660046136eb565b61123d565b61044661061b3660046136eb565b61129d565b61042561062e366004613922565b6112fb565b610446611381565b6104256106493660046136eb565b611395565b61044661065c36600461393f565b6113fb565b6006546103c790600160b01b900460ff1681565b6006546201000090046001600160a01b0316610404565b6006546103c790600160b81b900460ff1681565b600d54610404906001600160a01b031681565b6104466106c13660046139b8565b611706565b6104466106d43660046139f9565b6117e6565b6103e461193b565b6104466106ef3660046136eb565b61194a565b600e54610404906001600160a01b031681565b610446610715366004613a4b565b611957565b6104257f000000000000000000000000000000000000000000000000000000000000000081565b61044661074f366004613acd565b611aa6565b610767610762366004613b06565b611ab1565b6040516103d39190613b3b565b6104466107823660046136eb565b611ba5565b610446610795366004613c0a565b611c22565b6104466107a83660046138d7565b611c54565b6103e46107bb3660046136eb565b611d03565b6104256107ce3660046136eb565b611d75565b6104466107e136600461393f565b611db3565b600a54610404906001600160a01b031681565b61042560075481565b61044661081036600461399b565b612087565b61082861082336600461393f565b6120ad565b6040516103d39190613cb8565b610446610843366004613922565b612386565b6103c7610856366004613dd1565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610446610892366004613922565b6123b0565b6104466108a5366004613922565b612429565b6104466108b8366004613dff565b612453565b6104466108cb366004613922565b6125df565b60006001600160e01b031982166380ac58cd60e01b148061090157506001600160e01b03198216635b5e139f60e01b145b8061091c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461093190613ea0565b80601f016020809104026020016040519081016040528092919081815260200182805461095d90613ea0565b80156109aa5780601f1061097f576101008083540402835291602001916109aa565b820191906000526020600020905b81548152906001019060200180831161098d57829003601f168201915b5050505050905090565b60006109bf82612609565b506000908152600460205260409020546001600160a01b031690565b60006109e68261123d565b9050806001600160a01b0316836001600160a01b031603610a585760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a745750610a748133610856565b610ae65760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610a4f565b610af08383612668565b505050565b6000670de0b6b3a7640000610b2a837f0000000000000000000000000000000000000000000000000000000000000000613ef0565b61091c9190613f07565b610b3f335b826126d6565b610b5b5760405162461bcd60e51b8152600401610a4f90613f29565b610af0838383612755565b6000670de0b6b3a7640000610b2a837f0000000000000000000000000000000000000000000000000000000000000000613ef0565b6040805160808101825260008082526020820181905291810191909152606080820152600082815260106020908152604091829020825160808101845281546001600160601b038082168352600160601b82041693820193909352600160c01b90920464ffffffffff1692820192909252600182018054919291606084019190610c2490613ea0565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5090613ea0565b8015610c9d5780601f10610c7257610100808354040283529160200191610c9d565b820191906000526020600020905b815481529060010190602001808311610c8057829003601f168201915b5050505050815250509050919050565b600654600160b01b900460ff16610cd65760405162461bcd60e51b8152600401610a4f90613f76565b6107d060125410610cf95760405162461bcd60e51b8152600401610a4f90613f9c565b600f546001600160a01b031663d7aada813384846040518463ffffffff1660e01b8152600401610d2b93929190613fef565b600060405180830381600087803b158015610d4557600080fd5b505af1158015610d59573d6000803e3d6000fd5b50505050610d77610d673390565b670de0b6b3a764000086866128c6565b5050505050565b610d878361123d565b6001600160a01b0316336001600160a01b031614610dd65760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610a4f565b6000838152601060205260409020600101610df2828483614063565b5082610dfd8461123d565b6001600160a01b03167f200038820d751f67059d4e34d21526a659b7e2b7141ea1cfd7e1f95e1e0fca608484604051610e3792919061414b565b60405180910390a3505050565b610af083838360405180602001604052806000815250611c22565b610e67612a24565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e9583836126d6565b9392505050565b81610ea633610b39565b610ec25760405162461bcd60e51b8152600401610a4f9061415f565b610ecb83612a85565b60008381526010602052604081208054849290610ef29084906001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a546001600160a01b0316638769fd41610f2f85611221565b610f3885610b66565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015610f7657600080fd5b505af1158015610f8a573d6000803e3d6000fd5b5050505082610f988461123d565b6001600160a01b03167f13ea485b1d8135315e770779887880798ac429f039a7c5ca3ff5f6f99a95b58784604051610e3791815260200190565b82610fdc33610b39565b610ff85760405162461bcd60e51b8152600401610a4f9061415f565b670de0b6b3a76400008210156110205760405162461bcd60e51b8152600401610a4f906141af565b600061102b85611221565b600a549091506001600160a01b031663310ed7f0336040516001600160e01b031960e084901b168152600481019190915260248101849052604481018790526064016020604051808303816000875af115801561108c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b091906141d9565b506110ba85612a85565b600085815260106020526040812080548592906110e19084906001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a546001600160a01b0316638769fd418261111f86610b66565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561115d57600080fd5b505af1158015611171573d6000803e3d6000fd5b505050508461117f8661123d565b6001600160a01b03167f13ea485b1d8135315e770779887880798ac429f039a7c5ca3ff5f6f99a95b587856040516111b991815260200190565b60405180910390a35050505050565b806111d233610b39565b6111ee5760405162461bcd60e51b8152600401610a4f9061415f565b6111f782612a85565b5050565b611203612a24565b60068054911515600160b81b0260ff60b81b19909216919091179055565b60006bffffffffffffffffffffffff193060601b16821761091c565b6000818152600260205260408120546001600160a01b03168061091c5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a4f565b6112a5612a24565b67016345785d8a00008111156112f65760405162461bcd60e51b81526020600482015260166024820152750a4c2e8ca40daeae6e840c4ca40787a40605c62ca62760531b6044820152606401610a4f565b600955565b60006001600160a01b0382166113655760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610a4f565b506001600160a01b031660009081526003602052604090205490565b611389612a24565b6113936000612d3e565b565b6000818152601060205260408120546001600160601b0380821691610e95918391600160601b8104909116906113d990600160c01b900464ffffffffff16426141f6565b6113e285610af5565b6113ec9190613ef0565b6113f69190614209565b612d9a565b8161140533610b39565b6114215760405162461bcd60e51b8152600401610a4f9061415f565b600061142c84611221565b9050600061143984611221565b905061144484611395565b6000858152601060205260409020546001600160601b03161461149a5760405162461bcd60e51b815260206004820152600e60248201526d4e6f742073637261707061626c6560901b6044820152606401610a4f565b600b54600854604051631310588f60e11b8152600481018590526024810184905260448101919091526001600160a01b0390911690632620b11e90606401602060405180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151991906141d9565b6115545760405162461bcd60e51b815260206004820152600c60248201526b546f6f20666172206177617960a01b6044820152606401610a4f565b600084815260106020526040812080546001600160e81b03191681559061157e6001830182613571565b5050600a54604051631398fee160e31b8152600481018390526001600160a01b0390911690638769fd419083908390639cc7f70890602401602060405180830381865afa1580156115d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f7919061421c565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561163557600080fd5b505af1158015611649573d6000803e3d6000fd5b5050505061165684612db0565b600a54600754604051630d9778e560e11b81526004810185905260248101919091526001600160a01b0390911690631b2ef1ca90604401600060405180830381600087803b1580156116a757600080fd5b505af11580156116bb573d6000803e3d6000fd5b5050505083856116ca8761123d565b6001600160a01b03167f87c1be595bf1173580b78a0161f3e2f2a37d277fbc63f85f09d0be9bd83d210660405160405180910390a45050505050565b600654600160b81b900460ff1661172f5760405162461bcd60e51b8152600401610a4f90613f76565b6107d0601254106117525760405162461bcd60e51b8152600401610a4f90613f9c565b3360008181526011602052604090205460ff16156117a95760405162461bcd60e51b8152602060048201526014602482015273105b1c9958591e4818dbdb5b5a5cdcda5bdb995960621b6044820152606401610a4f565b6001600160a01b0381166000908152601160205260409020805460ff191660011790556117e081670de0b6b3a764000085856128c6565b50505050565b670de0b6b3a764000084101561180e5760405162461bcd60e51b8152600401610a4f906141af565b600a5433906001600160a01b03166379cc67908261182b88610b66565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561187157600080fd5b505af1158015611885573d6000803e3d6000fd5b505050506000611897828787876128c6565b600a549091506001600160a01b031663310ed7f06118bb846001600160a01b031690565b6118c484611221565b6040516001600160e01b031960e085901b16815260048101929092526024820152604481018690526064016020604051808303816000875af115801561190e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193291906141d9565b50505050505050565b60606001805461093190613ea0565b611952612a24565b600855565b600654600160b01b900460ff166119805760405162461bcd60e51b8152600401610a4f90613f76565b6107d0601254106119a35760405162461bcd60e51b8152600401610a4f90613f9c565b8281146119e45760405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610a4f565b600e546001600160a01b0316634ab4da9b338787876040518563ffffffff1660e01b8152600401611a189493929190614235565b600060405180830381600087803b158015611a3257600080fd5b505af1158015611a46573d6000803e3d6000fd5b5050505060005b83811015611a9e57611a8b33670de0b6b3a7640000858585818110611a7457611a74614262565b9050602002810190611a869190614278565b6128c6565b5080611a96816142be565b915050611a4d565b505050505050565b6111f7338383612e53565b6060816001600160401b03811115611acb57611acb613b9d565b604051908082528060200260200182016040528015611afe57816020015b6060815260200190600190039081611ae95790505b50905060005b82811015611b9e57611b6e30858584818110611b2257611b22614262565b9050602002810190611b349190614278565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612f1992505050565b828281518110611b8057611b80614262565b60200260200101819052508080611b96906142be565b915050611b04565b5092915050565b611bad612a24565b7f0000000000000000000000000000000000000000000000000000000000000000811115611c1d5760405162461bcd60e51b815260206004820152601c60248201527f526577617264206d757374206265203c3d206275696c6420636f7374000000006044820152606401610a4f565b600755565b611c2c33836126d6565b611c485760405162461bcd60e51b8152600401610a4f90613f29565b6117e084848484612f3e565b670de0b6b3a7640000831015611c7c5760405162461bcd60e51b8152600401610a4f906141af565b600a5433906001600160a01b03166379cc679082611c9987610b66565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015611cdf57600080fd5b505af1158015611cf3573d6000803e3d6000fd5b50505050610d77818585856128c6565b600c5460405163295d33a960e21b8152600481018390526060916001600160a01b03169063a574cea490602401600060405180830381865afa158015611d4d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261091c91908101906142d7565b6000670de0b6b3a7640000611d8983611395565b610b2a907f0000000000000000000000000000000000000000000000000000000000000000613ef0565b81611dbd33610b39565b611dd95760405162461bcd60e51b8152600401610a4f9061415f565b81611de333610b39565b611dff5760405162461bcd60e51b8152600401610a4f9061415f565b6000611e0a85611221565b90506000611e1785611221565b600b5460405163648414a560e01b815260048101859052602481018390529192506001600160a01b03169063648414a590604401602060405180830381865afa158015611e68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8c91906141d9565b611e9557600080fd5b611e9e86612a85565b611ea785612a85565b6000858152601060205260408082205488835290822080546001600160601b03928316939192611ed99185911661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600085815260106020526040812080546001600160e81b031916815590611f266001830182613571565b5050600a54604051631398fee160e31b8152600481018390526001600160a01b039091169063310ed7f090839085908490639cc7f70890602401602060405180830381865afa158015611f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa1919061421c565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016020604051808303816000875af1158015611fec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201091906141d9565b5061201a85612db0565b84866120258861123d565b6000898152601060209081526040918290205491516001600160601b0390921682526001600160a01b0392909216917fb3ce851d16b3bbec3774d5631a3893dfa2a80e067cfad265dd594402ac3d6096910160405180910390a4505050505050565b61208f612a24565b60068054911515600160b01b0260ff60b01b19909216919091179055565b6012546060908084106120c0575061091c565b60006120cc8486614209565b9050818111156120d95750805b6120e385826141f6565b6001600160401b038111156120fa576120fa613b9d565b60405190808252806020026020018201604052801561213357816020015b6121206135ab565b8152602001906001900390816121185790505b509250845b8181101561237d576040518060a0016040528082815260200161215a8361123d565b6001600160a01b039081168252600a5460209092019116639cc7f70861217f85611221565b6040518263ffffffff1660e01b815260040161219d91815260200190565b602060405180830381865afa1580156121ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121de919061421c565b8152600083815260106020908152604091829020825160808101845281546001600160601b038082168352600160601b82041682850152600160c01b900464ffffffffff16938101939093526001810180549290940193909160608401919061224690613ea0565b80601f016020809104026020016040519081016040528092919081815260200182805461227290613ea0565b80156122bf5780601f10612294576101008083540402835291602001916122bf565b820191906000526020600020905b8154815290600101906020018083116122a257829003601f168201915b505050919092525050508152600b546020909101906001600160a01b031663f3f9082f6122eb85611221565b6040518263ffffffff1660e01b815260040161230991815260200190565b60e060405180830381865afa158015612326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061234a9190614370565b81525084828151811061235f5761235f614262565b60200260200101819052508080612375906142be565b915050612138565b50505092915050565b61238e612a24565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6123b8612a24565b6001600160a01b03811661241d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a4f565b61242681612d3e565b50565b612431612a24565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b600654610100900460ff16158080156124735750600654600160ff909116105b8061248d5750303b15801561248d575060065460ff166001145b6124f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a4f565b6006805460ff191660011790558015612513576006805461ff0019166101001790555b600a80546001600160a01b03199081166001600160a01b038d811691909117909255600b805482168c8416179055600c805482168b8416179055600d805482168a8416179055600788905560088790556009869055600e80548216868416179055600f805490911691841691909117905561258d33612d3e565b80156125d3576006805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6125e7612a24565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000818152600260205260409020546001600160a01b03166124265760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a4f565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061269d8261123d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806126e28361123d565b9050806001600160a01b0316846001600160a01b0316148061272957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061274d5750836001600160a01b0316612742846109b4565b6001600160a01b0316145b949350505050565b826001600160a01b03166127688261123d565b6001600160a01b03161461278e5760405162461bcd60e51b8152600401610a4f90614421565b6001600160a01b0382166127f05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a4f565b6127fd8383836001612f71565b826001600160a01b03166128108261123d565b6001600160a01b0316146128365760405162461bcd60e51b8152600401610a4f90614421565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60128054600091826128d7836142be565b9190505590506040518060800160405280856001600160601b0316815260200160006001600160601b031681526020014264ffffffffff16815260200184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152601060209081526040918290208451815492860151938601516001600160601b039182166001600160c01b031990941693909317600160601b91909416029290921764ffffffffff60c01b1916600160c01b64ffffffffff90921691909102178155606083015190915060018201906129c89082614466565b509050506129d68582613139565b80856001600160a01b03167f3b1cc5a2c97b67a501e55d3eecf8cbd09cf2cd764461e9f445ea5fd8c9020119868686604051612a1493929190614525565b60405180910390a3949350505050565b6006546001600160a01b03620100009091041633146113935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a4f565b6000612a9082611d75565b90506000612a9d83611221565b600a54604051631398fee160e31b8152600481018390529192506000916001600160a01b0390911690639cc7f70890602401602060405180830381865afa158015612aec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b10919061421c565b6000858152601060205260409020805464ffffffffff60c01b1916600160c01b4264ffffffffff1602179055905080831115612c6857600a54604051638769fd4160e01b815260048101849052602481018390526001600160a01b0390911690638769fd4190604401600060405180830381600087803b158015612b9357600080fd5b505af1158015612ba7573d6000803e3d6000fd5b505050507f0000000000000000000000000000000000000000000000000000000000000000670de0b6b3a76400008285612be191906141f6565b612beb9190613ef0565b612bf59190613f07565b60008581526010602052604081208054909190612c1c9084906001600160601b031661453f565b82546001600160601b039182166101009390930a928302919092021990911617905550600084815260106020526040902080546bffffffffffffffffffffffff60601b19169055612cce565b600a54604051638769fd4160e01b815260048101849052602481018590526001600160a01b0390911690638769fd4190604401600060405180830381600087803b158015612cb557600080fd5b505af1158015612cc9573d6000803e3d6000fd5b505050505b83612cd88561123d565b6000868152601060209081526040918290205482516001600160601b0390911681529081018790526001600160a01b0392909216917fbf3e5a98eab8e611f59568e4a880c8465e0ec0b73006f9ca120ff865a555d8a0910160405180910390a350505050565b600680546001600160a01b038381166201000081810262010000600160b01b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000818310612da95781610e95565b5090919050565b6000612dbb8261123d565b9050612dcb816000846001612f71565b612dd48261123d565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603612eb45760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a4f565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319101610e37565b6060610e95838360405180606001604052806027815260200161461e602791396132d2565b612f49848484612755565b612f558484848461334a565b6117e05760405162461bcd60e51b8152600401610a4f9061455f565b6001600160a01b03841615801590612f9157506001600160a01b03831615155b1561312d57815b612fa28284614209565b81101561312b576000612fb482611395565b6000838152601060205260409020546001600160601b0316612fd691906141f6565b90508015613118576000670de0b6b3a764000060095483612ff79190613ef0565b6130019190613f07565b600084815260106020526040902080549192508291600c90613034908490600160601b90046001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a54600d546001600160a01b03918216916340c10f199116670de0b6b3a76400006130a37f000000000000000000000000000000000000000000000000000000000000000086613ef0565b6130ae906002613ef0565b6130b89190613f07565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156130fe57600080fd5b505af1158015613112573d6000803e3d6000fd5b50505050505b5080613123816142be565b915050612f98565b505b6117e08484848461344b565b6001600160a01b03821661318f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a4f565b6000818152600260205260409020546001600160a01b0316156131f45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a4f565b613202600083836001612f71565b6000818152600260205260409020546001600160a01b0316156132675760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a4f565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060600080856001600160a01b0316856040516132ef91906145b1565b600060405180830381855af49150503d806000811461332a576040519150601f19603f3d011682016040523d82523d6000602084013e61332f565b606091505b5091509150613340868383876134d3565b9695505050505050565b60006001600160a01b0384163b1561344057604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061338e9033908990889088906004016145cd565b6020604051808303816000875af19250505080156133c9575060408051601f3d908101601f191682019092526133c691810190614600565b60015b613426573d8080156133f7576040519150601f19603f3d011682016040523d82523d6000602084013e6133fc565b606091505b50805160000361341e5760405162461bcd60e51b8152600401610a4f9061455f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061274d565b506001949350505050565b60018111156117e0576001600160a01b03841615613491576001600160a01b0384166000908152600360205260408120805483929061348b9084906141f6565b90915550505b6001600160a01b038316156117e0576001600160a01b038316600090815260036020526040812080548392906134c8908490614209565b909155505050505050565b6060831561354257825160000361353b576001600160a01b0385163b61353b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a4f565b508161274d565b61274d83838151156135575781518083602001fd5b8060405162461bcd60e51b8152600401610a4f91906136d8565b50805461357d90613ea0565b6000825580601f1061358d575050565b601f016020900490600052602060002090810190612426919061363c565b6040518060a001604052806000815260200160006001600160a01b03168152602001600081526020016135fd604080516080810182526000808252602082018190529181019190915260608082015290565b81526040805160e08101825260008082526020828101829052928201819052606082018190526080820181905260a0820181905260c082015291015290565b5b80821115613651576000815560010161363d565b5090565b6001600160e01b03198116811461242657600080fd5b60006020828403121561367d57600080fd5b8135610e9581613655565b60005b838110156136a357818101518382015260200161368b565b50506000910152565b600081518084526136c4816020860160208601613688565b601f01601f19169290920160200192915050565b602081526000610e9560208301846136ac565b6000602082840312156136fd57600080fd5b5035919050565b6001600160a01b038116811461242657600080fd5b6000806040838503121561372c57600080fd5b823561373781613704565b946020939093013593505050565b60008060006060848603121561375a57600080fd5b833561376581613704565b9250602084013561377581613704565b929592945050506040919091013590565b60006001600160601b038083511684528060208401511660208501525064ffffffffff604083015116604084015260608201516080606085015261274d60808501826136ac565b602081526000610e956020830184613786565b60008083601f8401126137f257600080fd5b5081356001600160401b0381111561380957600080fd5b60208301915083602082850101111561382157600080fd5b9250929050565b60008083601f84011261383a57600080fd5b5081356001600160401b0381111561385157600080fd5b6020830191508360208260051b850101111561382157600080fd5b6000806000806040858703121561388257600080fd5b84356001600160401b038082111561389957600080fd5b6138a5888389016137e0565b909650945060208701359150808211156138be57600080fd5b506138cb87828801613828565b95989497509550505050565b6000806000604084860312156138ec57600080fd5b8335925060208401356001600160401b0381111561390957600080fd5b613915868287016137e0565b9497909650939450505050565b60006020828403121561393457600080fd5b8135610e9581613704565b6000806040838503121561395257600080fd5b50508035926020909101359150565b60008060006060848603121561397657600080fd5b505081359360208301359350604090920135919050565b801515811461242657600080fd5b6000602082840312156139ad57600080fd5b8135610e958161398d565b600080602083850312156139cb57600080fd5b82356001600160401b038111156139e157600080fd5b6139ed858286016137e0565b90969095509350505050565b60008060008060608587031215613a0f57600080fd5b8435935060208501356001600160401b03811115613a2c57600080fd5b613a38878288016137e0565b9598909750949560400135949350505050565b600080600080600060608688031215613a6357600080fd5b8535613a6e81613704565b945060208601356001600160401b0380821115613a8a57600080fd5b613a9689838a01613828565b90965094506040880135915080821115613aaf57600080fd5b50613abc88828901613828565b969995985093965092949392505050565b60008060408385031215613ae057600080fd5b8235613aeb81613704565b91506020830135613afb8161398d565b809150509250929050565b60008060208385031215613b1957600080fd5b82356001600160401b03811115613b2f57600080fd5b6139ed85828601613828565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613b9057603f19888603018452613b7e8583516136ac565b94509285019290850190600101613b62565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613bdb57613bdb613b9d565b604052919050565b60006001600160401b03821115613bfc57613bfc613b9d565b50601f01601f191660200190565b60008060008060808587031215613c2057600080fd5b8435613c2b81613704565b93506020850135613c3b81613704565b92506040850135915060608501356001600160401b03811115613c5d57600080fd5b8501601f81018713613c6e57600080fd5b8035613c81613c7c82613be3565b613bb3565b818152886020838501011115613c9657600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015613dc357888303603f19018552815180518452878101516001600160a01b03168885015286810151878501526060808201516101608287018190529190613d2c83880182613786565b92505060808084015193508351600481810b838a01528c860151915060a082820b818b01528c870151925060c083830b818c015285880151830b60e08c015264ffffffffff85890151166101008c0152818801519550613d966101208c018764ffffffffff169052565b96909601518015156101408b01529550613db09350505050565b9588019593505090860190600101613cdf565b509098975050505050505050565b60008060408385031215613de457600080fd5b8235613def81613704565b91506020830135613afb81613704565b60008060008060008060008060006101208a8c031215613e1e57600080fd5b8935613e2981613704565b985060208a0135613e3981613704565b975060408a0135613e4981613704565b965060608a0135613e5981613704565b955060808a0135945060a08a0135935060c08a0135925060e08a0135613e7e81613704565b91506101008a0135613e8f81613704565b809150509295985092959850929598565b600181811c90821680613eb457607f821691505b602082108103613ed457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761091c5761091c613eda565b600082613f2457634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6020808252600c908201526b139bdd081bdc195b881e595d60a21b604082015260600190565b6020808252600790820152664e6f206d6f726560c81b604082015260600190565b81835260006001600160fb1b03831115613fd657600080fd5b8260051b80836020870137939093016020019392505050565b6001600160a01b03841681526040602082018190526000906140149083018486613fbd565b95945050505050565b601f821115610af057600081815260208120601f850160051c810160208610156140445750805b601f850160051c820191505b81811015611a9e57828155600101614050565b6001600160401b0383111561407a5761407a613b9d565b61408e836140888354613ea0565b8361401d565b6000601f8411600181146140c257600085156140aa5750838201355b600019600387901b1c1916600186901b178355610d77565b600083815260209020601f19861690835b828110156140f357868501358255602094850194600190920191016140d3565b50868210156141105760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60208152600061274d602083018486614122565b60208082526016908201527527b7363c9030b8383937bb32b21037b91037bbb732b960511b604082015260600190565b6001600160601b03818116838216019080821115611b9e57611b9e613eda565b60208082526010908201526f2632b9b9903a3430b710189039b834b760811b604082015260600190565b6000602082840312156141eb57600080fd5b8151610e958161398d565b8181038181111561091c5761091c613eda565b8082018082111561091c5761091c613eda565b60006020828403121561422e57600080fd5b5051919050565b6001600160a01b038581168252841660208201526060604082018190526000906133409083018486613fbd565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261428f57600080fd5b8301803591506001600160401b038211156142a957600080fd5b60200191503681900382131561382157600080fd5b6000600182016142d0576142d0613eda565b5060010190565b6000602082840312156142e957600080fd5b81516001600160401b038111156142ff57600080fd5b8201601f8101841361431057600080fd5b805161431e613c7c82613be3565b81815285602083850101111561433357600080fd5b614014826020830160208601613688565b8051600481900b811461435657600080fd5b919050565b805164ffffffffff8116811461435657600080fd5b600060e0828403121561438257600080fd5b60405160e081018181106001600160401b03821117156143a4576143a4613b9d565b6040526143b083614344565b81526143be60208401614344565b60208201526143cf60408401614344565b60408201526143e060608401614344565b60608201526143f16080840161435b565b608082015261440260a0840161435b565b60a082015260c08301516144158161398d565b60c08201529392505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b81516001600160401b0381111561447f5761447f613b9d565b6144938161448d8454613ea0565b8461401d565b602080601f8311600181146144c857600084156144b05750858301515b600019600386901b1c1916600185901b178555611a9e565b600085815260208120601f198616915b828110156144f7578886015182559484019460019091019084016144d8565b50858210156145155787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b838152604060208201526000614014604083018486614122565b6001600160601b03828116828216039080821115611b9e57611b9e613eda565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082516145c3818460208701613688565b9190910192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613340908301846136ac565b60006020828403121561461257600080fd5b8151610e958161365556fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220497d977758a183f7d538f7633079b9a7444ce7b787a3362fd5472b05246a34e564736f6c634300081100330000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000278d00
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106103af5760003560e01c806373211164116101f4578063acd6cc851161011a578063e1801f9f116100ad578063f2fde38b1161007c578063f2fde38b14610884578063f3cb838514610897578063f8c527fc146108aa578063ffb52cfb146108bd57600080fd5b8063e1801f9f14610802578063e37a04f914610815578063e3df113014610835578063e985e9c51461084857600080fd5b8063ce87ddda116100e9578063ce87ddda146107c0578063d1c2babb146107d3578063d419c9ee146107e6578063d7282d15146107f957600080fd5b8063acd6cc8514610774578063b88d4fde14610787578063c09cd3641461079a578063c87b56dd146107ad57600080fd5b806394fa07fd116101925780639db1a133116101615780639db1a133146107075780639effb57e1461071a578063a22cb46514610741578063ac9650d81461075457600080fd5b806394fa07fd146106c657806395d89b41146106d957806396b58c7a146106e15780639bae60dd146106f457600080fd5b80638da5cb5b116101ce5780638da5cb5b146106755780638ea91f131461068c57806392071d7a146106a057806394a328fd146106b357600080fd5b8063732111641461063b57806384292e791461064e5780638577fa351461066157600080fd5b8063430c2081116102d95780635ed6a17a116102775780636352211e116102465780636352211e146105fa578063645412751461060d57806370a0823114610620578063715018a61461063357600080fd5b80635ed6a17a146105a457806360c5888e146105b757806361b8ce8c146105ca57806361e1e86d146105d357600080fd5b8063459999ef116102b3578063459999ef146105625780634c915d6d1461057557806353836e431461058857806354ec3f131461059b57600080fd5b8063430c208114610529578063451450ec1461053c578063454d6df51461054f57600080fd5b806326fe83f6116103515780633cf1ecd2116103205780633cf1ecd2146104dd5780633ec2d836146104f057806342842e0e1461050357806342fca82e1461051657600080fd5b806326fe83f61461046e5780632809967614610481578063367668d4146104aa578063392f37e9146104ca57600080fd5b8063083eb03b1161038d578063083eb03b1461041c578063095ea7b31461043357806319d071d21461044857806323b872dd1461045b57600080fd5b806301ffc9a7146103b457806306fdde03146103dc578063081812fc146103f1575b600080fd5b6103c76103c236600461366b565b6108d0565b60405190151581526020015b60405180910390f35b6103e4610922565b6040516103d391906136d8565b6104046103ff3660046136eb565b6109b4565b6040516001600160a01b0390911681526020016103d3565b61042560085481565b6040519081526020016103d3565b610446610441366004613719565b6109db565b005b6104256104563660046136eb565b610af5565b610446610469366004613745565b610b34565b61042561047c3660046136eb565b610b66565b61042561048f3660046136eb565b6000908152601060205260409020546001600160601b031690565b6104bd6104b83660046136eb565b610b9b565b6040516103d391906137cd565b600c54610404906001600160a01b031681565b6104466104eb36600461386c565b610cad565b6104466104fe3660046138d7565b610d7e565b610446610511366004613745565b610e44565b610446610524366004613922565b610e5f565b6103c7610537366004613719565b610e89565b61044661054a36600461393f565b610e9c565b61044661055d366004613961565b610fd2565b600f54610404906001600160a01b031681565b6104466105833660046136eb565b6111c8565b61044661059636600461399b565b6111fb565b61042560095481565b6104256105b23660046136eb565b611221565b600b54610404906001600160a01b031681565b61042560125481565b6104257f00000000000000000000000000000000000000000000000000000059d39e7f0f81565b6104046106083660046136eb565b61123d565b61044661061b3660046136eb565b61129d565b61042561062e366004613922565b6112fb565b610446611381565b6104256106493660046136eb565b611395565b61044661065c36600461393f565b6113fb565b6006546103c790600160b01b900460ff1681565b6006546201000090046001600160a01b0316610404565b6006546103c790600160b81b900460ff1681565b600d54610404906001600160a01b031681565b6104466106c13660046139b8565b611706565b6104466106d43660046139f9565b6117e6565b6103e461193b565b6104466106ef3660046136eb565b61194a565b600e54610404906001600160a01b031681565b610446610715366004613a4b565b611957565b6104257f0000000000000000000000000000000000000000000000056bc75e2d6310000081565b61044661074f366004613acd565b611aa6565b610767610762366004613b06565b611ab1565b6040516103d39190613b3b565b6104466107823660046136eb565b611ba5565b610446610795366004613c0a565b611c22565b6104466107a83660046138d7565b611c54565b6103e46107bb3660046136eb565b611d03565b6104256107ce3660046136eb565b611d75565b6104466107e136600461393f565b611db3565b600a54610404906001600160a01b031681565b61042560075481565b61044661081036600461399b565b612087565b61082861082336600461393f565b6120ad565b6040516103d39190613cb8565b610446610843366004613922565b612386565b6103c7610856366004613dd1565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610446610892366004613922565b6123b0565b6104466108a5366004613922565b612429565b6104466108b8366004613dff565b612453565b6104466108cb366004613922565b6125df565b60006001600160e01b031982166380ac58cd60e01b148061090157506001600160e01b03198216635b5e139f60e01b145b8061091c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b60606000805461093190613ea0565b80601f016020809104026020016040519081016040528092919081815260200182805461095d90613ea0565b80156109aa5780601f1061097f576101008083540402835291602001916109aa565b820191906000526020600020905b81548152906001019060200180831161098d57829003601f168201915b5050505050905090565b60006109bf82612609565b506000908152600460205260409020546001600160a01b031690565b60006109e68261123d565b9050806001600160a01b0316836001600160a01b031603610a585760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b0382161480610a745750610a748133610856565b610ae65760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c0000006064820152608401610a4f565b610af08383612668565b505050565b6000670de0b6b3a7640000610b2a837f00000000000000000000000000000000000000000000000000000059d39e7f0f613ef0565b61091c9190613f07565b610b3f335b826126d6565b610b5b5760405162461bcd60e51b8152600401610a4f90613f29565b610af0838383612755565b6000670de0b6b3a7640000610b2a837f0000000000000000000000000000000000000000000000056bc75e2d63100000613ef0565b6040805160808101825260008082526020820181905291810191909152606080820152600082815260106020908152604091829020825160808101845281546001600160601b038082168352600160601b82041693820193909352600160c01b90920464ffffffffff1692820192909252600182018054919291606084019190610c2490613ea0565b80601f0160208091040260200160405190810160405280929190818152602001828054610c5090613ea0565b8015610c9d5780601f10610c7257610100808354040283529160200191610c9d565b820191906000526020600020905b815481529060010190602001808311610c8057829003601f168201915b5050505050815250509050919050565b600654600160b01b900460ff16610cd65760405162461bcd60e51b8152600401610a4f90613f76565b6107d060125410610cf95760405162461bcd60e51b8152600401610a4f90613f9c565b600f546001600160a01b031663d7aada813384846040518463ffffffff1660e01b8152600401610d2b93929190613fef565b600060405180830381600087803b158015610d4557600080fd5b505af1158015610d59573d6000803e3d6000fd5b50505050610d77610d673390565b670de0b6b3a764000086866128c6565b5050505050565b610d878361123d565b6001600160a01b0316336001600160a01b031614610dd65760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b6044820152606401610a4f565b6000838152601060205260409020600101610df2828483614063565b5082610dfd8461123d565b6001600160a01b03167f200038820d751f67059d4e34d21526a659b7e2b7141ea1cfd7e1f95e1e0fca608484604051610e3792919061414b565b60405180910390a3505050565b610af083838360405180602001604052806000815250611c22565b610e67612a24565b600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000610e9583836126d6565b9392505050565b81610ea633610b39565b610ec25760405162461bcd60e51b8152600401610a4f9061415f565b610ecb83612a85565b60008381526010602052604081208054849290610ef29084906001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a546001600160a01b0316638769fd41610f2f85611221565b610f3885610b66565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b158015610f7657600080fd5b505af1158015610f8a573d6000803e3d6000fd5b5050505082610f988461123d565b6001600160a01b03167f13ea485b1d8135315e770779887880798ac429f039a7c5ca3ff5f6f99a95b58784604051610e3791815260200190565b82610fdc33610b39565b610ff85760405162461bcd60e51b8152600401610a4f9061415f565b670de0b6b3a76400008210156110205760405162461bcd60e51b8152600401610a4f906141af565b600061102b85611221565b600a549091506001600160a01b031663310ed7f0336040516001600160e01b031960e084901b168152600481019190915260248101849052604481018790526064016020604051808303816000875af115801561108c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110b091906141d9565b506110ba85612a85565b600085815260106020526040812080548592906110e19084906001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a546001600160a01b0316638769fd418261111f86610b66565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561115d57600080fd5b505af1158015611171573d6000803e3d6000fd5b505050508461117f8661123d565b6001600160a01b03167f13ea485b1d8135315e770779887880798ac429f039a7c5ca3ff5f6f99a95b587856040516111b991815260200190565b60405180910390a35050505050565b806111d233610b39565b6111ee5760405162461bcd60e51b8152600401610a4f9061415f565b6111f782612a85565b5050565b611203612a24565b60068054911515600160b81b0260ff60b81b19909216919091179055565b60006bffffffffffffffffffffffff193060601b16821761091c565b6000818152600260205260408120546001600160a01b03168061091c5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a4f565b6112a5612a24565b67016345785d8a00008111156112f65760405162461bcd60e51b81526020600482015260166024820152750a4c2e8ca40daeae6e840c4ca40787a40605c62ca62760531b6044820152606401610a4f565b600955565b60006001600160a01b0382166113655760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610a4f565b506001600160a01b031660009081526003602052604090205490565b611389612a24565b6113936000612d3e565b565b6000818152601060205260408120546001600160601b0380821691610e95918391600160601b8104909116906113d990600160c01b900464ffffffffff16426141f6565b6113e285610af5565b6113ec9190613ef0565b6113f69190614209565b612d9a565b8161140533610b39565b6114215760405162461bcd60e51b8152600401610a4f9061415f565b600061142c84611221565b9050600061143984611221565b905061144484611395565b6000858152601060205260409020546001600160601b03161461149a5760405162461bcd60e51b815260206004820152600e60248201526d4e6f742073637261707061626c6560901b6044820152606401610a4f565b600b54600854604051631310588f60e11b8152600481018590526024810184905260448101919091526001600160a01b0390911690632620b11e90606401602060405180830381865afa1580156114f5573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061151991906141d9565b6115545760405162461bcd60e51b815260206004820152600c60248201526b546f6f20666172206177617960a01b6044820152606401610a4f565b600084815260106020526040812080546001600160e81b03191681559061157e6001830182613571565b5050600a54604051631398fee160e31b8152600481018390526001600160a01b0390911690638769fd419083908390639cc7f70890602401602060405180830381865afa1580156115d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f7919061421c565b6040516001600160e01b031960e085901b16815260048101929092526024820152604401600060405180830381600087803b15801561163557600080fd5b505af1158015611649573d6000803e3d6000fd5b5050505061165684612db0565b600a54600754604051630d9778e560e11b81526004810185905260248101919091526001600160a01b0390911690631b2ef1ca90604401600060405180830381600087803b1580156116a757600080fd5b505af11580156116bb573d6000803e3d6000fd5b5050505083856116ca8761123d565b6001600160a01b03167f87c1be595bf1173580b78a0161f3e2f2a37d277fbc63f85f09d0be9bd83d210660405160405180910390a45050505050565b600654600160b81b900460ff1661172f5760405162461bcd60e51b8152600401610a4f90613f76565b6107d0601254106117525760405162461bcd60e51b8152600401610a4f90613f9c565b3360008181526011602052604090205460ff16156117a95760405162461bcd60e51b8152602060048201526014602482015273105b1c9958591e4818dbdb5b5a5cdcda5bdb995960621b6044820152606401610a4f565b6001600160a01b0381166000908152601160205260409020805460ff191660011790556117e081670de0b6b3a764000085856128c6565b50505050565b670de0b6b3a764000084101561180e5760405162461bcd60e51b8152600401610a4f906141af565b600a5433906001600160a01b03166379cc67908261182b88610b66565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b15801561187157600080fd5b505af1158015611885573d6000803e3d6000fd5b505050506000611897828787876128c6565b600a549091506001600160a01b031663310ed7f06118bb846001600160a01b031690565b6118c484611221565b6040516001600160e01b031960e085901b16815260048101929092526024820152604481018690526064016020604051808303816000875af115801561190e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061193291906141d9565b50505050505050565b60606001805461093190613ea0565b611952612a24565b600855565b600654600160b01b900460ff166119805760405162461bcd60e51b8152600401610a4f90613f76565b6107d0601254106119a35760405162461bcd60e51b8152600401610a4f90613f9c565b8281146119e45760405162461bcd60e51b815260206004820152600f60248201526e098cadccee8d040dad2e6dac2e8c6d608b1b6044820152606401610a4f565b600e546001600160a01b0316634ab4da9b338787876040518563ffffffff1660e01b8152600401611a189493929190614235565b600060405180830381600087803b158015611a3257600080fd5b505af1158015611a46573d6000803e3d6000fd5b5050505060005b83811015611a9e57611a8b33670de0b6b3a7640000858585818110611a7457611a74614262565b9050602002810190611a869190614278565b6128c6565b5080611a96816142be565b915050611a4d565b505050505050565b6111f7338383612e53565b6060816001600160401b03811115611acb57611acb613b9d565b604051908082528060200260200182016040528015611afe57816020015b6060815260200190600190039081611ae95790505b50905060005b82811015611b9e57611b6e30858584818110611b2257611b22614262565b9050602002810190611b349190614278565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250612f1992505050565b828281518110611b8057611b80614262565b60200260200101819052508080611b96906142be565b915050611b04565b5092915050565b611bad612a24565b7f0000000000000000000000000000000000000000000000056bc75e2d63100000811115611c1d5760405162461bcd60e51b815260206004820152601c60248201527f526577617264206d757374206265203c3d206275696c6420636f7374000000006044820152606401610a4f565b600755565b611c2c33836126d6565b611c485760405162461bcd60e51b8152600401610a4f90613f29565b6117e084848484612f3e565b670de0b6b3a7640000831015611c7c5760405162461bcd60e51b8152600401610a4f906141af565b600a5433906001600160a01b03166379cc679082611c9987610b66565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b158015611cdf57600080fd5b505af1158015611cf3573d6000803e3d6000fd5b50505050610d77818585856128c6565b600c5460405163295d33a960e21b8152600481018390526060916001600160a01b03169063a574cea490602401600060405180830381865afa158015611d4d573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261091c91908101906142d7565b6000670de0b6b3a7640000611d8983611395565b610b2a907f0000000000000000000000000000000000000000000000056bc75e2d63100000613ef0565b81611dbd33610b39565b611dd95760405162461bcd60e51b8152600401610a4f9061415f565b81611de333610b39565b611dff5760405162461bcd60e51b8152600401610a4f9061415f565b6000611e0a85611221565b90506000611e1785611221565b600b5460405163648414a560e01b815260048101859052602481018390529192506001600160a01b03169063648414a590604401602060405180830381865afa158015611e68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8c91906141d9565b611e9557600080fd5b611e9e86612a85565b611ea785612a85565b6000858152601060205260408082205488835290822080546001600160601b03928316939192611ed99185911661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600085815260106020526040812080546001600160e81b031916815590611f266001830182613571565b5050600a54604051631398fee160e31b8152600481018390526001600160a01b039091169063310ed7f090839085908490639cc7f70890602401602060405180830381865afa158015611f7d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fa1919061421c565b6040516001600160e01b031960e086901b1681526004810193909352602483019190915260448201526064016020604051808303816000875af1158015611fec573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061201091906141d9565b5061201a85612db0565b84866120258861123d565b6000898152601060209081526040918290205491516001600160601b0390921682526001600160a01b0392909216917fb3ce851d16b3bbec3774d5631a3893dfa2a80e067cfad265dd594402ac3d6096910160405180910390a4505050505050565b61208f612a24565b60068054911515600160b01b0260ff60b01b19909216919091179055565b6012546060908084106120c0575061091c565b60006120cc8486614209565b9050818111156120d95750805b6120e385826141f6565b6001600160401b038111156120fa576120fa613b9d565b60405190808252806020026020018201604052801561213357816020015b6121206135ab565b8152602001906001900390816121185790505b509250845b8181101561237d576040518060a0016040528082815260200161215a8361123d565b6001600160a01b039081168252600a5460209092019116639cc7f70861217f85611221565b6040518263ffffffff1660e01b815260040161219d91815260200190565b602060405180830381865afa1580156121ba573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121de919061421c565b8152600083815260106020908152604091829020825160808101845281546001600160601b038082168352600160601b82041682850152600160c01b900464ffffffffff16938101939093526001810180549290940193909160608401919061224690613ea0565b80601f016020809104026020016040519081016040528092919081815260200182805461227290613ea0565b80156122bf5780601f10612294576101008083540402835291602001916122bf565b820191906000526020600020905b8154815290600101906020018083116122a257829003601f168201915b505050919092525050508152600b546020909101906001600160a01b031663f3f9082f6122eb85611221565b6040518263ffffffff1660e01b815260040161230991815260200190565b60e060405180830381865afa158015612326573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061234a9190614370565b81525084828151811061235f5761235f614262565b60200260200101819052508080612375906142be565b915050612138565b50505092915050565b61238e612a24565b600d80546001600160a01b0319166001600160a01b0392909216919091179055565b6123b8612a24565b6001600160a01b03811661241d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610a4f565b61242681612d3e565b50565b612431612a24565b600c80546001600160a01b0319166001600160a01b0392909216919091179055565b600654610100900460ff16158080156124735750600654600160ff909116105b8061248d5750303b15801561248d575060065460ff166001145b6124f05760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610a4f565b6006805460ff191660011790558015612513576006805461ff0019166101001790555b600a80546001600160a01b03199081166001600160a01b038d811691909117909255600b805482168c8416179055600c805482168b8416179055600d805482168a8416179055600788905560088790556009869055600e80548216868416179055600f805490911691841691909117905561258d33612d3e565b80156125d3576006805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50505050505050505050565b6125e7612a24565b600b80546001600160a01b0319166001600160a01b0392909216919091179055565b6000818152600260205260409020546001600160a01b03166124265760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610a4f565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061269d8261123d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000806126e28361123d565b9050806001600160a01b0316846001600160a01b0316148061272957506001600160a01b0380821660009081526005602090815260408083209388168352929052205460ff165b8061274d5750836001600160a01b0316612742846109b4565b6001600160a01b0316145b949350505050565b826001600160a01b03166127688261123d565b6001600160a01b03161461278e5760405162461bcd60e51b8152600401610a4f90614421565b6001600160a01b0382166127f05760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a4f565b6127fd8383836001612f71565b826001600160a01b03166128108261123d565b6001600160a01b0316146128365760405162461bcd60e51b8152600401610a4f90614421565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0387811680865260038552838620805460001901905590871680865283862080546001019055868652600290945282852080549092168417909155905184937fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b60128054600091826128d7836142be565b9190505590506040518060800160405280856001600160601b0316815260200160006001600160601b031681526020014264ffffffffff16815260200184848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920182905250939094525050838152601060209081526040918290208451815492860151938601516001600160601b039182166001600160c01b031990941693909317600160601b91909416029290921764ffffffffff60c01b1916600160c01b64ffffffffff90921691909102178155606083015190915060018201906129c89082614466565b509050506129d68582613139565b80856001600160a01b03167f3b1cc5a2c97b67a501e55d3eecf8cbd09cf2cd764461e9f445ea5fd8c9020119868686604051612a1493929190614525565b60405180910390a3949350505050565b6006546001600160a01b03620100009091041633146113935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610a4f565b6000612a9082611d75565b90506000612a9d83611221565b600a54604051631398fee160e31b8152600481018390529192506000916001600160a01b0390911690639cc7f70890602401602060405180830381865afa158015612aec573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b10919061421c565b6000858152601060205260409020805464ffffffffff60c01b1916600160c01b4264ffffffffff1602179055905080831115612c6857600a54604051638769fd4160e01b815260048101849052602481018390526001600160a01b0390911690638769fd4190604401600060405180830381600087803b158015612b9357600080fd5b505af1158015612ba7573d6000803e3d6000fd5b505050507f0000000000000000000000000000000000000000000000056bc75e2d63100000670de0b6b3a76400008285612be191906141f6565b612beb9190613ef0565b612bf59190613f07565b60008581526010602052604081208054909190612c1c9084906001600160601b031661453f565b82546001600160601b039182166101009390930a928302919092021990911617905550600084815260106020526040902080546bffffffffffffffffffffffff60601b19169055612cce565b600a54604051638769fd4160e01b815260048101849052602481018590526001600160a01b0390911690638769fd4190604401600060405180830381600087803b158015612cb557600080fd5b505af1158015612cc9573d6000803e3d6000fd5b505050505b83612cd88561123d565b6000868152601060209081526040918290205482516001600160601b0390911681529081018790526001600160a01b0392909216917fbf3e5a98eab8e611f59568e4a880c8465e0ec0b73006f9ca120ff865a555d8a0910160405180910390a350505050565b600680546001600160a01b038381166201000081810262010000600160b01b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000818310612da95781610e95565b5090919050565b6000612dbb8261123d565b9050612dcb816000846001612f71565b612dd48261123d565b600083815260046020908152604080832080546001600160a01b03199081169091556001600160a01b0385168085526003845282852080546000190190558785526002909352818420805490911690555192935084927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b816001600160a01b0316836001600160a01b031603612eb45760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610a4f565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c319101610e37565b6060610e95838360405180606001604052806027815260200161461e602791396132d2565b612f49848484612755565b612f558484848461334a565b6117e05760405162461bcd60e51b8152600401610a4f9061455f565b6001600160a01b03841615801590612f9157506001600160a01b03831615155b1561312d57815b612fa28284614209565b81101561312b576000612fb482611395565b6000838152601060205260409020546001600160601b0316612fd691906141f6565b90508015613118576000670de0b6b3a764000060095483612ff79190613ef0565b6130019190613f07565b600084815260106020526040902080549192508291600c90613034908490600160601b90046001600160601b031661418f565b82546001600160601b039182166101009390930a928302919092021990911617905550600a54600d546001600160a01b03918216916340c10f199116670de0b6b3a76400006130a37f0000000000000000000000000000000000000000000000056bc75e2d6310000086613ef0565b6130ae906002613ef0565b6130b89190613f07565b6040516001600160e01b031960e085901b1681526001600160a01b0390921660048301526024820152604401600060405180830381600087803b1580156130fe57600080fd5b505af1158015613112573d6000803e3d6000fd5b50505050505b5080613123816142be565b915050612f98565b505b6117e08484848461344b565b6001600160a01b03821661318f5760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a4f565b6000818152600260205260409020546001600160a01b0316156131f45760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a4f565b613202600083836001612f71565b6000818152600260205260409020546001600160a01b0316156132675760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a4f565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b0319168417905551839291907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6060600080856001600160a01b0316856040516132ef91906145b1565b600060405180830381855af49150503d806000811461332a576040519150601f19603f3d011682016040523d82523d6000602084013e61332f565b606091505b5091509150613340868383876134d3565b9695505050505050565b60006001600160a01b0384163b1561344057604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061338e9033908990889088906004016145cd565b6020604051808303816000875af19250505080156133c9575060408051601f3d908101601f191682019092526133c691810190614600565b60015b613426573d8080156133f7576040519150601f19603f3d011682016040523d82523d6000602084013e6133fc565b606091505b50805160000361341e5760405162461bcd60e51b8152600401610a4f9061455f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061274d565b506001949350505050565b60018111156117e0576001600160a01b03841615613491576001600160a01b0384166000908152600360205260408120805483929061348b9084906141f6565b90915550505b6001600160a01b038316156117e0576001600160a01b038316600090815260036020526040812080548392906134c8908490614209565b909155505050505050565b6060831561354257825160000361353b576001600160a01b0385163b61353b5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610a4f565b508161274d565b61274d83838151156135575781518083602001fd5b8060405162461bcd60e51b8152600401610a4f91906136d8565b50805461357d90613ea0565b6000825580601f1061358d575050565b601f016020900490600052602060002090810190612426919061363c565b6040518060a001604052806000815260200160006001600160a01b03168152602001600081526020016135fd604080516080810182526000808252602082018190529181019190915260608082015290565b81526040805160e08101825260008082526020828101829052928201819052606082018190526080820181905260a0820181905260c082015291015290565b5b80821115613651576000815560010161363d565b5090565b6001600160e01b03198116811461242657600080fd5b60006020828403121561367d57600080fd5b8135610e9581613655565b60005b838110156136a357818101518382015260200161368b565b50506000910152565b600081518084526136c4816020860160208601613688565b601f01601f19169290920160200192915050565b602081526000610e9560208301846136ac565b6000602082840312156136fd57600080fd5b5035919050565b6001600160a01b038116811461242657600080fd5b6000806040838503121561372c57600080fd5b823561373781613704565b946020939093013593505050565b60008060006060848603121561375a57600080fd5b833561376581613704565b9250602084013561377581613704565b929592945050506040919091013590565b60006001600160601b038083511684528060208401511660208501525064ffffffffff604083015116604084015260608201516080606085015261274d60808501826136ac565b602081526000610e956020830184613786565b60008083601f8401126137f257600080fd5b5081356001600160401b0381111561380957600080fd5b60208301915083602082850101111561382157600080fd5b9250929050565b60008083601f84011261383a57600080fd5b5081356001600160401b0381111561385157600080fd5b6020830191508360208260051b850101111561382157600080fd5b6000806000806040858703121561388257600080fd5b84356001600160401b038082111561389957600080fd5b6138a5888389016137e0565b909650945060208701359150808211156138be57600080fd5b506138cb87828801613828565b95989497509550505050565b6000806000604084860312156138ec57600080fd5b8335925060208401356001600160401b0381111561390957600080fd5b613915868287016137e0565b9497909650939450505050565b60006020828403121561393457600080fd5b8135610e9581613704565b6000806040838503121561395257600080fd5b50508035926020909101359150565b60008060006060848603121561397657600080fd5b505081359360208301359350604090920135919050565b801515811461242657600080fd5b6000602082840312156139ad57600080fd5b8135610e958161398d565b600080602083850312156139cb57600080fd5b82356001600160401b038111156139e157600080fd5b6139ed858286016137e0565b90969095509350505050565b60008060008060608587031215613a0f57600080fd5b8435935060208501356001600160401b03811115613a2c57600080fd5b613a38878288016137e0565b9598909750949560400135949350505050565b600080600080600060608688031215613a6357600080fd5b8535613a6e81613704565b945060208601356001600160401b0380821115613a8a57600080fd5b613a9689838a01613828565b90965094506040880135915080821115613aaf57600080fd5b50613abc88828901613828565b969995985093965092949392505050565b60008060408385031215613ae057600080fd5b8235613aeb81613704565b91506020830135613afb8161398d565b809150509250929050565b60008060208385031215613b1957600080fd5b82356001600160401b03811115613b2f57600080fd5b6139ed85828601613828565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b82811015613b9057603f19888603018452613b7e8583516136ac565b94509285019290850190600101613b62565b5092979650505050505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613bdb57613bdb613b9d565b604052919050565b60006001600160401b03821115613bfc57613bfc613b9d565b50601f01601f191660200190565b60008060008060808587031215613c2057600080fd5b8435613c2b81613704565b93506020850135613c3b81613704565b92506040850135915060608501356001600160401b03811115613c5d57600080fd5b8501601f81018713613c6e57600080fd5b8035613c81613c7c82613be3565b613bb3565b818152886020838501011115613c9657600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b60006020808301818452808551808352604092508286019150828160051b87010184880160005b83811015613dc357888303603f19018552815180518452878101516001600160a01b03168885015286810151878501526060808201516101608287018190529190613d2c83880182613786565b92505060808084015193508351600481810b838a01528c860151915060a082820b818b01528c870151925060c083830b818c015285880151830b60e08c015264ffffffffff85890151166101008c0152818801519550613d966101208c018764ffffffffff169052565b96909601518015156101408b01529550613db09350505050565b9588019593505090860190600101613cdf565b509098975050505050505050565b60008060408385031215613de457600080fd5b8235613def81613704565b91506020830135613afb81613704565b60008060008060008060008060006101208a8c031215613e1e57600080fd5b8935613e2981613704565b985060208a0135613e3981613704565b975060408a0135613e4981613704565b965060608a0135613e5981613704565b955060808a0135945060a08a0135935060c08a0135925060e08a0135613e7e81613704565b91506101008a0135613e8f81613704565b809150509295985092959850929598565b600181811c90821680613eb457607f821691505b602082108103613ed457634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b808202811582820484141761091c5761091c613eda565b600082613f2457634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b6020808252600c908201526b139bdd081bdc195b881e595d60a21b604082015260600190565b6020808252600790820152664e6f206d6f726560c81b604082015260600190565b81835260006001600160fb1b03831115613fd657600080fd5b8260051b80836020870137939093016020019392505050565b6001600160a01b03841681526040602082018190526000906140149083018486613fbd565b95945050505050565b601f821115610af057600081815260208120601f850160051c810160208610156140445750805b601f850160051c820191505b81811015611a9e57828155600101614050565b6001600160401b0383111561407a5761407a613b9d565b61408e836140888354613ea0565b8361401d565b6000601f8411600181146140c257600085156140aa5750838201355b600019600387901b1c1916600186901b178355610d77565b600083815260209020601f19861690835b828110156140f357868501358255602094850194600190920191016140d3565b50868210156141105760001960f88860031b161c19848701351681555b505060018560011b0183555050505050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60208152600061274d602083018486614122565b60208082526016908201527527b7363c9030b8383937bb32b21037b91037bbb732b960511b604082015260600190565b6001600160601b03818116838216019080821115611b9e57611b9e613eda565b60208082526010908201526f2632b9b9903a3430b710189039b834b760811b604082015260600190565b6000602082840312156141eb57600080fd5b8151610e958161398d565b8181038181111561091c5761091c613eda565b8082018082111561091c5761091c613eda565b60006020828403121561422e57600080fd5b5051919050565b6001600160a01b038581168252841660208201526060604082018190526000906133409083018486613fbd565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261428f57600080fd5b8301803591506001600160401b038211156142a957600080fd5b60200191503681900382131561382157600080fd5b6000600182016142d0576142d0613eda565b5060010190565b6000602082840312156142e957600080fd5b81516001600160401b038111156142ff57600080fd5b8201601f8101841361431057600080fd5b805161431e613c7c82613be3565b81815285602083850101111561433357600080fd5b614014826020830160208601613688565b8051600481900b811461435657600080fd5b919050565b805164ffffffffff8116811461435657600080fd5b600060e0828403121561438257600080fd5b60405160e081018181106001600160401b03821117156143a4576143a4613b9d565b6040526143b083614344565b81526143be60208401614344565b60208201526143cf60408401614344565b60408201526143e060608401614344565b60608201526143f16080840161435b565b608082015261440260a0840161435b565b60a082015260c08301516144158161398d565b60c08201529392505050565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b81516001600160401b0381111561447f5761447f613b9d565b6144938161448d8454613ea0565b8461401d565b602080601f8311600181146144c857600084156144b05750858301515b600019600386901b1c1916600185901b178555611a9e565b600085815260208120601f198616915b828110156144f7578886015182559484019460019091019084016144d8565b50858210156145155787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b838152604060208201526000614014604083018486614122565b6001600160601b03828116828216039080821115611b9e57611b9e613eda565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b600082516145c3818460208701613688565b9190910192915050565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613340908301846136ac565b60006020828403121561461257600080fd5b8151610e958161365556fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220497d977758a183f7d538f7633079b9a7444ce7b787a3362fd5472b05246a34e564736f6c63430008110033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000000000000000000000000000000000000000278d00
-----Decoded View---------------
Arg [0] : buildCost_ (uint256): 100000000000000000000
Arg [1] : unitDecayInterval (uint256): 2592000
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000056bc75e2d63100000
Arg [1] : 0000000000000000000000000000000000000000000000000000000000278d00
Loading...
Loading
Loading...
Loading
OVERVIEW
Build ships, mine $Butter. Miaocraft is an on-chain space mining PvP.Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.