Feature Tip: Add private address tag to any address under My Name Tag !
More Info
Private Name Tags
Latest 25 from a total of 456 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
Value | ||||
---|---|---|---|---|---|---|---|---|---|
Claim Rewards | 18384195 | 258 days ago | IN | 0 ETH | 0.00065887 | ||||
Withdraw | 18384187 | 258 days ago | IN | 0 ETH | 0.00082656 | ||||
Withdraw | 17118508 | 435 days ago | IN | 0 ETH | 0.00493726 | ||||
Claim Rewards | 17118506 | 435 days ago | IN | 0 ETH | 0.00602995 | ||||
Withdraw | 17077763 | 441 days ago | IN | 0 ETH | 0.00552997 | ||||
Withdraw | 17011916 | 450 days ago | IN | 0 ETH | 0.00254302 | ||||
Withdraw | 16941967 | 460 days ago | IN | 0 ETH | 0.00453031 | ||||
Withdraw | 16941942 | 460 days ago | IN | 0 ETH | 0.00473779 | ||||
Claim Rewards | 16941730 | 460 days ago | IN | 0 ETH | 0.00665002 | ||||
Withdraw | 16932827 | 462 days ago | IN | 0 ETH | 0.00193095 | ||||
Claim Rewards | 16932821 | 462 days ago | IN | 0 ETH | 0.00305452 | ||||
Claim Rewards | 16750522 | 487 days ago | IN | 0 ETH | 0.00369772 | ||||
Claim Rewards | 16743677 | 488 days ago | IN | 0 ETH | 0.00338742 | ||||
Claim Rewards | 16530665 | 518 days ago | IN | 0 ETH | 0.00224825 | ||||
Withdraw | 16530657 | 518 days ago | IN | 0 ETH | 0.00146001 | ||||
Withdraw | 16522991 | 519 days ago | IN | 0 ETH | 0.00340202 | ||||
Claim Rewards | 16482087 | 525 days ago | IN | 0 ETH | 0.00168755 | ||||
Claim Rewards | 16474961 | 526 days ago | IN | 0 ETH | 0.00196858 | ||||
Claim Rewards | 16445759 | 530 days ago | IN | 0 ETH | 0.00209239 | ||||
Withdraw | 16445756 | 530 days ago | IN | 0 ETH | 0.00302974 | ||||
Claim Rewards | 16444178 | 530 days ago | IN | 0 ETH | 0.00203232 | ||||
Withdraw | 16429355 | 532 days ago | IN | 0 ETH | 0.0023968 | ||||
Withdraw | 16428491 | 532 days ago | IN | 0 ETH | 0.00307561 | ||||
Withdraw | 16422962 | 533 days ago | IN | 0 ETH | 0.00422097 | ||||
Claim Rewards | 16408512 | 535 days ago | IN | 0 ETH | 0.00321175 |
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers. Name tag integration is not available in advanced view.
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | Value | |||
---|---|---|---|---|---|---|---|
18384195 | 258 days ago | 0 ETH | |||||
18384195 | 258 days ago | 0 ETH | |||||
18384187 | 258 days ago | 0 ETH | |||||
18384187 | 258 days ago | 0 ETH | |||||
17118508 | 435 days ago | 0 ETH | |||||
17118508 | 435 days ago | 0 ETH | |||||
17118506 | 435 days ago | 0 ETH | |||||
17118506 | 435 days ago | 0 ETH | |||||
17077763 | 441 days ago | 0 ETH | |||||
17011916 | 450 days ago | 0 ETH | |||||
16941967 | 460 days ago | 0 ETH | |||||
16941967 | 460 days ago | 0 ETH | |||||
16941967 | 460 days ago | 0 ETH | |||||
16941967 | 460 days ago | 0 ETH | |||||
16941942 | 460 days ago | 0 ETH | |||||
16941730 | 460 days ago | 0 ETH | |||||
16941730 | 460 days ago | 0 ETH | |||||
16932827 | 462 days ago | 0 ETH | |||||
16932821 | 462 days ago | 0 ETH | |||||
16932821 | 462 days ago | 0 ETH | |||||
16750522 | 487 days ago | 0 ETH | |||||
16750522 | 487 days ago | 0 ETH | |||||
16743677 | 488 days ago | 0 ETH | |||||
16743677 | 488 days ago | 0 ETH | |||||
16530665 | 518 days ago | 0 ETH |
Loading...
Loading
Contract Name:
TykeStaking30Days
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 800 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.11; import "@thirdweb-dev/contracts/base/ERC20Base.sol"; import "@thirdweb-dev/contracts/extension/Ownable.sol"; import "@thirdweb-dev/contracts/base/ERC721Base.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; contract TykeStaking30Days is ReentrancyGuardUpgradeable, Ownable { // Interfaces for TokenERC20 and ERC721AUpgradeable ERC20Base public immutable rewardsToken; ERC721Base public immutable nftCollection; // Constructor function to set the rewards token and the NFT collection addresses constructor(ERC721Base _nftCollection, ERC20Base _rewardsToken) { nftCollection = _nftCollection; rewardsToken = _rewardsToken; _setupOwner(msg.sender); } struct StakedToken { // ID of the token uint16 tokenId; // Last time of the rewards were calculated for this user uint64 timeOfLastStake; // Last time of the rewards were calculated for this user uint64 timeOfLastClaim; } // Staker info struct Staker { // Staked token ids StakedToken[] stakedTokens; // Calculated, but unclaimed rewards for the User. The rewards are // calculated each time the user writes to the Smart Contract uint128 unclaimedRewards; } // BaseRate Info struct BaseRate { // Staked token ids uint16 tokenId; // rate given to each token based on Rarity uint128 dailyRate; } // SoulOwner Info struct SoulOwner { // Staked token ids address walletAddress; // flag to set if they are a soul owner or not bool isSoulOwner; } // withdraw period in terms of seconds in an average month (86,400 seconds per day x 30.437 avg days per month) uint64 public withdrawPeriod = 2629757; // Percent the treasury gets on top of each claim amount uint8 public treasuryPercentage = 35; // Percent the soul NFT awards an owner on top of the claim amount uint8 public soulPercentage = 11; // Treasury Wallet Address address public treasury = 0x87885321fAEF5F7F549009a60eE13C735c3438df; // Mapping of User Address to Staker info mapping(address => Staker) public stakers; // Mapping of Token to Base Rate Rarity mapping(uint16 => uint128) public baseRates; // Mapping of Token Id to staker. Made for the SC to remeber // who to send back the ERC721 Token to. mapping(uint16 => address) public stakerAddress; // Mapping of address to bool of whether staker owns a Soul NFT mapping(address => bool) public soulOwner; // Function to stake multiple tokens function stake(uint16[] memory _tokenIds) external nonReentrant { for (uint32 i = 0; i < _tokenIds.length; i++) { stakeInternalLogic(_tokenIds[i]); } } // Function to withdraw multiple tokens function withdraw(uint16[] memory _tokenIds) external nonReentrant { // Make sure the user has at least one token staked before withdrawing uint256 _stakedTokensLength = stakers[msg.sender].stakedTokens.length; require( _stakedTokensLength > 0, "You have no tokens staked" ); // Forces the user to set claimed Rewards on Withdraw updateUnclaimedInternal(_stakedTokensLength); for (uint16 i = 0; i < _tokenIds.length; i++) { withdrawInternalLogic(_tokenIds[i], _stakedTokensLength); } } // Function to claim rewards function claimRewards() external { uint128 rewards = calculateRewards(msg.sender) + stakers[msg.sender].unclaimedRewards; require(rewards > 0, "You have no rewards to claim"); // Loop through each staked Token and update the timeOfLastClaim uint256 _stakedTokensLength = stakers[msg.sender].stakedTokens.length; for (uint256 i = 0; i < _stakedTokensLength; i++) { stakers[msg.sender].stakedTokens[uint16(i)].timeOfLastClaim = uint32(block.timestamp); } // Set Claim Reward to 0 stakers[msg.sender].unclaimedRewards = 0; // Mint Tokens from ERC20 Token Staking Contractß rewardsToken.mintTo(msg.sender, rewards); // Mint Tokens from ERC20 Token Staking Contract to Treasury rewardsToken.mintTo(treasury, (rewards * treasuryPercentage) / 100); } // function used to calculate and set rewards upon withdraw function updateUnclaimedInternal(uint256 _stakedTokensLength) internal { uint128 rewards = calculateRewards(msg.sender) + stakers[msg.sender].unclaimedRewards; // Loop through each staked Token and update the timeOfLastClaim for (uint256 i = 0; i < _stakedTokensLength; i++) { stakers[msg.sender].stakedTokens[uint16(i)].timeOfLastClaim = uint32(block.timestamp); } // Set Claim Rewards stakers[msg.sender].unclaimedRewards = rewards; } ////////// // View // ////////// // Function to view the available rewards function availableRewards(address _staker) public view returns (uint128) { uint128 rewards = calculateRewards(_staker) + stakers[_staker].unclaimedRewards; return rewards; } // Function to get a list of staked tokens for a given user function getStakedTokens(address _user) public view returns (StakedToken[] memory) { return stakers[_user].stakedTokens; } ///////////// // Internal// ///////////// // Calculate rewards for param _staker by calculating the time passed // since last update in hours and mulitplying it to ERC721 Tokens Staked // and dailyRate. function calculateRewards(address _staker) internal view returns (uint128 _rewards) { // Get all Tokens that the address owns // Loop through each one and set the reward // return reward for each token that the address owns _rewards = 0; // for each staked Token in the Stakers array by address uint256 _stakedTokensLength = stakers[_staker].stakedTokens.length; for (uint256 i = 0; i < _stakedTokensLength; i++) { // Get time of Last Stake uint64 timeOfLastStake = stakers[_staker].stakedTokens[uint16(i)].timeOfLastStake; // Get time of Last Claim uint64 timeOfLastClaim = stakers[_staker].stakedTokens[uint16(i)].timeOfLastClaim; // Get the user's current Rate // TODO: Call to get this tokenId's base rate from external source uint128 rate = (baseRates[stakers[_staker].stakedTokens[uint16(i)].tokenId] * 1e18); if (withdrawPeriod < block.timestamp - timeOfLastStake) { if ((int64(withdrawPeriod) - (int64(timeOfLastClaim) - int64(timeOfLastStake))) > 0) { _rewards += ((withdrawPeriod - (timeOfLastClaim - timeOfLastStake)) * rate) / 86400; } else { _rewards += 0; } } else { _rewards += ((uint64(block.timestamp) - timeOfLastClaim) * rate) / 86400; } } // If the user is a soul owner, give them a 10% bonus if(soulOwner[msg.sender]) { _rewards = (_rewards * uint128(soulPercentage)) / 10; } return (_rewards); } // Internal function that the staking function calls to make the staking loop cleaner function stakeInternalLogic(uint16 _tokenId) internal { // Wallet must own the token they are trying to stake require( nftCollection.ownerOf(_tokenId) == msg.sender, "You don't own this token!" ); // Transfer the token from the wallet to the Smart contract nftCollection.transferFrom(msg.sender, address(this), _tokenId); // Create StakedToken StakedToken memory stakedToken = StakedToken(_tokenId, uint32(block.timestamp), uint32(block.timestamp)); // Add the token to the stakedTokens array stakers[msg.sender].stakedTokens.push(stakedToken); // Update the mapping of the tokenId to the staker's address stakerAddress[_tokenId] = msg.sender; } // Internal function that the withdraw function calls to make the withdraw loop cleaner function withdrawInternalLogic(uint16 _tokenId, uint256 _stakedTokensLength) internal { // Wallet must own the token they are trying to withdraw require(stakerAddress[_tokenId] == msg.sender, "You don't own one or more of these tokens!"); // Find the index of this token id in the stakedTokens array uint256 index = 0; for (uint256 i = 0; i < _stakedTokensLength; i++) { if ( stakers[msg.sender].stakedTokens[i].tokenId == _tokenId ) { index = i; break; } } // Check to see if token is elligible for withdraw based on stakedToken or extendedStake timestamp require(uint32(block.timestamp) - stakers[msg.sender].stakedTokens[index].timeOfLastStake > withdrawPeriod, "One or more of these tokens is not elligible for withdraw"); // On Withdraw, the user is ending their ability to compound. remove(index); stakerAddress[_tokenId] = address(0); // Transfer the token back to the withdrawer nftCollection.transferFrom(address(this), msg.sender, _tokenId); } function remove(uint256 index) internal{ stakers[msg.sender].stakedTokens[index] = stakers[msg.sender].stakedTokens[stakers[msg.sender].stakedTokens.length - 1]; stakers[msg.sender].stakedTokens.pop(); } function removeFailSafe(uint256 index, address _wallet) internal{ stakers[_wallet].stakedTokens[index] = stakers[_wallet].stakedTokens[stakers[_wallet].stakedTokens.length - 1]; stakers[_wallet].stakedTokens.pop(); } ///////////// // Owner Only // ///////////// // Function to set base rates function setBaseRate(BaseRate[] memory _newBaseRates) public onlyOwner { // Get each object passed in to setBaseRate for (uint16 i = 0; i < _newBaseRates.length; i++) { // Add Mapping for each object baseRates[_newBaseRates[i].tokenId] = _newBaseRates[i].dailyRate; } } // Function to set who is a soul owner function setSoulOwners(SoulOwner[] memory _newSoulOwners) public onlyOwner { // Get each object passed in to setBaseRate for (uint16 i = 0; i < _newSoulOwners.length; i++) { // Add Mapping for each object soulOwner[_newSoulOwners[i].walletAddress] = _newSoulOwners[i].isSoulOwner; } } // Function to set the withdraw Period. function setWithdrawPeriod(uint32 _newWithdrawPeriod) public onlyOwner { withdrawPeriod = _newWithdrawPeriod; } // Function to set the treasury address function setTreasuryAddress(address _newTreasuryAddress) public onlyOwner { treasury = _newTreasuryAddress; } // Function to set the treasury percentage function setTreasuryPercentage(uint8 _newtreasuryPercentage) public onlyOwner { treasuryPercentage = _newtreasuryPercentage; } // Function to set Soul Percentage function setSoulPercentage(uint8 _newtsoulPercentage) public onlyOwner { soulPercentage = _newtsoulPercentage; } // Used as an emergency function to set the new mapping in the event that the mapping is set to a null address without actually transferring function addNewStakerAddressMapping(uint256 _tokenId, address _walletAddress) public onlyOwner { stakerAddress[uint16(_tokenId)] = _walletAddress; } // This is a failSafe transfer that is only intended to be used if there is an error in the contract or staking needs an upgrade function failtransferFrom(uint256 _start, uint256 _end) public onlyOwner { for (uint256 i = _start; i < _end ; i++) { address _stakerAddress = stakerAddress[uint16(i)]; if (_stakerAddress != 0x0000000000000000000000000000000000000000 ) { uint256 index = 0; uint256 _stakedTokensLength = stakers[_stakerAddress].stakedTokens.length; for (uint256 j = 0; j < _stakedTokensLength; j++) { if ( stakers[_stakerAddress].stakedTokens[j].tokenId == i ) { index = j; break; } } removeFailSafe(index, _stakerAddress); nftCollection.transferFrom(address(this), _stakerAddress, i); stakerAddress[uint16(i)] = address(0); } } } // This is a failSafe transfer that is only intended to be used if there is an error in the contract or staking needs an upgrade - Single User Only function failtransferFromSingleUser(address _walletAddress) public onlyOwner { uint16 tokenCount = uint16(stakers[_walletAddress].stakedTokens.length); for (uint16 i = 0; i < tokenCount; i++) { uint16 tokenID = stakers[_walletAddress].stakedTokens[i].tokenId; nftCollection.transferFrom(address(this), _walletAddress, tokenID); stakerAddress[tokenID] = address(0); } delete stakers[_walletAddress].stakedTokens; } /*/////////////////////////////////////////////////////////////// Miscellaneous //////////////////////////////////////////////////////////////*/ /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual override returns (bool) { return msg.sender == owner(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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. Equivalent to `reinitializer(1)`. */ 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. * * `initializer` is equivalent to `reinitializer(1)`, so 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. * * 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. */ 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. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // 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.7.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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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: Apache-2.0 pragma solidity ^0.8.0; import "../openzeppelin-presets/token/ERC20/extensions/ERC20Permit.sol"; import "../extension/ContractMetadata.sol"; import "../extension/Multicall.sol"; import "../extension/Ownable.sol"; /** * The `ERC20Base` smart contract implements the ERC20 standard. * It includes the following additions to standard ERC20 logic: * * - Ability to mint & burn tokens via the provided `mint` & `burn` functions. * * - Ownership of the contract, with the ability to restrict certain functions to * only be called by the contract's owner. * * - Multicall capability to perform multiple actions atomically * * - EIP 2612 compliance: See {ERC20-permit} method, which can be used to change an account's ERC20 allowance by * presenting a message signed by the account. */ contract ERC20Base is ContractMetadata, Multicall, Ownable, ERC20Permit { /*////////////////////////////////////////////////////////////// Constructor //////////////////////////////////////////////////////////////*/ constructor(string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) { _setupOwner(msg.sender); } /*////////////////////////////////////////////////////////////// Minting logic //////////////////////////////////////////////////////////////*/ /** * @notice Lets an authorized address mint tokens to a recipient. * @dev The logic in the `_canMint` function determines whether the caller is authorized to mint tokens. * * @param _to The recipient of the tokens to mint. * @param _amount Quantity of tokens to mint. */ function mintTo(address _to, uint256 _amount) public virtual { require(_canMint(), "Not authorized to mint."); require(_amount != 0, "Minting zero tokens."); _mint(_to, _amount); } /** * @notice Lets an owner a given amount of their tokens. * @dev Caller should own the `_amount` of tokens. * * @param _amount The number of tokens to burn. */ function burn(uint256 _amount) external virtual { require(balanceOf(msg.sender) >= _amount, "not enough balance"); _burn(msg.sender, _amount); } /*////////////////////////////////////////////////////////////// Internal (overrideable) functions //////////////////////////////////////////////////////////////*/ /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Returns whether tokens can be minted in the given execution context. function _canMint() internal view virtual returns (bool) { return msg.sender == owner(); } /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual override returns (bool) { return msg.sender == owner(); } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import { ERC721A } from "../eip/ERC721A.sol"; import "../extension/ContractMetadata.sol"; import "../extension/Multicall.sol"; import "../extension/Ownable.sol"; import "../extension/Royalty.sol"; import "../extension/BatchMintMetadata.sol"; import "../lib/TWStrings.sol"; /** * The `ERC721Base` smart contract implements the ERC721 NFT standard, along with the ERC721A optimization to the standard. * It includes the following additions to standard ERC721 logic: * * - Ability to mint NFTs via the provided `mint` function. * * - Contract metadata for royalty support on platforms such as OpenSea that use * off-chain information to distribute roaylties. * * - Ownership of the contract, with the ability to restrict certain functions to * only be called by the contract's owner. * * - Multicall capability to perform multiple actions atomically * * - EIP 2981 compliance for royalty support on NFT marketplaces. */ contract ERC721Base is ERC721A, ContractMetadata, Multicall, Ownable, Royalty, BatchMintMetadata { using TWStrings for uint256; /*////////////////////////////////////////////////////////////// Mappings //////////////////////////////////////////////////////////////*/ mapping(uint256 => string) private fullURI; /*////////////////////////////////////////////////////////////// Constructor //////////////////////////////////////////////////////////////*/ constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps ) ERC721A(_name, _symbol) { _setupOwner(msg.sender); _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); } /*////////////////////////////////////////////////////////////// ERC165 Logic //////////////////////////////////////////////////////////////*/ /// @dev See ERC165: https://eips.ethereum.org/EIPS/eip-165 function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A, IERC165) returns (bool) { return interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165 interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721 interfaceId == 0x5b5e139f || // ERC165 Interface ID for ERC721Metadata interfaceId == type(IERC2981).interfaceId; // ERC165 ID for ERC2981 } /*////////////////////////////////////////////////////////////// Overriden ERC721 logic //////////////////////////////////////////////////////////////*/ /** * @notice Returns the metadata URI for an NFT. * @dev See `BatchMintMetadata` for handling of metadata in this contract. * * @param _tokenId The tokenId of an NFT. */ function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { string memory fullUriForToken = fullURI[_tokenId]; if (bytes(fullUriForToken).length > 0) { return fullUriForToken; } string memory batchUri = getBaseURI(_tokenId); return string(abi.encodePacked(batchUri, _tokenId.toString())); } /*////////////////////////////////////////////////////////////// Minting logic //////////////////////////////////////////////////////////////*/ /** * @notice Lets an authorized address mint an NFT to a recipient. * @dev The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs. * * @param _to The recipient of the NFT to mint. * @param _tokenURI The full metadata URI for the NFT minted. */ function mintTo(address _to, string memory _tokenURI) public virtual { require(_canMint(), "Not authorized to mint."); _setTokenURI(nextTokenIdToMint(), _tokenURI); _safeMint(_to, 1, ""); } /** * @notice Lets an authorized address mint multiple NFTs at once to a recipient. * @dev The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs. * * @param _to The recipient of the NFT to mint. * @param _quantity The number of NFTs to mint. * @param _baseURI The baseURI for the `n` number of NFTs minted. The metadata for each NFT is `baseURI/tokenId` * @param _data Additional data to pass along during the minting of the NFT. */ function batchMintTo( address _to, uint256 _quantity, string memory _baseURI, bytes memory _data ) public virtual { require(_canMint(), "Not authorized to mint."); _batchMintMetadata(nextTokenIdToMint(), _quantity, _baseURI); _safeMint(_to, _quantity, _data); } /** * @notice Lets an owner or approved operator burn the NFT of the given tokenId. * @dev ERC721A's `_burn(uint256,bool)` internally checks for token approvals. * * @param _tokenId The tokenId of the NFT to burn. */ function burn(uint256 _tokenId) external virtual { _burn(_tokenId, true); } /*////////////////////////////////////////////////////////////// Public getters //////////////////////////////////////////////////////////////*/ /// @notice The tokenId assigned to the next new NFT to be minted. function nextTokenIdToMint() public view virtual returns (uint256) { return _currentIndex; } /// @notice Returns whether a given address is the owner, or approved to transfer an NFT. function isApprovedOrOwner(address _operator, uint256 _tokenId) public view virtual returns (bool isApprovedOrOwnerOf) { address owner = ownerOf(_tokenId); isApprovedOrOwnerOf = (_operator == owner || isApprovedForAll(owner, _operator) || getApproved(_tokenId) == _operator); } /*////////////////////////////////////////////////////////////// Internal (overrideable) functions //////////////////////////////////////////////////////////////*/ function _setTokenURI(uint256 _tokenId, string memory _tokenURI) internal virtual { require(bytes(fullURI[_tokenId]).length == 0, "URI already set"); fullURI[_tokenId] = _tokenURI; } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Returns whether a token can be minted in the given execution context. function _canMint() internal view virtual returns (bool) { return msg.sender == owner(); } /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual override returns (bool) { return msg.sender == owner(); } /// @dev Returns whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view virtual override returns (bool) { return msg.sender == owner(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./interface/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 // ERC721A Contracts v3.3.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./interface/IERC721A.sol"; import "../openzeppelin-presets/token/ERC721/IERC721Receiver.sol"; import "../lib/TWAddress.sol"; import "../openzeppelin-presets/utils/Context.sol"; import "../lib/TWStrings.sol"; import "./ERC165.sol"; /** * @dev Implementation of [ERC721](https://eips.ethereum.org/EIPS/eip-721) Non-Fungible Token Standard, including * the Metadata extension. Built to optimize for lower gas during batch mints. * * Assumes serials are sequentially minted starting at _startTokenId() (defaults to 0, e.g. 0, 1, 2, 3..). * * Assumes that an owner cannot have more than 2^64 - 1 (max value of uint64) of supply. * * Assumes that the maximum token id cannot exceed 2^256 - 1 (max value of uint256). */ contract ERC721A is Context, ERC165, IERC721A { using TWAddress for address; using TWStrings for uint256; // The tokenId of the next token to be minted. uint256 internal _currentIndex; // The number of tokens burned. uint256 internal _burnCounter; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to ownership details // An empty struct value does not necessarily mean the token is unowned. See _ownershipOf implementation for details. mapping(uint256 => TokenOwnership) internal _ownerships; // Mapping owner address to address data mapping(address => AddressData) private _addressData; // 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; constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; _currentIndex = _startTokenId(); } /** * To change the starting tokenId, please override this function. */ function _startTokenId() internal view virtual returns (uint256) { return 0; } /** * @dev Burned tokens are calculated here, use _totalMinted() if you want to count just minted tokens. */ function totalSupply() public view override returns (uint256) { // Counter underflow is impossible as _burnCounter cannot be incremented // more than _currentIndex - _startTokenId() times unchecked { return _currentIndex - _burnCounter - _startTokenId(); } } /** * Returns the total amount of tokens minted in the contract. */ function _totalMinted() internal view returns (uint256) { // Counter underflow is impossible as _currentIndex does not decrement, // and it is initialized to _startTokenId() unchecked { return _currentIndex - _startTokenId(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { if (owner == address(0)) revert BalanceQueryForZeroAddress(); return uint256(_addressData[owner].balance); } /** * Returns the number of tokens minted by `owner`. */ function _numberMinted(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberMinted); } /** * Returns the number of tokens burned by or on behalf of `owner`. */ function _numberBurned(address owner) internal view returns (uint256) { return uint256(_addressData[owner].numberBurned); } /** * Returns the auxillary data for `owner`. (e.g. number of whitelist mint slots used). */ function _getAux(address owner) internal view returns (uint64) { return _addressData[owner].aux; } /** * Sets the auxillary data for `owner`. (e.g. number of whitelist mint slots used). * If there are multiple variables, please pack them into a uint64. */ function _setAux(address owner, uint64 aux) internal { _addressData[owner].aux = aux; } /** * Gas spent here starts off proportional to the maximum mint batch size. * It gradually moves to O(1) as tokens get transferred around in the collection over time. */ function _ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) { uint256 curr = tokenId; unchecked { if (_startTokenId() <= curr) if (curr < _currentIndex) { TokenOwnership memory ownership = _ownerships[curr]; if (!ownership.burned) { if (ownership.addr != address(0)) { return ownership; } // Invariant: // There will always be an ownership that has an address and is not burned // before an ownership that does not have an address and is not burned. // Hence, curr will not underflow. while (true) { curr--; ownership = _ownerships[curr]; if (ownership.addr != address(0)) { return ownership; } } } } } revert OwnerQueryForNonexistentToken(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _ownershipOf(tokenId).addr; } /** * @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) { if (!_exists(tokenId)) revert URIQueryForNonexistentToken(); 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 overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public override { address owner = ERC721A.ownerOf(tokenId); if (to == owner) revert ApprovalToCurrentOwner(); if (_msgSender() != owner) if (!isApprovedForAll(owner, _msgSender())) { revert ApprovalCallerNotOwnerNorApproved(); } _approve(to, tokenId, owner); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken(); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { if (operator == _msgSender()) revert ApproveToCaller(); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_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 { _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 { _transfer(from, to, tokenId); if (to.isContract()) if (!_checkContractOnERC721Received(from, to, tokenId, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } /** * @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`), */ function _exists(uint256 tokenId) internal view returns (bool) { return _startTokenId() <= tokenId && tokenId < _currentIndex && !_ownerships[tokenId].burned; } /** * @dev Equivalent to `_safeMint(to, quantity, '')`. */ function _safeMint(address to, uint256 quantity) internal { _safeMint(to, quantity, ""); } /** * @dev Safely mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - If `to` refers to a smart contract, it must implement * {IERC721Receiver-onERC721Received}, which is called for each safe transfer. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _safeMint( address to, uint256 quantity, bytes memory _data ) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; if (to.isContract()) { do { emit Transfer(address(0), to, updatedIndex); if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) { revert TransferToNonERC721ReceiverImplementer(); } } while (updatedIndex < end); // Reentrancy protection if (_currentIndex != startTokenId) revert(); } else { do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex < end); } _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Mints `quantity` tokens and transfers them to `to`. * * Requirements: * * - `to` cannot be the zero address. * - `quantity` must be greater than 0. * * Emits a {Transfer} event. */ function _mint(address to, uint256 quantity) internal { uint256 startTokenId = _currentIndex; if (to == address(0)) revert MintToZeroAddress(); if (quantity == 0) revert MintZeroQuantity(); _beforeTokenTransfers(address(0), to, startTokenId, quantity); // Overflows are incredibly unrealistic. // balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1 // updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1 unchecked { _addressData[to].balance += uint64(quantity); _addressData[to].numberMinted += uint64(quantity); _ownerships[startTokenId].addr = to; _ownerships[startTokenId].startTimestamp = uint64(block.timestamp); uint256 updatedIndex = startTokenId; uint256 end = updatedIndex + quantity; do { emit Transfer(address(0), to, updatedIndex++); } while (updatedIndex < end); _currentIndex = updatedIndex; } _afterTokenTransfers(address(0), to, startTokenId, quantity); } /** * @dev Transfers `tokenId` from `from` to `to`. * * 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 ) private { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); if (prevOwnership.addr != from) revert TransferFromIncorrectOwner(); bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { _addressData[from].balance -= 1; _addressData[to].balance += 1; TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = to; currSlot.startTimestamp = uint64(block.timestamp); // If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); } /** * @dev Equivalent to `_burn(tokenId, false)`. */ function _burn(uint256 tokenId) internal virtual { _burn(tokenId, false); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId, bool approvalCheck) internal virtual { TokenOwnership memory prevOwnership = _ownershipOf(tokenId); address from = prevOwnership.addr; if (approvalCheck) { bool isApprovedOrOwner = (_msgSender() == from || isApprovedForAll(from, _msgSender()) || getApproved(tokenId) == _msgSender()); if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved(); } _beforeTokenTransfers(from, address(0), tokenId, 1); // Clear approvals from the previous owner _approve(address(0), tokenId, from); // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as tokenId would have to be 2**256. unchecked { AddressData storage addressData = _addressData[from]; addressData.balance -= 1; addressData.numberBurned += 1; // Keep track of who burned the token, and the timestamp of burning. TokenOwnership storage currSlot = _ownerships[tokenId]; currSlot.addr = from; currSlot.startTimestamp = uint64(block.timestamp); currSlot.burned = true; // If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it. // Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls. uint256 nextTokenId = tokenId + 1; TokenOwnership storage nextSlot = _ownerships[nextTokenId]; if (nextSlot.addr == address(0)) { // This will suffice for checking _exists(nextTokenId), // as a burned slot cannot contain the zero address. if (nextTokenId != _currentIndex) { nextSlot.addr = from; nextSlot.startTimestamp = prevOwnership.startTimestamp; } } } emit Transfer(from, address(0), tokenId); _afterTokenTransfers(from, address(0), tokenId, 1); // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times. unchecked { _burnCounter++; } } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve( address to, uint256 tokenId, address owner ) private { _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target 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 _checkContractOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721Receiver(to).onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert TransferToNonERC721ReceiverImplementer(); } else { assembly { revert(add(32, reason), mload(reason)) } } } } /** * @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting. * And also called before burning one token. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, `tokenId` will be burned by `from`. * - `from` and `to` are never both zero. */ function _beforeTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} /** * @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes * minting. * And also called after one token has been burned. * * startTokenId - the first token id to be transferred * quantity - the amount to be transferred * * Calling conditions: * * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been * transferred to `to`. * - When `from` is zero, `tokenId` has been minted for `to`. * - When `to` is zero, `tokenId` has been burned by `from`. * - `from` and `to` are never both zero. */ function _afterTokenTransfers( address from, address to, uint256 startTokenId, uint256 quantity ) internal virtual {} }
// 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 * [EIP](https://eips.ethereum.org/EIPS/eip-165). * * 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 * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified) * 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: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20 interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20 { function totalSupply() external view returns (uint256); function balanceOf(address who) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function transfer(address to, uint256 value) external returns (bool); function approve(address spender, uint256 value) external returns (bool); function transferFrom( address from, address to, uint256 value ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title ERC20Metadata interface * @dev see https://github.com/ethereum/EIPs/issues/20 */ interface IERC20Metadata { function name() external view returns (string memory); function symbol() external view returns (string memory); function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: Apache 2.0 pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Interface for the NFT Royalty Standard. * * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal * support for royalty payments across all NFT marketplaces and ecosystem participants. * * _Available since v4.5._ */ interface IERC2981 is IERC165 { /** * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of * exchange. The royalty amount is denominated and should be payed in that same unit of exchange. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 { /** * @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); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address); /** * @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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * 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 Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address); /** * @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 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); /** * @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; }
// SPDX-License-Identifier: MIT // ERC721A Contracts v3.3.0 // Creator: Chiru Labs pragma solidity ^0.8.4; import "./IERC721.sol"; import "./IERC721Metadata.sol"; /** * @dev Interface of an ERC721A compliant contract. */ interface IERC721A is IERC721, IERC721Metadata { /** * The caller must own the token or be an approved operator. */ error ApprovalCallerNotOwnerNorApproved(); /** * The token does not exist. */ error ApprovalQueryForNonexistentToken(); /** * The caller cannot approve to their own address. */ error ApproveToCaller(); /** * The caller cannot approve to the current owner. */ error ApprovalToCurrentOwner(); /** * Cannot query the balance for the zero address. */ error BalanceQueryForZeroAddress(); /** * Cannot mint to the zero address. */ error MintToZeroAddress(); /** * The quantity of tokens minted must be more than zero. */ error MintZeroQuantity(); /** * The token does not exist. */ error OwnerQueryForNonexistentToken(); /** * The caller must own the token or be an approved operator. */ error TransferCallerNotOwnerNorApproved(); /** * The token must be owned by `from`. */ error TransferFromIncorrectOwner(); /** * Cannot safely transfer to a contract that does not implement the ERC721Receiver interface. */ error TransferToNonERC721ReceiverImplementer(); /** * Cannot transfer to the zero address. */ error TransferToZeroAddress(); /** * The token does not exist. */ error URIQueryForNonexistentToken(); // Compiler will pack this into a single 256bit word. struct TokenOwnership { // The address of the owner. address addr; // Keeps track of the start time of ownership with minimal overhead for tokenomics. uint64 startTimestamp; // Whether the token has been burned. bool burned; } // Compiler will pack this into a single 256bit word. struct AddressData { // Realistically, 2**64-1 is more than enough. uint64 balance; // Keeps track of mint count with minimal overhead for tokenomics. uint64 numberMinted; // Keeps track of burn count with minimal overhead for tokenomics. uint64 numberBurned; // For miscellaneous variable(s) pertaining to the address // (e.g. number of whitelist mint slots used). // If there are multiple variables, please pack them into a uint64. uint64 aux; } /** * @dev Returns the total amount of tokens stored by the contract. * * Burned tokens are calculated here, use `_totalMinted()` if you want to count just minted tokens. */ function totalSupply() external view returns (uint256); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension /// @dev See https://eips.ethereum.org/EIPS/eip-721 /// Note: the ERC-165 identifier for this interface is 0x5b5e139f. /* is ERC721 */ interface IERC721Metadata { /// @notice A descriptive name for a collection of NFTs in this contract function name() external view returns (string memory); /// @notice An abbreviated name for NFTs in this contract function symbol() external view returns (string memory); /// @notice A distinct Uniform Resource Identifier (URI) for a given asset. /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC /// 3986. The URI may point to a JSON file that conforms to the "ERC721 /// Metadata JSON Schema". function tokenURI(uint256 _tokenId) external view returns (string memory); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * @title Batch-mint Metadata * @notice The `BatchMintMetadata` is a contract extension for any base NFT contract. It lets the smart contract * using this extension set metadata for `n` number of NFTs all at once. This is enabled by storing a single * base URI for a batch of `n` NFTs, where the metadata for each NFT in a relevant batch is `baseURI/tokenId`. */ contract BatchMintMetadata { /// @dev Largest tokenId of each batch of tokens with the same baseURI. uint256[] private batchIds; /// @dev Mapping from id of a batch of tokens => to base URI for the respective batch of tokens. mapping(uint256 => string) private baseURI; /** * @notice Returns the count of batches of NFTs. * @dev Each batch of tokens has an in ID and an associated `baseURI`. * See {batchIds}. */ function getBaseURICount() public view returns (uint256) { return batchIds.length; } /** * @notice Returns the ID for the batch of tokens the given tokenId belongs to. * @dev See {getBaseURICount}. * @param _index ID of a token. */ function getBatchIdAtIndex(uint256 _index) public view returns (uint256) { if (_index >= getBaseURICount()) { revert("Invalid index"); } return batchIds[_index]; } /// @dev Returns the id for the batch of tokens the given tokenId belongs to. function getBatchId(uint256 _tokenId) internal view returns (uint256 batchId, uint256 index) { uint256 numOfTokenBatches = getBaseURICount(); uint256[] memory indices = batchIds; for (uint256 i = 0; i < numOfTokenBatches; i += 1) { if (_tokenId < indices[i]) { index = i; batchId = indices[i]; return (batchId, index); } } revert("Invalid tokenId"); } /// @dev Returns the baseURI for a token. The intended metadata URI for the token is baseURI + tokenId. function getBaseURI(uint256 _tokenId) internal view returns (string memory) { uint256 numOfTokenBatches = getBaseURICount(); uint256[] memory indices = batchIds; for (uint256 i = 0; i < numOfTokenBatches; i += 1) { if (_tokenId < indices[i]) { return baseURI[indices[i]]; } } revert("Invalid tokenId"); } /// @dev Sets the base URI for the batch of tokens with the given batchId. function _setBaseURI(uint256 _batchId, string memory _baseURI) internal { baseURI[_batchId] = _baseURI; } /// @dev Mints a batch of tokenIds and associates a common baseURI to all those Ids. function _batchMintMetadata( uint256 _startId, uint256 _amountToMint, string memory _baseURIForTokens ) internal returns (uint256 nextTokenIdToMint, uint256 batchId) { batchId = _startId + _amountToMint; nextTokenIdToMint = batchId; batchIds.push(batchId); baseURI[batchId] = _baseURIForTokens; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./interface/IContractMetadata.sol"; /** * @title Contract Metadata * @notice Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ abstract contract ContractMetadata is IContractMetadata { /// @notice Returns the contract metadata URI. string public override contractURI; /** * @notice Lets a contract admin set the URI for contract-level metadata. * @dev Caller should be authorized to setup contractURI, e.g. contract admin. * See {_canSetContractURI}. * Emits {ContractURIUpdated Event}. * * @param _uri keccak256 hash of the role. e.g. keccak256("TRANSFER_ROLE") */ function setContractURI(string memory _uri) external override { if (!_canSetContractURI()) { revert("Not authorized"); } _setupContractURI(_uri); } /// @dev Lets a contract admin set the URI for contract-level metadata. function _setupContractURI(string memory _uri) internal { string memory prevURI = contractURI; contractURI = _uri; emit ContractURIUpdated(prevURI, _uri); } /// @dev Returns whether contract metadata can be set in the given execution context. function _canSetContractURI() internal view virtual returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol) pragma solidity ^0.8.0; import "../lib/TWAddress.sol"; import "./interface/IMulticall.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ contract Multicall is IMulticall { /** * @notice Receives and executes a batch of function calls on this contract. * @dev Receives and executes a batch of function calls on this contract. * * @param data The bytes data that makes up the batch of function calls to execute. * @return results The bytes data that makes up the result of the batch of function calls executed. */ function multicall(bytes[] calldata data) external virtual override returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = TWAddress.functionDelegateCall(address(this), data[i]); } return results; } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./interface/IOwnable.sol"; /** * @title Ownable * @notice Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ abstract contract Ownable is IOwnable { /// @dev Owner of the contract (purpose: OpenSea compatibility) address private _owner; /// @dev Reverts if caller is not the owner. modifier onlyOwner() { if (msg.sender != _owner) { revert("Not authorized"); } _; } /** * @notice Returns the owner of the contract. */ function owner() public view override returns (address) { return _owner; } /** * @notice Lets an authorized wallet set a new owner for the contract. * @param _newOwner The address to set as the new owner of the contract. */ function setOwner(address _newOwner) external override { if (!_canSetOwner()) { revert("Not authorized"); } _setupOwner(_newOwner); } /// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin. function _setupOwner(address _newOwner) internal { address _prevOwner = _owner; _owner = _newOwner; emit OwnerUpdated(_prevOwner, _newOwner); } /// @dev Returns whether owner can be set in the given execution context. function _canSetOwner() internal view virtual returns (bool); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "./interface/IRoyalty.sol"; /** * @title Royalty * @notice Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * @dev The `Royalty` contract is ERC2981 compliant. */ abstract contract Royalty is IRoyalty { /// @dev The (default) address that receives all royalty value. address private royaltyRecipient; /// @dev The (default) % of a sale to take as royalty (in basis points). uint16 private royaltyBps; /// @dev Token ID => royalty recipient and bps for token mapping(uint256 => RoyaltyInfo) private royaltyInfoForToken; /** * @notice View royalty info for a given token and sale price. * @dev Returns royalty amount and recipient for `tokenId` and `salePrice`. * @param tokenId The tokenID of the NFT for which to query royalty info. * @param salePrice Sale price of the token. * * @return receiver Address of royalty recipient account. * @return royaltyAmount Royalty amount calculated at current royaltyBps value. */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view virtual override returns (address receiver, uint256 royaltyAmount) { (address recipient, uint256 bps) = getRoyaltyInfoForToken(tokenId); receiver = recipient; royaltyAmount = (salePrice * bps) / 10_000; } /** * @notice View royalty info for a given token. * @dev Returns royalty recipient and bps for `_tokenId`. * @param _tokenId The tokenID of the NFT for which to query royalty info. */ function getRoyaltyInfoForToken(uint256 _tokenId) public view override returns (address, uint16) { RoyaltyInfo memory royaltyForToken = royaltyInfoForToken[_tokenId]; return royaltyForToken.recipient == address(0) ? (royaltyRecipient, uint16(royaltyBps)) : (royaltyForToken.recipient, uint16(royaltyForToken.bps)); } /** * @notice Returns the defualt royalty recipient and BPS for this contract's NFTs. */ function getDefaultRoyaltyInfo() external view override returns (address, uint16) { return (royaltyRecipient, uint16(royaltyBps)); } /** * @notice Updates default royalty recipient and bps. * @dev Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {DefaultRoyalty Event}; See {_setupDefaultRoyaltyInfo}. * * @param _royaltyRecipient Address to be set as default royalty recipient. * @param _royaltyBps Updated royalty bps. */ function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupDefaultRoyaltyInfo(_royaltyRecipient, _royaltyBps); } /// @dev Lets a contract admin update the default royalty recipient and bps. function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal { if (_royaltyBps > 10_000) { revert("Exceeds max bps"); } royaltyRecipient = _royaltyRecipient; royaltyBps = uint16(_royaltyBps); emit DefaultRoyalty(_royaltyRecipient, _royaltyBps); } /** * @notice Updates default royalty recipient and bps for a particular token. * @dev Sets royalty info for `_tokenId`. Caller should be authorized to set royalty info. * See {_canSetRoyaltyInfo}. * Emits {RoyaltyForToken Event}; See {_setupRoyaltyInfoForToken}. * * @param _recipient Address to be set as royalty recipient for given token Id. * @param _bps Updated royalty bps for the token Id. */ function setRoyaltyInfoForToken( uint256 _tokenId, address _recipient, uint256 _bps ) external override { if (!_canSetRoyaltyInfo()) { revert("Not authorized"); } _setupRoyaltyInfoForToken(_tokenId, _recipient, _bps); } /// @dev Lets a contract admin set the royalty recipient and bps for a particular token Id. function _setupRoyaltyInfoForToken( uint256 _tokenId, address _recipient, uint256 _bps ) internal { if (_bps > 10_000) { revert("Exceeds max bps"); } royaltyInfoForToken[_tokenId] = RoyaltyInfo({ recipient: _recipient, bps: _bps }); emit RoyaltyForToken(_tokenId, _recipient, _bps); } /// @dev Returns whether royalty info can be set in the given execution context. function _canSetRoyaltyInfo() internal view virtual returns (bool); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * Thirdweb's `ContractMetadata` is a contract extension for any base contracts. It lets you set a metadata URI * for you contract. * * Additionally, `ContractMetadata` is necessary for NFT contracts that want royalties to get distributed on OpenSea. */ interface IContractMetadata { /// @dev Returns the metadata URI of the contract. function contractURI() external view returns (string memory); /** * @dev Sets contract URI for the storefront-level metadata of the contract. * Only module admin can call this function. */ function setContractURI(string calldata _uri) external; /// @dev Emitted when the contract URI is updated. event ContractURIUpdated(string prevURI, string newURI); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol) pragma solidity ^0.8.0; /** * @dev Provides a function to batch together multiple calls in a single external call. * * _Available since v4.1._ */ interface IMulticall { /** * @dev Receives and executes a batch of function calls on this contract. */ function multicall(bytes[] calldata data) external returns (bytes[] memory results); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; /** * Thirdweb's `Ownable` is a contract extension to be used with any base contract. It exposes functions for setting and reading * who the 'owner' of the inheriting smart contract is, and lets the inheriting contract perform conditional logic that uses * information about who the contract's owner is. */ interface IOwnable { /// @dev Returns the owner of the contract. function owner() external view returns (address); /// @dev Lets a module admin set a new owner for the contract. The new owner must be a module admin. function setOwner(address _newOwner) external; /// @dev Emitted when a new Owner is set. event OwnerUpdated(address indexed prevOwner, address indexed newOwner); }
// SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.0; import "../../eip/interface/IERC2981.sol"; /** * Thirdweb's `Royalty` is a contract extension to be used with any base contract. It exposes functions for setting and reading * the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic * that uses information about royalty fees, if desired. * * The `Royalty` contract is ERC2981 compliant. */ interface IRoyalty is IERC2981 { struct RoyaltyInfo { address recipient; uint256 bps; } /// @dev Returns the royalty recipient and fee bps. function getDefaultRoyaltyInfo() external view returns (address, uint16); /// @dev Lets a module admin update the royalty bps and recipient. function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external; /// @dev Lets a module admin set the royalty recipient for a particular token Id. function setRoyaltyInfoForToken( uint256 tokenId, address recipient, uint256 bps ) external; /// @dev Returns the royalty recipient for a particular token Id. function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16); /// @dev Emitted when royalty info is updated. event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps); /// @dev Emitted when royalty recipient for tokenId is set event RoyaltyForToken(uint256 indexed tokenId, address indexed royaltyRecipient, uint256 royaltyBps); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library TWAddress { /** * @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. * * [EIP1884](https://eips.ethereum.org/EIPS/eip-1884) 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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{ value: value }(data); return verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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 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/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library TWStrings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @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] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "../../../eip/interface/IERC20.sol"; import "../../../eip/interface/IERC20Metadata.sol"; import "../../utils/Context.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20 is Context, IERC20, IERC20Metadata { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, _allowances[owner][spender] + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = _allowances[owner][spender]; require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `sender` to `recipient`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; } _balances[to] += amount; emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; _balances[account] += amount; emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; } _totalSupply -= amount; emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Spend `amount` form the allowance of `owner` toward `spender`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-ERC20Permit.sol) pragma solidity ^0.8.0; import "../../../../eip/interface/IERC20Permit.sol"; import "../ERC20.sol"; import "../../../utils/cryptography/EIP712.sol"; import "../../../utils/cryptography/ECDSA.sol"; import "../../../utils/Counters.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * _Available since v3.4._ */ abstract contract ERC20Permit is ERC20, IERC20Permit { using Counters for Counters.Counter; mapping(address => Counters.Counter) private _nonces; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; // solhint-disable-next-line var-name-mixedcase uint256 private immutable _CACHED_CHAIN_ID; // solhint-disable-next-line var-name-mixedcase address private immutable _CACHED_THIS; // solhint-disable-next-line var-name-mixedcase bytes32 private immutable _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name_, string memory symbol_) ERC20(name_, symbol_) { _CACHED_CHAIN_ID = block.chainid; _CACHED_THIS = address(this); _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(); } /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual override { require(block.timestamp <= deadline, "ERC20Permit: expired deadline"); bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR(), structHash); address signer = ECDSA.recover(hash, v, r, s); require(signer == owner, "ERC20Permit: invalid signature"); _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override returns (uint256) { return _nonces[owner].current(); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() public view override returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name())), keccak256("1"), block.chainid, address(this) ) ); } /** * @dev "Consume a nonce": return the current value and increment. * * _Available since v4.1._ */ function _useNonce(address owner) internal virtual returns (uint256 current) { Counters.Counter storage nonce = _nonces[owner]; current = nonce.current(); nonce.increment(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../../../lib/TWStrings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", TWStrings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
{ "optimizer": { "enabled": true, "runs": 800 }, "evmVersion": "london", "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract ERC721Base","name":"_nftCollection","type":"address"},{"internalType":"contract ERC20Base","name":"_rewardsToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"prevOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerUpdated","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_walletAddress","type":"address"}],"name":"addNewStakerAddressMapping","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"availableRewards","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"baseRates","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_end","type":"uint256"}],"name":"failtransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_walletAddress","type":"address"}],"name":"failtransferFromSingleUser","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"getStakedTokens","outputs":[{"components":[{"internalType":"uint16","name":"tokenId","type":"uint16"},{"internalType":"uint64","name":"timeOfLastStake","type":"uint64"},{"internalType":"uint64","name":"timeOfLastClaim","type":"uint64"}],"internalType":"struct TykeStaking30Days.StakedToken[]","name":"","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftCollection","outputs":[{"internalType":"contract ERC721Base","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract ERC20Base","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint16","name":"tokenId","type":"uint16"},{"internalType":"uint128","name":"dailyRate","type":"uint128"}],"internalType":"struct TykeStaking30Days.BaseRate[]","name":"_newBaseRates","type":"tuple[]"}],"name":"setBaseRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"walletAddress","type":"address"},{"internalType":"bool","name":"isSoulOwner","type":"bool"}],"internalType":"struct TykeStaking30Days.SoulOwner[]","name":"_newSoulOwners","type":"tuple[]"}],"name":"setSoulOwners","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newtsoulPercentage","type":"uint8"}],"name":"setSoulPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newTreasuryAddress","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newtreasuryPercentage","type":"uint8"}],"name":"setTreasuryPercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"_newWithdrawPeriod","type":"uint32"}],"name":"setWithdrawPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"soulOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"soulPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"_tokenIds","type":"uint16[]"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"","type":"uint16"}],"name":"stakerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint128","name":"unclaimedRewards","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"treasuryPercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16[]","name":"_tokenIds","type":"uint16[]"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawPeriod","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60c0604052603380547d0b23000000000028207d0000000000000000000000000000000000000000600160a01b600160f01b0319909116179055603480546001600160a01b0319167387885321faef5f7f549009a60ee13c735c3438df1790553480156200006c57600080fd5b506040516200251e3803806200251e8339810160408190526200008f9162000120565b6001600160a01b0380831660a0528116608052620000ad33620000b5565b50506200015f565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b6001600160a01b03811681146200011d57600080fd5b50565b600080604083850312156200013457600080fd5b8251620001418162000107565b6020840151909250620001548162000107565b809150509250929050565b60805160a051612368620001b6600039600081816102d301528181610dd10152818161110c015281816115030152818161160601526116ec015260008181610452015281816108a7015261090901526123686000f3fe608060405234801561001057600080fd5b50600436106101ae5760003560e01c80638da5cb5b116100ee578063b2f57e6b11610097578063ce6cb9fd11610071578063ce6cb9fd1461043a578063d1af0c7d1461044d578063f27d865814610474578063f854a27f1461048757600080fd5b8063b2f57e6b146103ea578063b5331c1c146103fe578063c9b9918b1461042757600080fd5b80639168ae72116100c85780639168ae7214610398578063944d8d25146103c4578063a71bc5ff146103d757600080fd5b80638da5cb5b146103615780638f1fa6141461037257806390a8a3ba1461038557600080fd5b8063372500ab1161015b5780636588103b116101355780636588103b146102ce5780636605bfda146102f55780637ab5608314610308578063887553a01461032e57600080fd5b8063372500ab1461027b57806361d027b31461028357806363c28db1146102ae57600080fd5b806313af40351161018c57806313af4035146102425780632bdcfe72146102555780633317f7d91461026857600080fd5b8063081bc3f1146101b35780630a501950146101c857806312eb4f9a1461020e575b600080fd5b6101c66101c1366004611de3565b61049a565b005b6101f16101d6366004611e80565b6036602052600090815260409020546001600160801b031681565b6040516001600160801b0390911681526020015b60405180910390f35b60335461022990600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610205565b6101c6610250366004611eb0565b6105ae565b6101c6610263366004611de3565b6105ff565b6101c6610276366004611ecd565b6106aa565b6101c6610730565b603454610296906001600160a01b031681565b6040516001600160a01b039091168152602001610205565b6102c16102bc366004611eb0565b6109e4565b6040516102059190611ef0565b6102967f000000000000000000000000000000000000000000000000000000000000000081565b6101c6610303366004611eb0565b610a7f565b60335461031c90600160e01b900460ff1681565b60405160ff9091168152602001610205565b61035161033c366004611eb0565b60386020526000908152604090205460ff1681565b6040519015158152602001610205565b6033546001600160a01b0316610296565b6101c6610380366004611ecd565b610aec565b6101c6610393366004611f5b565b610b72565b6101f16103a6366004611eb0565b6035602052600090815260409020600101546001600160801b031681565b6101c66103d2366004612024565b610c65565b6101c66103e5366004611eb0565b610ced565b60335461031c90600160e81b900460ff1681565b61029661040c366004611e80565b6037602052600090815260409020546001600160a01b031681565b6101c661043536600461204a565b610e83565b6101c661044836600461207a565b610f02565b6102967f000000000000000000000000000000000000000000000000000000000000000081565b6101c661048236600461213e565b610fde565b6101f1610495366004611eb0565b6111a4565b6002600154036104f15760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260015533600090815260356020526040902054806105535760405162461bcd60e51b815260206004820152601960248201527f596f752068617665206e6f20746f6b656e73207374616b65640000000000000060448201526064016104e8565b61055c816111e5565b60005b82518161ffff1610156105a557610593838261ffff168151811061058557610585612160565b6020026020010151836112d9565b8061059d8161218c565b91505061055f565b50506001805550565b6105b6611564565b6105f35760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6105fc81611591565b50565b6002600154036106515760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104e8565b600260015560005b81518163ffffffff1610156106a257610690828263ffffffff168151811061068357610683612160565b60200260200101516115e3565b8061069a816121ad565b915050610659565b505060018055565b6033546001600160a01b031633146106f55760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6033805460ff909216600160e81b027fffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b3360008181526035602052604081206001015490916001600160801b039091169061075a90611805565b61076491906121c6565b90506000816001600160801b0316116107bf5760405162461bcd60e51b815260206004820152601c60248201527f596f752068617665206e6f207265776172647320746f20636c61696d0000000060448201526064016104e8565b33600090815260356020526040812054905b8181101561084f57336000908152603560205260409020805463ffffffff4216919061ffff841690811061080757610807612160565b6000918252602090912001805467ffffffffffffffff92909216600160501b0267ffffffffffffffff60501b1990921691909117905580610847816121f1565b9150506107d1565b50336000818152603560205260409081902060010180546fffffffffffffffffffffffffffffffff19169055516308934a5f60e31b815260048101919091526001600160801b03831660248201526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063449a52f890604401600060405180830381600087803b1580156108eb57600080fd5b505af11580156108ff573d6000803e3d6000fd5b50506034546033547f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03908116945063449a52f893509091169060649061095790600160e01b900460ff168761220a565b6109619190612239565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526001600160801b03166024820152604401600060405180830381600087803b1580156109c857600080fd5b505af11580156109dc573d6000803e3d6000fd5b505050505050565b6001600160a01b0381166000908152603560209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610a74576000848152602090819020604080516060810182529185015461ffff8116835267ffffffffffffffff620100008204811684860152600160501b9091041690820152825260019092019101610a1c565b505050509050919050565b6033546001600160a01b03163314610aca5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b603480546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610b375760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6033805460ff909216600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b6033546001600160a01b03163314610bbd5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b60005b81518161ffff161015610c6157818161ffff1681518110610be357610be3612160565b60200260200101516020015160366000848461ffff1681518110610c0957610c09612160565b6020908102919091018101515161ffff16825281019190915260400160002080546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905580610c598161218c565b915050610bc0565b5050565b6033546001600160a01b03163314610cb05760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b603380547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff1663ffffffff92909216600160a01b02919091179055565b6033546001600160a01b03163314610d385760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6001600160a01b038116600090815260356020526040812054905b8161ffff168161ffff161015610e61576001600160a01b0383166000908152603560205260408120805461ffff8416908110610d9157610d91612160565b6000918252602090912001546040516323b872dd60e01b81523060048201526001600160a01b03868116602483015261ffff9092166044820181905292507f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd90606401600060405180830381600087803b158015610e1757600080fd5b505af1158015610e2b573d6000803e3d6000fd5b5050505061ffff16600090815260376020526040902080546001600160a01b031916905580610e598161218c565b915050610d53565b506001600160a01b0382166000908152603560205260408120610c6191611cf1565b6033546001600160a01b03163314610ece5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b61ffff91909116600090815260376020526040902080546001600160a01b0319166001600160a01b03909216919091179055565b6033546001600160a01b03163314610f4d5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b60005b81518161ffff161015610c6157818161ffff1681518110610f7357610f73612160565b60200260200101516020015160386000848461ffff1681518110610f9957610f99612160565b602090810291909101810151516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580610fd68161218c565b915050610f50565b6033546001600160a01b031633146110295760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b815b8181101561119f5761ffff81166000908152603760205260409020546001600160a01b0316801561118c576001600160a01b038116600090815260356020526040812054815b818110156110d5576001600160a01b03841660009081526035602052604090208054869190839081106110a6576110a6612160565b60009182526020909120015461ffff16036110c3578092506110d5565b806110cd816121f1565b915050611071565b506110e08284611a93565b6040516323b872dd60e01b81523060048201526001600160a01b038481166024830152604482018690527f000000000000000000000000000000000000000000000000000000000000000016906323b872dd90606401600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b50505061ffff8516600090815260376020526040902080546001600160a01b03191690555050505b5080611197816121f1565b91505061102b565b505050565b6001600160a01b03811660009081526035602052604081206001015481906001600160801b03166111d484611805565b6111de91906121c6565b9392505050565b3360008181526035602052604081206001015490916001600160801b039091169061120f90611805565b61121991906121c6565b905060005b8281101561129c57336000908152603560205260409020805463ffffffff4216919061ffff841690811061125457611254612160565b6000918252602090912001805467ffffffffffffffff92909216600160501b0267ffffffffffffffff60501b1990921691909117905580611294816121f1565b91505061121e565b5033600090815260356020526040902060010180546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905550565b61ffff82166000908152603760205260409020546001600160a01b0316331461136a5760405162461bcd60e51b815260206004820152602a60248201527f596f7520646f6e2774206f776e206f6e65206f72206d6f7265206f662074686560448201527f736520746f6b656e73210000000000000000000000000000000000000000000060648201526084016104e8565b6000805b828110156113cd57336000908152603560205260409020805461ffff861691908390811061139e5761139e612160565b60009182526020909120015461ffff16036113bb578091506113cd565b806113c5816121f1565b91505061136e565b506033543360009081526035602052604090208054600160a01b90920467ffffffffffffffff16918390811061140557611405612160565b6000918252602090912001546114319062010000900467ffffffffffffffff164263ffffffff1661226d565b67ffffffffffffffff16116114ae5760405162461bcd60e51b815260206004820152603960248201527f4f6e65206f72206d6f7265206f6620746865736520746f6b656e73206973206e60448201527f6f7420656c6c696769626c6520666f722077697468647261770000000000000060648201526084016104e8565b6114b781611bd6565b61ffff83166000818152603760205260409081902080546001600160a01b0319169055516323b872dd60e01b815230600482015233602482015260448101919091526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906323b872dd90606401600060405180830381600087803b15801561154757600080fd5b505af115801561155b573d6000803e3d6000fd5b50505050505050565b60006115786033546001600160a01b031690565b6001600160a01b0316336001600160a01b031614905090565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b6040516331a9108f60e11b815261ffff8216600482015233906001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690636352211e90602401602060405180830381865afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190612296565b6001600160a01b0316146116c75760405162461bcd60e51b815260206004820152601960248201527f596f7520646f6e2774206f776e207468697320746f6b656e210000000000000060448201526064016104e8565b6040516323b872dd60e01b815233600482015230602482015261ffff821660448201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906323b872dd90606401600060405180830381600087803b15801561173857600080fd5b505af115801561174c573d6000803e3d6000fd5b50506040805160608101825261ffff9485168082524263ffffffff1660208084018281528486019283523360008181526035845287812080546001810182559082528482209751970180549351955197909b1669ffffffffffffffffffff19909316929092176201000067ffffffffffffffff958616021767ffffffffffffffff60501b1916600160501b94909616939093029490941790975590825260379095522080546001600160a01b0319169093179092555050565b6001600160a01b038116600090815260356020526040812054815b81811015611a4d576001600160a01b0384166000908152603560205260408120805461ffff841690811061185657611856612160565b6000918252602080832091909101546001600160a01b038816835260359091526040822080546201000090920467ffffffffffffffff1693509061ffff85169081106118a4576118a4612160565b6000918252602080832091909101546001600160a01b03891683526035909152604082208054600160501b90920467ffffffffffffffff16935060369183919061ffff88169081106118f8576118f8612160565b600091825260208083209091015461ffff168352820192909252604001902054611933906001600160801b0316670de0b6b3a764000061220a565b905061194967ffffffffffffffff8416426122b3565b603354600160a01b900467ffffffffffffffff1610156119fd57600061196f84846122ca565b60335461198d9190600160a01b900467ffffffffffffffff166122ca565b60070b13156119f25762015180816119a5858561226d565b6033546119c39190600160a01b900467ffffffffffffffff1661226d565b67ffffffffffffffff166119d7919061220a565b6119e19190612239565b6119eb90876121c6565b9550611a37565b6119eb6000876121c6565b6201518081611a0c844261226d565b67ffffffffffffffff16611a20919061220a565b611a2a9190612239565b611a3490876121c6565b95505b5050508080611a45906121f1565b915050611820565b503360009081526038602052604090205460ff1615611a8d57603354600a90611a8090600160e81b900460ff168461220a565b611a8a9190612239565b91505b50919050565b6001600160a01b03811660009081526035602052604090208054611ab9906001906122b3565b81548110611ac957611ac9612160565b9060005260206000200160356000836001600160a01b03166001600160a01b031681526020019081526020016000206000018381548110611b0c57611b0c612160565b6000918252602080832084549201805461ffff90931661ffff19841681178255855469ffffffffffffffffffff1990941617620100009384900467ffffffffffffffff90811690940217808255945467ffffffffffffffff60501b19909516600160501b95869004909316909402919091179092556001600160a01b0383168152603590915260409020805480611ba557611ba561231c565b6000828152602090208101600019908101805471ffffffffffffffffffffffffffffffffffff191690550190555050565b3360009081526035602052604090208054611bf3906001906122b3565b81548110611c0357611c03612160565b60009182526020808320338452603590915260409092208054929091019183908110611c3157611c31612160565b6000918252602080832084549201805461ffff90931661ffff19841681178255855469ffffffffffffffffffff1990941617620100009384900467ffffffffffffffff90811690940217808255945467ffffffffffffffff60501b19909516600160501b9586900490931690940291909117909255338152603590915260409020805480611cc157611cc161231c565b6000828152602090208101600019908101805471ffffffffffffffffffffffffffffffffffff1916905501905550565b50805460008255906000526020600020908101906105fc91905b80821115611d3457805471ffffffffffffffffffffffffffffffffffff19168155600101611d0b565b5090565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715611d7157611d71611d38565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611da057611da0611d38565b604052919050565b600067ffffffffffffffff821115611dc257611dc2611d38565b5060051b60200190565b803561ffff81168114611dde57600080fd5b919050565b60006020808385031215611df657600080fd5b823567ffffffffffffffff811115611e0d57600080fd5b8301601f81018513611e1e57600080fd5b8035611e31611e2c82611da8565b611d77565b81815260059190911b82018301908381019087831115611e5057600080fd5b928401925b82841015611e7557611e6684611dcc565b82529284019290840190611e55565b979650505050505050565b600060208284031215611e9257600080fd5b6111de82611dcc565b6001600160a01b03811681146105fc57600080fd5b600060208284031215611ec257600080fd5b81356111de81611e9b565b600060208284031215611edf57600080fd5b813560ff811681146111de57600080fd5b602080825282518282018190526000919060409081850190868401855b82811015611f4e578151805161ffff1685528681015167ffffffffffffffff9081168887015290860151168585015260609093019290850190600101611f0d565b5091979650505050505050565b60006020808385031215611f6e57600080fd5b823567ffffffffffffffff811115611f8557600080fd5b8301601f81018513611f9657600080fd5b8035611fa4611e2c82611da8565b81815260069190911b82018301908381019087831115611fc357600080fd5b928401925b82841015611e755760408489031215611fe15760008081fd5b611fe9611d4e565b611ff285611dcc565b8152858501356001600160801b038116811461200e5760008081fd5b8187015282526040939093019290840190611fc8565b60006020828403121561203657600080fd5b813563ffffffff811681146111de57600080fd5b6000806040838503121561205d57600080fd5b82359150602083013561206f81611e9b565b809150509250929050565b6000602080838503121561208d57600080fd5b823567ffffffffffffffff8111156120a457600080fd5b8301601f810185136120b557600080fd5b80356120c3611e2c82611da8565b81815260069190911b820183019083810190878311156120e257600080fd5b928401925b82841015611e7557604084890312156121005760008081fd5b612108611d4e565b843561211381611e9b565b81528486013580151581146121285760008081fd5b81870152825260409390930192908401906120e7565b6000806040838503121561215157600080fd5b50508035926020909101359150565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600061ffff8083168181036121a3576121a3612176565b6001019392505050565b600063ffffffff8083168181036121a3576121a3612176565b60006001600160801b038083168185168083038211156121e8576121e8612176565b01949350505050565b60006001820161220357612203612176565b5060010190565b60006001600160801b038083168185168183048111821515161561223057612230612176565b02949350505050565b60006001600160801b038084168061226157634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b600067ffffffffffffffff8381169083168181101561228e5761228e612176565b039392505050565b6000602082840312156122a857600080fd5b81516111de81611e9b565b6000828210156122c5576122c5612176565b500390565b60008160070b8360070b6000811281677fffffffffffffff19018312811516156122f6576122f6612176565b81677fffffffffffffff01831381161561231257612312612176565b5090039392505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220f1c00384d1f4297815ab4278890e9e191d02d26ccfb835f5bcb9c72fdb562a4e64736f6c634300080d00330000000000000000000000000e32cee0445413e118b14d02e0409303d338487a000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc2822
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c80638da5cb5b116100ee578063b2f57e6b11610097578063ce6cb9fd11610071578063ce6cb9fd1461043a578063d1af0c7d1461044d578063f27d865814610474578063f854a27f1461048757600080fd5b8063b2f57e6b146103ea578063b5331c1c146103fe578063c9b9918b1461042757600080fd5b80639168ae72116100c85780639168ae7214610398578063944d8d25146103c4578063a71bc5ff146103d757600080fd5b80638da5cb5b146103615780638f1fa6141461037257806390a8a3ba1461038557600080fd5b8063372500ab1161015b5780636588103b116101355780636588103b146102ce5780636605bfda146102f55780637ab5608314610308578063887553a01461032e57600080fd5b8063372500ab1461027b57806361d027b31461028357806363c28db1146102ae57600080fd5b806313af40351161018c57806313af4035146102425780632bdcfe72146102555780633317f7d91461026857600080fd5b8063081bc3f1146101b35780630a501950146101c857806312eb4f9a1461020e575b600080fd5b6101c66101c1366004611de3565b61049a565b005b6101f16101d6366004611e80565b6036602052600090815260409020546001600160801b031681565b6040516001600160801b0390911681526020015b60405180910390f35b60335461022990600160a01b900467ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610205565b6101c6610250366004611eb0565b6105ae565b6101c6610263366004611de3565b6105ff565b6101c6610276366004611ecd565b6106aa565b6101c6610730565b603454610296906001600160a01b031681565b6040516001600160a01b039091168152602001610205565b6102c16102bc366004611eb0565b6109e4565b6040516102059190611ef0565b6102967f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a81565b6101c6610303366004611eb0565b610a7f565b60335461031c90600160e01b900460ff1681565b60405160ff9091168152602001610205565b61035161033c366004611eb0565b60386020526000908152604090205460ff1681565b6040519015158152602001610205565b6033546001600160a01b0316610296565b6101c6610380366004611ecd565b610aec565b6101c6610393366004611f5b565b610b72565b6101f16103a6366004611eb0565b6035602052600090815260409020600101546001600160801b031681565b6101c66103d2366004612024565b610c65565b6101c66103e5366004611eb0565b610ced565b60335461031c90600160e81b900460ff1681565b61029661040c366004611e80565b6037602052600090815260409020546001600160a01b031681565b6101c661043536600461204a565b610e83565b6101c661044836600461207a565b610f02565b6102967f000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc282281565b6101c661048236600461213e565b610fde565b6101f1610495366004611eb0565b6111a4565b6002600154036104f15760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b600260015533600090815260356020526040902054806105535760405162461bcd60e51b815260206004820152601960248201527f596f752068617665206e6f20746f6b656e73207374616b65640000000000000060448201526064016104e8565b61055c816111e5565b60005b82518161ffff1610156105a557610593838261ffff168151811061058557610585612160565b6020026020010151836112d9565b8061059d8161218c565b91505061055f565b50506001805550565b6105b6611564565b6105f35760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6105fc81611591565b50565b6002600154036106515760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104e8565b600260015560005b81518163ffffffff1610156106a257610690828263ffffffff168151811061068357610683612160565b60200260200101516115e3565b8061069a816121ad565b915050610659565b505060018055565b6033546001600160a01b031633146106f55760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6033805460ff909216600160e81b027fffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b3360008181526035602052604081206001015490916001600160801b039091169061075a90611805565b61076491906121c6565b90506000816001600160801b0316116107bf5760405162461bcd60e51b815260206004820152601c60248201527f596f752068617665206e6f207265776172647320746f20636c61696d0000000060448201526064016104e8565b33600090815260356020526040812054905b8181101561084f57336000908152603560205260409020805463ffffffff4216919061ffff841690811061080757610807612160565b6000918252602090912001805467ffffffffffffffff92909216600160501b0267ffffffffffffffff60501b1990921691909117905580610847816121f1565b9150506107d1565b50336000818152603560205260409081902060010180546fffffffffffffffffffffffffffffffff19169055516308934a5f60e31b815260048101919091526001600160801b03831660248201526001600160a01b037f000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc2822169063449a52f890604401600060405180830381600087803b1580156108eb57600080fd5b505af11580156108ff573d6000803e3d6000fd5b50506034546033547f000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc28226001600160a01b03908116945063449a52f893509091169060649061095790600160e01b900460ff168761220a565b6109619190612239565b6040517fffffffff0000000000000000000000000000000000000000000000000000000060e085901b1681526001600160a01b0390921660048301526001600160801b03166024820152604401600060405180830381600087803b1580156109c857600080fd5b505af11580156109dc573d6000803e3d6000fd5b505050505050565b6001600160a01b0381166000908152603560209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610a74576000848152602090819020604080516060810182529185015461ffff8116835267ffffffffffffffff620100008204811684860152600160501b9091041690820152825260019092019101610a1c565b505050509050919050565b6033546001600160a01b03163314610aca5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b603480546001600160a01b0319166001600160a01b0392909216919091179055565b6033546001600160a01b03163314610b375760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6033805460ff909216600160e01b027fffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffffffff909216919091179055565b6033546001600160a01b03163314610bbd5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b60005b81518161ffff161015610c6157818161ffff1681518110610be357610be3612160565b60200260200101516020015160366000848461ffff1681518110610c0957610c09612160565b6020908102919091018101515161ffff16825281019190915260400160002080546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905580610c598161218c565b915050610bc0565b5050565b6033546001600160a01b03163314610cb05760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b603380547fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff1663ffffffff92909216600160a01b02919091179055565b6033546001600160a01b03163314610d385760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b6001600160a01b038116600090815260356020526040812054905b8161ffff168161ffff161015610e61576001600160a01b0383166000908152603560205260408120805461ffff8416908110610d9157610d91612160565b6000918252602090912001546040516323b872dd60e01b81523060048201526001600160a01b03868116602483015261ffff9092166044820181905292507f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a909116906323b872dd90606401600060405180830381600087803b158015610e1757600080fd5b505af1158015610e2b573d6000803e3d6000fd5b5050505061ffff16600090815260376020526040902080546001600160a01b031916905580610e598161218c565b915050610d53565b506001600160a01b0382166000908152603560205260408120610c6191611cf1565b6033546001600160a01b03163314610ece5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b61ffff91909116600090815260376020526040902080546001600160a01b0319166001600160a01b03909216919091179055565b6033546001600160a01b03163314610f4d5760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b60005b81518161ffff161015610c6157818161ffff1681518110610f7357610f73612160565b60200260200101516020015160386000848461ffff1681518110610f9957610f99612160565b602090810291909101810151516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580610fd68161218c565b915050610f50565b6033546001600160a01b031633146110295760405162461bcd60e51b815260206004820152600e60248201526d139bdd08185d5d1a1bdc9a5e995960921b60448201526064016104e8565b815b8181101561119f5761ffff81166000908152603760205260409020546001600160a01b0316801561118c576001600160a01b038116600090815260356020526040812054815b818110156110d5576001600160a01b03841660009081526035602052604090208054869190839081106110a6576110a6612160565b60009182526020909120015461ffff16036110c3578092506110d5565b806110cd816121f1565b915050611071565b506110e08284611a93565b6040516323b872dd60e01b81523060048201526001600160a01b038481166024830152604482018690527f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a16906323b872dd90606401600060405180830381600087803b15801561115057600080fd5b505af1158015611164573d6000803e3d6000fd5b50505061ffff8516600090815260376020526040902080546001600160a01b03191690555050505b5080611197816121f1565b91505061102b565b505050565b6001600160a01b03811660009081526035602052604081206001015481906001600160801b03166111d484611805565b6111de91906121c6565b9392505050565b3360008181526035602052604081206001015490916001600160801b039091169061120f90611805565b61121991906121c6565b905060005b8281101561129c57336000908152603560205260409020805463ffffffff4216919061ffff841690811061125457611254612160565b6000918252602090912001805467ffffffffffffffff92909216600160501b0267ffffffffffffffff60501b1990921691909117905580611294816121f1565b91505061121e565b5033600090815260356020526040902060010180546fffffffffffffffffffffffffffffffff19166001600160801b039290921691909117905550565b61ffff82166000908152603760205260409020546001600160a01b0316331461136a5760405162461bcd60e51b815260206004820152602a60248201527f596f7520646f6e2774206f776e206f6e65206f72206d6f7265206f662074686560448201527f736520746f6b656e73210000000000000000000000000000000000000000000060648201526084016104e8565b6000805b828110156113cd57336000908152603560205260409020805461ffff861691908390811061139e5761139e612160565b60009182526020909120015461ffff16036113bb578091506113cd565b806113c5816121f1565b91505061136e565b506033543360009081526035602052604090208054600160a01b90920467ffffffffffffffff16918390811061140557611405612160565b6000918252602090912001546114319062010000900467ffffffffffffffff164263ffffffff1661226d565b67ffffffffffffffff16116114ae5760405162461bcd60e51b815260206004820152603960248201527f4f6e65206f72206d6f7265206f6620746865736520746f6b656e73206973206e60448201527f6f7420656c6c696769626c6520666f722077697468647261770000000000000060648201526084016104e8565b6114b781611bd6565b61ffff83166000818152603760205260409081902080546001600160a01b0319169055516323b872dd60e01b815230600482015233602482015260448101919091526001600160a01b037f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a16906323b872dd90606401600060405180830381600087803b15801561154757600080fd5b505af115801561155b573d6000803e3d6000fd5b50505050505050565b60006115786033546001600160a01b031690565b6001600160a01b0316336001600160a01b031614905090565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d7690600090a35050565b6040516331a9108f60e11b815261ffff8216600482015233906001600160a01b037f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a1690636352211e90602401602060405180830381865afa15801561164d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116719190612296565b6001600160a01b0316146116c75760405162461bcd60e51b815260206004820152601960248201527f596f7520646f6e2774206f776e207468697320746f6b656e210000000000000060448201526064016104e8565b6040516323b872dd60e01b815233600482015230602482015261ffff821660448201527f0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a6001600160a01b0316906323b872dd90606401600060405180830381600087803b15801561173857600080fd5b505af115801561174c573d6000803e3d6000fd5b50506040805160608101825261ffff9485168082524263ffffffff1660208084018281528486019283523360008181526035845287812080546001810182559082528482209751970180549351955197909b1669ffffffffffffffffffff19909316929092176201000067ffffffffffffffff958616021767ffffffffffffffff60501b1916600160501b94909616939093029490941790975590825260379095522080546001600160a01b0319169093179092555050565b6001600160a01b038116600090815260356020526040812054815b81811015611a4d576001600160a01b0384166000908152603560205260408120805461ffff841690811061185657611856612160565b6000918252602080832091909101546001600160a01b038816835260359091526040822080546201000090920467ffffffffffffffff1693509061ffff85169081106118a4576118a4612160565b6000918252602080832091909101546001600160a01b03891683526035909152604082208054600160501b90920467ffffffffffffffff16935060369183919061ffff88169081106118f8576118f8612160565b600091825260208083209091015461ffff168352820192909252604001902054611933906001600160801b0316670de0b6b3a764000061220a565b905061194967ffffffffffffffff8416426122b3565b603354600160a01b900467ffffffffffffffff1610156119fd57600061196f84846122ca565b60335461198d9190600160a01b900467ffffffffffffffff166122ca565b60070b13156119f25762015180816119a5858561226d565b6033546119c39190600160a01b900467ffffffffffffffff1661226d565b67ffffffffffffffff166119d7919061220a565b6119e19190612239565b6119eb90876121c6565b9550611a37565b6119eb6000876121c6565b6201518081611a0c844261226d565b67ffffffffffffffff16611a20919061220a565b611a2a9190612239565b611a3490876121c6565b95505b5050508080611a45906121f1565b915050611820565b503360009081526038602052604090205460ff1615611a8d57603354600a90611a8090600160e81b900460ff168461220a565b611a8a9190612239565b91505b50919050565b6001600160a01b03811660009081526035602052604090208054611ab9906001906122b3565b81548110611ac957611ac9612160565b9060005260206000200160356000836001600160a01b03166001600160a01b031681526020019081526020016000206000018381548110611b0c57611b0c612160565b6000918252602080832084549201805461ffff90931661ffff19841681178255855469ffffffffffffffffffff1990941617620100009384900467ffffffffffffffff90811690940217808255945467ffffffffffffffff60501b19909516600160501b95869004909316909402919091179092556001600160a01b0383168152603590915260409020805480611ba557611ba561231c565b6000828152602090208101600019908101805471ffffffffffffffffffffffffffffffffffff191690550190555050565b3360009081526035602052604090208054611bf3906001906122b3565b81548110611c0357611c03612160565b60009182526020808320338452603590915260409092208054929091019183908110611c3157611c31612160565b6000918252602080832084549201805461ffff90931661ffff19841681178255855469ffffffffffffffffffff1990941617620100009384900467ffffffffffffffff90811690940217808255945467ffffffffffffffff60501b19909516600160501b9586900490931690940291909117909255338152603590915260409020805480611cc157611cc161231c565b6000828152602090208101600019908101805471ffffffffffffffffffffffffffffffffffff1916905501905550565b50805460008255906000526020600020908101906105fc91905b80821115611d3457805471ffffffffffffffffffffffffffffffffffff19168155600101611d0b565b5090565b634e487b7160e01b600052604160045260246000fd5b6040805190810167ffffffffffffffff81118282101715611d7157611d71611d38565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611da057611da0611d38565b604052919050565b600067ffffffffffffffff821115611dc257611dc2611d38565b5060051b60200190565b803561ffff81168114611dde57600080fd5b919050565b60006020808385031215611df657600080fd5b823567ffffffffffffffff811115611e0d57600080fd5b8301601f81018513611e1e57600080fd5b8035611e31611e2c82611da8565b611d77565b81815260059190911b82018301908381019087831115611e5057600080fd5b928401925b82841015611e7557611e6684611dcc565b82529284019290840190611e55565b979650505050505050565b600060208284031215611e9257600080fd5b6111de82611dcc565b6001600160a01b03811681146105fc57600080fd5b600060208284031215611ec257600080fd5b81356111de81611e9b565b600060208284031215611edf57600080fd5b813560ff811681146111de57600080fd5b602080825282518282018190526000919060409081850190868401855b82811015611f4e578151805161ffff1685528681015167ffffffffffffffff9081168887015290860151168585015260609093019290850190600101611f0d565b5091979650505050505050565b60006020808385031215611f6e57600080fd5b823567ffffffffffffffff811115611f8557600080fd5b8301601f81018513611f9657600080fd5b8035611fa4611e2c82611da8565b81815260069190911b82018301908381019087831115611fc357600080fd5b928401925b82841015611e755760408489031215611fe15760008081fd5b611fe9611d4e565b611ff285611dcc565b8152858501356001600160801b038116811461200e5760008081fd5b8187015282526040939093019290840190611fc8565b60006020828403121561203657600080fd5b813563ffffffff811681146111de57600080fd5b6000806040838503121561205d57600080fd5b82359150602083013561206f81611e9b565b809150509250929050565b6000602080838503121561208d57600080fd5b823567ffffffffffffffff8111156120a457600080fd5b8301601f810185136120b557600080fd5b80356120c3611e2c82611da8565b81815260069190911b820183019083810190878311156120e257600080fd5b928401925b82841015611e7557604084890312156121005760008081fd5b612108611d4e565b843561211381611e9b565b81528486013580151581146121285760008081fd5b81870152825260409390930192908401906120e7565b6000806040838503121561215157600080fd5b50508035926020909101359150565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600061ffff8083168181036121a3576121a3612176565b6001019392505050565b600063ffffffff8083168181036121a3576121a3612176565b60006001600160801b038083168185168083038211156121e8576121e8612176565b01949350505050565b60006001820161220357612203612176565b5060010190565b60006001600160801b038083168185168183048111821515161561223057612230612176565b02949350505050565b60006001600160801b038084168061226157634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b600067ffffffffffffffff8381169083168181101561228e5761228e612176565b039392505050565b6000602082840312156122a857600080fd5b81516111de81611e9b565b6000828210156122c5576122c5612176565b500390565b60008160070b8360070b6000811281677fffffffffffffff19018312811516156122f6576122f6612176565b81677fffffffffffffff01831381161561231257612312612176565b5090039392505050565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220f1c00384d1f4297815ab4278890e9e191d02d26ccfb835f5bcb9c72fdb562a4e64736f6c634300080d0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc2822
-----Decoded View---------------
Arg [0] : _nftCollection (address): 0x0E32cEE0445413e118b14d02E0409303D338487a
Arg [1] : _rewardsToken (address): 0xC221E9e48C396c1A5A0EF47a7989127f8Fcc2822
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000000e32cee0445413e118b14d02e0409303d338487a
Arg [1] : 000000000000000000000000c221e9e48c396c1a5a0ef47a7989127f8fcc2822
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
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.