Polygon Sponsored slots available. Book your slot here!
Overview
MATIC Balance
0 MATIC
MATIC Value
$0.00More Info
Private Name Tags
ContractCreator:
Sponsored
Latest 1 from a total of 1 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
0x60806040 | 36307219 | 482 days ago | IN | Create: TraitsProvider | 0 MATIC | 0.11542779 |
Loading...
Loading
Contract Name:
TraitsProvider
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/math/SafeCast.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import {GAME_NFT_CONTRACT_ROLE, GAME_ITEMS_CONTRACT_ROLE, MANAGER_ROLE, GAME_LOGIC_CONTRACT_ROLE} from "./Constants.sol"; import "./libraries/UtilLibrary.sol"; import "./interfaces/ITraitsProvider.sol"; import "./GameRegistryConsumerUpgradeable.sol"; /** @title Holds static and dynamic traits for a given NFT or ERC1155 token type */ contract TraitsProvider is GameRegistryConsumerUpgradeable, ITraitsProvider { using Strings for uint256; /// @notice Meta data for each type of trait and its expected behavior mapping(uint256 => TraitMetadata) private _traitMetadata; /// @notice Mapping of address/tokenId to traits for that token mapping(address => mapping(uint256 => uint256[])) private tokenTraitIds; /// @notice Mapping of address/tokenId/traitId to the datatype that has been set for that trait mapping(address => mapping(uint256 => mapping(uint256 => TraitDataType))) private tokenTraitDataTypes; /// @notice Mapping of address/tokenId/traitId to the abi-encoded bytes value for a trait mapping(address => mapping(uint256 => mapping(uint256 => bytes))) private tokenTraitValue; /** EVENTS **/ /// @notice Emitted when a given trait's metadata has changed event TraitMetadataSet(uint256 indexed traitId); /// @notice Emitted when a token has had it's traits updated. event TraitsUpdated(address tokenContract, uint256 tokenId); /** ERRORS **/ /// @notice TraitMetadata has already been initialized error MetadataAlreadyInitialized(); /// @notice TraitMetadata must have a name error MustSetTraitName(); /// @notice Trait behavior must be a value other than NOT_INITIALIZED error MustSetTraitBehavior(); /// @notice TraitMetadata must have a dataType set error MustSetTraitDataType(); /// @notice When the trait uri generation is passed an invalid datatype error InvalidTraitDataType(TraitDataType dataType); /// @notice String behavior must be immutable or unrestricted error InvalidStringBehavior(); /// @notice Array lengths are either zero or don't match error InvalidArrayLengths(); /// @notice Need non-zero amount error InvalidAmount(); /// @notice Trait behavior does not support incrementing value error NotIncrementable(); /// @notice Trait behavior does not support decrementing value error NotDecrementable(); /// @notice Decrementing below zero error DecrementingBelowZero(); /// @notice Trait has not been initialized to the proper type error DataTypeMismatch(TraitDataType expected, TraitDataType actual); /// @notice tokenContract has not been allowlisted for gameplay error TokenNotAllowlisted(); /// @notice Trait has already been initialized error TraitAlreadyInitialized(); /// @notice TraitMetadata has not been initialized error TraitNotInitialized(); /** SETUP **/ /** Initializer function for upgradeable contract */ function initialize(address gameRegistryAddress) public initializer { __GameRegistryConsumer_init(gameRegistryAddress, ID); } /** EXTERNAL **/ /** * Sets the metadata for the Trait * * @param traitId Id of the trait type to set * @param traitMetadata Metadata of the trait to set */ function setTraitMetadata( uint256 traitId, TraitMetadata calldata traitMetadata ) external onlyRole(MANAGER_ROLE) { // Trait types can only be set once! if (_traitMetadata[traitId].behavior != TraitBehavior.NOT_INITIALIZED) { revert MetadataAlreadyInitialized(); } if (traitMetadata.behavior == TraitBehavior.NOT_INITIALIZED) { revert MustSetTraitBehavior(); } if (bytes(traitMetadata.name).length == 0) { revert MustSetTraitName(); } if (traitMetadata.dataType == TraitDataType.NOT_INITIALIZED) { revert MustSetTraitDataType(); } // Extra behavior check for string datatypes if (traitMetadata.dataType == TraitDataType.STRING) { if ( traitMetadata.behavior != TraitBehavior.UNRESTRICTED && traitMetadata.behavior != TraitBehavior.IMMUTABLE ) { revert InvalidStringBehavior(); } } _traitMetadata[traitId] = traitMetadata; emit TraitMetadataSet(traitId); } /** * Sets the value for the string trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitString( address tokenContract, uint256 tokenId, uint256 traitId, string calldata value ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); _setTraitBytes( tokenContract, tokenId, traitId, abi.encode(value), TraitDataType.STRING ); emit TraitsUpdated(tokenContract, tokenId); } /** * Sets several string traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Id of the token to set traits for * @param traitIds Ids of traits to set * @param values Value of traits to set */ function batchSetTraitString( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, string[] calldata values ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if ( traitIds.length == 0 || traitIds.length != values.length || traitIds.length != tokenIds.length ) { revert InvalidArrayLengths(); } uint256 lastTokenId = 0; for (uint256 idx; idx < traitIds.length; ++idx) { uint256 tokenId = tokenIds[idx]; _setTraitBytes( tokenContract, tokenId, traitIds[idx], abi.encode(values[idx]), TraitDataType.STRING ); // Presumably we will be packing traits for the same token consecutively, so we can only emit one event for when the tokenId changes if (lastTokenId != tokenId) { emit TraitsUpdated(tokenContract, tokenId); lastTokenId = tokenId; } } } /** * Sets the value for the uint256 trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitUint256( address tokenContract, uint256 tokenId, uint256 traitId, uint256 value ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); _setTraitBytes( tokenContract, tokenId, traitId, abi.encode(value), TraitDataType.UINT ); emit TraitsUpdated(tokenContract, tokenId); } /** * Sets several uint256 traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Id of the token to set traits for * @param traitIds Ids of traits to set * @param values Value of traits to set */ function batchSetTraitUint256( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, uint256[] calldata values ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if ( traitIds.length == 0 || traitIds.length != values.length || traitIds.length != tokenIds.length ) { revert InvalidArrayLengths(); } uint256 lastTokenId = 0; for (uint256 idx; idx < traitIds.length; ++idx) { uint256 tokenId = tokenIds[idx]; _setTraitBytes( tokenContract, tokenId, traitIds[idx], abi.encode(values[idx]), TraitDataType.UINT ); // Presumably we will be packing traits for the same token consecutively, so we can only emit one event for when the tokenId changes if (lastTokenId != tokenId) { emit TraitsUpdated(tokenContract, tokenId); lastTokenId = tokenId; } } } /** * Sets the value for the int256 trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitInt256( address tokenContract, uint256 tokenId, uint256 traitId, int256 value ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); _setTraitBytes( tokenContract, tokenId, traitId, abi.encode(value), TraitDataType.INT ); emit TraitsUpdated(tokenContract, tokenId); } /** * Sets several int256 traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Id of the token to set traits for * @param traitIds Ids of traits to set * @param values Value of traits to set */ function batchSetTraitInt256( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, int256[] calldata values ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if ( traitIds.length == 0 || traitIds.length != values.length || traitIds.length != tokenIds.length ) { revert InvalidArrayLengths(); } uint256 lastTokenId = 0; for (uint256 idx; idx < traitIds.length; ++idx) { uint256 tokenId = tokenIds[idx]; _setTraitBytes( tokenContract, tokenId, traitIds[idx], abi.encode(values[idx]), TraitDataType.INT ); // Presumably we will be packing traits for the same token consecutively, so we can only emit one event for when the tokenId changes if (lastTokenId != tokenId) { emit TraitsUpdated(tokenContract, tokenId); lastTokenId = tokenId; } } } /** * Sets the value for the bool trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitBool( address tokenContract, uint256 tokenId, uint256 traitId, bool value ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); _setTraitBytes( tokenContract, tokenId, traitId, abi.encode(value), TraitDataType.BOOL ); emit TraitsUpdated(tokenContract, tokenId); } /** * Sets several bool traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Id of the token to set traits for * @param traitIds Ids of traits to set * @param values Value of traits to set */ function batchSetTraitBool( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, bool[] calldata values ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if ( traitIds.length == 0 || traitIds.length != values.length || traitIds.length != tokenIds.length ) { revert InvalidArrayLengths(); } uint256 lastTokenId = 0; for (uint256 idx; idx < traitIds.length; ++idx) { uint256 tokenId = tokenIds[idx]; _setTraitBytes( tokenContract, tokenId, traitIds[idx], abi.encode(values[idx]), TraitDataType.BOOL ); // Presumably we will be packing traits for the same token consecutively, so we can only emit one event for when the tokenId changes if (lastTokenId != tokenId) { emit TraitsUpdated(tokenContract, tokenId); lastTokenId = tokenId; } } } /** * Increments the trait for a token by the given amount * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param amount Amount to increment trait by */ function incrementTrait( address tokenContract, uint256 tokenId, uint256 traitId, uint256 amount ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if (amount == 0) { revert InvalidAmount(); } TraitMetadata memory traitMetadata = _requireTraitMetadata(traitId); if ( traitMetadata.behavior != TraitBehavior.INCREMENT_ONLY && traitMetadata.behavior != TraitBehavior.UNRESTRICTED ) { revert NotIncrementable(); } // Make sure that the trait wasn't previously initialized to another data type TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if (dataType != traitMetadata.dataType) { revert DataTypeMismatch(traitMetadata.dataType, dataType); } mapping(uint256 => bytes) storage traitValues = tokenTraitValue[ tokenContract ][tokenId]; if (dataType == TraitDataType.UINT) { uint256 newValue = abi.decode(traitValues[traitId], (uint256)) + uint256(amount); traitValues[traitId] = abi.encode(newValue); } else if (dataType == TraitDataType.INT) { int256 newValue = abi.decode(traitValues[traitId], (int256)) + int256(amount); traitValues[traitId] = abi.encode(newValue); } else { revert NotIncrementable(); } emit TraitsUpdated(tokenContract, tokenId); } /** * Decrements the trait for a token by the given amount * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param amount Amount to decrement trait by */ function decrementTrait( address tokenContract, uint256 tokenId, uint256 traitId, uint256 amount ) external override onlyRole(GAME_LOGIC_CONTRACT_ROLE) { _requireAllowlistedTokenContract(tokenContract); if (amount == 0) { revert InvalidAmount(); } TraitMetadata memory traitMetadata = _requireTraitMetadata(traitId); if ( traitMetadata.behavior != TraitBehavior.DECREMENT_ONLY && traitMetadata.behavior != TraitBehavior.UNRESTRICTED ) { revert NotDecrementable(); } TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if (dataType != traitMetadata.dataType) { revert DataTypeMismatch(traitMetadata.dataType, dataType); } mapping(uint256 => bytes) storage traitValues = tokenTraitValue[ tokenContract ][tokenId]; if (dataType == TraitDataType.UINT) { uint256 oldValue = abi.decode(traitValues[traitId], (uint256)); if (amount > oldValue) { revert DecrementingBelowZero(); } uint256 newValue = oldValue - amount; traitValues[traitId] = abi.encode(newValue); } else if (dataType == TraitDataType.INT) { int256 newValue = abi.decode(traitValues[traitId], (int256)) - int256(amount); traitValues[traitId] = abi.encode(newValue); } else { revert NotDecrementable(); } emit TraitsUpdated(tokenContract, tokenId); } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * * @return A struct containing all traits for the token */ function getTraitIds(address tokenContract, uint256 tokenId) external view override returns (uint256[] memory) { return tokenTraitIds[tokenContract][tokenId]; } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Trait value as abi-encoded bytes */ function getTraitBytes( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (bytes memory) { TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if (dataType == TraitDataType.NOT_INITIALIZED) { revert DataTypeMismatch(TraitDataType.INT, dataType); } return tokenTraitValue[tokenContract][tokenId][traitId]; } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Trait value as a int256 */ function getTraitInt256( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (int256) { TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if ( dataType == TraitDataType.STRING || dataType == TraitDataType.NOT_INITIALIZED ) { revert DataTypeMismatch(TraitDataType.INT, dataType); } return abi.decode( tokenTraitValue[tokenContract][tokenId][traitId], (int256) ); } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Trait value as a uint256 */ function getTraitUint256( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (uint256) { return SafeCast.toUint256( this.getTraitInt256(tokenContract, tokenId, traitId) ); } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Trait value as a bool */ function getTraitBool( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (bool) { return this.getTraitInt256(tokenContract, tokenId, traitId) == 1; } /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Trait value as a string */ function getTraitString( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (string memory) { TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if (dataType != TraitDataType.STRING) { revert DataTypeMismatch(TraitDataType.STRING, dataType); } return abi.decode( tokenTraitValue[tokenContract][tokenId][traitId], (string) ); } /** * @param traitId Id of the trait to get metadata for * @return Metadata for the given trait */ function getTraitMetadata(uint256 traitId) external view override returns (TraitMetadata memory) { return _traitMetadata[traitId]; } /** * Returns whether or not the given token has a trait * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Whether or not the token has the trait */ function hasTrait( address tokenContract, uint256 tokenId, uint256 traitId ) external view override returns (bool) { return tokenTraitDataTypes[tokenContract][tokenId][traitId] != TraitDataType.NOT_INITIALIZED; } /** * Generate a tokenURI based on a set of global properties and traits * * @param tokenContract Address of the token contract * @param tokenId Id of the token to generate traits for * * @return base64-encoded fully-formed tokenURI */ function generateTokenURI( address tokenContract, uint256 tokenId, TokenURITrait[] memory extraTraits ) external view returns (string memory) { // Gather all dynamic trait ids uint256[] memory traitIds = this.getTraitIds(tokenContract, tokenId); // Fetch and process dynamic traits for this token TokenURITrait[] memory allTraits = new TokenURITrait[]( traitIds.length + extraTraits.length ); for (uint256 idx; idx < traitIds.length; ++idx) { uint256 traitId = traitIds[idx]; TraitMetadata memory traitMetadata = this.getTraitMetadata(traitId); allTraits[idx].name = traitMetadata.name; allTraits[idx].dataType = traitMetadata.dataType; allTraits[idx].isTopLevelProperty = traitMetadata .isTopLevelProperty; allTraits[idx].value = this.getTraitBytes( tokenContract, tokenId, traitId ); } // Append the extra traits onto the allTraits array for (uint256 idx; idx < extraTraits.length; ++idx) { allTraits[traitIds.length + idx] = extraTraits[idx]; } // Generate JSON strings string memory propertiesJSON = _generatePropertiesJSON(allTraits); string memory attributesJSON = _generateAttributesJSON(allTraits); string memory comma = bytes(propertiesJSON).length > 0 ? "," : ""; string memory metadata = string( abi.encodePacked( "{", propertiesJSON, comma, '"attributes":[', attributesJSON, "]}" ) ); return string( abi.encodePacked( "data:application/json;base64,", Base64.encode(bytes(metadata)) ) ); } /** * @inheritdoc IERC165 */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(ITraitsProvider).interfaceId || interfaceId == type(IERC165).interfaceId; } /** PRIVATE **/ /** * Sets a abi-encoded bytes trait value * @dev It's not recommended to use this function as it doesn't have type safety */ function _setTraitBytes( address tokenContract, uint256 tokenId, uint256 traitId, bytes memory value, TraitDataType encodedType ) private { TraitMetadata memory traitMetadata = _requireTraitMetadata(traitId); if ( encodedType != TraitDataType.NOT_INITIALIZED && traitMetadata.dataType != encodedType ) { revert DataTypeMismatch(traitMetadata.dataType, encodedType); } TraitDataType dataType = tokenTraitDataTypes[tokenContract][tokenId][ traitId ]; if ( dataType != TraitDataType.NOT_INITIALIZED && traitMetadata.behavior != TraitBehavior.UNRESTRICTED ) { revert TraitAlreadyInitialized(); } // Set new trait if (dataType == TraitDataType.NOT_INITIALIZED) { tokenTraitDataTypes[tokenContract][tokenId][traitId] = traitMetadata .dataType; tokenTraitIds[tokenContract][tokenId].push(traitId); } tokenTraitValue[tokenContract][tokenId][traitId] = value; } /** Reverts if the tokenContract is not allowlisted */ function _requireAllowlistedTokenContract(address tokenContract) private view { if ( _hasAccessRole(GAME_NFT_CONTRACT_ROLE, tokenContract) == false && _hasAccessRole(GAME_ITEMS_CONTRACT_ROLE, tokenContract) == false ) { revert TokenNotAllowlisted(); } } /** Reverts if the trait has not been initialized yet */ function _requireTraitMetadata(uint256 traitId) private view returns (TraitMetadata memory) { TraitMetadata memory traitMetadata = _traitMetadata[traitId]; if (traitMetadata.behavior == TraitBehavior.NOT_INITIALIZED) { revert TraitNotInitialized(); } return traitMetadata; } /** INTERNAL **/ function _generatePropertiesJSON(TokenURITrait[] memory allTraits) internal pure returns (string memory) { string memory propertiesJSON = ""; bool isFirstElement = true; for (uint256 idx; idx < allTraits.length; ++idx) { TokenURITrait memory trait = allTraits[idx]; if (trait.isTopLevelProperty == false) { continue; } string memory value = _traitValueToString(trait); string memory comma = isFirstElement ? "" : ","; propertiesJSON = string( abi.encodePacked( propertiesJSON, comma, '"', trait.name, '":', value ) ); isFirstElement = false; } return propertiesJSON; } /** * @param allTraits All of the traits for a given token to use to generate a attributes JSON array * @return a JSON string for all of the attributes for the given token */ function _generateAttributesJSON(TokenURITrait[] memory allTraits) internal view virtual returns (string memory) { string memory finalString = ""; bool isFirstElement = true; for (uint256 idx; idx < allTraits.length; ++idx) { TokenURITrait memory trait = allTraits[idx]; // Skip if its not an attribute type if (trait.isTopLevelProperty == true) { continue; } // Skip including attribute if the string value is empty if ( trait.dataType == TraitDataType.STRING && bytes(abi.decode(trait.value, (string))).length == 0 ) { continue; } string memory json = _attributeJSON(trait); string memory comma = isFirstElement ? "" : ","; finalString = string(abi.encodePacked(finalString, comma, json)); isFirstElement = false; } return finalString; } /** @return Token metadata attribute JSON string */ function _attributeJSON(TokenURITrait memory trait) internal pure returns (string memory) { string memory value = _traitValueToString(trait); return string( abi.encodePacked( '{"trait_type":"', trait.name, '","value":', value, "}" ) ); } /** Converts a trait's numeric or string value into a printable JSON string value */ function _traitValueToString(TokenURITrait memory trait) internal pure returns (string memory) { TraitDataType dataType = trait.dataType; if (dataType == TraitDataType.STRING) { string memory value = abi.decode(trait.value, (string)); return string(abi.encodePacked('"', value, '"')); } else if (dataType == TraitDataType.BOOL) { bool value = abi.decode(trait.value, (bool)); return value ? "true" : "false"; } else if (dataType == TraitDataType.UINT) { uint256 value = abi.decode(trait.value, (uint256)); return value.toString(); } else if (dataType == TraitDataType.INT) { int256 value = abi.decode(trait.value, (int256)); return UtilLibrary.int2str(value); // Convert int256 to string } revert InvalidTraitDataType(trait.dataType); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /** * @title The ERC-2771 Recipient Base Abstract Class - Declarations * * @notice A contract must implement this interface in order to support relayed transaction. * * @notice It is recommended that your contract inherits from the ERC2771Recipient contract. */ abstract contract IERC2771Recipient { /** * :warning: **Warning** :warning: The Forwarder can have a full control over your Recipient. Only trust verified Forwarder. * @param forwarder The address of the Forwarder contract that is being used. * @return isTrustedForwarder `true` if the Forwarder is trusted to forward relayed transactions by this Recipient. */ function isTrustedForwarder(address forwarder) public virtual view returns(bool); /** * @notice Use this method the contract anywhere instead of msg.sender to support relayed transactions. * @return sender The real sender of this call. * For a call that came through the Forwarder the real sender is extracted from the last 20 bytes of the `msg.data`. * Otherwise simply returns `msg.sender`. */ function _msgSender() internal virtual view returns (address); /** * @notice Use this method in the contract instead of `msg.data` when difference matters (hashing, signature, etc.) * @return data The real `msg.data` of this call. * For a call that came through the Forwarder, the real sender address was appended as the last 20 bytes * of the `msg.data` - so this method will strip those 20 bytes off. * Otherwise (if the call was made directly and not through the forwarder) simply returns `msg.data`. */ function _msgData() internal virtual view returns (bytes calldata); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Internal function that returns the initialized version. Returns `_initialized` */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Internal function that returns the initialized version. Returns `_initializing` */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ReentrancyGuardUpgradeable is Initializable { // 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; function __ReentrancyGuard_init() internal onlyInitializing { __ReentrancyGuard_init_unchained(); } function __ReentrancyGuard_init_unchained() internal onlyInitializing { _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 This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _safeTransfer(from, to, tokenId, data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _ownerOf(tokenId) != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory data ) private returns (bool) { if (to.isContract()) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (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) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol) pragma solidity ^0.8.0; /** * @dev Provides a set of functions to operate with Base64 strings. * * _Available since v4.5._ */ library Base64 { /** * @dev Base64 Encoding/Decoding Table */ string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /** * @dev Converts a `bytes` to its Bytes64 `string` representation. */ function encode(bytes memory data) internal pure returns (string memory) { /** * Inspired by Brecht Devos (Brechtpd) implementation - MIT licence * https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol */ if (data.length == 0) return ""; // Loads the table into memory string memory table = _TABLE; // Encoding takes 3 bytes chunks of binary data from `bytes` data parameter // and split into 4 numbers of 6 bits. // The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up // - `data.length + 2` -> Round up // - `/ 3` -> Number of 3-bytes chunks // - `4 *` -> 4 characters for each chunk string memory result = new string(4 * ((data.length + 2) / 3)); /// @solidity memory-safe-assembly assembly { // Prepare the lookup table (skip the first "length" byte) let tablePtr := add(table, 1) // Prepare result pointer, jump over length let resultPtr := add(result, 32) // Run over the input, 3 bytes at a time for { let dataPtr := data let endPtr := add(data, mload(data)) } lt(dataPtr, endPtr) { } { // Advance 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // To write each character, shift the 3 bytes (18 bits) chunk // 4 times in blocks of 6 bits for each character (18, 12, 6, 0) // and apply logical AND with 0x3F which is the number of // the previous character in the ASCII table prior to the Base64 Table // The result is then added to the table to get the character to write, // and finally write it in the result pointer but with a left shift // of 256 (1 byte) - 8 (1 ASCII char) = 248 bits mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F)))) resultPtr := add(resultPtr, 1) // Advance mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F)))) resultPtr := add(resultPtr, 1) // Advance } // When data `bytes` is not exactly 3 bytes long // it is padded with `=` characters at the end switch mod(mload(data), 3) case 1 { mstore8(sub(resultPtr, 1), 0x3d) mstore8(sub(resultPtr, 2), 0x3d) } case 2 { mstore8(sub(resultPtr, 1), 0x3d) } } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; // Used for calculating decimal-point percentages (10000 = 100%) uint256 constant PERCENTAGE_RANGE = 10000; // Pauser Role - Can pause the game bytes32 constant PAUSER_ROLE = keccak256("PAUSER_ROLE"); // Minter Role - Can mint items, NFTs, and ERC20 currency bytes32 constant MINTER_ROLE = keccak256("MINTER_ROLE"); // Manager Role - Can manage the shop, loot tables, and other game data bytes32 constant MANAGER_ROLE = keccak256("MANAGER_ROLE"); // Game Logic Contract - Contract that executes game logic and accesses other systems bytes32 constant GAME_LOGIC_CONTRACT_ROLE = keccak256( "GAME_LOGIC_CONTRACT_ROLE" ); // Game Currency Contract - Allowlisted currency ERC20 contract bytes32 constant GAME_CURRENCY_CONTRACT_ROLE = keccak256( "GAME_CURRENCY_CONTRACT_ROLE" ); // Game NFT Contract - Allowlisted game NFT ERC721 contract bytes32 constant GAME_NFT_CONTRACT_ROLE = keccak256("GAME_NFT_CONTRACT_ROLE"); // Game Items Contract - Allowlist game items ERC1155 contract bytes32 constant GAME_ITEMS_CONTRACT_ROLE = keccak256( "GAME_ITEMS_CONTRACT_ROLE" ); // Depositor role - used by Polygon bridge to mint on child chain bytes32 constant DEPOSITOR_ROLE = keccak256("DEPOSITOR_ROLE"); // Randomizer role - Used by the randomizer contract to callback bytes32 constant RANDOMIZER_ROLE = keccak256("RANDOMIZER_ROLE"); // Trusted forwarder role - Used by meta transactions to verify trusted forwader(s) bytes32 constant TRUSTED_FORWARDER_ROLE = keccak256("TRUSTED_FORWARDER_ROLE"); // ===== // All of the possible traits in the system // ===== // Generation of a token uint256 constant GENERATION_TRAIT_ID = uint256(keccak256("generation")); // XP for a token uint256 constant XP_TRAIT_ID = uint256(keccak256("xp")); // Current level of a token uint256 constant LEVEL_TRAIT_ID = uint256(keccak256("level")); // Whether or not a token is a pirate uint256 constant IS_PIRATE_TRAIT_ID = uint256(keccak256("is_pirate")); // Rank of the ship uint256 constant SHIP_RANK_TRAIT_ID = uint256(keccak256("ship_rank")); // Image hash of token's image, used for verifiable / fair drops uint256 constant IMAGE_HASH_TRAIT_ID = uint256(keccak256("image_hash")); // Name of a token uint256 constant NAME_TRAIT_ID = uint256(keccak256("name_trait")); // Description of a token uint256 constant DESCRIPTION_TRAIT_ID = uint256(keccak256("description_trait")); // General rarity for a token (corresponds to IGameRarity) uint256 constant RARITY_TRAIT_ID = uint256(keccak256("rarity")); // The character's affinity for a specific element uint256 constant ELEMENTAL_AFFINITY_TRAIT_ID = uint256( keccak256("elemental_affinity") ); // The character's dice rolls uint256 constant DICE_ROLL_1_TRAIT_ID = uint256(keccak256("dice_roll_1")); uint256 constant DICE_ROLL_2_TRAIT_ID = uint256(keccak256("dice_roll_2")); // The character's star sign (astrology) uint256 constant STAR_SIGN_TRAIT_ID = uint256(keccak256("star_sign")); // Image for the token uint256 constant IMAGE_TRAIT_ID = uint256(keccak256("image_trait")); // How much energy the token provides if used uint256 constant ENERGY_PROVIDED_TRAIT_ID = uint256( keccak256("energy_provided") ); // Whether a given token is soulbound, meaning it is unable to be transferred uint256 constant SOULBOUND_TRAIT_ID = uint256(keccak256("soulbound")); // ------ // Avatar Profile Picture related traits // If an avatar is a 1 of 1, this is their only trait uint256 constant PROFILE_IS_LEGENDARY_TRAIT_ID = uint256( keccak256("profile_is_legendary") ); // Avatar's archetype -- possible values: Human (including Druid, Mage, Berserker, Crusty), Robot, Animal, Zombie, Vampire, Ghost uint256 constant PROFILE_CHARACTER_TYPE = uint256( keccak256("profile_character_type") ); // Avatar's profile picture's background image uint256 constant PROFILE_BACKGROUND_TRAIT_ID = uint256( keccak256("profile_background") ); // Avatar's eye style uint256 constant PROFILE_EYES_TRAIT_ID = uint256(keccak256("profile_eyes")); // Avatar's facial hair type uint256 constant PROFILE_FACIAL_HAIR_TRAIT_ID = uint256( keccak256("profile_facial_hair") ); // Avatar's hair style uint256 constant PROFILE_HAIR_TRAIT_ID = uint256(keccak256("profile_hair")); // Avatar's skin color uint256 constant PROFILE_SKIN_TRAIT_ID = uint256(keccak256("profile_skin")); // Avatar's coat color uint256 constant PROFILE_COAT_TRAIT_ID = uint256(keccak256("profile_coat")); // Avatar's earring(s) type uint256 constant PROFILE_EARRING_TRAIT_ID = uint256( keccak256("profile_facial_hair") ); // Avatar's eye covering uint256 constant PROFILE_EYE_COVERING_TRAIT_ID = uint256( keccak256("profile_eye_covering") ); // Avatar's headwear uint256 constant PROFILE_HEADWEAR_TRAIT_ID = uint256( keccak256("profile_headwear") ); // Avatar's (Mages only) gem color uint256 constant PROFILE_MAGE_GEM_TRAIT_ID = uint256( keccak256("profile_mage_gem") );
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@opengsn/contracts/src/interfaces/IERC2771Recipient.sol"; import {PERCENTAGE_RANGE, TRUSTED_FORWARDER_ROLE} from "./Constants.sol"; import {ISystem} from "./interfaces/ISystem.sol"; import {ITraitsProvider, ID as TRAITS_PROVIDER_ID} from "./interfaces/ITraitsProvider.sol"; import {ILockingSystem, ID as LOCKING_SYSTEM_ID} from "./locking/ILockingSystem.sol"; import {IRandomizer, IRandomizerCallback, ID as RANDOMIZER_ID} from "./randomizer/IRandomizer.sol"; import {ILootSystem, ID as LOOT_SYSTEM_ID} from "./loot/ILootSystem.sol"; import "./interfaces/IGameRegistry.sol"; /** @title Contract that lets a child contract access the GameRegistry contract */ abstract contract GameRegistryConsumerUpgradeable is OwnableUpgradeable, ReentrancyGuardUpgradeable, IERC2771Recipient, IRandomizerCallback, ISystem { /// @notice Whether or not the contract is paused bool private _paused; /// @notice Reference to the game registry that this contract belongs to IGameRegistry private _gameRegistry; /// @notice Id for the system/component uint256 private _id; /** EVENTS **/ /// @dev Emitted when the pause is triggered by `account`. event Paused(address account); /// @dev Emitted when the pause is lifted by `account`. event Unpaused(address account); /** ERRORS **/ /// @notice Not authorized to perform action error MissingRole(address account, bytes32 expectedRole); /** MODIFIERS **/ /// @notice Modifier to verify a user has the appropriate role to call a given function modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** ERRORS **/ /// @notice Error if the game registry specified is invalid error InvalidGameRegistry(); /** SETUP **/ /** * Initializer for this upgradeable contract * * @param gameRegistryAddress Address of the GameRegistry contract * @param id Id of the system/component */ function __GameRegistryConsumer_init( address gameRegistryAddress, uint256 id ) internal onlyInitializing { __Ownable_init(); __ReentrancyGuard_init(); _gameRegistry = IGameRegistry(gameRegistryAddress); if (gameRegistryAddress == address(0)) { revert InvalidGameRegistry(); } _paused = true; _id = id; } /** @return ID for this system */ function getId() public view override returns (uint256) { return _id; } /** * Pause/Unpause the contract * * @param shouldPause Whether or pause or unpause */ function setPaused(bool shouldPause) external onlyOwner { if (shouldPause) { _pause(); } else { _unpause(); } } /** * @dev Returns true if the contract OR the GameRegistry is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused || _gameRegistry.paused(); } /** * Sets the GameRegistry contract address for this contract * * @param gameRegistryAddress Address for the GameRegistry contract */ function setGameRegistry(address gameRegistryAddress) external onlyOwner { _gameRegistry = IGameRegistry(gameRegistryAddress); if (gameRegistryAddress == address(0)) { revert InvalidGameRegistry(); } } /** @return GameRegistry contract for this contract */ function getGameRegistry() external view returns (IGameRegistry) { return _gameRegistry; } /// @inheritdoc IERC2771Recipient function isTrustedForwarder(address forwarder) public view virtual override(IERC2771Recipient) returns (bool) { return address(_gameRegistry) != address(0) && _hasAccessRole(TRUSTED_FORWARDER_ROLE, forwarder); } /** * Callback for when a random number request has returned with random words * * @param requestId Id of the request * @param randomWords Random words */ function fulfillRandomWordsCallback( uint256 requestId, uint256[] memory randomWords ) external virtual override { // Do nothing by default } /** INTERNAL **/ /** * @dev Returns `true` if `account` has been granted `role`. */ function _hasAccessRole(bytes32 role, address account) internal view returns (bool) { return _gameRegistry.hasAccessRole(role, account); } /** * @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 { if (!_gameRegistry.hasAccessRole(role, account)) { revert MissingRole(account, role); } } /** Returns the traits provider for this contract */ function _traitsProvider() internal view returns (ITraitsProvider) { return ITraitsProvider(_getSystem(TRAITS_PROVIDER_ID)); } /** @return Interface to the LockingSystem */ function _lockingSystem() internal view returns (ILockingSystem) { return ILockingSystem(_gameRegistry.getSystem(LOCKING_SYSTEM_ID)); } /** @return Interface to the LootSystem */ function _lootSystem() internal view returns (ILootSystem) { return ILootSystem(_gameRegistry.getSystem(LOOT_SYSTEM_ID)); } /** @return Interface to the Randomizer */ function _randomizer() internal view returns (IRandomizer) { return IRandomizer(_gameRegistry.getSystem(RANDOMIZER_ID)); } /** @return Address for a given system */ function _getSystem(uint256 systemId) internal view returns (address) { return _gameRegistry.getSystem(systemId); } /** * Requests randomness from the game's Randomizer contract * * @param numWords Number of words to request from the VRF * * @return Id of the randomness request */ function _requestRandomWords(uint32 numWords) internal returns (uint256) { return _randomizer().requestRandomWords( IRandomizerCallback(this), numWords ); } /** * Returns the Player address for the Operator account * @param operatorAccount address of the Operator account to retrieve the player for */ function _getPlayerAccount(address operatorAccount) internal view returns (address playerAccount) { return _gameRegistry.getPlayerAccount(operatorAccount); } /// @inheritdoc IERC2771Recipient function _msgSender() internal view virtual override(ContextUpgradeable, IERC2771Recipient) returns (address ret) { if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) { assembly { ret := shr(96, calldataload(sub(calldatasize(), 20))) } } else { ret = msg.sender; } } /// @inheritdoc IERC2771Recipient function _msgData() internal view virtual override(ContextUpgradeable, IERC2771Recipient) returns (bytes calldata ret) { if (msg.data.length >= 20 && isTrustedForwarder(msg.sender)) { return msg.data[0:msg.data.length - 20]; } else { return msg.data; } } /** PAUSABLE **/ /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual { require(_paused == false, "Pausable: not paused"); _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual { require(_paused == true, "Pausable: not paused"); _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; // @title Interface the game's ACL / Management Layer interface IGameRegistry is IERC165 { /** * @dev Returns `true` if `account` has been granted `role`. */ function hasAccessRole(bytes32 role, address account) external view returns (bool); /** @return Whether or not the registry is paused */ function paused() external view returns (bool); /** * Registers a system by id * * @param systemId Id of the system * @param systemAddress Address of the system contract */ function registerSystem(uint256 systemId, address systemAddress) external; /** @return System based on an id */ function getSystem(uint256 systemId) external view returns (address); /** @return Authorized Player account for an address * @param operatorAddress Address of the Operator account */ function getPlayerAccount(address operatorAddress) external view returns (address); }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /** * Defines a system the game engine */ interface ISystem { /** @return The ID for the system. Ex: a uint256 casted keccak256 hash */ function getId() external view returns (uint256); }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; uint256 constant ID = uint256(keccak256("game.piratenation.traitsprovider")); // Enum describing how the trait can be modified enum TraitBehavior { NOT_INITIALIZED, // Trait has not been initialized UNRESTRICTED, // Trait can be changed unrestricted IMMUTABLE, // Trait can only be set once and then never changed INCREMENT_ONLY, // Trait can only be incremented DECREMENT_ONLY // Trait can only be decremented } // Type of data to allow in the trait enum TraitDataType { NOT_INITIALIZED, // Trait has not been initialized INT, // int256 data type UINT, // uint128 data type BOOL, // bool data type STRING // string data type } // Holds metadata for a given trait type struct TraitMetadata { // Name of the trait, used in tokenURIs string name; // How the trait can be modified TraitBehavior behavior; // Trait type TraitDataType dataType; // Whether or not the trait is a top-level property and should not be in the attribute array bool isTopLevelProperty; } // Used to pass traits around for URI generation struct TokenURITrait { string name; bytes value; TraitDataType dataType; bool isTopLevelProperty; } /** @title Provides a set of traits to a set of ERC721/ERC1155 contracts */ interface ITraitsProvider is IERC165 { /** * Sets the value for the string trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitString( address tokenContract, uint256 tokenId, uint256 traitId, string calldata value ) external; /** * Sets several string traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Ids of the token to set traits for * @param traitIds Ids of traits to set * @param values Values of traits to set */ function batchSetTraitString( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, string[] calldata values ) external; /** * Sets the value for the uint256 trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitUint256( address tokenContract, uint256 tokenId, uint256 traitId, uint256 value ) external; /** * Sets several uint256 traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Ids of the token to set traits for * @param traitIds Ids of traits to set * @param values Values of traits to set */ function batchSetTraitUint256( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, uint256[] calldata values ) external; /** * Sets the value for the int256 trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitInt256( address tokenContract, uint256 tokenId, uint256 traitId, int256 value ) external; /** * Sets several int256 traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Ids of the token to set traits for * @param traitIds Ids of traits to set * @param values Values of traits to set */ function batchSetTraitInt256( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, int256[] calldata values ) external; /** * Sets the value for the bool trait of a token, also checks to make sure trait can be modified * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param value New value for the given trait */ function setTraitBool( address tokenContract, uint256 tokenId, uint256 traitId, bool value ) external; /** * Sets several bool traits for a given token * * @param tokenContract Address of the token's contract * @param tokenIds Ids of the token to set traits for * @param traitIds Ids of traits to set * @param values Values of traits to set */ function batchSetTraitBool( address tokenContract, uint256[] calldata tokenIds, uint256[] calldata traitIds, bool[] calldata values ) external; /** * Increments the trait for a token by the given amount * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param amount Amount to increment trait by */ function incrementTrait( address tokenContract, uint256 tokenId, uint256 traitId, uint256 amount ) external; /** * Decrements the trait for a token by the given amount * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to modify * @param amount Amount to decrement trait by */ function decrementTrait( address tokenContract, uint256 tokenId, uint256 traitId, uint256 amount ) external; /** * Returns the trait data for a given token * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * * @return A struct containing all traits for the token */ function getTraitIds(address tokenContract, uint256 tokenId) external view returns (uint256[] memory); /** * Retrieves a raw abi-encoded byte data for the given trait * * @param tokenContract Token contract (ERC721 or ERC1155) * @param tokenId Id of the NFT or token type * @param traitId Id of the trait to retrieve * * @return The value of the trait if it exists, reverts if the trait has not been set or is of a different type. */ function getTraitBytes( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (bytes memory); /** * Retrieves a int256 trait for the given token * * @param tokenContract Token contract (ERC721 or ERC1155) * @param tokenId Id of the NFT or token type * @param traitId Id of the trait to retrieve * * @return The value of the trait if it exists, reverts if the trait has not been set or is of a different type. */ function getTraitInt256( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (int256); /** * Retrieves a uint256 trait for the given token * * @param tokenContract Token contract (ERC721 or ERC1155) * @param tokenId Id of the NFT or token type * @param traitId Id of the trait to retrieve * * @return The value of the trait if it exists, reverts if the trait has not been set or is of a different type. */ function getTraitUint256( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (uint256); /** * Retrieves a bool trait for the given token * * @param tokenContract Token contract (ERC721 or ERC1155) * @param tokenId Id of the NFT or token type * @param traitId Id of the trait to retrieve * * @return The value of the trait if it exists, reverts if the trait has not been set or is of a different type. */ function getTraitBool( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (bool); /** * Retrieves a string trait for the given token * * @param tokenContract Token contract (ERC721 or ERC1155) * @param tokenId Id of the NFT or token type * @param traitId Id of the trait to retrieve * * @return The value of the trait if it exists, reverts if the trait has not been set or is of a different type. */ function getTraitString( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (string memory); /** * Returns whether or not the given token has a trait * * @param tokenContract Address of the token's contract * @param tokenId NFT tokenId or ERC1155 token type id * @param traitId Id of the trait to retrieve * * @return Whether or not the token has the trait */ function hasTrait( address tokenContract, uint256 tokenId, uint256 traitId ) external view returns (bool); /** * @param traitId Id of the trait to get metadata for * @return Metadata for the given trait */ function getTraitMetadata(uint256 traitId) external view returns (TraitMetadata memory); /** * Generate a tokenURI based on a set of global properties and traits * * @param tokenContract Address of the token contract * @param tokenId Id of the token to generate traits for * * @return base64-encoded fully-formed tokenURI */ function generateTokenURI( address tokenContract, uint256 tokenId, TokenURITrait[] memory extraTraits ) external view returns (string memory); }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; /** @title Common utility functions for the game **/ library UtilLibrary { /** @return Convert an int256 to a string */ function int2str(int256 value) internal pure returns (string memory) { // Adapted from OpenZepplin Strings.sol if (value == 0) { return "0"; } bool negative = value < 0; uint256 unsignedValue = uint256(negative ? -value : value); uint256 temp = unsignedValue; uint256 digits = negative ? 1 : 0; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (unsignedValue != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(unsignedValue % 10))); unsignedValue /= 10; } if (negative) { buffer[0] = "-"; } return string(buffer); } }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; uint256 constant ID = uint256(keccak256("game.piratenation.lockingsystem")); /// @title Interface for the LockingSystem that allows tokens to be locked by the game to prevent transfer interface ILockingSystem is IERC165 { /** * Whether or not an NFT is locked * * @param tokenContract Token contract address * @param tokenId Id of the token */ function isNFTLocked(address tokenContract, uint256 tokenId) external view returns (bool); /** * Amount of token locked in the system by a given owner * * @param account Token owner * @param tokenContract Token contract address * @param tokenId Id of the token * * @return Number of tokens locked */ function itemAmountLocked( address account, address tokenContract, uint256 tokenId ) external view returns (uint256); /** * Amount of tokens available for unlock * * @param account Token owner * @param tokenContract Token contract address * @param tokenId Id of the token * * @return Number of tokens locked */ function itemAmountUnlocked( address account, address tokenContract, uint256 tokenId ) external view returns (uint256); /** * Whether or not the given items can be transferred * * @param account Token owner * @param tokenContract Token contract address * @param ids Ids of the tokens * @param amounts Amounts of the tokens * * @return Whether or not the given items can be transferred */ function canTransferItems( address account, address tokenContract, uint256[] memory ids, uint256[] memory amounts ) external view returns (bool); /** * Lets the game add a reservation to a given NFT, this prevents the NFT from being unlocked * * @param tokenContract Token contract address * @param tokenId Token id to reserve * @param exclusive Whether or not the reservation is exclusive. Exclusive reservations prevent other reservations from using the tokens by removing them from the pool. * @param data Data determined by the reserver, can be used to identify the source of the reservation for display in UI */ function addNFTReservation( address tokenContract, uint256 tokenId, bool exclusive, uint32 data ) external returns (uint32); /** * Lets the game remove a reservation from a given token * * @param tokenContract Token contract * @param tokenId Id of the token * @param reservationId Id of the reservation to remove */ function removeNFTReservation( address tokenContract, uint256 tokenId, uint32 reservationId ) external; /** * Lets the game add a reservation to a given token, this prevents the token from being unlocked * * @param account Owner of the token to reserver * @param tokenContract Token contract address * @param tokenId Token id to reserve * @param amount Number of tokens to reserve (1 for NFTs, >=1 for ERC1155) * @param exclusive Whether or not the reservation is exclusive. Exclusive reservations prevent other reservations from using the tokens by removing them from the pool. * @param data Data determined by the reserver, can be used to identify the source of the reservation for display in UI */ function addItemReservation( address account, address tokenContract, uint256 tokenId, uint256 amount, bool exclusive, uint32 data ) external returns (uint32); /** * Lets the game remove a reservation from a given token * * @param account Owner to remove reservation from * @param tokenContract Token contract * @param tokenId Id of the token * @param reservationId Id of the reservation to remove */ function removeItemReservation( address account, address tokenContract, uint256 tokenId, uint32 reservationId ) external; }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; uint256 constant ID = uint256(keccak256("game.piratenation.lootsystem")); /// @title Interface for the LootSystem that gives player loot (tokens, XP, etc) for playing the game interface ILootSystem is IERC165 { // Type of loot enum LootType { UNDEFINED, ERC20, ERC721, ERC1155, LOOT_TABLE } // Individual loot to grant struct Loot { // Type of fulfillment (ERC721, ERC1155, ERC20, LOOT_TABLE) LootType lootType; // Contract to grant tokens from address tokenContract; // Id of the token to grant (ERC1155/LOOT TABLE types only) uint256 lootId; // Amount of token to grant (XP, ERC20, ERC1155) uint256 amount; } /** * Grants the given user loot(s), calls VRF to ensure it's truly random * * @param to Address to grant loot to * @param loots Loots to grant */ function grantLoot(address to, Loot[] calldata loots) external; /** * Grants the given user loot(s), calls VRF to ensure it's truly random * * @param to Address to grant loot to * @param loots Loots to grant * @param randomWord Optional random word to skip VRF callback if we already have words generated / are in a VRF callback */ function grantLootWithRandomWord( address to, Loot[] calldata loots, uint256 randomWord ) external; /** * Validate that loots are properly formed. Reverts if the loots are not valid * * @param loots Loots to validate * @return needsVRF Whether or not the loots specified require VRF to generate */ function validateLoots(Loot[] calldata loots) external view returns (bool needsVRF); }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import {IRandomizerCallback} from "./IRandomizerCallback.sol"; uint256 constant ID = uint256(keccak256("game.piratenation.randomizer")); interface IRandomizer is IERC165 { /** * Starts a VRF random number request * * @param callbackAddress Address to callback with the random numbers * @param numWords Number of words to request from VRF * * @return requestId for the random number, will be passed to the callback contract */ function requestRandomWords( IRandomizerCallback callbackAddress, uint32 numWords ) external returns (uint256); }
// SPDX-License-Identifier: MIT LICENSE pragma solidity ^0.8.9; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; interface IRandomizerCallback { /** * Callback for when the Chainlink request returns * * @param requestId Id of the random word request * @param randomWords Random words that were generated by the VRF */ function fulfillRandomWordsCallback( uint256 requestId, uint256[] memory randomWords ) external; }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"enum TraitDataType","name":"expected","type":"uint8"},{"internalType":"enum TraitDataType","name":"actual","type":"uint8"}],"name":"DataTypeMismatch","type":"error"},{"inputs":[],"name":"DecrementingBelowZero","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidArrayLengths","type":"error"},{"inputs":[],"name":"InvalidGameRegistry","type":"error"},{"inputs":[],"name":"InvalidStringBehavior","type":"error"},{"inputs":[{"internalType":"enum TraitDataType","name":"dataType","type":"uint8"}],"name":"InvalidTraitDataType","type":"error"},{"inputs":[],"name":"MetadataAlreadyInitialized","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"expectedRole","type":"bytes32"}],"name":"MissingRole","type":"error"},{"inputs":[],"name":"MustSetTraitBehavior","type":"error"},{"inputs":[],"name":"MustSetTraitDataType","type":"error"},{"inputs":[],"name":"MustSetTraitName","type":"error"},{"inputs":[],"name":"NotDecrementable","type":"error"},{"inputs":[],"name":"NotIncrementable","type":"error"},{"inputs":[],"name":"TokenNotAllowlisted","type":"error"},{"inputs":[],"name":"TraitAlreadyInitialized","type":"error"},{"inputs":[],"name":"TraitNotInitialized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"TraitMetadataSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenContract","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TraitsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"traitIds","type":"uint256[]"},{"internalType":"bool[]","name":"values","type":"bool[]"}],"name":"batchSetTraitBool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"traitIds","type":"uint256[]"},{"internalType":"int256[]","name":"values","type":"int256[]"}],"name":"batchSetTraitInt256","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"traitIds","type":"uint256[]"},{"internalType":"string[]","name":"values","type":"string[]"}],"name":"batchSetTraitString","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"traitIds","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"batchSetTraitUint256","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"decrementTrait","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"requestId","type":"uint256"},{"internalType":"uint256[]","name":"randomWords","type":"uint256[]"}],"name":"fulfillRandomWordsCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"bytes","name":"value","type":"bytes"},{"internalType":"enum TraitDataType","name":"dataType","type":"uint8"},{"internalType":"bool","name":"isTopLevelProperty","type":"bool"}],"internalType":"struct TokenURITrait[]","name":"extraTraits","type":"tuple[]"}],"name":"generateTokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getGameRegistry","outputs":[{"internalType":"contract IGameRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitBool","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitBytes","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTraitIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitInt256","outputs":[{"internalType":"int256","name":"","type":"int256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitMetadata","outputs":[{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"enum TraitBehavior","name":"behavior","type":"uint8"},{"internalType":"enum TraitDataType","name":"dataType","type":"uint8"},{"internalType":"bool","name":"isTopLevelProperty","type":"bool"}],"internalType":"struct TraitMetadata","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitString","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"getTraitUint256","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"}],"name":"hasTrait","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"incrementTrait","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gameRegistryAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"gameRegistryAddress","type":"address"}],"name":"setGameRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"shouldPause","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setTraitBool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"int256","name":"value","type":"int256"}],"name":"setTraitInt256","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"traitId","type":"uint256"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"enum TraitBehavior","name":"behavior","type":"uint8"},{"internalType":"enum TraitDataType","name":"dataType","type":"uint8"},{"internalType":"bool","name":"isTopLevelProperty","type":"bool"}],"internalType":"struct TraitMetadata","name":"traitMetadata","type":"tuple"}],"name":"setTraitMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"string","name":"value","type":"string"}],"name":"setTraitString","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenContract","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"traitId","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"setTraitUint256","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506144a2806100206000396000f3fe608060405234801561001057600080fd5b50600436106101f05760003560e01c80636c055bc51161010f578063c4d66de8116100a2578063e22e02f811610071578063e22e02f814610445578063ed022ebd14610458578063f1c134241461046e578063f2fde38b1461048157600080fd5b8063c4d66de8146103ec578063d1bfc2af146103ff578063d25ba1431461041f578063dd898b2f1461043257600080fd5b80638aebebec116100de5780638aebebec1461038e5780638da5cb5b146103a15780639b9a15b3146103c6578063a16d95f3146103d957600080fd5b80636c055bc51461034d5780636e76c8f414610360578063715018a6146103735780637d4ec3b31461037b57600080fd5b80632d1856ef11610187578063572b6c0511610156578063572b6c051461030a57806358bf4d3e1461031d5780635c975abb1461033d5780635d1ca6311461034557600080fd5b80632d1856ef146102b157806339050c91146102c45780634239abe4146102d757806344307286146102f757600080fd5b806316c38b3c116101c357806316c38b3c146102655780631b7709e1146102785780631d0795a51461028b578063283b8f321461029e57600080fd5b806301ffc9a7146101f557806306c1cb911461021d57806309a43b9b146102315780630b3f2a6314610244575b600080fd5b610208610203366004613323565b610494565b60405190151581526020015b60405180910390f35b61022f61022b3660046133de565b5050565b005b61022f61023f36600461349b565b6104cb565b6102576102523660046134d4565b61055a565b604051908152602001610214565b61022f610273366004613520565b6105e6565b61022f610286366004613588565b610607565b61022f610299366004613632565b61072b565b61022f6102ac366004613588565b610780565b61022f6102bf36600461367a565b6108a6565b6102086102d23660046134d4565b610aa9565b6102ea6102e53660046134d4565b610b2d565b6040516102149190613723565b6102576103053660046134d4565b610c5e565b610208610318366004613736565b610db1565b61033061032b366004613751565b610df8565b604051610214919061377b565b610208610e6d565b609854610257565b61022f61035b36600461349b565b610ef8565b6102ea61036e3660046134d4565b611285565b61022f6113b5565b61022f61038936600461349b565b6113c9565b61022f61039c3660046137bf565b61141c565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610214565b6102086103d43660046134d4565b6114a7565b61022f6103e7366004613588565b6114f4565b61022f6103fa366004613736565b611616565b61041261040d366004613852565b611749565b604051610214919061389f565b6102ea61042d366004613995565b611883565b61022f610440366004613736565b611c63565b61022f610453366004613588565b611cae565b60975461010090046001600160a01b03166103ae565b61022f61047c36600461349b565b611dc6565b61022f61048f366004613736565b61213c565b60006001600160e01b03198216639449f45d60e01b14806104c557506001600160e01b031982166301ffc9a760e01b145b92915050565b60008051602061442d8339815191526104eb816104e66121b2565b6121e0565b6104f485612289565b6105238585858560405160200161050d91815260200190565b6040516020818303038152906040526001612305565b604080516001600160a01b03871681526020810186905260008051602061444d833981519152910160405180910390a15050505050565b604051632218394360e11b81526001600160a01b038416600482015260248101839052604481018290526000906105dc903090634430728690606401602060405180830381865afa1580156105b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d79190613aed565b6124e3565b90505b9392505050565b6105ee612539565b80156105ff576105fc6125b2565b50565b6105fc61264f565b60008051602061442d833981519152610622816104e66121b2565b61062b88612289565b8315806106385750838214155b806106435750838614155b156106615760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f57600089898381811061068157610681613b06565b9050602002013590506106d38b828a8a868181106106a1576106a1613b06565b905060200201358989878181106106ba576106ba613b06565b9050602002013560405160200161050d91815260200190565b80831461070e57604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061071881613b32565b9050610665565b50505050505050505050565b60008051602061442d833981519152610746816104e66121b2565b61074f85612289565b6105238585858560405160200161076a911515815260200190565b6040516020818303038152906040526003612305565b60008051602061442d83398151915261079b816104e66121b2565b6107a488612289565b8315806107b15750838214155b806107bc5750838614155b156107da5760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f5760008989838181106107fa576107fa613b06565b90506020020135905061085a8b828a8a8681811061081a5761081a613b06565b9050602002013589898781811061083357610833613b06565b90506020020160208101906108489190613520565b6040805191151560208301520161076a565b80831461089557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061089f81613b32565b90506107de565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b086108d3816104e66121b2565b60008381526099602052604081206001015460ff1660048111156108f9576108f961386b565b14610917576040516330f0c20f60e11b815260040160405180910390fd5b60006109296040840160208501613b4b565b600481111561093a5761093a61386b565b0361095857604051631fa4f72760e21b815260040160405180910390fd5b6109628280613b68565b905060000361098457604051632a05aa3160e21b815260040160405180910390fd5b60006109966060840160408501613b4b565b60048111156109a7576109a761386b565b036109c557604051634c2d2bc360e01b815260040160405180910390fd5b60046109d76060840160408501613b4b565b60048111156109e8576109e861386b565b03610a5d5760016109ff6040840160208501613b4b565b6004811115610a1057610a1061386b565b14158015610a3f57506002610a2b6040840160208501613b4b565b6004811115610a3c57610a3c61386b565b14155b15610a5d57604051633b31f3dd60e21b815260040160405180910390fd5b60008381526099602052604090208290610a778282613c8e565b505060405183907f23dda45fb7d791f876a0edcc3f30a4f048972a9d2b1d339fafa0395d0e9af77e90600090a2505050565b604051632218394360e11b81526001600160a01b038416600482015260248101839052604481018290526000903090634430728690606401602060405180830381865afa158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190613aed565b600114949350505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915281205460609160ff90911690816004811115610b7457610b7461386b565b03610ba0576001816040516303221c9b60e11b8152600401610b97929190613dd2565b60405180910390fd5b6001600160a01b0385166000908152609c60209081526040808320878452825280832086845290915290208054610bd690613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054610c0290613bae565b8015610c4f5780601f10610c2457610100808354040283529160200191610c4f565b820191906000526020600020905b815481529060010190602001808311610c3257829003601f168201915b50505050509150509392505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915281205460ff166004816004811115610ca157610ca161386b565b1480610cbe57506000816004811115610cbc57610cbc61386b565b145b15610ce1576001816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0385166000908152609c60209081526040808320878452825280832086845290915290208054610d1790613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054610d4390613bae565b8015610d905780601f10610d6557610100808354040283529160200191610d90565b820191906000526020600020905b815481529060010190602001808311610d7357829003601f168201915b5050505050806020019051810190610da89190613aed565b95945050505050565b60975460009061010090046001600160a01b0316158015906104c557506104c57fd3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d2836126d0565b6001600160a01b0382166000908152609a60209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015610e6057602002820191906000526020600020905b815481526020019060010190808311610e4c575b5050505050905092915050565b60975460009060ff1680610ef35750609760019054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ecf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef39190613df8565b905090565b60008051602061442d833981519152610f13816104e66121b2565b610f1c85612289565b81600003610f3d5760405163162908e360e11b815260040160405180910390fd5b6000610f488461274b565b9050600381602001516004811115610f6257610f6261386b565b14158015610f865750600181602001516004811115610f8357610f8361386b565b14155b15610fa457604051632d5d3f5360e11b815260040160405180910390fd5b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915290819020549082015160ff909116906004811115610fed57610fed61386b565b816004811115610fff57610fff61386b565b14611025578160400151816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0387166000908152609c602090815260408083208984529091529020600282600481111561105c5761105c61386b565b03611162576000868152602082905260408120805487919061107d90613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546110a990613bae565b80156110f65780601f106110cb576101008083540402835291602001916110f6565b820191906000526020600020905b8154815290600101906020018083116110d957829003601f168201915b505050505080602001905181019061110e9190613aed565b6111189190613e15565b90508060405160200161112d91815260200190565b60408051601f1981840301815291815260008981526020858152919020825161115b93919290910190613246565b505061124b565b60018260048111156111765761117661386b565b03611232576000868152602082905260408120805487919061119790613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546111c390613bae565b80156112105780601f106111e557610100808354040283529160200191611210565b820191906000526020600020905b8154815290600101906020018083116111f357829003601f168201915b50505050508060200190518101906112289190613aed565b6111189190613e2d565b604051632d5d3f5360e11b815260040160405180910390fd5b604080516001600160a01b038a1681526020810189905260008051602061444d833981519152910160405180910390a15050505050505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915290205460609060ff1660048160048111156112cb576112cb61386b565b146112ee576004816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0385166000908152609c6020908152604080832087845282528083208684529091529020805461132490613bae565b80601f016020809104026020016040519081016040528092919081815260200182805461135090613bae565b801561139d5780601f106113725761010080835404028352916020019161139d565b820191906000526020600020905b81548152906001019060200180831161138057829003601f168201915b5050505050806020019051810190610da89190613ebe565b6113bd612539565b6113c760006128b6565b565b60008051602061442d8339815191526113e4816104e66121b2565b6113ed85612289565b6105238585858560405160200161140691815260200190565b6040516020818303038152906040526002612305565b60008051602061442d833981519152611437816104e66121b2565b61144086612289565b61146f8686868686604051602001611459929190613ef2565b6040516020818303038152906040526004612305565b604080516001600160a01b03881681526020810187905260008051602061444d833981519152910160405180910390a1505050505050565b6000806001600160a01b0385166000908152609b60209081526040808320878452825280832086845290915290205460ff1660048111156114ea576114ea61386b565b1415949350505050565b60008051602061442d83398151915261150f816104e66121b2565b61151888612289565b8315806115255750838214155b806115305750838614155b1561154e5760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f57600089898381811061156e5761156e613b06565b9050602002013590506115ca8b828a8a8681811061158e5761158e613b06565b905060200201358989878181106115a7576115a7613b06565b90506020028101906115b99190613b68565b604051602001611459929190613ef2565b80831461160557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061160f81613b32565b9050611552565b600054610100900460ff16158080156116365750600054600160ff909116105b806116505750303b158015611650575060005460ff166001145b6116b35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b97565b6000805460ff1916600117905580156116d6576000805461ff0019166101001790555b611700827f01f158cde3348caf657c186dba8f4f8ad98b974273df8754bfbbcf30386dabba612908565b801561022b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6117516132c6565b6000828152609960205260409081902081516080810190925280548290829061177990613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546117a590613bae565b80156117f25780601f106117c7576101008083540402835291602001916117f2565b820191906000526020600020905b8154815290600101906020018083116117d557829003601f168201915b5050509183525050600182015460209091019060ff1660048111156118195761181961386b565b600481111561182a5761182a61386b565b81526020016001820160019054906101000a900460ff1660048111156118525761185261386b565b60048111156118635761186361386b565b81526001919091015462010000900460ff16151560209091015292915050565b604051632c5fa69f60e11b81526001600160a01b03841660048201526024810183905260609060009030906358bf4d3e90604401600060405180830381865afa1580156118d4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118fc9190810190613f21565b905060008351825161190e9190613e15565b6001600160401b038111156119255761192561334d565b60405190808252806020026020018201604052801561195e57816020015b61194b6132f0565b8152602001906001900390816119435790505b50905060005b8251811015611b4c57600083828151811061198157611981613b06565b602002602001015190506000306001600160a01b031663d1bfc2af836040518263ffffffff1660e01b81526004016119bb91815260200190565b600060405180830381865afa1580156119d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611a009190810190613fb1565b90508060000151848481518110611a1957611a19613b06565b6020026020010151600001819052508060400151848481518110611a3f57611a3f613b06565b6020026020010151604001906004811115611a5c57611a5c61386b565b90816004811115611a6f57611a6f61386b565b815250508060600151848481518110611a8a57611a8a613b06565b602090810291909101015190151560609091015260405163108e6af960e21b81526001600160a01b038a16600482015260248101899052604481018390523090634239abe490606401600060405180830381865afa158015611af0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b189190810190614060565b848481518110611b2a57611b2a613b06565b602002602001015160200181905250505080611b4590613b32565b9050611964565b5060005b8451811015611bad57848181518110611b6b57611b6b613b06565b602002602001015182828551611b819190613e15565b81518110611b9157611b91613b06565b602002602001018190525080611ba690613b32565b9050611b50565b506000611bb982612995565b90506000611bc683612a7a565b9050600080835111611be75760405180602001604052806000815250611c02565b604051806040016040528060018152602001600b60fa1b8152505b90506000838284604051602001611c1b939291906140a8565b6040516020818303038152906040529050611c3581612b99565b604051602001611c459190614126565b60405160208183030381529060405296505050505050509392505050565b611c6b612539565b60978054610100600160a81b0319166101006001600160a01b038416908102919091179091556105fc5760405163a4b9148160e01b815260040160405180910390fd5b60008051602061442d833981519152611cc9816104e66121b2565b611cd288612289565b831580611cdf5750838214155b80611cea5750838614155b15611d085760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f576000898983818110611d2857611d28613b06565b905060200201359050611d7a8b828a8a86818110611d4857611d48613b06565b90506020020135898987818110611d6157611d61613b06565b9050602002013560405160200161140691815260200190565b808314611db557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b50611dbf81613b32565b9050611d0c565b60008051602061442d833981519152611de1816104e66121b2565b611dea85612289565b81600003611e0b5760405163162908e360e11b815260040160405180910390fd5b6000611e168461274b565b9050600481602001516004811115611e3057611e3061386b565b14158015611e545750600181602001516004811115611e5157611e5161386b565b14155b15611e725760405163179faceb60e21b815260040160405180910390fd5b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915290819020549082015160ff909116906004811115611ebb57611ebb61386b565b816004811115611ecd57611ecd61386b565b14611ef3578160400151816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0387166000908152609c6020908152604080832089845290915290206002826004811115611f2a57611f2a61386b565b036120535760008681526020829052604081208054611f4890613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054611f7490613bae565b8015611fc15780601f10611f9657610100808354040283529160200191611fc1565b820191906000526020600020905b815481529060010190602001808311611fa457829003601f168201915b5050505050806020019051810190611fd99190613aed565b905080861115611ffc5760405163834d35cf60e01b815260040160405180910390fd5b6000612008878361416b565b90508060405160200161201d91815260200190565b60408051601f1981840301815291815260008a81526020868152919020825161204b93919290910190613246565b50505061124b565b60018260048111156120675761206761386b565b03612123576000868152602082905260408120805487919061208890613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546120b490613bae565b80156121015780601f106120d657610100808354040283529160200191612101565b820191906000526020600020905b8154815290600101906020018083116120e457829003601f168201915b50505050508060200190518101906121199190613aed565b6111189190614182565b60405163179faceb60e21b815260040160405180910390fd5b612144612539565b6001600160a01b0381166121a95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b97565b6105fc816128b6565b6000601436108015906121c957506121c933610db1565b156121db575060131936013560601c90565b503390565b6097546040516361b6ebf560e11b8152600481018490526001600160a01b0383811660248301526101009092049091169063c36dd7ea90604401602060405180830381865afa158015612237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225b9190613df8565b61022b5760405162b0d32560e11b81526001600160a01b038216600482015260248101839052604401610b97565b6122b37f5a0afddc7ecb0deaa549d40e18566f1c87c8ed09187b6915eaf44079f37e2aca826126d0565b1580156122e757506122e57ff7b302cb700b7a54f3e005e07d62e8f53814068ec358c9a9e3f0423fa744c6a7826126d0565b155b156105fc5760405163175d4d3160e11b815260040160405180910390fd5b60006123108461274b565b905060008260048111156123265761232661386b565b1415801561235a57508160048111156123415761234161386b565b816040015160048111156123575761235761386b565b14155b15612380578060400151826040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915281205460ff16908160048111156123c2576123c261386b565b141580156123e657506001826020015160048111156123e3576123e361386b565b14155b156124045760405163a20ed46360e01b815260040160405180910390fd5b60008160048111156124185761241861386b565b036124a0576040808301516001600160a01b0389166000908152609b60209081528382208a83528152838220898352905291909120805460ff191660018360048111156124675761246761386b565b02179055506001600160a01b0387166000908152609a602090815260408083208984528252822080546001810182559083529120018590555b6001600160a01b0387166000908152609c602090815260408083208984528252808320888452825290912085516124d992870190613246565b5050505050505050565b6000808212156125355760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610b97565b5090565b6125416121b2565b6001600160a01b031661255c6033546001600160a01b031690565b6001600160a01b0316146113c75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b97565b60975460ff16156125fc5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b97565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126326121b2565b6040516001600160a01b03909116815260200160405180910390a1565b60975460ff16151560011461269d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b97565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6126326121b2565b6097546040516361b6ebf560e11b8152600481018490526001600160a01b0383811660248301526000926101009004169063c36dd7ea90604401602060405180830381865afa158015612727573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105df9190613df8565b6127536132c6565b60008281526099602052604080822081516080810190925280548290829061277a90613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546127a690613bae565b80156127f35780601f106127c8576101008083540402835291602001916127f3565b820191906000526020600020905b8154815290600101906020018083116127d657829003601f168201915b5050509183525050600182015460209091019060ff16600481111561281a5761281a61386b565b600481111561282b5761282b61386b565b81526020016001820160019054906101000a900460ff1660048111156128535761285361386b565b60048111156128645761286461386b565b81526001919091015462010000900460ff16151560209091015290506000816020015160048111156128985761289861386b565b036104c5576040516379a4388160e11b815260040160405180910390fd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661292f5760405162461bcd60e51b8152600401610b97906141c1565b612937612ceb565b61293f612d1a565b60978054610100600160a81b0319166101006001600160a01b038516908102919091179091556129825760405163a4b9148160e01b815260040160405180910390fd5b6097805460ff1916600117905560985550565b60408051602081019091526000808252606091906001905b8451811015612a715760008582815181106129ca576129ca613b06565b602002602001015190508060600151151560001515036129ea5750612a61565b60006129f582612d49565b9050600084612a1d57604051806040016040528060018152602001600b60fa1b815250612a2e565b604051806020016040528060008152505b8351604051919250612a489188918491869060200161420c565b6040516020818303038152906040529550600094505050505b612a6a81613b32565b90506129ad565b50909392505050565b60408051602081019091526000808252606091906001905b8451811015612a71576000858281518110612aaf57612aaf613b06565b60200260200101519050806060015115156001151503612acf5750612b89565b600481604001516004811115612ae757612ae761386b565b148015612b0a57508060200151806020019051810190612b079190613ebe565b51155b15612b155750612b89565b6000612b2082612ecd565b9050600084612b4857604051806040016040528060018152602001600b60fa1b815250612b59565b604051806020016040528060008152505b9050858183604051602001612b7093929190614280565b6040516020818303038152906040529550600094505050505b612b9281613b32565b9050612a92565b60608151600003612bb857505060408051602081019091526000815290565b60006040518060600160405280604081526020016143ed6040913990506000600384516002612be79190613e15565b612bf191906142d9565b612bfc9060046142ed565b6001600160401b03811115612c1357612c1361334d565b6040519080825280601f01601f191660200182016040528015612c3d576020820181803683370190505b509050600182016020820185865187015b80821015612ca9576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250612c4e565b5050600386510660018114612cc55760028114612cd857612ce0565b603d6001830353603d6002830353612ce0565b603d60018303535b509195945050505050565b600054610100900460ff16612d125760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f07565b600054610100900460ff16612d415760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f3e565b60408101516060906004816004811115612d6557612d6561386b565b03612daf5760008360200151806020019051810190612d849190613ebe565b905080604051602001612d97919061430c565b60405160208183030381529060405292505050919050565b6003816004811115612dc357612dc361386b565b03612e325760008360200151806020019051810190612de29190613df8565b905080612e0c576040518060400160405280600581526020016466616c736560d81b815250612e2a565b604051806040016040528060048152602001637472756560e01b8152505b949350505050565b6002816004811115612e4657612e4661386b565b03612e705760008360200151806020019051810190612e659190613aed565b9050612e2a81612f6c565b6001816004811115612e8457612e8461386b565b03612eae5760008360200151806020019051810190612ea39190613aed565b9050612e2a81612ffe565b8260400151604051633cd8199760e11b8152600401610b97919061433a565b60606000612eda83612d49565b8351604051919250612ef091839060200161434d565b604051602081830303815290604052915050919050565b600054610100900460ff16612f2e5760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f396121b2565b6128b6565b600054610100900460ff16612f655760405162461bcd60e51b8152600401610b97906141c1565b6001606555565b60606000612f798361316e565b60010190506000816001600160401b03811115612f9857612f9861334d565b6040519080825280601f01601f191660200182016040528015612fc2576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612fcc57509392505050565b6060816000036130255750506040805180820190915260018152600360fc1b602082015290565b60008083129081613036578361303f565b61303f846143bc565b905080600083613050576000613053565b60015b60ff1690505b811561307f578061306981613b32565b91506130789050600a836142d9565b9150613059565b6000816001600160401b038111156130995761309961334d565b6040519080825280601f01601f1916602001820160405280156130c3576020820181803683370190505b5090505b831561312e576130d860018361416b565b91506130e5600a856143d8565b6130f0906030613e15565b60f81b81838151811061310557613105613b06565b60200101906001600160f81b031916908160001a905350613127600a856142d9565b93506130c7565b841561316457602d60f81b8160008151811061314c5761314c613b06565b60200101906001600160f81b031916908160001a9053505b9695505050505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106131ad5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106131d9576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106131f757662386f26fc10000830492506010015b6305f5e100831061320f576305f5e100830492506008015b612710831061322357612710830492506004015b60648310613235576064830492506002015b600a83106104c55760010192915050565b82805461325290613bae565b90600052602060002090601f01602090048101928261327457600085556132ba565b82601f1061328d57805160ff19168380011785556132ba565b828001600101855582156132ba579182015b828111156132ba57825182559160200191906001019061329f565b5061253592915061330e565b604080516080810190915260608152602081016000815260200160005b8152600060209091015290565b604080516080810182526060808252602082015290810160006132e3565b5b80821115612535576000815560010161330f565b60006020828403121561333557600080fd5b81356001600160e01b0319811681146105df57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156133855761338561334d565b60405290565b604051601f8201601f191681016001600160401b03811182821017156133b3576133b361334d565b604052919050565b60006001600160401b038211156133d4576133d461334d565b5060051b60200190565b600080604083850312156133f157600080fd5b823591506020808401356001600160401b0381111561340f57600080fd5b8401601f8101861361342057600080fd5b803561343361342e826133bb565b61338b565b81815260059190911b8201830190838101908883111561345257600080fd5b928401925b8284101561347057833582529284019290840190613457565b80955050505050509250929050565b80356001600160a01b038116811461349657600080fd5b919050565b600080600080608085870312156134b157600080fd5b6134ba8561347f565b966020860135965060408601359560600135945092505050565b6000806000606084860312156134e957600080fd5b6134f28461347f565b95602085013595506040909401359392505050565b80151581146105fc57600080fd5b803561349681613507565b60006020828403121561353257600080fd5b81356105df81613507565b60008083601f84011261354f57600080fd5b5081356001600160401b0381111561356657600080fd5b6020830191508360208260051b850101111561358157600080fd5b9250929050565b60008060008060008060006080888a0312156135a357600080fd5b6135ac8861347f565b965060208801356001600160401b03808211156135c857600080fd5b6135d48b838c0161353d565b909850965060408a01359150808211156135ed57600080fd5b6135f98b838c0161353d565b909650945060608a013591508082111561361257600080fd5b5061361f8a828b0161353d565b989b979a50959850939692959293505050565b6000806000806080858703121561364857600080fd5b6136518561347f565b93506020850135925060408501359150606085013561366f81613507565b939692955090935050565b6000806040838503121561368d57600080fd5b8235915060208301356001600160401b038111156136aa57600080fd5b8301608081860312156136bc57600080fd5b809150509250929050565b60005b838110156136e25781810151838201526020016136ca565b838111156136f1576000848401525b50505050565b6000815180845261370f8160208601602086016136c7565b601f01601f19169290920160200192915050565b6020815260006105df60208301846136f7565b60006020828403121561374857600080fd5b6105df8261347f565b6000806040838503121561376457600080fd5b61376d8361347f565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156137b357835183529284019291840191600101613797565b50909695505050505050565b6000806000806000608086880312156137d757600080fd5b6137e08661347f565b9450602086013593506040860135925060608601356001600160401b038082111561380a57600080fd5b818801915088601f83011261381e57600080fd5b81358181111561382d57600080fd5b89602082850101111561383f57600080fd5b9699959850939650602001949392505050565b60006020828403121561386457600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600581106105fc57634e487b7160e01b600052602160045260246000fd5b6020815260008251608060208401526138bb60a08401826136f7565b905060208401516138cb81613881565b8060408501525060408401516138e081613881565b806060850152506060840151151560808401528091505092915050565b60006001600160401b038211156139165761391661334d565b50601f01601f191660200190565b600061393261342e846138fd565b905082815283838301111561394657600080fd5b828260208301376000602084830101529392505050565b600082601f83011261396e57600080fd5b6105df83833560208501613924565b600581106105fc57600080fd5b80356134968161397d565b6000806000606084860312156139aa57600080fd5b6139b38461347f565b9250602080850135925060408501356001600160401b03808211156139d757600080fd5b818701915087601f8301126139eb57600080fd5b81356139f961342e826133bb565b81815260059190911b8301840190848101908a831115613a1857600080fd5b8585015b83811015613adc57803585811115613a3357600080fd5b86016080818e03601f19011215613a4957600080fd5b613a51613363565b8882013587811115613a6257600080fd5b8201603f81018f13613a7357600080fd5b613a848f8b83013560408401613924565b825250604082013587811115613a9957600080fd5b613aa78f8b8386010161395d565b8a83015250613ab86060830161398a565b6040820152613ac960808301613515565b6060820152845250918601918601613a1c565b508096505050505050509250925092565b600060208284031215613aff57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613b4457613b44613b1c565b5060010190565b600060208284031215613b5d57600080fd5b81356105df8161397d565b6000808335601e19843603018112613b7f57600080fd5b8301803591506001600160401b03821115613b9957600080fd5b60200191503681900382131561358157600080fd5b600181811c90821680613bc257607f821691505b602082108103613be257634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115613c3257600081815260208120601f850160051c81016020861015613c0f5750805b601f850160051c820191505b81811015613c2e57828155600101613c1b565b5050505b505050565b600081356104c58161397d565b613c4d82613881565b60ff1981541660ff831681178255505050565b613c6982613881565b805461ff008360081b1661ff00198216178255505050565b600081356104c581613507565b8135601e19833603018112613ca257600080fd5b820180356001600160401b03811115613cba57600080fd5b60208136038184011315613ccd57600080fd5b613ce182613cdb8654613bae565b86613be8565b6000601f831160018114613d175760008415613cff57508482018301355b600019600386901b1c1916600185901b178655613d74565b600086815260209020601f19851690835b82811015613d49578785018601358255938501936001909101908501613d28565b5085821015613d685760001960f88760031b161c198585890101351681555b505060018460011b0186555b5050600184019250613d90613d8a828701613c37565b84613c44565b5050613da7613da160408501613c37565b82613c60565b613c32613db660608501613c81565b82805462ff0000191691151560101b62ff000016919091179055565b60408101613ddf84613881565b838252613deb83613881565b8260208301529392505050565b600060208284031215613e0a57600080fd5b81516105df81613507565b60008219821115613e2857613e28613b1c565b500190565b600080821280156001600160ff1b0384900385131615613e4f57613e4f613b1c565b600160ff1b8390038412811615613e6857613e68613b1c565b50500190565b6000613e7c61342e846138fd565b9050828152838383011115613e9057600080fd5b6105df8360208301846136c7565b600082601f830112613eaf57600080fd5b6105df83835160208501613e6e565b600060208284031215613ed057600080fd5b81516001600160401b03811115613ee657600080fd5b612e2a84828501613e9e565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60006020808385031215613f3457600080fd5b82516001600160401b03811115613f4a57600080fd5b8301601f81018513613f5b57600080fd5b8051613f6961342e826133bb565b81815260059190911b82018301908381019087831115613f8857600080fd5b928401925b82841015613fa657835182529284019290840190613f8d565b979650505050505050565b600060208284031215613fc357600080fd5b81516001600160401b0380821115613fda57600080fd5b9083019060808286031215613fee57600080fd5b613ff6613363565b82518281111561400557600080fd5b61401187828601613e9e565b825250602083015191506140248261397d565b8160208201526040830151915061403a8261397d565b8160408201526060830151925061405083613507565b6060810192909252509392505050565b60006020828403121561407257600080fd5b81516001600160401b0381111561408857600080fd5b8201601f8101841361409957600080fd5b612e2a84825160208401613e6e565b607b60f81b8152600084516140c48160018501602089016136c7565b8451908301906140db8160018401602089016136c7565b6d2261747472696275746573223a5b60901b60019290910191820152835161410a81600f8401602088016136c7565b615d7d60f01b600f929091019182015260110195945050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161415e81601d8501602087016136c7565b91909101601d0192915050565b60008282101561417d5761417d613b1c565b500390565b60008083128015600160ff1b8501841216156141a0576141a0613b1c565b6001600160ff1b03840183138116156141bb576141bb613b1c565b50500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000855161421e818460208a016136c7565b855190830190614232818360208a016136c7565b601160f91b9101908152845161424f8160018401602089016136c7565b61111d60f11b6001929091019182015283516142728160038401602088016136c7565b016003019695505050505050565b600084516142928184602089016136c7565b8451908301906142a68183602089016136c7565b84519101906142b98183602088016136c7565b0195945050505050565b634e487b7160e01b600052601260045260246000fd5b6000826142e8576142e86142c3565b500490565b600081600019048311821515161561430757614307613b1c565b500290565b6000601160f91b80835283516143298160018601602088016136c7565b600193019283015250600201919050565b6020810161434783613881565b91905290565b6e3d913a3930b4ba2fba3cb832911d1160891b8152825160009061437881600f8501602088016136c7565b691116113b30b63ab2911d60b11b600f9184019182015283516143a28160198401602088016136c7565b607d60f81b60199290910191820152601a01949350505050565b6000600160ff1b82016143d1576143d1613b1c565b5060000390565b6000826143e7576143e76142c3565b50069056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fd3dc2a3a14cbd0cdbf3069fc3927e48506f271b9dda2c21625b93e6a99d3eb5327e7aef89b6a8015f2f0025e2d80f71db344055da034de9b4c6170a7b8209a51a2646970667358221220b63c540fb0f0e108358b67c49a7135e908b0d71bae5027aea6e9e63f83729dfb64736f6c634300080d0033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101f05760003560e01c80636c055bc51161010f578063c4d66de8116100a2578063e22e02f811610071578063e22e02f814610445578063ed022ebd14610458578063f1c134241461046e578063f2fde38b1461048157600080fd5b8063c4d66de8146103ec578063d1bfc2af146103ff578063d25ba1431461041f578063dd898b2f1461043257600080fd5b80638aebebec116100de5780638aebebec1461038e5780638da5cb5b146103a15780639b9a15b3146103c6578063a16d95f3146103d957600080fd5b80636c055bc51461034d5780636e76c8f414610360578063715018a6146103735780637d4ec3b31461037b57600080fd5b80632d1856ef11610187578063572b6c0511610156578063572b6c051461030a57806358bf4d3e1461031d5780635c975abb1461033d5780635d1ca6311461034557600080fd5b80632d1856ef146102b157806339050c91146102c45780634239abe4146102d757806344307286146102f757600080fd5b806316c38b3c116101c357806316c38b3c146102655780631b7709e1146102785780631d0795a51461028b578063283b8f321461029e57600080fd5b806301ffc9a7146101f557806306c1cb911461021d57806309a43b9b146102315780630b3f2a6314610244575b600080fd5b610208610203366004613323565b610494565b60405190151581526020015b60405180910390f35b61022f61022b3660046133de565b5050565b005b61022f61023f36600461349b565b6104cb565b6102576102523660046134d4565b61055a565b604051908152602001610214565b61022f610273366004613520565b6105e6565b61022f610286366004613588565b610607565b61022f610299366004613632565b61072b565b61022f6102ac366004613588565b610780565b61022f6102bf36600461367a565b6108a6565b6102086102d23660046134d4565b610aa9565b6102ea6102e53660046134d4565b610b2d565b6040516102149190613723565b6102576103053660046134d4565b610c5e565b610208610318366004613736565b610db1565b61033061032b366004613751565b610df8565b604051610214919061377b565b610208610e6d565b609854610257565b61022f61035b36600461349b565b610ef8565b6102ea61036e3660046134d4565b611285565b61022f6113b5565b61022f61038936600461349b565b6113c9565b61022f61039c3660046137bf565b61141c565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610214565b6102086103d43660046134d4565b6114a7565b61022f6103e7366004613588565b6114f4565b61022f6103fa366004613736565b611616565b61041261040d366004613852565b611749565b604051610214919061389f565b6102ea61042d366004613995565b611883565b61022f610440366004613736565b611c63565b61022f610453366004613588565b611cae565b60975461010090046001600160a01b03166103ae565b61022f61047c36600461349b565b611dc6565b61022f61048f366004613736565b61213c565b60006001600160e01b03198216639449f45d60e01b14806104c557506001600160e01b031982166301ffc9a760e01b145b92915050565b60008051602061442d8339815191526104eb816104e66121b2565b6121e0565b6104f485612289565b6105238585858560405160200161050d91815260200190565b6040516020818303038152906040526001612305565b604080516001600160a01b03871681526020810186905260008051602061444d833981519152910160405180910390a15050505050565b604051632218394360e11b81526001600160a01b038416600482015260248101839052604481018290526000906105dc903090634430728690606401602060405180830381865afa1580156105b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105d79190613aed565b6124e3565b90505b9392505050565b6105ee612539565b80156105ff576105fc6125b2565b50565b6105fc61264f565b60008051602061442d833981519152610622816104e66121b2565b61062b88612289565b8315806106385750838214155b806106435750838614155b156106615760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f57600089898381811061068157610681613b06565b9050602002013590506106d38b828a8a868181106106a1576106a1613b06565b905060200201358989878181106106ba576106ba613b06565b9050602002013560405160200161050d91815260200190565b80831461070e57604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061071881613b32565b9050610665565b50505050505050505050565b60008051602061442d833981519152610746816104e66121b2565b61074f85612289565b6105238585858560405160200161076a911515815260200190565b6040516020818303038152906040526003612305565b60008051602061442d83398151915261079b816104e66121b2565b6107a488612289565b8315806107b15750838214155b806107bc5750838614155b156107da5760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f5760008989838181106107fa576107fa613b06565b90506020020135905061085a8b828a8a8681811061081a5761081a613b06565b9050602002013589898781811061083357610833613b06565b90506020020160208101906108489190613520565b6040805191151560208301520161076a565b80831461089557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061089f81613b32565b90506107de565b7f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b086108d3816104e66121b2565b60008381526099602052604081206001015460ff1660048111156108f9576108f961386b565b14610917576040516330f0c20f60e11b815260040160405180910390fd5b60006109296040840160208501613b4b565b600481111561093a5761093a61386b565b0361095857604051631fa4f72760e21b815260040160405180910390fd5b6109628280613b68565b905060000361098457604051632a05aa3160e21b815260040160405180910390fd5b60006109966060840160408501613b4b565b60048111156109a7576109a761386b565b036109c557604051634c2d2bc360e01b815260040160405180910390fd5b60046109d76060840160408501613b4b565b60048111156109e8576109e861386b565b03610a5d5760016109ff6040840160208501613b4b565b6004811115610a1057610a1061386b565b14158015610a3f57506002610a2b6040840160208501613b4b565b6004811115610a3c57610a3c61386b565b14155b15610a5d57604051633b31f3dd60e21b815260040160405180910390fd5b60008381526099602052604090208290610a778282613c8e565b505060405183907f23dda45fb7d791f876a0edcc3f30a4f048972a9d2b1d339fafa0395d0e9af77e90600090a2505050565b604051632218394360e11b81526001600160a01b038416600482015260248101839052604481018290526000903090634430728690606401602060405180830381865afa158015610afe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b229190613aed565b600114949350505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915281205460609160ff90911690816004811115610b7457610b7461386b565b03610ba0576001816040516303221c9b60e11b8152600401610b97929190613dd2565b60405180910390fd5b6001600160a01b0385166000908152609c60209081526040808320878452825280832086845290915290208054610bd690613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054610c0290613bae565b8015610c4f5780601f10610c2457610100808354040283529160200191610c4f565b820191906000526020600020905b815481529060010190602001808311610c3257829003601f168201915b50505050509150509392505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915281205460ff166004816004811115610ca157610ca161386b565b1480610cbe57506000816004811115610cbc57610cbc61386b565b145b15610ce1576001816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0385166000908152609c60209081526040808320878452825280832086845290915290208054610d1790613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054610d4390613bae565b8015610d905780601f10610d6557610100808354040283529160200191610d90565b820191906000526020600020905b815481529060010190602001808311610d7357829003601f168201915b5050505050806020019051810190610da89190613aed565b95945050505050565b60975460009061010090046001600160a01b0316158015906104c557506104c57fd3df22cd6a774f62b0ae21ffd602cc92e7f3390518eee8b33307fc70380da7d2836126d0565b6001600160a01b0382166000908152609a60209081526040808320848452825291829020805483518184028101840190945280845260609392830182828015610e6057602002820191906000526020600020905b815481526020019060010190808311610e4c575b5050505050905092915050565b60975460009060ff1680610ef35750609760019054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ecf573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ef39190613df8565b905090565b60008051602061442d833981519152610f13816104e66121b2565b610f1c85612289565b81600003610f3d5760405163162908e360e11b815260040160405180910390fd5b6000610f488461274b565b9050600381602001516004811115610f6257610f6261386b565b14158015610f865750600181602001516004811115610f8357610f8361386b565b14155b15610fa457604051632d5d3f5360e11b815260040160405180910390fd5b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915290819020549082015160ff909116906004811115610fed57610fed61386b565b816004811115610fff57610fff61386b565b14611025578160400151816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0387166000908152609c602090815260408083208984529091529020600282600481111561105c5761105c61386b565b03611162576000868152602082905260408120805487919061107d90613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546110a990613bae565b80156110f65780601f106110cb576101008083540402835291602001916110f6565b820191906000526020600020905b8154815290600101906020018083116110d957829003601f168201915b505050505080602001905181019061110e9190613aed565b6111189190613e15565b90508060405160200161112d91815260200190565b60408051601f1981840301815291815260008981526020858152919020825161115b93919290910190613246565b505061124b565b60018260048111156111765761117661386b565b03611232576000868152602082905260408120805487919061119790613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546111c390613bae565b80156112105780601f106111e557610100808354040283529160200191611210565b820191906000526020600020905b8154815290600101906020018083116111f357829003601f168201915b50505050508060200190518101906112289190613aed565b6111189190613e2d565b604051632d5d3f5360e11b815260040160405180910390fd5b604080516001600160a01b038a1681526020810189905260008051602061444d833981519152910160405180910390a15050505050505050565b6001600160a01b0383166000908152609b60209081526040808320858452825280832084845290915290205460609060ff1660048160048111156112cb576112cb61386b565b146112ee576004816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0385166000908152609c6020908152604080832087845282528083208684529091529020805461132490613bae565b80601f016020809104026020016040519081016040528092919081815260200182805461135090613bae565b801561139d5780601f106113725761010080835404028352916020019161139d565b820191906000526020600020905b81548152906001019060200180831161138057829003601f168201915b5050505050806020019051810190610da89190613ebe565b6113bd612539565b6113c760006128b6565b565b60008051602061442d8339815191526113e4816104e66121b2565b6113ed85612289565b6105238585858560405160200161140691815260200190565b6040516020818303038152906040526002612305565b60008051602061442d833981519152611437816104e66121b2565b61144086612289565b61146f8686868686604051602001611459929190613ef2565b6040516020818303038152906040526004612305565b604080516001600160a01b03881681526020810187905260008051602061444d833981519152910160405180910390a1505050505050565b6000806001600160a01b0385166000908152609b60209081526040808320878452825280832086845290915290205460ff1660048111156114ea576114ea61386b565b1415949350505050565b60008051602061442d83398151915261150f816104e66121b2565b61151888612289565b8315806115255750838214155b806115305750838614155b1561154e5760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f57600089898381811061156e5761156e613b06565b9050602002013590506115ca8b828a8a8681811061158e5761158e613b06565b905060200201358989878181106115a7576115a7613b06565b90506020028101906115b99190613b68565b604051602001611459929190613ef2565b80831461160557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b5061160f81613b32565b9050611552565b600054610100900460ff16158080156116365750600054600160ff909116105b806116505750303b158015611650575060005460ff166001145b6116b35760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610b97565b6000805460ff1916600117905580156116d6576000805461ff0019166101001790555b611700827f01f158cde3348caf657c186dba8f4f8ad98b974273df8754bfbbcf30386dabba612908565b801561022b576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b6117516132c6565b6000828152609960205260409081902081516080810190925280548290829061177990613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546117a590613bae565b80156117f25780601f106117c7576101008083540402835291602001916117f2565b820191906000526020600020905b8154815290600101906020018083116117d557829003601f168201915b5050509183525050600182015460209091019060ff1660048111156118195761181961386b565b600481111561182a5761182a61386b565b81526020016001820160019054906101000a900460ff1660048111156118525761185261386b565b60048111156118635761186361386b565b81526001919091015462010000900460ff16151560209091015292915050565b604051632c5fa69f60e11b81526001600160a01b03841660048201526024810183905260609060009030906358bf4d3e90604401600060405180830381865afa1580156118d4573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526118fc9190810190613f21565b905060008351825161190e9190613e15565b6001600160401b038111156119255761192561334d565b60405190808252806020026020018201604052801561195e57816020015b61194b6132f0565b8152602001906001900390816119435790505b50905060005b8251811015611b4c57600083828151811061198157611981613b06565b602002602001015190506000306001600160a01b031663d1bfc2af836040518263ffffffff1660e01b81526004016119bb91815260200190565b600060405180830381865afa1580156119d8573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611a009190810190613fb1565b90508060000151848481518110611a1957611a19613b06565b6020026020010151600001819052508060400151848481518110611a3f57611a3f613b06565b6020026020010151604001906004811115611a5c57611a5c61386b565b90816004811115611a6f57611a6f61386b565b815250508060600151848481518110611a8a57611a8a613b06565b602090810291909101015190151560609091015260405163108e6af960e21b81526001600160a01b038a16600482015260248101899052604481018390523090634239abe490606401600060405180830381865afa158015611af0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611b189190810190614060565b848481518110611b2a57611b2a613b06565b602002602001015160200181905250505080611b4590613b32565b9050611964565b5060005b8451811015611bad57848181518110611b6b57611b6b613b06565b602002602001015182828551611b819190613e15565b81518110611b9157611b91613b06565b602002602001018190525080611ba690613b32565b9050611b50565b506000611bb982612995565b90506000611bc683612a7a565b9050600080835111611be75760405180602001604052806000815250611c02565b604051806040016040528060018152602001600b60fa1b8152505b90506000838284604051602001611c1b939291906140a8565b6040516020818303038152906040529050611c3581612b99565b604051602001611c459190614126565b60405160208183030381529060405296505050505050509392505050565b611c6b612539565b60978054610100600160a81b0319166101006001600160a01b038416908102919091179091556105fc5760405163a4b9148160e01b815260040160405180910390fd5b60008051602061442d833981519152611cc9816104e66121b2565b611cd288612289565b831580611cdf5750838214155b80611cea5750838614155b15611d085760405163a9854bc960e01b815260040160405180910390fd5b6000805b8581101561071f576000898983818110611d2857611d28613b06565b905060200201359050611d7a8b828a8a86818110611d4857611d48613b06565b90506020020135898987818110611d6157611d61613b06565b9050602002013560405160200161140691815260200190565b808314611db557604080516001600160a01b038d1681526020810183905260008051602061444d833981519152910160405180910390a18092505b50611dbf81613b32565b9050611d0c565b60008051602061442d833981519152611de1816104e66121b2565b611dea85612289565b81600003611e0b5760405163162908e360e11b815260040160405180910390fd5b6000611e168461274b565b9050600481602001516004811115611e3057611e3061386b565b14158015611e545750600181602001516004811115611e5157611e5161386b565b14155b15611e725760405163179faceb60e21b815260040160405180910390fd5b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915290819020549082015160ff909116906004811115611ebb57611ebb61386b565b816004811115611ecd57611ecd61386b565b14611ef3578160400151816040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0387166000908152609c6020908152604080832089845290915290206002826004811115611f2a57611f2a61386b565b036120535760008681526020829052604081208054611f4890613bae565b80601f0160208091040260200160405190810160405280929190818152602001828054611f7490613bae565b8015611fc15780601f10611f9657610100808354040283529160200191611fc1565b820191906000526020600020905b815481529060010190602001808311611fa457829003601f168201915b5050505050806020019051810190611fd99190613aed565b905080861115611ffc5760405163834d35cf60e01b815260040160405180910390fd5b6000612008878361416b565b90508060405160200161201d91815260200190565b60408051601f1981840301815291815260008a81526020868152919020825161204b93919290910190613246565b50505061124b565b60018260048111156120675761206761386b565b03612123576000868152602082905260408120805487919061208890613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546120b490613bae565b80156121015780601f106120d657610100808354040283529160200191612101565b820191906000526020600020905b8154815290600101906020018083116120e457829003601f168201915b50505050508060200190518101906121199190613aed565b6111189190614182565b60405163179faceb60e21b815260040160405180910390fd5b612144612539565b6001600160a01b0381166121a95760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610b97565b6105fc816128b6565b6000601436108015906121c957506121c933610db1565b156121db575060131936013560601c90565b503390565b6097546040516361b6ebf560e11b8152600481018490526001600160a01b0383811660248301526101009092049091169063c36dd7ea90604401602060405180830381865afa158015612237573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061225b9190613df8565b61022b5760405162b0d32560e11b81526001600160a01b038216600482015260248101839052604401610b97565b6122b37f5a0afddc7ecb0deaa549d40e18566f1c87c8ed09187b6915eaf44079f37e2aca826126d0565b1580156122e757506122e57ff7b302cb700b7a54f3e005e07d62e8f53814068ec358c9a9e3f0423fa744c6a7826126d0565b155b156105fc5760405163175d4d3160e11b815260040160405180910390fd5b60006123108461274b565b905060008260048111156123265761232661386b565b1415801561235a57508160048111156123415761234161386b565b816040015160048111156123575761235761386b565b14155b15612380578060400151826040516303221c9b60e11b8152600401610b97929190613dd2565b6001600160a01b0386166000908152609b60209081526040808320888452825280832087845290915281205460ff16908160048111156123c2576123c261386b565b141580156123e657506001826020015160048111156123e3576123e361386b565b14155b156124045760405163a20ed46360e01b815260040160405180910390fd5b60008160048111156124185761241861386b565b036124a0576040808301516001600160a01b0389166000908152609b60209081528382208a83528152838220898352905291909120805460ff191660018360048111156124675761246761386b565b02179055506001600160a01b0387166000908152609a602090815260408083208984528252822080546001810182559083529120018590555b6001600160a01b0387166000908152609c602090815260408083208984528252808320888452825290912085516124d992870190613246565b5050505050505050565b6000808212156125355760405162461bcd60e51b815260206004820181905260248201527f53616665436173743a2076616c7565206d75737420626520706f7369746976656044820152606401610b97565b5090565b6125416121b2565b6001600160a01b031661255c6033546001600160a01b031690565b6001600160a01b0316146113c75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b97565b60975460ff16156125fc5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b97565b6097805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586126326121b2565b6040516001600160a01b03909116815260200160405180910390a1565b60975460ff16151560011461269d5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610b97565b6097805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6126326121b2565b6097546040516361b6ebf560e11b8152600481018490526001600160a01b0383811660248301526000926101009004169063c36dd7ea90604401602060405180830381865afa158015612727573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105df9190613df8565b6127536132c6565b60008281526099602052604080822081516080810190925280548290829061277a90613bae565b80601f01602080910402602001604051908101604052809291908181526020018280546127a690613bae565b80156127f35780601f106127c8576101008083540402835291602001916127f3565b820191906000526020600020905b8154815290600101906020018083116127d657829003601f168201915b5050509183525050600182015460209091019060ff16600481111561281a5761281a61386b565b600481111561282b5761282b61386b565b81526020016001820160019054906101000a900460ff1660048111156128535761285361386b565b60048111156128645761286461386b565b81526001919091015462010000900460ff16151560209091015290506000816020015160048111156128985761289861386b565b036104c5576040516379a4388160e11b815260040160405180910390fd5b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661292f5760405162461bcd60e51b8152600401610b97906141c1565b612937612ceb565b61293f612d1a565b60978054610100600160a81b0319166101006001600160a01b038516908102919091179091556129825760405163a4b9148160e01b815260040160405180910390fd5b6097805460ff1916600117905560985550565b60408051602081019091526000808252606091906001905b8451811015612a715760008582815181106129ca576129ca613b06565b602002602001015190508060600151151560001515036129ea5750612a61565b60006129f582612d49565b9050600084612a1d57604051806040016040528060018152602001600b60fa1b815250612a2e565b604051806020016040528060008152505b8351604051919250612a489188918491869060200161420c565b6040516020818303038152906040529550600094505050505b612a6a81613b32565b90506129ad565b50909392505050565b60408051602081019091526000808252606091906001905b8451811015612a71576000858281518110612aaf57612aaf613b06565b60200260200101519050806060015115156001151503612acf5750612b89565b600481604001516004811115612ae757612ae761386b565b148015612b0a57508060200151806020019051810190612b079190613ebe565b51155b15612b155750612b89565b6000612b2082612ecd565b9050600084612b4857604051806040016040528060018152602001600b60fa1b815250612b59565b604051806020016040528060008152505b9050858183604051602001612b7093929190614280565b6040516020818303038152906040529550600094505050505b612b9281613b32565b9050612a92565b60608151600003612bb857505060408051602081019091526000815290565b60006040518060600160405280604081526020016143ed6040913990506000600384516002612be79190613e15565b612bf191906142d9565b612bfc9060046142ed565b6001600160401b03811115612c1357612c1361334d565b6040519080825280601f01601f191660200182016040528015612c3d576020820181803683370190505b509050600182016020820185865187015b80821015612ca9576003820191508151603f8160121c168501518453600184019350603f81600c1c168501518453600184019350603f8160061c168501518453600184019350603f8116850151845350600183019250612c4e565b5050600386510660018114612cc55760028114612cd857612ce0565b603d6001830353603d6002830353612ce0565b603d60018303535b509195945050505050565b600054610100900460ff16612d125760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f07565b600054610100900460ff16612d415760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f3e565b60408101516060906004816004811115612d6557612d6561386b565b03612daf5760008360200151806020019051810190612d849190613ebe565b905080604051602001612d97919061430c565b60405160208183030381529060405292505050919050565b6003816004811115612dc357612dc361386b565b03612e325760008360200151806020019051810190612de29190613df8565b905080612e0c576040518060400160405280600581526020016466616c736560d81b815250612e2a565b604051806040016040528060048152602001637472756560e01b8152505b949350505050565b6002816004811115612e4657612e4661386b565b03612e705760008360200151806020019051810190612e659190613aed565b9050612e2a81612f6c565b6001816004811115612e8457612e8461386b565b03612eae5760008360200151806020019051810190612ea39190613aed565b9050612e2a81612ffe565b8260400151604051633cd8199760e11b8152600401610b97919061433a565b60606000612eda83612d49565b8351604051919250612ef091839060200161434d565b604051602081830303815290604052915050919050565b600054610100900460ff16612f2e5760405162461bcd60e51b8152600401610b97906141c1565b6113c7612f396121b2565b6128b6565b600054610100900460ff16612f655760405162461bcd60e51b8152600401610b97906141c1565b6001606555565b60606000612f798361316e565b60010190506000816001600160401b03811115612f9857612f9861334d565b6040519080825280601f01601f191660200182016040528015612fc2576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a8504945084612fcc57509392505050565b6060816000036130255750506040805180820190915260018152600360fc1b602082015290565b60008083129081613036578361303f565b61303f846143bc565b905080600083613050576000613053565b60015b60ff1690505b811561307f578061306981613b32565b91506130789050600a836142d9565b9150613059565b6000816001600160401b038111156130995761309961334d565b6040519080825280601f01601f1916602001820160405280156130c3576020820181803683370190505b5090505b831561312e576130d860018361416b565b91506130e5600a856143d8565b6130f0906030613e15565b60f81b81838151811061310557613105613b06565b60200101906001600160f81b031916908160001a905350613127600a856142d9565b93506130c7565b841561316457602d60f81b8160008151811061314c5761314c613b06565b60200101906001600160f81b031916908160001a9053505b9695505050505050565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106131ad5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef810000000083106131d9576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc1000083106131f757662386f26fc10000830492506010015b6305f5e100831061320f576305f5e100830492506008015b612710831061322357612710830492506004015b60648310613235576064830492506002015b600a83106104c55760010192915050565b82805461325290613bae565b90600052602060002090601f01602090048101928261327457600085556132ba565b82601f1061328d57805160ff19168380011785556132ba565b828001600101855582156132ba579182015b828111156132ba57825182559160200191906001019061329f565b5061253592915061330e565b604080516080810190915260608152602081016000815260200160005b8152600060209091015290565b604080516080810182526060808252602082015290810160006132e3565b5b80821115612535576000815560010161330f565b60006020828403121561333557600080fd5b81356001600160e01b0319811681146105df57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051608081016001600160401b03811182821017156133855761338561334d565b60405290565b604051601f8201601f191681016001600160401b03811182821017156133b3576133b361334d565b604052919050565b60006001600160401b038211156133d4576133d461334d565b5060051b60200190565b600080604083850312156133f157600080fd5b823591506020808401356001600160401b0381111561340f57600080fd5b8401601f8101861361342057600080fd5b803561343361342e826133bb565b61338b565b81815260059190911b8201830190838101908883111561345257600080fd5b928401925b8284101561347057833582529284019290840190613457565b80955050505050509250929050565b80356001600160a01b038116811461349657600080fd5b919050565b600080600080608085870312156134b157600080fd5b6134ba8561347f565b966020860135965060408601359560600135945092505050565b6000806000606084860312156134e957600080fd5b6134f28461347f565b95602085013595506040909401359392505050565b80151581146105fc57600080fd5b803561349681613507565b60006020828403121561353257600080fd5b81356105df81613507565b60008083601f84011261354f57600080fd5b5081356001600160401b0381111561356657600080fd5b6020830191508360208260051b850101111561358157600080fd5b9250929050565b60008060008060008060006080888a0312156135a357600080fd5b6135ac8861347f565b965060208801356001600160401b03808211156135c857600080fd5b6135d48b838c0161353d565b909850965060408a01359150808211156135ed57600080fd5b6135f98b838c0161353d565b909650945060608a013591508082111561361257600080fd5b5061361f8a828b0161353d565b989b979a50959850939692959293505050565b6000806000806080858703121561364857600080fd5b6136518561347f565b93506020850135925060408501359150606085013561366f81613507565b939692955090935050565b6000806040838503121561368d57600080fd5b8235915060208301356001600160401b038111156136aa57600080fd5b8301608081860312156136bc57600080fd5b809150509250929050565b60005b838110156136e25781810151838201526020016136ca565b838111156136f1576000848401525b50505050565b6000815180845261370f8160208601602086016136c7565b601f01601f19169290920160200192915050565b6020815260006105df60208301846136f7565b60006020828403121561374857600080fd5b6105df8261347f565b6000806040838503121561376457600080fd5b61376d8361347f565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156137b357835183529284019291840191600101613797565b50909695505050505050565b6000806000806000608086880312156137d757600080fd5b6137e08661347f565b9450602086013593506040860135925060608601356001600160401b038082111561380a57600080fd5b818801915088601f83011261381e57600080fd5b81358181111561382d57600080fd5b89602082850101111561383f57600080fd5b9699959850939650602001949392505050565b60006020828403121561386457600080fd5b5035919050565b634e487b7160e01b600052602160045260246000fd5b600581106105fc57634e487b7160e01b600052602160045260246000fd5b6020815260008251608060208401526138bb60a08401826136f7565b905060208401516138cb81613881565b8060408501525060408401516138e081613881565b806060850152506060840151151560808401528091505092915050565b60006001600160401b038211156139165761391661334d565b50601f01601f191660200190565b600061393261342e846138fd565b905082815283838301111561394657600080fd5b828260208301376000602084830101529392505050565b600082601f83011261396e57600080fd5b6105df83833560208501613924565b600581106105fc57600080fd5b80356134968161397d565b6000806000606084860312156139aa57600080fd5b6139b38461347f565b9250602080850135925060408501356001600160401b03808211156139d757600080fd5b818701915087601f8301126139eb57600080fd5b81356139f961342e826133bb565b81815260059190911b8301840190848101908a831115613a1857600080fd5b8585015b83811015613adc57803585811115613a3357600080fd5b86016080818e03601f19011215613a4957600080fd5b613a51613363565b8882013587811115613a6257600080fd5b8201603f81018f13613a7357600080fd5b613a848f8b83013560408401613924565b825250604082013587811115613a9957600080fd5b613aa78f8b8386010161395d565b8a83015250613ab86060830161398a565b6040820152613ac960808301613515565b6060820152845250918601918601613a1c565b508096505050505050509250925092565b600060208284031215613aff57600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201613b4457613b44613b1c565b5060010190565b600060208284031215613b5d57600080fd5b81356105df8161397d565b6000808335601e19843603018112613b7f57600080fd5b8301803591506001600160401b03821115613b9957600080fd5b60200191503681900382131561358157600080fd5b600181811c90821680613bc257607f821691505b602082108103613be257634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115613c3257600081815260208120601f850160051c81016020861015613c0f5750805b601f850160051c820191505b81811015613c2e57828155600101613c1b565b5050505b505050565b600081356104c58161397d565b613c4d82613881565b60ff1981541660ff831681178255505050565b613c6982613881565b805461ff008360081b1661ff00198216178255505050565b600081356104c581613507565b8135601e19833603018112613ca257600080fd5b820180356001600160401b03811115613cba57600080fd5b60208136038184011315613ccd57600080fd5b613ce182613cdb8654613bae565b86613be8565b6000601f831160018114613d175760008415613cff57508482018301355b600019600386901b1c1916600185901b178655613d74565b600086815260209020601f19851690835b82811015613d49578785018601358255938501936001909101908501613d28565b5085821015613d685760001960f88760031b161c198585890101351681555b505060018460011b0186555b5050600184019250613d90613d8a828701613c37565b84613c44565b5050613da7613da160408501613c37565b82613c60565b613c32613db660608501613c81565b82805462ff0000191691151560101b62ff000016919091179055565b60408101613ddf84613881565b838252613deb83613881565b8260208301529392505050565b600060208284031215613e0a57600080fd5b81516105df81613507565b60008219821115613e2857613e28613b1c565b500190565b600080821280156001600160ff1b0384900385131615613e4f57613e4f613b1c565b600160ff1b8390038412811615613e6857613e68613b1c565b50500190565b6000613e7c61342e846138fd565b9050828152838383011115613e9057600080fd5b6105df8360208301846136c7565b600082601f830112613eaf57600080fd5b6105df83835160208501613e6e565b600060208284031215613ed057600080fd5b81516001600160401b03811115613ee657600080fd5b612e2a84828501613e9e565b60208152816020820152818360408301376000818301604090810191909152601f909201601f19160101919050565b60006020808385031215613f3457600080fd5b82516001600160401b03811115613f4a57600080fd5b8301601f81018513613f5b57600080fd5b8051613f6961342e826133bb565b81815260059190911b82018301908381019087831115613f8857600080fd5b928401925b82841015613fa657835182529284019290840190613f8d565b979650505050505050565b600060208284031215613fc357600080fd5b81516001600160401b0380821115613fda57600080fd5b9083019060808286031215613fee57600080fd5b613ff6613363565b82518281111561400557600080fd5b61401187828601613e9e565b825250602083015191506140248261397d565b8160208201526040830151915061403a8261397d565b8160408201526060830151925061405083613507565b6060810192909252509392505050565b60006020828403121561407257600080fd5b81516001600160401b0381111561408857600080fd5b8201601f8101841361409957600080fd5b612e2a84825160208401613e6e565b607b60f81b8152600084516140c48160018501602089016136c7565b8451908301906140db8160018401602089016136c7565b6d2261747472696275746573223a5b60901b60019290910191820152835161410a81600f8401602088016136c7565b615d7d60f01b600f929091019182015260110195945050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161415e81601d8501602087016136c7565b91909101601d0192915050565b60008282101561417d5761417d613b1c565b500390565b60008083128015600160ff1b8501841216156141a0576141a0613b1c565b6001600160ff1b03840183138116156141bb576141bb613b1c565b50500390565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000855161421e818460208a016136c7565b855190830190614232818360208a016136c7565b601160f91b9101908152845161424f8160018401602089016136c7565b61111d60f11b6001929091019182015283516142728160038401602088016136c7565b016003019695505050505050565b600084516142928184602089016136c7565b8451908301906142a68183602089016136c7565b84519101906142b98183602088016136c7565b0195945050505050565b634e487b7160e01b600052601260045260246000fd5b6000826142e8576142e86142c3565b500490565b600081600019048311821515161561430757614307613b1c565b500290565b6000601160f91b80835283516143298160018601602088016136c7565b600193019283015250600201919050565b6020810161434783613881565b91905290565b6e3d913a3930b4ba2fba3cb832911d1160891b8152825160009061437881600f8501602088016136c7565b691116113b30b63ab2911d60b11b600f9184019182015283516143a28160198401602088016136c7565b607d60f81b60199290910191820152601a01949350505050565b6000600160ff1b82016143d1576143d1613b1c565b5060000390565b6000826143e7576143e76142c3565b50069056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fd3dc2a3a14cbd0cdbf3069fc3927e48506f271b9dda2c21625b93e6a99d3eb5327e7aef89b6a8015f2f0025e2d80f71db344055da034de9b4c6170a7b8209a51a2646970667358221220b63c540fb0f0e108358b67c49a7135e908b0d71bae5027aea6e9e63f83729dfb64736f6c634300080d0033
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.