Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00| Transaction Hash |
Method
|
Block
|
From
|
|
To
|
||||
|---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
| Parent Transaction Hash | Method | Block |
From
|
|
To
|
||
|---|---|---|---|---|---|---|---|
| 0x60806040 | 23932604 | 2 hrs ago | Contract Creation | 0 ETH |
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
GenAiNftFactoryFacet
Compiler Version
v0.8.23+commit.f704f362
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import { AccessControlInternal } from "@solidstate/contracts/access/access_control/AccessControlInternal.sol";
import { LibGenAiNftFactoryStorage } from "../libraries/LibGenAiNftFactoryStorage.sol";
import { IGenAiNftFactory } from "../interfaces/IGenAiNftFactory.sol";
import { TokenFiGenAiNft } from "../TokenFiGenAiNft.sol";
import { EnumerableSet } from "@solidstate/contracts/data/EnumerableSet.sol";
import { Create2Deployer } from "../libraries/Create2Deployer.sol";
/**
* @title GenAiNftFactoryFacet
* @dev Factory facet for deploying TokenFiGenAiNft instances
*/
contract GenAiNftFactoryFacet is IGenAiNftFactory, AccessControlInternal {
using EnumerableSet for EnumerableSet.AddressSet;
/**
* @dev Internal helper to get bytecode for TokenFiGenAiNft deployment
*/
function _getNftBytecode(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_
) private view returns (bytes memory) {
return abi.encodePacked(type(TokenFiGenAiNft).creationCode, abi.encode(name_, symbol_, baseURI_, maxSupply_, adminAddress_, address(this)));
}
/**
* @dev Internal function to deploy a new TokenFiGenAiNft instance
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @param deployer_ The address of the deployer (msg.sender)
* @return The address of the newly deployed NFT contract
*/
function _deployNftInternal(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address deployer_
) internal returns (address) {
require(adminAddress_ != address(0), "Invalid admin address");
require(bytes(name_).length > 0, "Name cannot be empty");
require(bytes(symbol_).length > 0, "Symbol cannot be empty");
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
// Get and increment the nonce for this deployer to prevent salt collisions
uint256 nonce = ds.deployerNonces[deployer_];
ds.deployerNonces[deployer_] = nonce + 1;
// Deploy using CREATE2 for deterministic address
// Salt is computed from deployer address and nonce to allow multiple deployments per user
address nftAddress = Create2Deployer.deploy(_getNftBytecode(name_, symbol_, baseURI_, maxSupply_, adminAddress_), deployer_, nonce);
// Verify the contract was deployed successfully
require(nftAddress != address(0), "Deployment failed");
// Store the deployed NFT address
ds.deployedNfts.add(nftAddress);
ds.nftsByDeployer[deployer_].add(nftAddress);
emit NftDeployed(ds.nftDeployedLastBlock, nftAddress, name_, symbol_, baseURI_, maxSupply_, adminAddress_, deployer_);
ds.nftDeployedLastBlock = block.number;
return nftAddress;
}
/**
* @dev Deploy a new TokenFiGenAiNft instance
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @return The address of the newly deployed NFT contract
*/
function deployNft(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_
) external override returns (address) {
return _deployNftInternal(name_, symbol_, baseURI_, maxSupply_, adminAddress_, msg.sender);
}
/**
* @dev Deploy a new TokenFiGenAiNft instance with msg.sender as admin
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @return The address of the newly deployed NFT contract
*/
function deployNftWithSenderAsAdmin(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_
) external override returns (address) {
return _deployNftInternal(name_, symbol_, baseURI_, maxSupply_, msg.sender, msg.sender);
}
/**
* @dev Batch deploy multiple NFT contracts
* @param names_ Array of names for the NFT collections
* @param symbols_ Array of symbols for the NFT collections
* @param baseURIs_ Array of base URIs for token metadata
* @param maxSupplies_ Array of maximum supplies (0 for unlimited)
* @param adminAddresses_ Array of admin addresses for the deployed NFT contracts
* @return An array of addresses of the newly deployed NFT contracts
*/
function batchDeployNft(
string[] memory names_,
string[] memory symbols_,
string[] memory baseURIs_,
uint256[] memory maxSupplies_,
address[] memory adminAddresses_
) external override returns (address[] memory) {
require(names_.length > 0, "Empty arrays");
require(
names_.length == symbols_.length &&
names_.length == baseURIs_.length &&
names_.length == maxSupplies_.length &&
names_.length == adminAddresses_.length,
"Array length mismatch"
);
address[] memory deployedNfts = new address[](names_.length);
for (uint256 i = 0; i < names_.length; i++) {
deployedNfts[i] = _deployNftInternal(names_[i], symbols_[i], baseURIs_[i], maxSupplies_[i], adminAddresses_[i], msg.sender);
}
return deployedNfts;
}
/**
* @dev Get deployed NFT contracts with pagination
* @param offset The starting index
* @param limit The maximum number of items to return (0 for all remaining)
* @return A PaginatedNfts struct containing NFT addresses and pagination details
*/
function getDeployedNfts(uint256 offset, uint256 limit) external view override returns (IGenAiNftFactory.PaginatedNfts memory) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
uint256 totalLength = ds.deployedNfts.length();
// Return empty result if offset is out of bounds
if (offset >= totalLength && totalLength > 0) {
return
IGenAiNftFactory.PaginatedNfts({
nfts: new address[](0),
totalCount: totalLength,
currentPage: 0,
totalPages: limit > 0 ? (totalLength + limit - 1) / limit : 1,
offset: offset,
limit: limit
});
}
// Calculate the actual number of items to return
uint256 remaining = totalLength > offset ? totalLength - offset : 0;
uint256 count = (limit == 0 || limit > remaining) ? remaining : limit;
// Create result array and populate it
address[] memory result = new address[](count);
for (uint256 i = 0; i < count; i++) {
result[i] = ds.deployedNfts.at(offset + i);
}
// Calculate pagination details
uint256 currentPage = limit > 0 ? (offset / limit) + 1 : 1;
uint256 totalPages = limit > 0 ? (totalLength + limit - 1) / limit : 1;
return
IGenAiNftFactory.PaginatedNfts({
nfts: result,
totalCount: totalLength,
currentPage: currentPage,
totalPages: totalPages,
offset: offset,
limit: limit
});
}
/**
* @dev Get the number of deployed NFT contracts
* @return The count of deployed NFT contracts
*/
function getDeployedNftsCount() external view override returns (uint256) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
return ds.deployedNfts.length();
}
/**
* @dev Get a deployed NFT contract by index
* @param index The index of the deployed NFT contract
* @return The address of the deployed NFT contract
*/
function getDeployedNftByIndex(uint256 index) external view override returns (address) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
require(index < ds.deployedNfts.length(), "Index out of bounds");
return ds.deployedNfts.at(index);
}
/**
* @dev Get all NFTs deployed by a specific user
* @param deployer The address of the deployer
* @return An array of addresses of NFTs deployed by the user
*/
function getNftsByDeployer(address deployer) external view override returns (address[] memory) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
uint256 length = ds.nftsByDeployer[deployer].length();
address[] memory result = new address[](length);
for (uint256 i = 0; i < length; i++) {
result[i] = ds.nftsByDeployer[deployer].at(i);
}
return result;
}
/**
* @dev Get the number of NFTs deployed by a specific user
* @param deployer The address of the deployer
* @return The count of NFTs deployed by the user
*/
function getNftsCountByDeployer(address deployer) external view override returns (uint256) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
return ds.nftsByDeployer[deployer].length();
}
/**
* @dev Get the last block numbers for various operations
* @return A LastBlockInfo struct containing the last block numbers
*/
function getLastBlockInfo() external view override returns (IGenAiNftFactory.LastBlockInfo memory) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
return IGenAiNftFactory.LastBlockInfo({ nftDeployedLastBlock: ds.nftDeployedLastBlock, nftMintedLastBlock: ds.nftMintedLastBlock });
}
/**
* @dev Predict the address where an NFT will be deployed using CREATE2
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @param deployer_ The address of the deployer
* @return The predicted address where the NFT will be deployed
*/
function predictNftAddress(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address deployer_
) external view override returns (address) {
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
// Get the current nonce for this deployer (will be used for the next deployment)
uint256 nonce = ds.deployerNonces[deployer_];
// Get the bytecode and compute CREATE2 address
// Salt is computed from deployer address and nonce to allow multiple deployments per user
bytes memory bytecode = _getNftBytecode(name_, symbol_, baseURI_, maxSupply_, adminAddress_);
return Create2Deployer.computeAddress(address(this), deployer_, nonce, keccak256(bytecode));
}
/**
* @dev Predict the address where an NFT will be deployed using CREATE2 with a specific nonce
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @param deployer_ The address of the deployer
* @param nonce_ The nonce to use for the prediction
* @return The predicted address where the NFT will be deployed
*/
function predictNftAddressWithNonce(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address deployer_,
uint256 nonce_
) external view override returns (address) {
// Get the bytecode and compute CREATE2 address with the specified nonce
bytes memory bytecode = _getNftBytecode(name_, symbol_, baseURI_, maxSupply_, adminAddress_);
return Create2Deployer.computeAddress(address(this), deployer_, nonce_, keccak256(bytecode));
}
/**
* @dev Called by deployed NFT contracts to emit mint events on the diamond
* @param to The address receiving the NFT
* @param tokenId The token ID that was minted
* @param tokenURI The token URI (empty string if using base URI)
*/
function emitNftMintEvent(address to, uint256 tokenId, string memory tokenURI) external override {
address nftAddress = msg.sender;
LibGenAiNftFactoryStorage.DiamondStorage storage ds = LibGenAiNftFactoryStorage.diamondStorage();
// Verify that the caller is a deployed NFT contract
require(ds.deployedNfts.contains(nftAddress), "Invalid NFT address");
emit NftMinted(ds.nftMintedLastBlock, nftAddress, to, tokenId, tokenURI);
ds.nftMintedLastBlock = block.number;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(account),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* May emit a {RoleGranted} event.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Grants `role` to `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 {}
/**
* @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 {}
/**
* @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override.
*
* WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant
* being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such
* that `ownerOf(tokenId)` is `a`.
*/
// solhint-disable-next-line func-name-mixedcase
function __unsafe_increaseBalance(address account, uint256 amount) internal {
_balances[account] += amount;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.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 (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
import "./IERC721Enumerable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev See {ERC721-_beforeTokenTransfer}.
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
if (batchSize > 1) {
// Will only trigger during construction. Batch transferring (minting) is not available afterwards.
revert("ERC721Enumerable: consecutive transfers not supported");
}
uint256 tokenId = firstTokenId;
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}// 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.9.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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/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 (last updated v4.9.4) (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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
import "./math/Math.sol";
import "./math/SignedMath.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 `int256` to its ASCII `string` decimal representation.
*/
function toString(int256 value) internal pure returns (string memory) {
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
}
/**
* @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);
}
/**
* @dev Returns true if the two strings are equal.
*/
function equal(string memory a, string memory b) internal pure returns (bool) {
return keccak256(bytes(a)) == keccak256(bytes(b));
}
}// 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.9.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) {
// Solidity will revert if denominator == 0, unlike the div opcode on its own.
// The surrounding unchecked block does not change this fact.
// See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
return prod0 / denominator;
}
// Make sure the result is less than 2^256. Also prevents denominator == 0.
require(denominator > prod1, "Math: mulDiv overflow");
///////////////////////////////////////////////
// 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 256, 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 << 3) < 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;
import { EnumerableSet } from '../../data/EnumerableSet.sol';
import { AddressUtils } from '../../utils/AddressUtils.sol';
import { UintUtils } from '../../utils/UintUtils.sol';
import { IAccessControlInternal } from './IAccessControlInternal.sol';
import { AccessControlStorage } from './AccessControlStorage.sol';
/**
* @title Role-based access control system
* @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)
*/
abstract contract AccessControlInternal is IAccessControlInternal {
using AddressUtils for address;
using EnumerableSet for EnumerableSet.AddressSet;
using UintUtils for uint256;
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/*
* @notice query whether role is assigned to account
* @param role role to query
* @param account account to query
* @return whether role is assigned to account
*/
function _hasRole(
bytes32 role,
address account
) internal view virtual returns (bool) {
return
AccessControlStorage.layout().roles[role].members.contains(account);
}
/**
* @notice revert if sender does not have given role
* @param role role to query
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, msg.sender);
}
/**
* @notice revert if given account does not have given role
* @param role role to query
* @param account to query
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!_hasRole(role, account)) {
revert(
string(
abi.encodePacked(
'AccessControl: account ',
account.toString(),
' is missing role ',
uint256(role).toHexString(32)
)
)
);
}
}
/*
* @notice query admin role for given role
* @param role role to query
* @return admin role
*/
function _getRoleAdmin(
bytes32 role
) internal view virtual returns (bytes32) {
return AccessControlStorage.layout().roles[role].adminRole;
}
/**
* @notice set role as admin role
* @param role role to set
* @param adminRole admin role to set
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = _getRoleAdmin(role);
AccessControlStorage.layout().roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/*
* @notice assign role to given account
* @param role role to assign
* @param account recipient of role assignment
*/
function _grantRole(bytes32 role, address account) internal virtual {
AccessControlStorage.layout().roles[role].members.add(account);
emit RoleGranted(role, account, msg.sender);
}
/*
* @notice unassign role from given account
* @param role role to unassign
* @parm account
*/
function _revokeRole(bytes32 role, address account) internal virtual {
AccessControlStorage.layout().roles[role].members.remove(account);
emit RoleRevoked(role, account, msg.sender);
}
/**
* @notice relinquish role
* @param role role to relinquish
*/
function _renounceRole(bytes32 role) internal virtual {
_revokeRole(role, msg.sender);
}
/**
* @notice query role for member at given index
* @param role role to query
* @param index index to query
*/
function _getRoleMember(
bytes32 role,
uint256 index
) internal view virtual returns (address) {
return AccessControlStorage.layout().roles[role].members.at(index);
}
/**
* @notice query role for member count
* @param role role to query
*/
function _getRoleMemberCount(
bytes32 role
) internal view virtual returns (uint256) {
return AccessControlStorage.layout().roles[role].members.length();
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import { EnumerableSet } from '../../data/EnumerableSet.sol';
library AccessControlStorage {
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
struct Layout {
mapping(bytes32 => RoleData) roles;
}
bytes32 internal constant DEFAULT_ADMIN_ROLE = 0x00;
bytes32 internal constant STORAGE_SLOT =
keccak256('solidstate.contracts.storage.AccessControl');
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Partial AccessControl interface needed by internal functions
*/
interface IAccessControlInternal {
event RoleAdminChanged(
bytes32 indexed role,
bytes32 indexed previousAdminRole,
bytes32 indexed newAdminRole
);
event RoleGranted(
bytes32 indexed role,
address indexed account,
address indexed sender
);
event RoleRevoked(
bytes32 indexed role,
address indexed account,
address indexed sender
);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
/**
* @title Set implementation with enumeration functions
* @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts (MIT license)
*/
library EnumerableSet {
error EnumerableSet__IndexOutOfBounds();
struct Set {
bytes32[] _values;
// 1-indexed to allow 0 to signify nonexistence
mapping(bytes32 => uint256) _indexes;
}
struct Bytes32Set {
Set _inner;
}
struct AddressSet {
Set _inner;
}
struct UintSet {
Set _inner;
}
function at(
Bytes32Set storage set,
uint256 index
) internal view returns (bytes32) {
return _at(set._inner, index);
}
function at(
AddressSet storage set,
uint256 index
) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
function at(
UintSet storage set,
uint256 index
) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
function contains(
Bytes32Set storage set,
bytes32 value
) internal view returns (bool) {
return _contains(set._inner, value);
}
function contains(
AddressSet storage set,
address value
) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
function contains(
UintSet storage set,
uint256 value
) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function indexOf(
Bytes32Set storage set,
bytes32 value
) internal view returns (uint256) {
return _indexOf(set._inner, value);
}
function indexOf(
AddressSet storage set,
address value
) internal view returns (uint256) {
return _indexOf(set._inner, bytes32(uint256(uint160(value))));
}
function indexOf(
UintSet storage set,
uint256 value
) internal view returns (uint256) {
return _indexOf(set._inner, bytes32(value));
}
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function add(
Bytes32Set storage set,
bytes32 value
) internal returns (bool) {
return _add(set._inner, value);
}
function add(
AddressSet storage set,
address value
) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(
Bytes32Set storage set,
bytes32 value
) internal returns (bool) {
return _remove(set._inner, value);
}
function remove(
AddressSet storage set,
address value
) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
function remove(
UintSet storage set,
uint256 value
) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function toArray(
Bytes32Set storage set
) internal view returns (bytes32[] memory) {
return set._inner._values;
}
function toArray(
AddressSet storage set
) internal view returns (address[] memory) {
bytes32[] storage values = set._inner._values;
address[] storage array;
assembly {
array.slot := values.slot
}
return array;
}
function toArray(
UintSet storage set
) internal view returns (uint256[] memory) {
bytes32[] storage values = set._inner._values;
uint256[] storage array;
assembly {
array.slot := values.slot
}
return array;
}
function _at(
Set storage set,
uint256 index
) private view returns (bytes32) {
if (index >= set._values.length)
revert EnumerableSet__IndexOutOfBounds();
return set._values[index];
}
function _contains(
Set storage set,
bytes32 value
) private view returns (bool) {
return set._indexes[value] != 0;
}
function _indexOf(
Set storage set,
bytes32 value
) private view returns (uint256) {
unchecked {
return set._indexes[value] - 1;
}
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _add(
Set storage set,
bytes32 value
) private returns (bool status) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
status = true;
}
}
function _remove(
Set storage set,
bytes32 value
) private returns (bool status) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
unchecked {
bytes32 last = set._values[set._values.length - 1];
// move last value to now-vacant index
set._values[valueIndex - 1] = last;
set._indexes[last] = valueIndex;
}
// clear last index
set._values.pop();
delete set._indexes[value];
status = true;
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
import { UintUtils } from './UintUtils.sol';
library AddressUtils {
using UintUtils for uint256;
error AddressUtils__InsufficientBalance();
error AddressUtils__NotContract();
error AddressUtils__SendValueFailed();
function toString(address account) internal pure returns (string memory) {
return uint256(uint160(account)).toHexString(20);
}
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
function sendValue(address payable account, uint256 amount) internal {
(bool success, ) = account.call{ value: amount }('');
if (!success) revert AddressUtils__SendValueFailed();
}
function functionCall(
address target,
bytes memory data
) internal returns (bytes memory) {
return
functionCall(target, data, 'AddressUtils: failed low-level call');
}
function functionCall(
address target,
bytes memory data,
string memory error
) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, error);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return
functionCallWithValue(
target,
data,
value,
'AddressUtils: failed low-level call with value'
);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory error
) internal returns (bytes memory) {
if (value > address(this).balance)
revert AddressUtils__InsufficientBalance();
return _functionCallWithValue(target, data, value, error);
}
/**
* @notice execute arbitrary external call with limited gas usage and amount of copied return data
* @dev derived from https://github.com/nomad-xyz/ExcessivelySafeCall (MIT License)
* @param target recipient of call
* @param gasAmount gas allowance for call
* @param value native token value to include in call
* @param maxCopy maximum number of bytes to copy from return data
* @param data encoded call data
* @return success whether call is successful
* @return returnData copied return data
*/
function excessivelySafeCall(
address target,
uint256 gasAmount,
uint256 value,
uint16 maxCopy,
bytes memory data
) internal returns (bool success, bytes memory returnData) {
returnData = new bytes(maxCopy);
assembly {
// execute external call via assembly to avoid automatic copying of return data
success := call(
gasAmount,
target,
value,
add(data, 0x20),
mload(data),
0,
0
)
// determine whether to limit amount of data to copy
let toCopy := returndatasize()
if gt(toCopy, maxCopy) {
toCopy := maxCopy
}
// store the length of the copied bytes
mstore(returnData, toCopy)
// copy the bytes from returndata[0:toCopy]
returndatacopy(add(returnData, 0x20), 0, toCopy)
}
}
function _functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory error
) private returns (bytes memory) {
if (!isContract(target)) revert AddressUtils__NotContract();
(bool success, bytes memory returnData) = target.call{ value: value }(
data
);
if (success) {
return returnData;
} else if (returnData.length > 0) {
assembly {
let returnData_size := mload(returnData)
revert(add(32, returnData), returnData_size)
}
} else {
revert(error);
}
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.8;
/**
* @title utility functions for uint256 operations
* @dev derived from https://github.com/OpenZeppelin/openzeppelin-contracts/ (MIT license)
*/
library UintUtils {
error UintUtils__InsufficientHexLength();
bytes16 private constant HEX_SYMBOLS = '0123456789abcdef';
function add(uint256 a, int256 b) internal pure returns (uint256) {
return b < 0 ? sub(a, -b) : a + uint256(b);
}
function sub(uint256 a, int256 b) internal pure returns (uint256) {
return b < 0 ? add(a, -b) : a - uint256(b);
}
function toString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return '0';
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return '0x00';
}
uint256 length = 0;
for (uint256 temp = value; temp != 0; temp >>= 8) {
unchecked {
length++;
}
}
return toHexString(value, 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';
unchecked {
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
}
if (value != 0) revert UintUtils__InsufficientHexLength();
return string(buffer);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { ERC721Enumerable } from "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import { AccessControl } from "@openzeppelin/contracts/access/AccessControl.sol";
import { ReentrancyGuard } from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import { GenerativeAiNftLogic } from "./libraries/GenerativeAiNftLogic.sol";
import { IGenAiNftFactory } from "./interfaces/IGenAiNftFactory.sol";
/**
* @title TokenFiGenAiNft
* @dev Non-upgradeable NFT contract deployed by the GenAiNftFactory diamond
*/
contract TokenFiGenAiNft is ERC721, ERC721Enumerable, AccessControl, ReentrancyGuard {
using GenerativeAiNftLogic for *;
string internal _baseURIStorage;
mapping(uint256 => string) private _tokenURIs;
uint256 public maxSupply;
address public immutable diamondAddress;
// Public mint settings
bool public publicMintEnabled;
uint256 public mintPrice; // Price in wei (native currency)
uint256 public publicMintLastBlock;
uint256 public publicBatchMintLastBlock;
event PublicMintToggled(bool enabled);
event MintPriceUpdated(uint256 newPrice);
event PublicMint(uint256 previousBlock, address indexed to, uint256 indexed tokenId, uint256 price);
event PublicBatchMint(uint256 previousBlock, address indexed to, uint256 quantity, uint256 totalPrice);
event RefundSent(address indexed to, uint256 amount);
event Withdrawn(address indexed recipient, uint256 amount);
constructor(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address diamondAddress_
) ERC721(name_, symbol_) {
require(adminAddress_ != address(0), "Invalid admin address");
require(diamondAddress_ != address(0), "Invalid diamond address");
_baseURIStorage = baseURI_;
maxSupply = maxSupply_;
publicMintEnabled = false; // Disabled by default
mintPrice = 0; // Free by default
diamondAddress = diamondAddress_;
_grantRole(DEFAULT_ADMIN_ROLE, adminAddress_);
}
function mint(address account, string memory tokenURI_) external onlyRole(DEFAULT_ADMIN_ROLE) {
_mintToken(account, tokenURI_);
}
function mint(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
_mintToken(account, "");
}
function batchMintWithURIs(address account, string[] memory tokenURIs) external onlyRole(DEFAULT_ADMIN_ROLE) {
GenerativeAiNftLogic.validateBatchMint(tokenURIs, totalSupply(), maxSupply);
for (uint256 i = 0; i < tokenURIs.length; i++) {
_mintToken(account, tokenURIs[i]);
}
}
function _mintToken(address account, string memory tokenURI_) internal {
GenerativeAiNftLogic.validateMint(totalSupply(), maxSupply);
uint256 newTokenId = totalSupply() + 1; // Token IDs start from 1
_mint(account, newTokenId);
// Only set custom URI if provided
if (bytes(tokenURI_).length > 0) {
_tokenURIs[newTokenId] = tokenURI_;
}
IGenAiNftFactory(diamondAddress).emitNftMintEvent(account, newTokenId, tokenURI_);
}
/**
* @dev Internal function to collect payment and refund overpayment
* @param quantity Number of tokens being minted
* @return actualCost The actual cost paid (before refund)
*/
function _collectPayment(uint256 quantity) internal returns (uint256 actualCost) {
actualCost = GenerativeAiNftLogic.collectPayment(mintPrice, quantity);
// Emit refund event if overpayment occurred
uint256 overpayment = msg.value - actualCost;
if (overpayment > 0) {
emit RefundSent(msg.sender, overpayment);
}
}
/**
* @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 override returns (string memory) {
return _baseURIStorage;
}
/**
* @dev Returns the base URI
*/
function baseURI() public view returns (string memory) {
return _baseURIStorage;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireMinted(tokenId);
return bytes(_tokenURIs[tokenId]).length > 0 ? _tokenURIs[tokenId] : super.tokenURI(tokenId);
}
/**
* @dev Public mint function that can be called by anyone when enabled
*/
function publicMint(string memory tokenURI_) external payable nonReentrant {
require(publicMintEnabled, "Public mint is disabled");
uint256 actualCost = _collectPayment(1);
_mintToken(msg.sender, tokenURI_);
emit PublicMint(publicMintLastBlock, msg.sender, totalSupply(), actualCost);
publicMintLastBlock = block.number;
}
/**
* @dev Public batch mint function that allows minting multiple NFTs at once
* Follows Checks-Effects-Interactions: collect payment before minting to prevent reentrancy
*/
function publicBatchMint(string[] memory tokenURIs) external payable nonReentrant {
GenerativeAiNftLogic.validatePublicBatchMint(publicMintEnabled, tokenURIs, totalSupply(), maxSupply);
uint256 actualCost = _collectPayment(tokenURIs.length);
for (uint256 i = 0; i < tokenURIs.length; i++) {
_mintToken(msg.sender, tokenURIs[i]);
}
emit PublicBatchMint(publicBatchMintLastBlock, msg.sender, tokenURIs.length, actualCost);
publicBatchMintLastBlock = block.number;
}
/**
* @dev Enable or disable public minting
*/
function setPublicMintEnabled(bool enabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
publicMintEnabled = enabled;
emit PublicMintToggled(enabled);
}
/**
* @dev Set the price for public minting (in wei)
*/
function setMintPrice(uint256 price) external onlyRole(DEFAULT_ADMIN_ROLE) {
mintPrice = price;
emit MintPriceUpdated(price);
}
/**
* @dev Withdraw contract balance to admin
*/
function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 balance = address(this).balance;
GenerativeAiNftLogic.withdraw(payable(msg.sender), balance);
emit Withdrawn(msg.sender, balance);
}
/**
* @dev Withdraw specific amount to a specific address
*/
function withdrawTo(address payable recipient, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
GenerativeAiNftLogic.withdrawTo(recipient, amount, address(this).balance);
emit Withdrawn(recipient, amount);
}
function setBaseURI(string memory newBaseURI) external onlyRole(DEFAULT_ADMIN_ROLE) {
_baseURIStorage = newBaseURI;
}
/**
* @dev Returns all token IDs owned by a specific address
* @param owner The address to query
* @return An array of token IDs owned by the address
*/
function tokensOfOwner(address owner) external view returns (uint256[] memory) {
uint256 tokenCount = balanceOf(owner);
uint256[] memory tokenIds = new uint256[](tokenCount);
for (uint256 i = 0; i < tokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(owner, i);
}
return tokenIds;
}
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable, AccessControl) returns (bool) {
return ERC721Enumerable.supportsInterface(interfaceId) || AccessControl.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual override(ERC721, ERC721Enumerable) {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
interface IGenAiNftFactory {
struct PaginatedNfts {
address[] nfts;
uint256 totalCount;
uint256 currentPage;
uint256 totalPages;
uint256 offset;
uint256 limit;
}
event NftDeployed(
uint256 previousBlock,
address indexed nftAddress,
string name,
string symbol,
string baseURI,
uint256 maxSupply,
address indexed adminAddress,
address indexed deployer
);
event NftMinted(uint256 previousBlock, address indexed nftAddress, address indexed to, uint256 indexed tokenId, string tokenURI);
/**
* @dev Called by deployed NFT contracts to emit mint events on the diamond
* @param to The address receiving the NFT
* @param tokenId The token ID that was minted
* @param tokenURI The token URI (empty string if using base URI)
*/
function emitNftMintEvent(address to, uint256 tokenId, string memory tokenURI) external;
/**
* @dev Deploy a new NFT contract
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @return The address of the newly deployed NFT contract
*/
function deployNft(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_
) external returns (address);
/**
* @dev Deploy a new NFT contract with msg.sender as admin
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @return The address of the newly deployed NFT contract
*/
function deployNftWithSenderAsAdmin(string memory name_, string memory symbol_, string memory baseURI_, uint256 maxSupply_) external returns (address);
/**
* @dev Batch deploy multiple NFT contracts
* @param names_ Array of names for the NFT collections
* @param symbols_ Array of symbols for the NFT collections
* @param baseURIs_ Array of base URIs for token metadata
* @param maxSupplies_ Array of maximum supplies (0 for unlimited)
* @param adminAddresses_ Array of admin addresses for the deployed NFT contracts
* @return An array of addresses of the newly deployed NFT contracts
*/
function batchDeployNft(
string[] memory names_,
string[] memory symbols_,
string[] memory baseURIs_,
uint256[] memory maxSupplies_,
address[] memory adminAddresses_
) external returns (address[] memory);
/**
* @dev Get deployed NFT contracts with pagination
* @param offset The starting index
* @param limit The maximum number of items to return (0 for all remaining)
* @return A PaginatedNfts struct containing NFT addresses and pagination details
*/
function getDeployedNfts(uint256 offset, uint256 limit) external view returns (PaginatedNfts memory);
/**
* @dev Get the number of deployed NFT contracts
* @return The count of deployed NFT contracts
*/
function getDeployedNftsCount() external view returns (uint256);
/**
* @dev Get a deployed NFT contract by index
* @param index The index of the deployed NFT contract
* @return The address of the deployed NFT contract
*/
function getDeployedNftByIndex(uint256 index) external view returns (address);
/**
* @dev Get all NFTs deployed by a specific user
* @param deployer The address of the deployer
* @return An array of addresses of NFTs deployed by the user
*/
function getNftsByDeployer(address deployer) external view returns (address[] memory);
/**
* @dev Get the number of NFTs deployed by a specific user
* @param deployer The address of the deployer
* @return The count of NFTs deployed by the user
*/
function getNftsCountByDeployer(address deployer) external view returns (uint256);
struct LastBlockInfo {
uint256 nftDeployedLastBlock;
uint256 nftMintedLastBlock;
}
/**
* @dev Get the last block numbers for various operations
* @return A LastBlockInfo struct containing the last block numbers
*/
function getLastBlockInfo() external view returns (LastBlockInfo memory);
/**
* @dev Predict the address where an NFT will be deployed using CREATE2
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @param deployer_ The address of the deployer
* @return The predicted address where the NFT will be deployed
*/
function predictNftAddress(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address deployer_
) external view returns (address);
/**
* @dev Predict the address where an NFT will be deployed using CREATE2 with a specific nonce
* @param name_ The name of the NFT collection
* @param symbol_ The symbol of the NFT collection
* @param baseURI_ The base URI for token metadata
* @param maxSupply_ Maximum supply (0 for unlimited)
* @param adminAddress_ The admin address for the deployed NFT contract
* @param deployer_ The address of the deployer
* @param nonce_ The nonce to use for the prediction
* @return The predicted address where the NFT will be deployed
*/
function predictNftAddressWithNonce(
string memory name_,
string memory symbol_,
string memory baseURI_,
uint256 maxSupply_,
address adminAddress_,
address deployer_,
uint256 nonce_
) external view returns (address);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
/**
* @title Create2Deployer
* @dev Library for deploying contracts using CREATE2 opcode for deterministic addresses
*/
library Create2Deployer {
/**
* @dev Computes the CREATE2 address for a contract deployment
* @param deployer The address that will deploy the contract (factory address)
* @param userDeployer The address of the user deploying the NFT (used as salt)
* @param nonce The nonce for this deployment (allows multiple deployments per user)
* @param bytecodeHash The keccak256 hash of the contract bytecode + constructor args
* @return The predicted address where the contract will be deployed
*/
function computeAddress(address deployer, address userDeployer, uint256 nonce, bytes32 bytecodeHash) internal pure returns (address) {
// Combine user deployer address and nonce as salt to allow multiple deployments per user
bytes32 salt = keccak256(abi.encodePacked(userDeployer, nonce));
bytes32 data = keccak256(abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash));
return address(uint160(uint256(data)));
}
/**
* @dev Deploys a contract using CREATE2
* @param bytecode The contract bytecode (including constructor args)
* @param userDeployer The address of the user deploying the NFT (used as salt)
* @param nonce The nonce for this deployment (allows multiple deployments per user)
* @return deployedAddress The address of the deployed contract
*/
function deploy(bytes memory bytecode, address userDeployer, uint256 nonce) internal returns (address deployedAddress) {
// Combine user deployer address and nonce as salt to allow multiple deployments per user
bytes32 salt = keccak256(abi.encodePacked(userDeployer, nonce));
assembly {
deployedAddress := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
}
require(deployedAddress != address(0), "Create2: deployment failed");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
/**
* @title GenerativeAiNftLogic
* @dev Library containing shared logic for Generative AI NFT contracts
* This allows code reuse between upgradeable and non-upgradeable implementations
*/
library GenerativeAiNftLogic {
/**
* @dev Internal function to collect payment and refund overpayment
* @param mintPrice The price per token
* @param quantity Number of tokens being minted
* @return actualCost The actual cost paid (before refund)
*/
function collectPayment(uint256 mintPrice, uint256 quantity) internal returns (uint256 actualCost) {
actualCost = mintPrice * quantity;
require(msg.value >= actualCost, "Insufficient payment");
// Refund overpayment if any
uint256 overpayment = msg.value - actualCost;
if (overpayment > 0) {
(bool success, ) = payable(msg.sender).call{ value: overpayment }("");
require(success, "Refund failed");
}
return actualCost;
}
/**
* @dev Validate batch mint parameters
* @param tokenURIs Array of token URIs
* @param currentSupply Current total supply
* @param maxSupply Maximum supply (0 = unlimited)
*/
function validateBatchMint(string[] memory tokenURIs, uint256 currentSupply, uint256 maxSupply) internal pure {
uint256 length = tokenURIs.length;
require(length > 0, "Empty array");
// Check max supply if it's not 0 (0 means unlimited)
if (maxSupply > 0) {
require(currentSupply + length <= maxSupply, "Exceeds max supply");
}
}
/**
* @dev Validate single mint against max supply
* @param currentSupply Current total supply
* @param maxSupply Maximum supply (0 = unlimited)
*/
function validateMint(uint256 currentSupply, uint256 maxSupply) internal pure {
// Check max supply if it's not 0 (0 means unlimited)
if (maxSupply > 0) {
require(currentSupply < maxSupply, "Max supply reached");
}
}
/**
* @dev Validate public batch mint
* @param publicMintEnabled Whether public minting is enabled
* @param tokenURIs Array of token URIs
* @param currentSupply Current total supply
* @param maxSupply Maximum supply (0 = unlimited)
*/
function validatePublicBatchMint(bool publicMintEnabled, string[] memory tokenURIs, uint256 currentSupply, uint256 maxSupply) internal pure {
require(publicMintEnabled, "Public mint is disabled");
uint256 quantity = tokenURIs.length;
require(quantity > 0, "Quantity must be greater than 0");
// Check max supply if it's not 0 (0 means unlimited)
if (maxSupply > 0) {
require(currentSupply + quantity <= maxSupply, "Exceeds max supply");
}
}
/**
* @dev Withdraw contract balance
* @param recipient Address to receive funds
* @param balance Amount to withdraw
*/
function withdraw(address payable recipient, uint256 balance) internal {
require(balance > 0, "No funds to withdraw");
(bool success, ) = recipient.call{ value: balance }("");
require(success, "Withdrawal failed");
}
/**
* @dev Withdraw specific amount to a specific address
* @param recipient Address to receive funds
* @param amount Amount to withdraw
* @param contractBalance Current contract balance
*/
function withdrawTo(address payable recipient, uint256 amount, uint256 contractBalance) internal {
require(recipient != address(0), "Invalid recipient");
require(amount <= contractBalance, "Insufficient contract balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Withdrawal failed");
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import { EnumerableSet } from "@solidstate/contracts/data/EnumerableSet.sol";
/// @notice Storage for Generative AI NFT Factory
library LibGenAiNftFactoryStorage {
using EnumerableSet for EnumerableSet.AddressSet;
bytes32 internal constant DIAMOND_STORAGE_POSITION = keccak256("tokenfi.genainftfactory.diamond.storage");
struct DiamondStorage {
EnumerableSet.AddressSet deployedNfts; // Set of all deployed NFT contracts
mapping(address => EnumerableSet.AddressSet) nftsByDeployer; // Mapping of deployer address to their deployed NFTs
mapping(address => uint256) deployerNonces; // Mapping of deployer address to their deployment nonce
uint256 nftDeployedLastBlock;
uint256 nftMintedLastBlock;
}
function diamondStorage() internal pure returns (DiamondStorage storage ds) {
bytes32 position = DIAMOND_STORAGE_POSITION;
// solhint-disable-next-line no-inline-assembly
assembly {
ds.slot := position
}
}
}{
"evmVersion": "london",
"metadata": {
"bytecodeHash": "none",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 10
},
"remappings": [],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"EnumerableSet__IndexOutOfBounds","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousBlock","type":"uint256"},{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":false,"internalType":"string","name":"name","type":"string"},{"indexed":false,"internalType":"string","name":"symbol","type":"string"},{"indexed":false,"internalType":"string","name":"baseURI","type":"string"},{"indexed":false,"internalType":"uint256","name":"maxSupply","type":"uint256"},{"indexed":true,"internalType":"address","name":"adminAddress","type":"address"},{"indexed":true,"internalType":"address","name":"deployer","type":"address"}],"name":"NftDeployed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"previousBlock","type":"uint256"},{"indexed":true,"internalType":"address","name":"nftAddress","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"tokenURI","type":"string"}],"name":"NftMinted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"inputs":[{"internalType":"string[]","name":"names_","type":"string[]"},{"internalType":"string[]","name":"symbols_","type":"string[]"},{"internalType":"string[]","name":"baseURIs_","type":"string[]"},{"internalType":"uint256[]","name":"maxSupplies_","type":"uint256[]"},{"internalType":"address[]","name":"adminAddresses_","type":"address[]"}],"name":"batchDeployNft","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"uint256","name":"maxSupply_","type":"uint256"},{"internalType":"address","name":"adminAddress_","type":"address"}],"name":"deployNft","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"uint256","name":"maxSupply_","type":"uint256"}],"name":"deployNftWithSenderAsAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"tokenURI","type":"string"}],"name":"emitNftMintEvent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getDeployedNftByIndex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"getDeployedNfts","outputs":[{"components":[{"internalType":"address[]","name":"nfts","type":"address[]"},{"internalType":"uint256","name":"totalCount","type":"uint256"},{"internalType":"uint256","name":"currentPage","type":"uint256"},{"internalType":"uint256","name":"totalPages","type":"uint256"},{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"limit","type":"uint256"}],"internalType":"struct IGenAiNftFactory.PaginatedNfts","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getDeployedNftsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastBlockInfo","outputs":[{"components":[{"internalType":"uint256","name":"nftDeployedLastBlock","type":"uint256"},{"internalType":"uint256","name":"nftMintedLastBlock","type":"uint256"}],"internalType":"struct IGenAiNftFactory.LastBlockInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"deployer","type":"address"}],"name":"getNftsByDeployer","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"deployer","type":"address"}],"name":"getNftsCountByDeployer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"uint256","name":"maxSupply_","type":"uint256"},{"internalType":"address","name":"adminAddress_","type":"address"},{"internalType":"address","name":"deployer_","type":"address"}],"name":"predictNftAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"uint256","name":"maxSupply_","type":"uint256"},{"internalType":"address","name":"adminAddress_","type":"address"},{"internalType":"address","name":"deployer_","type":"address"},{"internalType":"uint256","name":"nonce_","type":"uint256"}],"name":"predictNftAddressWithNonce","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b50614c79806100206000396000f3fe60806040523480156200001157600080fd5b5060043610620000b25760003560e01c80630e882ffc14620000b757806312f0595614620000d457806323b4d3c214620000fa5780634908145d146200012a5780635d1430b714620001415780637b26f4a6146200015857806388cea551146200017e5780639437101814620001a4578063b250417114620001bb578063b8f37e7e14620001d4578063d2d2f51214620001eb578063e49d84011462000202575b600080fd5b620000c162000219565b6040519081526020015b60405180910390f35b620000eb620000e536600462001177565b62000239565b604051620000cb919062001258565b620001116200010b366004620012a7565b6200042b565b6040516001600160a01b039091168152602001620000cb565b620001116200013b36600462001371565b62000461565b620001116200015236600462001430565b620004c0565b62000162620004dc565b60408051825181526020928301519281019290925201620000cb565b620001956200018f366004620014de565b6200051e565b604051620000cb919062001501565b620000c1620001b536600462001591565b6200078a565b620001d2620001cc366004620015af565b620007c6565b005b62000111620001e53660046200160b565b62000886565b620000eb620001fc36600462001591565b620008a1565b6200011162000213366004620016a4565b62000995565b6000806200022662000a01565b9050620002338162000a25565b91505090565b60606000865111620002815760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b60448201526064015b60405180910390fd5b8451865114801562000294575083518651145b8015620002a2575082518651145b8015620002b0575081518651145b620002f65760405162461bcd60e51b8152602060048201526015602482015274082e4e4c2f240d8cadccee8d040dad2e6dac2e8c6d605b1b604482015260640162000278565b600086516001600160401b0381111562000314576200031462000f11565b6040519080825280602002602001820160405280156200033e578160200160208202803683370190505b50905060005b87518110156200042057620003ea888281518110620003675762000367620016be565b6020026020010151888381518110620003845762000384620016be565b6020026020010151888481518110620003a157620003a1620016be565b6020026020010151888581518110620003be57620003be620016be565b6020026020010151888681518110620003db57620003db620016be565b60200260200101513362000a30565b828281518110620003ff57620003ff620016be565b6001600160a01b039092166020928302919091019091015260010162000344565b509695505050505050565b6000806200043d898989898962000c84565b905062000454308585848051906020012062000d01565b9998505050505050505050565b6000806200046e62000a01565b6001600160a01b03841660009081526003820160205260408120549192506200049b8a8a8a8a8a62000c84565b9050620004b2308684848051906020012062000d01565b9a9950505050505050505050565b6000620004d286868686863362000a30565b9695505050505050565b60408051808201909152600080825260208201526000620004fc62000a01565b6040805180820190915260048201548152600590910154602082015292915050565b620005586040518060c001604052806060815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006200056462000a01565b90506000620005738262000a25565b9050808510158015620005865750600081115b15620006015760408051600060c0820181815260e083018452825260208201849052918101919091526060810185620005c1576001620005e8565b856001620005d08286620016ea565b620005dc919062001700565b620005e8919062001716565b8152602001868152602001858152509250505062000784565b6000858211620006135760006200061f565b6200061f868362001700565b905060008515806200063057508186115b6200063c57856200063e565b815b90506000816001600160401b038111156200065d576200065d62000f11565b60405190808252806020026020018201604052801562000687578160200160208202803683370190505b50905060005b82811015620006e457620006ae620006a6828b620016ea565b879062000d85565b828281518110620006c357620006c3620016be565b6001600160a01b03909216602092830291909101909101526001016200068d565b506000808811620006f757600162000710565b62000703888a62001716565b62000710906001620016ea565b90506000808911620007245760016200074b565b886001620007338289620016ea565b6200073f919062001700565b6200074b919062001716565b90506040518060c001604052808481526020018781526020018381526020018281526020018b81526020018a8152509750505050505050505b92915050565b6000806200079762000a01565b6001600160a01b03841660009081526002820160205260409020909150620007bf9062000a25565b9392505050565b336000620007d362000a01565b9050620007e1818362000d93565b620008255760405162461bcd60e51b8152602060048201526013602482015272496e76616c6964204e4654206164647265737360681b604482015260640162000278565b83856001600160a01b0316836001600160a01b03167f9f7882bec3934df27344113b17a0cf428639957f9bbba75036c2436778cbf8fd846005015487604051620008719291906200178d565b60405180910390a44360059091015550505050565b60006200089885858585333362000a30565b95945050505050565b60606000620008af62000a01565b6001600160a01b0384166000908152600282016020526040812091925090620008d89062000a25565b90506000816001600160401b03811115620008f757620008f762000f11565b60405190808252806020026020018201604052801562000921578160200160208202803683370190505b50905060005b828110156200098c576001600160a01b0386166000908152600285016020526040902062000956908262000d85565b8282815181106200096b576200096b620016be565b6001600160a01b039092166020928302919091019091015260010162000927565b50949350505050565b600080620009a262000a01565b9050620009af8162000a25565b8310620009f55760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b604482015260640162000278565b620007bf818462000d85565b7fc60626e571088dd69ed5d5a2adaf2d2777837753186d4cd0475203c3dd0cf6c090565b600062000784825490565b60006001600160a01b03831662000a825760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642061646d696e206164647265737360581b604482015260640162000278565b600087511162000acc5760405162461bcd60e51b81526020600482015260146024820152734e616d652063616e6e6f7420626520656d70747960601b604482015260640162000278565b600086511162000b185760405162461bcd60e51b815260206004820152601660248201527553796d626f6c2063616e6e6f7420626520656d70747960501b604482015260640162000278565b600062000b2462000a01565b6001600160a01b038416600090815260038201602052604090205490915062000b4f816001620016ea565b6001600160a01b038516600090815260038401602052604081209190915562000b8862000b808b8b8b8b8b62000c84565b868462000daa565b90506001600160a01b03811662000bd65760405162461bcd60e51b815260206004820152601160248201527011195c1b1bde5b595b9d0819985a5b1959607a1b604482015260640162000278565b62000be2838262000e43565b506001600160a01b0385166000908152600284016020526040902062000c09908262000e43565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167fc78df55feab101bcb09783db5f55ab9c2769fd281d06d55a230340f2593de3be86600401548e8e8e8e60405162000c65959493929190620017b0565b60405180910390a4436004909301929092555090509695505050505050565b60606040518060200162000c989062000f03565b601f1982820381018352601f90910116604081905262000cc79088908890889088908890309060200162001808565b60408051601f198184030181529082905262000ce7929160200162001870565b604051602081830303815290604052905095945050505050565b600080848460405160200162000d19929190620018a3565b60408051601f1981840301815282825280516020918201206001600160f81b03198285015260609990991b6001600160601b0319166021840152603583019890985260558083019590955280518083039095018552607590910190525050805193019290922092915050565b6000620007bf838362000e5a565b6000620007bf836001600160a01b03841662000eaa565b600080838360405160200162000dc2929190620018a3565b604051602081830303815290604052805190602001209050808551602087016000f591506001600160a01b03821662000e3b5760405162461bcd60e51b815260206004820152601a60248201527910dc99585d194c8e8819195c1b1bde5b595b9d0819985a5b195960321b604482015260640162000278565b509392505050565b6000620007bf836001600160a01b03841662000ec2565b8154600090821062000e7f5760405163e637bf3b60e01b815260040160405180910390fd5b82600001828154811062000e975762000e97620016be565b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b600062000ed0838362000eaa565b62000784575081546001808201845560008481526020808220909301849055845493815293810190915260409092205590565b6133ac80620018c183390190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000f525762000f5262000f11565b604052919050565b60006001600160401b0382111562000f765762000f7662000f11565b5060051b60200190565b600082601f83011262000f9257600080fd5b81356001600160401b0381111562000fae5762000fae62000f11565b62000fc3601f8201601f191660200162000f27565b81815284602083860101111562000fd957600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126200100857600080fd5b81356020620010216200101b8362000f5a565b62000f27565b82815260059290921b840181019181810190868411156200104157600080fd5b8286015b84811015620004205780356001600160401b03811115620010665760008081fd5b620010768986838b010162000f80565b84525091830191830162001045565b600082601f8301126200109757600080fd5b81356020620010aa6200101b8362000f5a565b8083825260208201915060208460051b870101935086841115620010cd57600080fd5b602086015b84811015620004205780358352918301918301620010d2565b80356001600160a01b03811681146200110357600080fd5b919050565b600082601f8301126200111a57600080fd5b813560206200112d6200101b8362000f5a565b8083825260208201915060208460051b8701019350868411156200115057600080fd5b602086015b8481101562000420576200116981620010eb565b835291830191830162001155565b600080600080600060a086880312156200119057600080fd5b85356001600160401b0380821115620011a857600080fd5b620011b689838a0162000ff6565b96506020880135915080821115620011cd57600080fd5b620011db89838a0162000ff6565b95506040880135915080821115620011f257600080fd5b6200120089838a0162000ff6565b945060608801359150808211156200121757600080fd5b6200122589838a0162001085565b935060808801359150808211156200123c57600080fd5b506200124b8882890162001108565b9150509295509295909350565b6020808252825182820181905260009190848201906040850190845b818110156200129b5783516001600160a01b03168352928401929184019160010162001274565b50909695505050505050565b600080600080600080600060e0888a031215620012c357600080fd5b87356001600160401b0380821115620012db57600080fd5b620012e98b838c0162000f80565b985060208a01359150808211156200130057600080fd5b6200130e8b838c0162000f80565b975060408a01359150808211156200132557600080fd5b50620013348a828b0162000f80565b955050606088013593506200134c60808901620010eb565b92506200135c60a08901620010eb565b915060c0880135905092959891949750929550565b60008060008060008060c087890312156200138b57600080fd5b86356001600160401b0380821115620013a357600080fd5b620013b18a838b0162000f80565b97506020890135915080821115620013c857600080fd5b620013d68a838b0162000f80565b96506040890135915080821115620013ed57600080fd5b50620013fc89828a0162000f80565b945050606087013592506200141460808801620010eb565b91506200142460a08801620010eb565b90509295509295509295565b600080600080600060a086880312156200144957600080fd5b85356001600160401b03808211156200146157600080fd5b6200146f89838a0162000f80565b965060208801359150808211156200148657600080fd5b6200149489838a0162000f80565b95506040880135915080821115620014ab57600080fd5b50620014ba8882890162000f80565b93505060608601359150620014d260808701620010eb565b90509295509295909350565b60008060408385031215620014f257600080fd5b50508035926020909101359150565b6020808252825160c083830152805160e084018190526000929182019083906101008601905b80831015620015525783516001600160a01b0316825292840192600192909201919084019062001527565b508387015160408701526040870151606087015260608701516080870152608087015160a087015260a087015160c08701528094505050505092915050565b600060208284031215620015a457600080fd5b620007bf82620010eb565b600080600060608486031215620015c557600080fd5b620015d084620010eb565b92506020840135915060408401356001600160401b03811115620015f357600080fd5b620016018682870162000f80565b9150509250925092565b600080600080608085870312156200162257600080fd5b84356001600160401b03808211156200163a57600080fd5b620016488883890162000f80565b955060208701359150808211156200165f57600080fd5b6200166d8883890162000f80565b945060408701359150808211156200168457600080fd5b50620016938782880162000f80565b949793965093946060013593505050565b600060208284031215620016b757600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115620007845762000784620016d4565b81810381811115620007845762000784620016d4565b6000826200173457634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015620017565781810151838201526020016200173c565b50506000910152565b600081518084526200177981602086016020860162001739565b601f01601f19169290920160200192915050565b828152604060208201526000620017a860408301846200175f565b949350505050565b85815260a060208201526000620017cb60a08301876200175f565b8281036040840152620017df81876200175f565b90508281036060840152620017f581866200175f565b9150508260808301529695505050505050565b60c0815260006200181d60c08301896200175f565b82810360208401526200183181896200175f565b905082810360408401526200184781886200175f565b606084019690965250506001600160a01b039283166080820152911660a0909101529392505050565b600083516200188481846020880162001739565b8351908301906200189a81836020880162001739565b01949350505050565b60609290921b6001600160601b031916825260148201526034019056fe60a06040523480156200001157600080fd5b50604051620033ac380380620033ac8339810160408190526200003491620002e3565b8585600062000044838262000433565b50600162000053828262000433565b50506001600b55506001600160a01b038216620000b75760405162461bcd60e51b815260206004820152601560248201527f496e76616c69642061646d696e2061646472657373000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b0381166200010f5760405162461bcd60e51b815260206004820152601760248201527f496e76616c6964206469616d6f6e6420616464726573730000000000000000006044820152606401620000ae565b600c6200011d858262000433565b50600e839055600f805460ff19169055600060108190556001600160a01b0382166080526200014d908362000159565b505050505050620004ff565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16620001fa576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001b93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200022657600080fd5b81516001600160401b0380821115620002435762000243620001fe565b604051601f8301601f19908116603f011681019082821181831017156200026e576200026e620001fe565b81604052838152602092508660208588010111156200028c57600080fd5b600091505b83821015620002b0578582018301518183018401529082019062000291565b6000602085830101528094505050505092915050565b80516001600160a01b0381168114620002de57600080fd5b919050565b60008060008060008060c08789031215620002fd57600080fd5b86516001600160401b03808211156200031557600080fd5b620003238a838b0162000214565b975060208901519150808211156200033a57600080fd5b620003488a838b0162000214565b965060408901519150808211156200035f57600080fd5b506200036e89828a0162000214565b945050606087015192506200038660808801620002c6565b91506200039660a08801620002c6565b90509295509295509295565b600181811c90821680620003b757607f821691505b602082108103620003d857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200042e576000816000526020600020601f850160051c81016020861015620004095750805b601f850160051c820191505b818110156200042a5782815560010162000415565b5050505b505050565b81516001600160401b038111156200044f576200044f620001fe565b6200046781620004608454620003a2565b84620003de565b602080601f8311600181146200049f5760008415620004865750858301515b600019600386901b1c1916600185901b1785556200042a565b600085815260208120601f198616915b82811015620004d057888601518255948401946001909101908401620004af565b5085821015620004ef5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051612e8a620005226000396000818161046001526116cf0152612e8a6000f3fe6080604052600436106101cb5760003560e01c806301ffc9a7146101d057806306fdde0314610205578063081812fc14610227578063095ea7b31461025f5780630f4161aa1461028157806318160ddd1461029b578063205c2878146102ba57806323b872dd146102da578063248a9ca3146102fa5780632f2ff15d1461031a5780632f745c591461033a57806330781e521461035a57806336568abe1461036d5780633ccfd60b1461038d57806342842e0e146103a25780634f6ccce7146103c257806355f804b3146103e25780636352211e1461040257806367ed2c57146104225780636817c76c146104385780636a60c3b71461044e5780636a627842146104825780636c0360eb146104a257806370a08231146104b7578063818668d7146104d75780638462151c146104f757806391d148541461052457806395d89b4114610544578063a217fddf14610559578063a22cb4651461056e578063b3d7acf91461058e578063b88d4fde146105a1578063c3f8cba6146105c1578063c87b56dd146105d7578063d0def521146105f7578063d547741f14610617578063d5abeb0114610637578063e985e9c51461064d578063f4a0a5281461066d578063f4c2d8901461068d575b600080fd5b3480156101dc57600080fd5b506101f06101eb366004612453565b6106ad565b60405190151581526020015b60405180910390f35b34801561021157600080fd5b5061021a6106cd565b6040516101fc91906124c0565b34801561023357600080fd5b506102476102423660046124d3565b61075f565b6040516001600160a01b0390911681526020016101fc565b34801561026b57600080fd5b5061027f61027a366004612501565b610786565b005b34801561028d57600080fd5b50600f546101f09060ff1681565b3480156102a757600080fd5b506008545b6040519081526020016101fc565b3480156102c657600080fd5b5061027f6102d5366004612501565b6108a0565b3480156102e657600080fd5b5061027f6102f536600461252d565b6108ec565b34801561030657600080fd5b506102ac6103153660046124d3565b61091d565b34801561032657600080fd5b5061027f61033536600461256e565b610932565b34801561034657600080fd5b506102ac610355366004612501565b61094e565b61027f6103683660046126f9565b6109e4565b34801561037957600080fd5b5061027f61038836600461256e565b610aa8565b34801561039957600080fd5b5061027f610b26565b3480156103ae57600080fd5b5061027f6103bd36600461252d565b610b63565b3480156103ce57600080fd5b506102ac6103dd3660046124d3565b610b7e565b3480156103ee57600080fd5b5061027f6103fd36600461272d565b610c11565b34801561040e57600080fd5b5061024761041d3660046124d3565b610c28565b34801561042e57600080fd5b506102ac60115481565b34801561044457600080fd5b506102ac60105481565b34801561045a57600080fd5b506102477f000000000000000000000000000000000000000000000000000000000000000081565b34801561048e57600080fd5b5061027f61049d366004612761565b610c5c565b3480156104ae57600080fd5b5061021a610c80565b3480156104c357600080fd5b506102ac6104d2366004612761565b610c8f565b3480156104e357600080fd5b5061027f6104f2366004612793565b610d15565b34801561050357600080fd5b50610517610512366004612761565b610d69565b6040516101fc91906127ae565b34801561053057600080fd5b506101f061053f36600461256e565b610e00565b34801561055057600080fd5b5061021a610e2b565b34801561056557600080fd5b506102ac600081565b34801561057a57600080fd5b5061027f6105893660046127f2565b610e3a565b61027f61059c36600461272d565b610e45565b3480156105ad57600080fd5b5061027f6105bc366004612827565b610ed7565b3480156105cd57600080fd5b506102ac60125481565b3480156105e357600080fd5b5061021a6105f23660046124d3565b610f0f565b34801561060357600080fd5b5061027f6106123660046128a6565b610fe5565b34801561062357600080fd5b5061027f61063236600461256e565b610ffa565b34801561064357600080fd5b506102ac600e5481565b34801561065957600080fd5b506101f06106683660046128f5565b611016565b34801561067957600080fd5b5061027f6106883660046124d3565b611044565b34801561069957600080fd5b5061027f6106a8366004612923565b611084565b60006106b8826110ce565b806106c757506106c7826110f3565b92915050565b6060600080546106dc90612968565b80601f016020809104026020016040519081016040528092919081815260200182805461070890612968565b80156107555780601f1061072a57610100808354040283529160200191610755565b820191906000526020600020905b81548152906001019060200180831161073857829003601f168201915b5050505050905090565b600061076a82611118565b506000908152600460205260409020546001600160a01b031690565b600061079182610c28565b9050806001600160a01b0316836001600160a01b0316036108035760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061081f575061081f8133611016565b6108915760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016107fa565b61089b838361113d565b505050565b60006108ab816111ab565b6108b68383476111b5565b826001600160a01b0316600080516020612e5e833981519152836040516108df91815260200190565b60405180910390a2505050565b6108f633826112c2565b6109125760405162461bcd60e51b81526004016107fa9061299c565b61089b838383611321565b6000908152600a602052604090206001015490565b61093b8261091d565b610944816111ab565b61089b8383611480565b600061095983610c8f565b82106109bb5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016107fa565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6109ec611506565b600f54610a089060ff1682610a0060085490565b600e5461155f565b6000610a148251611601565b905060005b8251811015610a4d57610a4533848381518110610a3857610a386129e9565b6020026020010151611661565b600101610a19565b506012548251604080519283526020830191909152810182905233907f560fa9ae3608118640273d6206fa6cf31330295b13c4f2075f942c50b6eb63969060600160405180910390a25043601255610aa56001600b55565b50565b6001600160a01b0381163314610b185760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016107fa565b610b22828261173f565b5050565b6000610b31816111ab565b47610b3c33826117a6565b6040518181523390600080516020612e5e8339815191529060200160405180910390a25050565b61089b83838360405180602001604052806000815250610ed7565b6000610b8960085490565b8210610bec5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016107fa565b60088281548110610bff57610bff6129e9565b90600052602060002001549050919050565b6000610c1c816111ab565b600c61089b8382612a4f565b600080610c3483611860565b90506001600160a01b0381166106c75760405162461bcd60e51b81526004016107fa90612b0e565b6000610c67816111ab565b610b228260405180602001604052806000815250611661565b6060600c80546106dc90612968565b60006001600160a01b038216610cf95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016107fa565b506001600160a01b031660009081526003602052604090205490565b6000610d20816111ab565b600f805460ff19168315159081179091556040519081527fa81e445dac2343503dc87e4663774817434721db7d985310a6959766e6d4480e906020015b60405180910390a15050565b60606000610d7683610c8f565b90506000816001600160401b03811115610d9257610d9261259e565b604051908082528060200260200182016040528015610dbb578160200160208202803683370190505b50905060005b82811015610df857610dd3858261094e565b828281518110610de557610de56129e9565b6020908102919091010152600101610dc1565b509392505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546106dc90612968565b610b2233838361187b565b610e4d611506565b600f5460ff16610e6f5760405162461bcd60e51b81526004016107fa90612b40565b6000610e7b6001611601565b9050610e873383611661565b600854601154604080519182526020820184905233917f1886253aaa3b9944c4a0db093f9a1aa619cbd2b51eebdb7bda362ac0b967c828910160405180910390a35043601155610aa56001600b55565b610ee133836112c2565b610efd5760405162461bcd60e51b81526004016107fa9061299c565b610f0984848484611945565b50505050565b6060610f1a82611118565b6000828152600d602052604081208054610f3390612968565b905011610f4857610f4382611978565b6106c7565b6000828152600d602052604090208054610f6190612968565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8d90612968565b8015610fda5780601f10610faf57610100808354040283529160200191610fda565b820191906000526020600020905b815481529060010190602001808311610fbd57829003601f168201915b505050505092915050565b6000610ff0816111ab565b61089b8383611661565b6110038261091d565b61100c816111ab565b61089b838361173f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600061104f816111ab565b60108290556040518281527f525b762709cc2a983aec5ccdfd807a061f993c91090b5bcd7da92ca254976aaa90602001610d5d565b600061108f816111ab565b6110a48261109c60085490565b600e546119df565b60005b8251811015610f09576110c684848381518110610a3857610a386129e9565b6001016110a7565b60006001600160e01b0319821663780e9d6360e01b14806106c757506106c782611a4b565b60006001600160e01b03198216637965db0b60e01b14806106c757506106c7826110ce565b61112181611a9b565b610aa55760405162461bcd60e51b81526004016107fa90612b0e565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061117282610c28565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610aa58133611ab8565b6001600160a01b0383166111ff5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b60448201526064016107fa565b8082111561124f5760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e7420636f6e74726163742062616c616e636500000060448201526064016107fa565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461129c576040519150601f19603f3d011682016040523d82523d6000602084013e6112a1565b606091505b5050905080610f095760405162461bcd60e51b81526004016107fa90612b71565b6000806112ce83610c28565b9050806001600160a01b0316846001600160a01b031614806112f557506112f58185611016565b806113195750836001600160a01b031661130e8461075f565b6001600160a01b0316145b949350505050565b826001600160a01b031661133482610c28565b6001600160a01b03161461135a5760405162461bcd60e51b81526004016107fa90612b9c565b6001600160a01b0382166113bc5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107fa565b6113c98383836001611b11565b826001600160a01b03166113dc82610c28565b6001600160a01b0316146114025760405162461bcd60e51b81526004016107fa90612b9c565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b038781168086526003855283862080546000190190559087168086528386208054600101905586865260029094528285208054909216841790915590518493600080516020612e3e83398151915291a4505050565b61148a8282610e00565b610b22576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556114c23390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6002600b54036115585760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107fa565b6002600b55565b8361157c5760405162461bcd60e51b81526004016107fa90612b40565b8251806115cb5760405162461bcd60e51b815260206004820152601f60248201527f5175616e74697479206d7573742062652067726561746572207468616e20300060448201526064016107fa565b81156115fa57816115dc8285612bf7565b11156115fa5760405162461bcd60e51b81526004016107fa90612c0a565b5050505050565b600061160f60105483611b1d565b9050600061161d8234612c36565b9050801561165b5760405181815233907fe309aa15fd2f6bd8a58603632508694071e7d35e967bdbb827926e429b7ef34d9060200160405180910390a25b50919050565b61167561166d60085490565b600e54611c17565b600061168060085490565b61168b906001612bf7565b90506116978382611c61565b8151156116b8576000818152600d602052604090206116b68382612a4f565b505b60405163b250417160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b25041719061170890869085908790600401612c49565b600060405180830381600087803b15801561172257600080fd5b505af1158015611736573d6000803e3d6000fd5b50505050505050565b6117498282610e00565b15610b22576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081116117ed5760405162461bcd60e51b81526020600482015260146024820152734e6f2066756e647320746f20776974686472617760601b60448201526064016107fa565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461183a576040519150601f19603f3d011682016040523d82523d6000602084013e61183f565b606091505b505090508061089b5760405162461bcd60e51b81526004016107fa90612b71565b6000908152600260205260409020546001600160a01b031690565b816001600160a01b0316836001600160a01b0316036118d85760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016107fa565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611950848484611321565b61195c84848484611d6a565b610f095760405162461bcd60e51b81526004016107fa90612c79565b606061198382611118565b600061198d610c80565b905060008151116119ad57604051806020016040528060008152506119d8565b806119b784611e6b565b6040516020016119c8929190612ccb565b6040516020818303038152906040525b9392505050565b825180611a1c5760405162461bcd60e51b815260206004820152600b60248201526a456d70747920617272617960a81b60448201526064016107fa565b8115610f095781611a2d8285612bf7565b1115610f095760405162461bcd60e51b81526004016107fa90612c0a565b60006001600160e01b031982166380ac58cd60e01b1480611a7c57506001600160e01b03198216635b5e139f60e01b145b806106c757506301ffc9a760e01b6001600160e01b03198316146106c7565b600080611aa783611860565b6001600160a01b0316141592915050565b611ac28282610e00565b610b2257611acf81611efd565b611ada836020611f0f565b604051602001611aeb929190612cfa565b60408051601f198184030181529082905262461bcd60e51b82526107fa916004016124c0565b610f09848484846120aa565b6000611b298284612d69565b905080341015611b725760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b60448201526064016107fa565b6000611b7e8234612c36565b90508015611c1057604051600090339083908381818185875af1925050503d8060008114611bc8576040519150601f19603f3d011682016040523d82523d6000602084013e611bcd565b606091505b5050905080611c0e5760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016107fa565b505b5092915050565b8015610b2257808210610b225760405162461bcd60e51b815260206004820152601260248201527113585e081cdd5c1c1b1e481c995858da195960721b60448201526064016107fa565b6001600160a01b038216611cb75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107fa565b611cc081611a9b565b15611cdd5760405162461bcd60e51b81526004016107fa90612d80565b611ceb600083836001611b11565b611cf481611a9b565b15611d115760405162461bcd60e51b81526004016107fa90612d80565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b031916841790555183929190600080516020612e3e833981519152908290a45050565b60006001600160a01b0384163b15611e6057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611dae903390899088908890600401612db6565b6020604051808303816000875af1925050508015611de9575060408051601f3d908101601f19168201909252611de691810190612df3565b60015b611e46573d808015611e17576040519150601f19603f3d011682016040523d82523d6000602084013e611e1c565b606091505b508051600003611e3e5760405162461bcd60e51b81526004016107fa90612c79565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611319565b506001949350505050565b60606000611e78836121d7565b60010190506000816001600160401b03811115611e9757611e9761259e565b6040519080825280601f01601f191660200182016040528015611ec1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611ecb57509392505050565b60606106c76001600160a01b03831660145b60606000611f1e836002612d69565b611f29906002612bf7565b6001600160401b03811115611f4057611f4061259e565b6040519080825280601f01601f191660200182016040528015611f6a576020820181803683370190505b509050600360fc1b81600081518110611f8557611f856129e9565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611fb457611fb46129e9565b60200101906001600160f81b031916908160001a9053506000611fd8846002612d69565b611fe3906001612bf7565b90505b600181111561205b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612017576120176129e9565b1a60f81b82828151811061202d5761202d6129e9565b60200101906001600160f81b031916908160001a90535060049490941c9361205481612e10565b9050611fe6565b5083156119d85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107fa565b60018111156121195760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b60648201526084016107fa565b816001600160a01b0385166121755761217081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612198565b836001600160a01b0316856001600160a01b0316146121985761219885826122ad565b6001600160a01b0384166121b4576121af8161234a565b6115fa565b846001600160a01b0316846001600160a01b0316146115fa576115fa84826123f9565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106122165772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b8310612240576904ee2d6d415b85acef8160201b830492506020015b662386f26fc10000831061225e57662386f26fc10000830492506010015b6305f5e1008310612276576305f5e100830492506008015b612710831061228a57612710830492506004015b6064831061229c576064830492506002015b600a83106106c75760010192915050565b600060016122ba84610c8f565b6122c49190612c36565b600083815260076020526040902054909150808214612317576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061235c90600190612c36565b60008381526009602052604081205460088054939450909284908110612384576123846129e9565b9060005260206000200154905080600883815481106123a5576123a56129e9565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806123dd576123dd612e27565b6001900381819060005260206000200160009055905550505050565b600061240483610c8f565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610aa557600080fd5b60006020828403121561246557600080fd5b81356119d88161243d565b60005b8381101561248b578181015183820152602001612473565b50506000910152565b600081518084526124ac816020860160208601612470565b601f01601f19169290920160200192915050565b6020815260006119d86020830184612494565b6000602082840312156124e557600080fd5b5035919050565b6001600160a01b0381168114610aa557600080fd5b6000806040838503121561251457600080fd5b823561251f816124ec565b946020939093013593505050565b60008060006060848603121561254257600080fd5b833561254d816124ec565b9250602084013561255d816124ec565b929592945050506040919091013590565b6000806040838503121561258157600080fd5b823591506020830135612593816124ec565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156125dc576125dc61259e565b604052919050565b60006001600160401b038311156125fd576125fd61259e565b612610601f8401601f19166020016125b4565b905082815283838301111561262457600080fd5b828260208301376000602084830101529392505050565b600082601f83011261264c57600080fd5b6119d8838335602085016125e4565b600082601f83011261266c57600080fd5b813560206001600160401b03808311156126885761268861259e565b8260051b6126978382016125b4565b93845285810183019383810190888611156126b157600080fd5b84880192505b858310156126ed578235848111156126cf5760008081fd5b6126dd8a87838c010161263b565b83525091840191908401906126b7565b98975050505050505050565b60006020828403121561270b57600080fd5b81356001600160401b0381111561272157600080fd5b6113198482850161265b565b60006020828403121561273f57600080fd5b81356001600160401b0381111561275557600080fd5b6113198482850161263b565b60006020828403121561277357600080fd5b81356119d8816124ec565b8035801515811461278e57600080fd5b919050565b6000602082840312156127a557600080fd5b6119d88261277e565b6020808252825182820181905260009190848201906040850190845b818110156127e6578351835292840192918401916001016127ca565b50909695505050505050565b6000806040838503121561280557600080fd5b8235612810816124ec565b915061281e6020840161277e565b90509250929050565b6000806000806080858703121561283d57600080fd5b8435612848816124ec565b93506020850135612858816124ec565b92506040850135915060608501356001600160401b0381111561287a57600080fd5b8501601f8101871361288b57600080fd5b61289a878235602084016125e4565b91505092959194509250565b600080604083850312156128b957600080fd5b82356128c4816124ec565b915060208301356001600160401b038111156128df57600080fd5b6128eb8582860161263b565b9150509250929050565b6000806040838503121561290857600080fd5b8235612913816124ec565b91506020830135612593816124ec565b6000806040838503121561293657600080fd5b8235612941816124ec565b915060208301356001600160401b0381111561295c57600080fd5b6128eb8582860161265b565b600181811c9082168061297c57607f821691505b60208210810361165b57634e487b7160e01b600052602260045260246000fd5b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b601f82111561089b576000816000526020600020601f850160051c81016020861015612a285750805b601f850160051c820191505b81811015612a4757828155600101612a34565b505050505050565b81516001600160401b03811115612a6857612a6861259e565b612a7c81612a768454612968565b846129ff565b602080601f831160018114612ab15760008415612a995750858301515b600019600386901b1c1916600185901b178555612a47565b600085815260208120601f198616915b82811015612ae057888601518255948401946001909101908401612ac1565b5085821015612afe5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b602080825260179082015276141d589b1a58c81b5a5b9d081a5cc8191a5cd8589b1959604a1b604082015260600190565b60208082526011908201527015da5d1a191c985dd85b0819985a5b1959607a1b604082015260600190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b808201808211156106c7576106c7612be1565b60208082526012908201527145786365656473206d617820737570706c7960701b604082015260600190565b818103818111156106c7576106c7612be1565b60018060a01b0384168152826020820152606060408201526000612c706060830184612494565b95945050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612cdd818460208801612470565b835190830190612cf1818360208801612470565b01949350505050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612d2c816017850160208801612470565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612d5d816028840160208801612470565b01602801949350505050565b80820281158282048414176106c7576106c7612be1565b6020808252601c908201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b604082015260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612de990830184612494565b9695505050505050565b600060208284031215612e0557600080fd5b81516119d88161243d565b600081612e1f57612e1f612be1565b506000190190565b634e487b7160e01b600052603160045260246000fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5a164736f6c6343000817000aa164736f6c6343000817000a
Deployed Bytecode
0x60806040523480156200001157600080fd5b5060043610620000b25760003560e01c80630e882ffc14620000b757806312f0595614620000d457806323b4d3c214620000fa5780634908145d146200012a5780635d1430b714620001415780637b26f4a6146200015857806388cea551146200017e5780639437101814620001a4578063b250417114620001bb578063b8f37e7e14620001d4578063d2d2f51214620001eb578063e49d84011462000202575b600080fd5b620000c162000219565b6040519081526020015b60405180910390f35b620000eb620000e536600462001177565b62000239565b604051620000cb919062001258565b620001116200010b366004620012a7565b6200042b565b6040516001600160a01b039091168152602001620000cb565b620001116200013b36600462001371565b62000461565b620001116200015236600462001430565b620004c0565b62000162620004dc565b60408051825181526020928301519281019290925201620000cb565b620001956200018f366004620014de565b6200051e565b604051620000cb919062001501565b620000c1620001b536600462001591565b6200078a565b620001d2620001cc366004620015af565b620007c6565b005b62000111620001e53660046200160b565b62000886565b620000eb620001fc36600462001591565b620008a1565b6200011162000213366004620016a4565b62000995565b6000806200022662000a01565b9050620002338162000a25565b91505090565b60606000865111620002815760405162461bcd60e51b815260206004820152600c60248201526b456d7074792061727261797360a01b60448201526064015b60405180910390fd5b8451865114801562000294575083518651145b8015620002a2575082518651145b8015620002b0575081518651145b620002f65760405162461bcd60e51b8152602060048201526015602482015274082e4e4c2f240d8cadccee8d040dad2e6dac2e8c6d605b1b604482015260640162000278565b600086516001600160401b0381111562000314576200031462000f11565b6040519080825280602002602001820160405280156200033e578160200160208202803683370190505b50905060005b87518110156200042057620003ea888281518110620003675762000367620016be565b6020026020010151888381518110620003845762000384620016be565b6020026020010151888481518110620003a157620003a1620016be565b6020026020010151888581518110620003be57620003be620016be565b6020026020010151888681518110620003db57620003db620016be565b60200260200101513362000a30565b828281518110620003ff57620003ff620016be565b6001600160a01b039092166020928302919091019091015260010162000344565b509695505050505050565b6000806200043d898989898962000c84565b905062000454308585848051906020012062000d01565b9998505050505050505050565b6000806200046e62000a01565b6001600160a01b03841660009081526003820160205260408120549192506200049b8a8a8a8a8a62000c84565b9050620004b2308684848051906020012062000d01565b9a9950505050505050505050565b6000620004d286868686863362000a30565b9695505050505050565b60408051808201909152600080825260208201526000620004fc62000a01565b6040805180820190915260048201548152600590910154602082015292915050565b620005586040518060c001604052806060815260200160008152602001600081526020016000815260200160008152602001600081525090565b60006200056462000a01565b90506000620005738262000a25565b9050808510158015620005865750600081115b15620006015760408051600060c0820181815260e083018452825260208201849052918101919091526060810185620005c1576001620005e8565b856001620005d08286620016ea565b620005dc919062001700565b620005e8919062001716565b8152602001868152602001858152509250505062000784565b6000858211620006135760006200061f565b6200061f868362001700565b905060008515806200063057508186115b6200063c57856200063e565b815b90506000816001600160401b038111156200065d576200065d62000f11565b60405190808252806020026020018201604052801562000687578160200160208202803683370190505b50905060005b82811015620006e457620006ae620006a6828b620016ea565b879062000d85565b828281518110620006c357620006c3620016be565b6001600160a01b03909216602092830291909101909101526001016200068d565b506000808811620006f757600162000710565b62000703888a62001716565b62000710906001620016ea565b90506000808911620007245760016200074b565b886001620007338289620016ea565b6200073f919062001700565b6200074b919062001716565b90506040518060c001604052808481526020018781526020018381526020018281526020018b81526020018a8152509750505050505050505b92915050565b6000806200079762000a01565b6001600160a01b03841660009081526002820160205260409020909150620007bf9062000a25565b9392505050565b336000620007d362000a01565b9050620007e1818362000d93565b620008255760405162461bcd60e51b8152602060048201526013602482015272496e76616c6964204e4654206164647265737360681b604482015260640162000278565b83856001600160a01b0316836001600160a01b03167f9f7882bec3934df27344113b17a0cf428639957f9bbba75036c2436778cbf8fd846005015487604051620008719291906200178d565b60405180910390a44360059091015550505050565b60006200089885858585333362000a30565b95945050505050565b60606000620008af62000a01565b6001600160a01b0384166000908152600282016020526040812091925090620008d89062000a25565b90506000816001600160401b03811115620008f757620008f762000f11565b60405190808252806020026020018201604052801562000921578160200160208202803683370190505b50905060005b828110156200098c576001600160a01b0386166000908152600285016020526040902062000956908262000d85565b8282815181106200096b576200096b620016be565b6001600160a01b039092166020928302919091019091015260010162000927565b50949350505050565b600080620009a262000a01565b9050620009af8162000a25565b8310620009f55760405162461bcd60e51b8152602060048201526013602482015272496e646578206f7574206f6620626f756e647360681b604482015260640162000278565b620007bf818462000d85565b7fc60626e571088dd69ed5d5a2adaf2d2777837753186d4cd0475203c3dd0cf6c090565b600062000784825490565b60006001600160a01b03831662000a825760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642061646d696e206164647265737360581b604482015260640162000278565b600087511162000acc5760405162461bcd60e51b81526020600482015260146024820152734e616d652063616e6e6f7420626520656d70747960601b604482015260640162000278565b600086511162000b185760405162461bcd60e51b815260206004820152601660248201527553796d626f6c2063616e6e6f7420626520656d70747960501b604482015260640162000278565b600062000b2462000a01565b6001600160a01b038416600090815260038201602052604090205490915062000b4f816001620016ea565b6001600160a01b038516600090815260038401602052604081209190915562000b8862000b808b8b8b8b8b62000c84565b868462000daa565b90506001600160a01b03811662000bd65760405162461bcd60e51b815260206004820152601160248201527011195c1b1bde5b595b9d0819985a5b1959607a1b604482015260640162000278565b62000be2838262000e43565b506001600160a01b0385166000908152600284016020526040902062000c09908262000e43565b50846001600160a01b0316866001600160a01b0316826001600160a01b03167fc78df55feab101bcb09783db5f55ab9c2769fd281d06d55a230340f2593de3be86600401548e8e8e8e60405162000c65959493929190620017b0565b60405180910390a4436004909301929092555090509695505050505050565b60606040518060200162000c989062000f03565b601f1982820381018352601f90910116604081905262000cc79088908890889088908890309060200162001808565b60408051601f198184030181529082905262000ce7929160200162001870565b604051602081830303815290604052905095945050505050565b600080848460405160200162000d19929190620018a3565b60408051601f1981840301815282825280516020918201206001600160f81b03198285015260609990991b6001600160601b0319166021840152603583019890985260558083019590955280518083039095018552607590910190525050805193019290922092915050565b6000620007bf838362000e5a565b6000620007bf836001600160a01b03841662000eaa565b600080838360405160200162000dc2929190620018a3565b604051602081830303815290604052805190602001209050808551602087016000f591506001600160a01b03821662000e3b5760405162461bcd60e51b815260206004820152601a60248201527910dc99585d194c8e8819195c1b1bde5b595b9d0819985a5b195960321b604482015260640162000278565b509392505050565b6000620007bf836001600160a01b03841662000ec2565b8154600090821062000e7f5760405163e637bf3b60e01b815260040160405180910390fd5b82600001828154811062000e975762000e97620016be565b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b600062000ed0838362000eaa565b62000784575081546001808201845560008481526020808220909301849055845493815293810190915260409092205590565b6133ac80620018c183390190565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b038111828210171562000f525762000f5262000f11565b604052919050565b60006001600160401b0382111562000f765762000f7662000f11565b5060051b60200190565b600082601f83011262000f9257600080fd5b81356001600160401b0381111562000fae5762000fae62000f11565b62000fc3601f8201601f191660200162000f27565b81815284602083860101111562000fd957600080fd5b816020850160208301376000918101602001919091529392505050565b600082601f8301126200100857600080fd5b81356020620010216200101b8362000f5a565b62000f27565b82815260059290921b840181019181810190868411156200104157600080fd5b8286015b84811015620004205780356001600160401b03811115620010665760008081fd5b620010768986838b010162000f80565b84525091830191830162001045565b600082601f8301126200109757600080fd5b81356020620010aa6200101b8362000f5a565b8083825260208201915060208460051b870101935086841115620010cd57600080fd5b602086015b84811015620004205780358352918301918301620010d2565b80356001600160a01b03811681146200110357600080fd5b919050565b600082601f8301126200111a57600080fd5b813560206200112d6200101b8362000f5a565b8083825260208201915060208460051b8701019350868411156200115057600080fd5b602086015b8481101562000420576200116981620010eb565b835291830191830162001155565b600080600080600060a086880312156200119057600080fd5b85356001600160401b0380821115620011a857600080fd5b620011b689838a0162000ff6565b96506020880135915080821115620011cd57600080fd5b620011db89838a0162000ff6565b95506040880135915080821115620011f257600080fd5b6200120089838a0162000ff6565b945060608801359150808211156200121757600080fd5b6200122589838a0162001085565b935060808801359150808211156200123c57600080fd5b506200124b8882890162001108565b9150509295509295909350565b6020808252825182820181905260009190848201906040850190845b818110156200129b5783516001600160a01b03168352928401929184019160010162001274565b50909695505050505050565b600080600080600080600060e0888a031215620012c357600080fd5b87356001600160401b0380821115620012db57600080fd5b620012e98b838c0162000f80565b985060208a01359150808211156200130057600080fd5b6200130e8b838c0162000f80565b975060408a01359150808211156200132557600080fd5b50620013348a828b0162000f80565b955050606088013593506200134c60808901620010eb565b92506200135c60a08901620010eb565b915060c0880135905092959891949750929550565b60008060008060008060c087890312156200138b57600080fd5b86356001600160401b0380821115620013a357600080fd5b620013b18a838b0162000f80565b97506020890135915080821115620013c857600080fd5b620013d68a838b0162000f80565b96506040890135915080821115620013ed57600080fd5b50620013fc89828a0162000f80565b945050606087013592506200141460808801620010eb565b91506200142460a08801620010eb565b90509295509295509295565b600080600080600060a086880312156200144957600080fd5b85356001600160401b03808211156200146157600080fd5b6200146f89838a0162000f80565b965060208801359150808211156200148657600080fd5b6200149489838a0162000f80565b95506040880135915080821115620014ab57600080fd5b50620014ba8882890162000f80565b93505060608601359150620014d260808701620010eb565b90509295509295909350565b60008060408385031215620014f257600080fd5b50508035926020909101359150565b6020808252825160c083830152805160e084018190526000929182019083906101008601905b80831015620015525783516001600160a01b0316825292840192600192909201919084019062001527565b508387015160408701526040870151606087015260608701516080870152608087015160a087015260a087015160c08701528094505050505092915050565b600060208284031215620015a457600080fd5b620007bf82620010eb565b600080600060608486031215620015c557600080fd5b620015d084620010eb565b92506020840135915060408401356001600160401b03811115620015f357600080fd5b620016018682870162000f80565b9150509250925092565b600080600080608085870312156200162257600080fd5b84356001600160401b03808211156200163a57600080fd5b620016488883890162000f80565b955060208701359150808211156200165f57600080fd5b6200166d8883890162000f80565b945060408701359150808211156200168457600080fd5b50620016938782880162000f80565b949793965093946060013593505050565b600060208284031215620016b757600080fd5b5035919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115620007845762000784620016d4565b81810381811115620007845762000784620016d4565b6000826200173457634e487b7160e01b600052601260045260246000fd5b500490565b60005b83811015620017565781810151838201526020016200173c565b50506000910152565b600081518084526200177981602086016020860162001739565b601f01601f19169290920160200192915050565b828152604060208201526000620017a860408301846200175f565b949350505050565b85815260a060208201526000620017cb60a08301876200175f565b8281036040840152620017df81876200175f565b90508281036060840152620017f581866200175f565b9150508260808301529695505050505050565b60c0815260006200181d60c08301896200175f565b82810360208401526200183181896200175f565b905082810360408401526200184781886200175f565b606084019690965250506001600160a01b039283166080820152911660a0909101529392505050565b600083516200188481846020880162001739565b8351908301906200189a81836020880162001739565b01949350505050565b60609290921b6001600160601b031916825260148201526034019056fe60a06040523480156200001157600080fd5b50604051620033ac380380620033ac8339810160408190526200003491620002e3565b8585600062000044838262000433565b50600162000053828262000433565b50506001600b55506001600160a01b038216620000b75760405162461bcd60e51b815260206004820152601560248201527f496e76616c69642061646d696e2061646472657373000000000000000000000060448201526064015b60405180910390fd5b6001600160a01b0381166200010f5760405162461bcd60e51b815260206004820152601760248201527f496e76616c6964206469616d6f6e6420616464726573730000000000000000006044820152606401620000ae565b600c6200011d858262000433565b50600e839055600f805460ff19169055600060108190556001600160a01b0382166080526200014d908362000159565b505050505050620004ff565b6000828152600a602090815260408083206001600160a01b038516845290915290205460ff16620001fa576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620001b93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126200022657600080fd5b81516001600160401b0380821115620002435762000243620001fe565b604051601f8301601f19908116603f011681019082821181831017156200026e576200026e620001fe565b81604052838152602092508660208588010111156200028c57600080fd5b600091505b83821015620002b0578582018301518183018401529082019062000291565b6000602085830101528094505050505092915050565b80516001600160a01b0381168114620002de57600080fd5b919050565b60008060008060008060c08789031215620002fd57600080fd5b86516001600160401b03808211156200031557600080fd5b620003238a838b0162000214565b975060208901519150808211156200033a57600080fd5b620003488a838b0162000214565b965060408901519150808211156200035f57600080fd5b506200036e89828a0162000214565b945050606087015192506200038660808801620002c6565b91506200039660a08801620002c6565b90509295509295509295565b600181811c90821680620003b757607f821691505b602082108103620003d857634e487b7160e01b600052602260045260246000fd5b50919050565b601f8211156200042e576000816000526020600020601f850160051c81016020861015620004095750805b601f850160051c820191505b818110156200042a5782815560010162000415565b5050505b505050565b81516001600160401b038111156200044f576200044f620001fe565b6200046781620004608454620003a2565b84620003de565b602080601f8311600181146200049f5760008415620004865750858301515b600019600386901b1c1916600185901b1785556200042a565b600085815260208120601f198616915b82811015620004d057888601518255948401946001909101908401620004af565b5085821015620004ef5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b608051612e8a620005226000396000818161046001526116cf0152612e8a6000f3fe6080604052600436106101cb5760003560e01c806301ffc9a7146101d057806306fdde0314610205578063081812fc14610227578063095ea7b31461025f5780630f4161aa1461028157806318160ddd1461029b578063205c2878146102ba57806323b872dd146102da578063248a9ca3146102fa5780632f2ff15d1461031a5780632f745c591461033a57806330781e521461035a57806336568abe1461036d5780633ccfd60b1461038d57806342842e0e146103a25780634f6ccce7146103c257806355f804b3146103e25780636352211e1461040257806367ed2c57146104225780636817c76c146104385780636a60c3b71461044e5780636a627842146104825780636c0360eb146104a257806370a08231146104b7578063818668d7146104d75780638462151c146104f757806391d148541461052457806395d89b4114610544578063a217fddf14610559578063a22cb4651461056e578063b3d7acf91461058e578063b88d4fde146105a1578063c3f8cba6146105c1578063c87b56dd146105d7578063d0def521146105f7578063d547741f14610617578063d5abeb0114610637578063e985e9c51461064d578063f4a0a5281461066d578063f4c2d8901461068d575b600080fd5b3480156101dc57600080fd5b506101f06101eb366004612453565b6106ad565b60405190151581526020015b60405180910390f35b34801561021157600080fd5b5061021a6106cd565b6040516101fc91906124c0565b34801561023357600080fd5b506102476102423660046124d3565b61075f565b6040516001600160a01b0390911681526020016101fc565b34801561026b57600080fd5b5061027f61027a366004612501565b610786565b005b34801561028d57600080fd5b50600f546101f09060ff1681565b3480156102a757600080fd5b506008545b6040519081526020016101fc565b3480156102c657600080fd5b5061027f6102d5366004612501565b6108a0565b3480156102e657600080fd5b5061027f6102f536600461252d565b6108ec565b34801561030657600080fd5b506102ac6103153660046124d3565b61091d565b34801561032657600080fd5b5061027f61033536600461256e565b610932565b34801561034657600080fd5b506102ac610355366004612501565b61094e565b61027f6103683660046126f9565b6109e4565b34801561037957600080fd5b5061027f61038836600461256e565b610aa8565b34801561039957600080fd5b5061027f610b26565b3480156103ae57600080fd5b5061027f6103bd36600461252d565b610b63565b3480156103ce57600080fd5b506102ac6103dd3660046124d3565b610b7e565b3480156103ee57600080fd5b5061027f6103fd36600461272d565b610c11565b34801561040e57600080fd5b5061024761041d3660046124d3565b610c28565b34801561042e57600080fd5b506102ac60115481565b34801561044457600080fd5b506102ac60105481565b34801561045a57600080fd5b506102477f000000000000000000000000000000000000000000000000000000000000000081565b34801561048e57600080fd5b5061027f61049d366004612761565b610c5c565b3480156104ae57600080fd5b5061021a610c80565b3480156104c357600080fd5b506102ac6104d2366004612761565b610c8f565b3480156104e357600080fd5b5061027f6104f2366004612793565b610d15565b34801561050357600080fd5b50610517610512366004612761565b610d69565b6040516101fc91906127ae565b34801561053057600080fd5b506101f061053f36600461256e565b610e00565b34801561055057600080fd5b5061021a610e2b565b34801561056557600080fd5b506102ac600081565b34801561057a57600080fd5b5061027f6105893660046127f2565b610e3a565b61027f61059c36600461272d565b610e45565b3480156105ad57600080fd5b5061027f6105bc366004612827565b610ed7565b3480156105cd57600080fd5b506102ac60125481565b3480156105e357600080fd5b5061021a6105f23660046124d3565b610f0f565b34801561060357600080fd5b5061027f6106123660046128a6565b610fe5565b34801561062357600080fd5b5061027f61063236600461256e565b610ffa565b34801561064357600080fd5b506102ac600e5481565b34801561065957600080fd5b506101f06106683660046128f5565b611016565b34801561067957600080fd5b5061027f6106883660046124d3565b611044565b34801561069957600080fd5b5061027f6106a8366004612923565b611084565b60006106b8826110ce565b806106c757506106c7826110f3565b92915050565b6060600080546106dc90612968565b80601f016020809104026020016040519081016040528092919081815260200182805461070890612968565b80156107555780601f1061072a57610100808354040283529160200191610755565b820191906000526020600020905b81548152906001019060200180831161073857829003601f168201915b5050505050905090565b600061076a82611118565b506000908152600460205260409020546001600160a01b031690565b600061079182610c28565b9050806001600160a01b0316836001600160a01b0316036108035760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061081f575061081f8133611016565b6108915760405162461bcd60e51b815260206004820152603d60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c00000060648201526084016107fa565b61089b838361113d565b505050565b60006108ab816111ab565b6108b68383476111b5565b826001600160a01b0316600080516020612e5e833981519152836040516108df91815260200190565b60405180910390a2505050565b6108f633826112c2565b6109125760405162461bcd60e51b81526004016107fa9061299c565b61089b838383611321565b6000908152600a602052604090206001015490565b61093b8261091d565b610944816111ab565b61089b8383611480565b600061095983610c8f565b82106109bb5760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b60648201526084016107fa565b506001600160a01b03919091166000908152600660209081526040808320938352929052205490565b6109ec611506565b600f54610a089060ff1682610a0060085490565b600e5461155f565b6000610a148251611601565b905060005b8251811015610a4d57610a4533848381518110610a3857610a386129e9565b6020026020010151611661565b600101610a19565b506012548251604080519283526020830191909152810182905233907f560fa9ae3608118640273d6206fa6cf31330295b13c4f2075f942c50b6eb63969060600160405180910390a25043601255610aa56001600b55565b50565b6001600160a01b0381163314610b185760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084016107fa565b610b22828261173f565b5050565b6000610b31816111ab565b47610b3c33826117a6565b6040518181523390600080516020612e5e8339815191529060200160405180910390a25050565b61089b83838360405180602001604052806000815250610ed7565b6000610b8960085490565b8210610bec5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b60648201526084016107fa565b60088281548110610bff57610bff6129e9565b90600052602060002001549050919050565b6000610c1c816111ab565b600c61089b8382612a4f565b600080610c3483611860565b90506001600160a01b0381166106c75760405162461bcd60e51b81526004016107fa90612b0e565b6000610c67816111ab565b610b228260405180602001604052806000815250611661565b6060600c80546106dc90612968565b60006001600160a01b038216610cf95760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b60648201526084016107fa565b506001600160a01b031660009081526003602052604090205490565b6000610d20816111ab565b600f805460ff19168315159081179091556040519081527fa81e445dac2343503dc87e4663774817434721db7d985310a6959766e6d4480e906020015b60405180910390a15050565b60606000610d7683610c8f565b90506000816001600160401b03811115610d9257610d9261259e565b604051908082528060200260200182016040528015610dbb578160200160208202803683370190505b50905060005b82811015610df857610dd3858261094e565b828281518110610de557610de56129e9565b6020908102919091010152600101610dc1565b509392505050565b6000918252600a602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6060600180546106dc90612968565b610b2233838361187b565b610e4d611506565b600f5460ff16610e6f5760405162461bcd60e51b81526004016107fa90612b40565b6000610e7b6001611601565b9050610e873383611661565b600854601154604080519182526020820184905233917f1886253aaa3b9944c4a0db093f9a1aa619cbd2b51eebdb7bda362ac0b967c828910160405180910390a35043601155610aa56001600b55565b610ee133836112c2565b610efd5760405162461bcd60e51b81526004016107fa9061299c565b610f0984848484611945565b50505050565b6060610f1a82611118565b6000828152600d602052604081208054610f3390612968565b905011610f4857610f4382611978565b6106c7565b6000828152600d602052604090208054610f6190612968565b80601f0160208091040260200160405190810160405280929190818152602001828054610f8d90612968565b8015610fda5780601f10610faf57610100808354040283529160200191610fda565b820191906000526020600020905b815481529060010190602001808311610fbd57829003601f168201915b505050505092915050565b6000610ff0816111ab565b61089b8383611661565b6110038261091d565b61100c816111ab565b61089b838361173f565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b600061104f816111ab565b60108290556040518281527f525b762709cc2a983aec5ccdfd807a061f993c91090b5bcd7da92ca254976aaa90602001610d5d565b600061108f816111ab565b6110a48261109c60085490565b600e546119df565b60005b8251811015610f09576110c684848381518110610a3857610a386129e9565b6001016110a7565b60006001600160e01b0319821663780e9d6360e01b14806106c757506106c782611a4b565b60006001600160e01b03198216637965db0b60e01b14806106c757506106c7826110ce565b61112181611a9b565b610aa55760405162461bcd60e51b81526004016107fa90612b0e565b600081815260046020526040902080546001600160a01b0319166001600160a01b038416908117909155819061117282610c28565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b610aa58133611ab8565b6001600160a01b0383166111ff5760405162461bcd60e51b8152602060048201526011602482015270125b9d985b1a59081c9958da5c1a595b9d607a1b60448201526064016107fa565b8082111561124f5760405162461bcd60e51b815260206004820152601d60248201527f496e73756666696369656e7420636f6e74726163742062616c616e636500000060448201526064016107fa565b6000836001600160a01b03168360405160006040518083038185875af1925050503d806000811461129c576040519150601f19603f3d011682016040523d82523d6000602084013e6112a1565b606091505b5050905080610f095760405162461bcd60e51b81526004016107fa90612b71565b6000806112ce83610c28565b9050806001600160a01b0316846001600160a01b031614806112f557506112f58185611016565b806113195750836001600160a01b031661130e8461075f565b6001600160a01b0316145b949350505050565b826001600160a01b031661133482610c28565b6001600160a01b03161461135a5760405162461bcd60e51b81526004016107fa90612b9c565b6001600160a01b0382166113bc5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b60648201526084016107fa565b6113c98383836001611b11565b826001600160a01b03166113dc82610c28565b6001600160a01b0316146114025760405162461bcd60e51b81526004016107fa90612b9c565b600081815260046020908152604080832080546001600160a01b03199081169091556001600160a01b038781168086526003855283862080546000190190559087168086528386208054600101905586865260029094528285208054909216841790915590518493600080516020612e3e83398151915291a4505050565b61148a8282610e00565b610b22576000828152600a602090815260408083206001600160a01b03851684529091529020805460ff191660011790556114c23390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6002600b54036115585760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016107fa565b6002600b55565b8361157c5760405162461bcd60e51b81526004016107fa90612b40565b8251806115cb5760405162461bcd60e51b815260206004820152601f60248201527f5175616e74697479206d7573742062652067726561746572207468616e20300060448201526064016107fa565b81156115fa57816115dc8285612bf7565b11156115fa5760405162461bcd60e51b81526004016107fa90612c0a565b5050505050565b600061160f60105483611b1d565b9050600061161d8234612c36565b9050801561165b5760405181815233907fe309aa15fd2f6bd8a58603632508694071e7d35e967bdbb827926e429b7ef34d9060200160405180910390a25b50919050565b61167561166d60085490565b600e54611c17565b600061168060085490565b61168b906001612bf7565b90506116978382611c61565b8151156116b8576000818152600d602052604090206116b68382612a4f565b505b60405163b250417160e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b25041719061170890869085908790600401612c49565b600060405180830381600087803b15801561172257600080fd5b505af1158015611736573d6000803e3d6000fd5b50505050505050565b6117498282610e00565b15610b22576000828152600a602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b600081116117ed5760405162461bcd60e51b81526020600482015260146024820152734e6f2066756e647320746f20776974686472617760601b60448201526064016107fa565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461183a576040519150601f19603f3d011682016040523d82523d6000602084013e61183f565b606091505b505090508061089b5760405162461bcd60e51b81526004016107fa90612b71565b6000908152600260205260409020546001600160a01b031690565b816001600160a01b0316836001600160a01b0316036118d85760405162461bcd60e51b815260206004820152601960248201527822a9219b99189d1030b8383937bb32903a379031b0b63632b960391b60448201526064016107fa565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b611950848484611321565b61195c84848484611d6a565b610f095760405162461bcd60e51b81526004016107fa90612c79565b606061198382611118565b600061198d610c80565b905060008151116119ad57604051806020016040528060008152506119d8565b806119b784611e6b565b6040516020016119c8929190612ccb565b6040516020818303038152906040525b9392505050565b825180611a1c5760405162461bcd60e51b815260206004820152600b60248201526a456d70747920617272617960a81b60448201526064016107fa565b8115610f095781611a2d8285612bf7565b1115610f095760405162461bcd60e51b81526004016107fa90612c0a565b60006001600160e01b031982166380ac58cd60e01b1480611a7c57506001600160e01b03198216635b5e139f60e01b145b806106c757506301ffc9a760e01b6001600160e01b03198316146106c7565b600080611aa783611860565b6001600160a01b0316141592915050565b611ac28282610e00565b610b2257611acf81611efd565b611ada836020611f0f565b604051602001611aeb929190612cfa565b60408051601f198184030181529082905262461bcd60e51b82526107fa916004016124c0565b610f09848484846120aa565b6000611b298284612d69565b905080341015611b725760405162461bcd60e51b8152602060048201526014602482015273125b9cdd59999a58da595b9d081c185e5b595b9d60621b60448201526064016107fa565b6000611b7e8234612c36565b90508015611c1057604051600090339083908381818185875af1925050503d8060008114611bc8576040519150601f19603f3d011682016040523d82523d6000602084013e611bcd565b606091505b5050905080611c0e5760405162461bcd60e51b815260206004820152600d60248201526c1499599d5b990819985a5b1959609a1b60448201526064016107fa565b505b5092915050565b8015610b2257808210610b225760405162461bcd60e51b815260206004820152601260248201527113585e081cdd5c1c1b1e481c995858da195960721b60448201526064016107fa565b6001600160a01b038216611cb75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f206164647265737360448201526064016107fa565b611cc081611a9b565b15611cdd5760405162461bcd60e51b81526004016107fa90612d80565b611ceb600083836001611b11565b611cf481611a9b565b15611d115760405162461bcd60e51b81526004016107fa90612d80565b6001600160a01b038216600081815260036020908152604080832080546001019055848352600290915280822080546001600160a01b031916841790555183929190600080516020612e3e833981519152908290a45050565b60006001600160a01b0384163b15611e6057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611dae903390899088908890600401612db6565b6020604051808303816000875af1925050508015611de9575060408051601f3d908101601f19168201909252611de691810190612df3565b60015b611e46573d808015611e17576040519150601f19603f3d011682016040523d82523d6000602084013e611e1c565b606091505b508051600003611e3e5760405162461bcd60e51b81526004016107fa90612c79565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611319565b506001949350505050565b60606000611e78836121d7565b60010190506000816001600160401b03811115611e9757611e9761259e565b6040519080825280601f01601f191660200182016040528015611ec1576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084611ecb57509392505050565b60606106c76001600160a01b03831660145b60606000611f1e836002612d69565b611f29906002612bf7565b6001600160401b03811115611f4057611f4061259e565b6040519080825280601f01601f191660200182016040528015611f6a576020820181803683370190505b509050600360fc1b81600081518110611f8557611f856129e9565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110611fb457611fb46129e9565b60200101906001600160f81b031916908160001a9053506000611fd8846002612d69565b611fe3906001612bf7565b90505b600181111561205b576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110612017576120176129e9565b1a60f81b82828151811061202d5761202d6129e9565b60200101906001600160f81b031916908160001a90535060049490941c9361205481612e10565b9050611fe6565b5083156119d85760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e7460448201526064016107fa565b60018111156121195760405162461bcd60e51b815260206004820152603560248201527f455243373231456e756d657261626c653a20636f6e7365637574697665207472604482015274185b9cd9995c9cc81b9bdd081cdd5c1c1bdc9d1959605a1b60648201526084016107fa565b816001600160a01b0385166121755761217081600880546000838152600960205260408120829055600182018355919091527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b612198565b836001600160a01b0316856001600160a01b0316146121985761219885826122ad565b6001600160a01b0384166121b4576121af8161234a565b6115fa565b846001600160a01b0316846001600160a01b0316146115fa576115fa84826123f9565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106122165772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6904ee2d6d415b85acef8160201b8310612240576904ee2d6d415b85acef8160201b830492506020015b662386f26fc10000831061225e57662386f26fc10000830492506010015b6305f5e1008310612276576305f5e100830492506008015b612710831061228a57612710830492506004015b6064831061229c576064830492506002015b600a83106106c75760010192915050565b600060016122ba84610c8f565b6122c49190612c36565b600083815260076020526040902054909150808214612317576001600160a01b03841660009081526006602090815260408083208584528252808320548484528184208190558352600790915290208190555b5060009182526007602090815260408084208490556001600160a01b039094168352600681528383209183525290812055565b60085460009061235c90600190612c36565b60008381526009602052604081205460088054939450909284908110612384576123846129e9565b9060005260206000200154905080600883815481106123a5576123a56129e9565b60009182526020808320909101929092558281526009909152604080822084905585825281205560088054806123dd576123dd612e27565b6001900381819060005260206000200160009055905550505050565b600061240483610c8f565b6001600160a01b039093166000908152600660209081526040808320868452825280832085905593825260079052919091209190915550565b6001600160e01b031981168114610aa557600080fd5b60006020828403121561246557600080fd5b81356119d88161243d565b60005b8381101561248b578181015183820152602001612473565b50506000910152565b600081518084526124ac816020860160208601612470565b601f01601f19169290920160200192915050565b6020815260006119d86020830184612494565b6000602082840312156124e557600080fd5b5035919050565b6001600160a01b0381168114610aa557600080fd5b6000806040838503121561251457600080fd5b823561251f816124ec565b946020939093013593505050565b60008060006060848603121561254257600080fd5b833561254d816124ec565b9250602084013561255d816124ec565b929592945050506040919091013590565b6000806040838503121561258157600080fd5b823591506020830135612593816124ec565b809150509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156125dc576125dc61259e565b604052919050565b60006001600160401b038311156125fd576125fd61259e565b612610601f8401601f19166020016125b4565b905082815283838301111561262457600080fd5b828260208301376000602084830101529392505050565b600082601f83011261264c57600080fd5b6119d8838335602085016125e4565b600082601f83011261266c57600080fd5b813560206001600160401b03808311156126885761268861259e565b8260051b6126978382016125b4565b93845285810183019383810190888611156126b157600080fd5b84880192505b858310156126ed578235848111156126cf5760008081fd5b6126dd8a87838c010161263b565b83525091840191908401906126b7565b98975050505050505050565b60006020828403121561270b57600080fd5b81356001600160401b0381111561272157600080fd5b6113198482850161265b565b60006020828403121561273f57600080fd5b81356001600160401b0381111561275557600080fd5b6113198482850161263b565b60006020828403121561277357600080fd5b81356119d8816124ec565b8035801515811461278e57600080fd5b919050565b6000602082840312156127a557600080fd5b6119d88261277e565b6020808252825182820181905260009190848201906040850190845b818110156127e6578351835292840192918401916001016127ca565b50909695505050505050565b6000806040838503121561280557600080fd5b8235612810816124ec565b915061281e6020840161277e565b90509250929050565b6000806000806080858703121561283d57600080fd5b8435612848816124ec565b93506020850135612858816124ec565b92506040850135915060608501356001600160401b0381111561287a57600080fd5b8501601f8101871361288b57600080fd5b61289a878235602084016125e4565b91505092959194509250565b600080604083850312156128b957600080fd5b82356128c4816124ec565b915060208301356001600160401b038111156128df57600080fd5b6128eb8582860161263b565b9150509250929050565b6000806040838503121561290857600080fd5b8235612913816124ec565b91506020830135612593816124ec565b6000806040838503121561293657600080fd5b8235612941816124ec565b915060208301356001600160401b0381111561295c57600080fd5b6128eb8582860161265b565b600181811c9082168061297c57607f821691505b60208210810361165b57634e487b7160e01b600052602260045260246000fd5b6020808252602d908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526c1c881bdc88185c1c1c9bdd9959609a1b606082015260800190565b634e487b7160e01b600052603260045260246000fd5b601f82111561089b576000816000526020600020601f850160051c81016020861015612a285750805b601f850160051c820191505b81811015612a4757828155600101612a34565b505050505050565b81516001600160401b03811115612a6857612a6861259e565b612a7c81612a768454612968565b846129ff565b602080601f831160018114612ab15760008415612a995750858301515b600019600386901b1c1916600185901b178555612a47565b600085815260208120601f198616915b82811015612ae057888601518255948401946001909101908401612ac1565b5085821015612afe5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b602080825260189082015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b604082015260600190565b602080825260179082015276141d589b1a58c81b5a5b9d081a5cc8191a5cd8589b1959604a1b604082015260600190565b60208082526011908201527015da5d1a191c985dd85b0819985a5b1959607a1b604082015260600190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b808201808211156106c7576106c7612be1565b60208082526012908201527145786365656473206d617820737570706c7960701b604082015260600190565b818103818111156106c7576106c7612be1565b60018060a01b0384168152826020820152606060408201526000612c706060830184612494565b95945050505050565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b60008351612cdd818460208801612470565b835190830190612cf1818360208801612470565b01949350505050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b815260008351612d2c816017850160208801612470565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351612d5d816028840160208801612470565b01602801949350505050565b80820281158282048414176106c7576106c7612be1565b6020808252601c908201527b115490cdcc8c4e881d1bdad95b88185b1c9958591e481b5a5b9d195960221b604082015260600190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090612de990830184612494565b9695505050505050565b600060208284031215612e0557600080fd5b81516119d88161243d565b600081612e1f57612e1f612be1565b506000190190565b634e487b7160e01b600052603160045260246000fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5a164736f6c6343000817000aa164736f6c6343000817000a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.