ERC-1155
Overview
Max Total Supply
1,000 ALPHASTARTER
Holders
86
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x2205d043...6CbD8832C The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
Alphastarter1155
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity 0.8.26; import {Ownable, Ownable2Step} from "./libs/@openzeppelin/contracts/access/Ownable2Step.sol"; import {EnumerableSet} from "./libs/@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {ERC1155} from "./libs/@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {Strings} from "./libs/@openzeppelin/contracts/utils/Strings.sol"; import {ERC1155Holders} from "./erc1155/holders/ERC1155Holders.sol"; import {ERC1155Votes} from "./erc1155/votes/ERC1155Votes.sol"; import {Multicall} from "./utils/Multicall.sol"; /** * @title Alphastarter1155 * @notice ERC1155 token with minter role and finalized flag, also sanpshot for voting */ contract Alphastarter1155 is Ownable2Step, ERC1155, ERC1155Holders, ERC1155Votes, Multicall { using Strings for uint256; using EnumerableSet for EnumerableSet.AddressSet; error IdFinalized(uint256 id); error IdNotExists(uint256 id); error IdNotFinalized(uint256 id); error InvalidArrayLength(uint256 length1, uint256 length2); error NotMinter(address caller); error NotOwnerOrMinter(address caller); event BaseURIChanged(string baseURI); event Finalized(uint256 indexed id, bool flag); event MinterAdded(address indexed minter); event MinterRemoved(address indexed minter); /** * @dev list of minters (fundraiser contracts) */ EnumerableSet.AddressSet private _minters; /** * @dev flag to check if id is finalized * finalized token can be transfered or burned but can not be minted */ mapping(uint256 id => bool) private _finalized; /** * @dev token's name */ string private _name; /** * @dev token's symbol */ string private _symbol; /** * @dev token's base uri, must be ended with '/' */ string private _baseURI = ""; /** * @notice constructor * @param initialOwner the owner of the contract * @param name_ the name of the token * @param symbol_ the symbol of the token * @param baseURI the base uri of the token */ constructor( address initialOwner, string memory name_, string memory symbol_, string memory baseURI ) ERC1155("") Ownable(initialOwner) { _name = name_; _symbol = symbol_; _setBaseURI(baseURI); } modifier onlyMinter() { if (!isMinter(_msgSender())) { revert NotMinter(_msgSender()); } _; } modifier onlyOwnerOrMinter() { if (owner() != _msgSender() && !isMinter(_msgSender())) { revert NotOwnerOrMinter(_msgSender()); } _; } modifier onlyNotFinalized(uint256 id) { _checkNotFinalized(id); _; } modifier onlyNotFinalizedBatch(uint256[] memory ids) { for (uint256 i = 0; i < ids.length; i++) { _checkNotFinalized(ids[i]); } _; } modifier onlyFinalized(uint256 id) { _checkFinalized(id); _; } modifier onlyFinalizedBatch(uint256[] memory ids) { for (uint256 i = 0; i < ids.length; i++) { _checkFinalized(ids[i]); } _; } /** * @notice Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @notice Returns the symbol of the token, usually a shorter version of the name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev IERC6372, overrided for timestamp-based clock */ function clock() public view override returns (uint48) { return uint48(block.timestamp); } /** * @dev IERC6372, overrided for timestamp-based clock */ // solhint-disable-next-line func-name-mixedcase function CLOCK_MODE() public pure override returns (string memory) { return "mode=timestamp"; } /** * @dev set base uri, must be set with '/' at the end */ function _setBaseURI(string memory baseURI) internal { _baseURI = baseURI; emit BaseURIChanged(baseURI); } /** * @notice set base uri */ function setBaseURI(string memory baseURI) public onlyOwner { _setBaseURI(baseURI); } /** * @notice get base uri */ function getBaseURI() public view returns (string memory) { return _baseURI; } /** * @notice returns the token's uri based on the id * reverts if id does not exist (totalSupply is 0) */ function uri(uint256 id) public view override returns (string memory) { if (!exists(id)) { revert IdNotExists(id); } return string.concat(_baseURI, id.toString()); } /** * @dev check if id finalizes */ function _checkFinalized(uint256 id) internal view { if (!isFinalized(id)) { revert IdNotFinalized(id); } } /** * @dev check if id not finalizes */ function _checkNotFinalized(uint256 id) internal view { if (isFinalized(id)) { revert IdFinalized(id); } } /** * @notice check the token of id is finalized */ function isFinalized(uint256 id) public view returns (bool) { return _finalized[id]; } /** * @dev set finalized flag for id */ function _finalize(uint256 id, bool flag) internal { _finalized[id] = flag; emit Finalized(id, flag); } /** * @notice finalize the token of id */ function finalize(uint256 id, bool flag) public onlyOwnerOrMinter { _finalize(id, flag); } /** * @notice finalize multiple tokens of ids */ function finalizeBatch(uint256[] memory ids, bool[] memory flags) public onlyOwnerOrMinter { if (ids.length != flags.length) { revert InvalidArrayLength(ids.length, flags.length); } for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; bool flag = flags[i]; _finalize(id, flag); } } /** * @notice add the address as minter * fundraiser contract should be added as minter */ function addMinter(address minter) public onlyOwner { _minters.add(minter); emit MinterAdded(minter); } /** * @notice remove the address from minter */ function removeMinter(address minter) public onlyOwner { _minters.remove(minter); emit MinterRemoved(minter); } /** * @notice get the list of minter addresses */ function getMinters() public view returns (address[] memory) { return _minters.values(); } /** * @notice get the number of minter addresses */ function getMinterCount() public view returns (uint256) { return _minters.length(); } /** * @notice get the minter address at index */ function getMinterAt(uint256 index) public view returns (address) { return _minters.at(index); } /** * @notice check if the address is minter */ function isMinter(address account) public view returns (bool) { return _minters.contains(account); } /** * @notice mint 1155 token with single id * @dev token id must not be finalized */ function mint( address account, uint256 id, uint256 amount, bytes memory data ) public onlyMinter onlyNotFinalized(id) { _mint(account, id, amount, data); } /** * @notice mint 1155 tokens with multiple ids * @dev all ids must not be finalized */ function mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public onlyMinter onlyNotFinalizedBatch(ids) { _mintBatch(to, ids, amounts, data); } /** * @notice burn 1155 token with single id * @dev token id must be finalized */ function burn(address account, uint256 id, uint256 value) public onlyFinalized(id) { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burn(account, id, value); } /** * @notice burn 1155 tokens with multiple ids * @dev all ids must be finalized */ function burnBatch(address account, uint256[] memory ids, uint256[] memory values) public onlyFinalizedBatch(ids) { if (account != _msgSender() && !isApprovedForAll(account, _msgSender())) { revert ERC1155MissingApprovalForAll(_msgSender(), account); } _burnBatch(account, ids, values); } /** * @notice transfer 1155 token with single id * @dev token id must be finalized */ function safeTransferFrom( address from, address to, uint256 id, uint256 value, bytes memory data ) public override onlyFinalized(id) { super.safeTransferFrom(from, to, id, value, data); } /** * @notice transfer 1155 token with mutiple ids * @dev all ids must be finalized */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public override onlyFinalizedBatch(ids) { super.safeBatchTransferFrom(from, to, ids, values, data); } // The following functions are overrides required by Solidity. function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal override(ERC1155, ERC1155Votes, ERC1155Holders) { super._update(from, to, ids, values); } }
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity 0.8.26; import {ERC1155} from "../../libs/@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {EnumerableSet} from "../../libs/@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; /** * @dev Extension of ERC1155 to support voting and delegation as implemented by {Votes} * * Tokens do not count as votes until they are delegated, because votes must be tracked which incurs an additional cost * on every transfer. Token holders can either delegate to a trusted representative who will decide how to make use of * the votes in governance decisions, or they can delegate to themselves to be their own representative. */ abstract contract ERC1155Holders is ERC1155 { using EnumerableSet for EnumerableSet.AddressSet; using EnumerableSet for EnumerableSet.UintSet; mapping(uint256 id => uint256) private _totalSupply; uint256 private _totalSupplyAll; mapping(uint256 id => EnumerableSet.AddressSet) private _holders; mapping(address account => EnumerableSet.UintSet) private _holdingTokens; EnumerableSet.UintSet private _existingTokens; /** * @dev Total value of tokens in with a given id. */ function totalSupply(uint256 id) public view virtual returns (uint256) { return _totalSupply[id]; } /** * @dev Total value of tokens. */ function totalSupplyAll() public view virtual returns (uint256) { return _totalSupplyAll; } /** * @dev Indicates whether any token exist with a given id, or not. */ function exists(uint256 id) public view virtual returns (bool) { return totalSupply(id) > 0; } function getHolders(uint256 id) public view returns (address[] memory) { return _holders[id].values(); } function getHoldersCount(uint256 id) public view returns (uint256) { return _holders[id].length(); } function getHolderAt(uint256 id, uint256 index) public view returns (address) { return _holders[id].at(index); } function getHoldingTokens(address account) public view returns (uint256[] memory) { return _holdingTokens[account].values(); } function getHoldingTokensCount(address account) public view returns (uint256) { return _holdingTokens[account].length(); } function getHoldingTokenAt(address account, uint256 index) public view returns (uint256) { return _holdingTokens[account].at(index); } function getExistingTokens() public view returns (uint256[] memory) { return _existingTokens.values(); } function getExistingTokensCount() public view returns (uint256) { return _existingTokens.length(); } function getExistingTokenAt(uint256 index) public view returns (uint256) { return _existingTokens.at(index); } // The following functions are overrides required by Solidity. function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override { super._update(from, to, ids, values); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 value = values[i]; if (from != address(0)) { if (balanceOf(from, id) == 0) { _holders[id].remove(from); _holdingTokens[from].remove(id); } } else { // mint _totalSupply[id] += value; if (_totalSupply[id] > 0) { _existingTokens.add(id); } _totalSupplyAll += value; } if (to != address(0)) { if (balanceOf(to, id) > 0) { _holders[id].add(to); _holdingTokens[to].add(id); } } else { // burn _totalSupply[id] -= value; if (_totalSupply[id] == 0) { _existingTokens.remove(id); } _totalSupplyAll -= value; } } } }
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity 0.8.26; import {ERC1155} from "../../libs/@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import {Checkpoints} from "../../libs/@openzeppelin/contracts/utils/structs/Checkpoints.sol"; import {Votes} from "./Votes.sol"; abstract contract ERC1155Votes is ERC1155, Votes { function getTotalSupply(uint256 id) public view returns (uint256) { return _getTotalSupply(id); } function getNumCheckpoints(address account, uint256 id) public view virtual returns (uint32) { return _numCheckpoints(account, id); } function getCheckPoints( address account, uint256 id, uint32 pos ) public view returns (Checkpoints.Checkpoint208 memory) { return _checkpoints(account, id, pos); } /** * @dev See {ERC1155-_update}. Adjusts votes when tokens are transferred. * * Emits a {IVotes-VotesChanged} event. */ function _update( address from, address to, uint256[] memory ids, uint256[] memory values ) internal virtual override { super._update(from, to, ids, values); for (uint256 i = 0; i < ids.length; ++i) { _transferVotingUnits(from, to, ids[i], values[i]); } } }
// SPDX-License-Identifier: MIT // Compatible with OpenZeppelin Contracts ^5.0.0 pragma solidity 0.8.26; import {IERC6372} from "../../libs/@openzeppelin/contracts/interfaces/IERC6372.sol"; import {Context} from "../../libs/@openzeppelin/contracts/utils/Context.sol"; import {Checkpoints} from "../../libs/@openzeppelin/contracts/utils/structs/Checkpoints.sol"; import {SafeCast} from "../../libs/@openzeppelin/contracts/utils/math/SafeCast.sol"; import {Time} from "../../libs/@openzeppelin/contracts/utils/types/Time.sol"; /** * @dev This is a base abstract contract that tracks voting units, which are a measure of voting power that can be * transferred, and provides a system of vote delegation, where an account can delegate its voting units to a sort of * "representative" that will pool delegated voting units from different accounts and can then use it to vote in * decisions. In fact, voting units _must_ be delegated in order to count as actual votes, and an account has to * delegate those votes to itself if it wishes to participate in decisions and does not have a trusted representative. * * This contract is often combined with a token contract such that voting units correspond to token units. For an * example, see {ERC721Votes}. * * The full history of delegate votes is tracked on-chain so that governance protocols can consider votes as distributed * at a particular block number to protect against flash loans and double voting. The opt-in delegate system makes the * cost of this history tracking optional. * * When using this module the derived contract must implement {_getVotingUnits} (for example, make it return * {ERC721-balanceOf}), and can use {_transferVotingUnits} to track a change in the distribution of those units (in the * previous example, it would be included in {ERC721-_update}). */ abstract contract Votes is Context, IERC6372 { using Checkpoints for Checkpoints.Trace208; mapping(uint256 id => mapping(address account => Checkpoints.Trace208)) private _accountCheckpoints; mapping(uint256 id => Checkpoints.Trace208) private _totalCheckpoints; event VotesChanged(address account, uint256 id, uint256 oldValue, uint256 newValue); /** * @dev The clock was incorrectly modified. */ error ERC6372InconsistentClock(); /** * @dev Lookup to future votes is not available. */ error VotesFutureLookup(uint256 timepoint, uint48 clock); /** * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based * checkpoints (and voting), in which case {CLOCK_MODE} should be overridden as well to match. */ function clock() public view virtual returns (uint48) { return Time.blockNumber(); } /** * @dev Machine-readable description of the clock as specified in EIP-6372. */ // solhint-disable-next-line func-name-mixedcase function CLOCK_MODE() public view virtual returns (string memory) { // Check that the clock was not modified if (clock() != Time.blockNumber()) { revert ERC6372InconsistentClock(); } return "mode=blocknumber&from=default"; } /** * @dev Returns the current amount of votes that `account` has. */ function getVotes(address account, uint256 id) public view virtual returns (uint256) { return _accountCheckpoints[id][account].latest(); } /** * @dev Returns the amount of votes that `account` had at a specific moment in the past. If the `clock()` is * configured to use block numbers, this will return the value at the end of the corresponding block. * * Requirements: * * - `timepoint` must be in the past. If operating using block numbers, the block must be already mined. */ function getPastVotes(address account, uint256 id, uint256 timepoint) public view virtual returns (uint256) { uint48 currentTimepoint = clock(); if (timepoint >= currentTimepoint) { revert VotesFutureLookup(timepoint, currentTimepoint); } return _accountCheckpoints[id][account].upperLookupRecent(SafeCast.toUint48(timepoint)); } /** * @dev Returns the total supply of votes available at a specific moment in the past. If the `clock()` is * configured to use block numbers, this will return the value at the end of the corresponding block. * * NOTE: This value is the sum of all available votes, which is not necessarily the sum of all delegated votes. * Votes that have not been delegated are still part of total supply, even though they would not participate in a * vote. * * Requirements: * * - `timepoint` must be in the past. If operating using block numbers, the block must be already mined. */ function getPastTotalSupply(uint256 id, uint256 timepoint) public view virtual returns (uint256) { uint48 currentTimepoint = clock(); if (timepoint >= currentTimepoint) { revert VotesFutureLookup(timepoint, currentTimepoint); } return _totalCheckpoints[id].upperLookupRecent(SafeCast.toUint48(timepoint)); } /** * @dev Returns the current total supply of votes. */ function _getTotalSupply(uint256 id) internal view virtual returns (uint256) { return _totalCheckpoints[id].latest(); } /** * @dev Transfers, mints, or burns voting units. To register a mint, `from` should be zero. To register a burn, `to` * should be zero. Total supply of voting units will be adjusted with mints and burns. */ function _transferVotingUnits(address from, address to, uint256 id, uint256 amount) internal virtual { if (from == address(0)) { _push(_totalCheckpoints[id], _add, SafeCast.toUint208(amount)); } if (to == address(0)) { _push(_totalCheckpoints[id], _subtract, SafeCast.toUint208(amount)); } _moveVotes(from, to, id, amount); } /** * @dev Moves votes from one to another. */ function _moveVotes(address from, address to, uint256 id, uint256 amount) private { if (from != to && amount > 0) { if (from != address(0)) { (uint256 oldValue, uint256 newValue) = _push( _accountCheckpoints[id][from], _subtract, SafeCast.toUint208(amount) ); emit VotesChanged(from, id, oldValue, newValue); } if (to != address(0)) { (uint256 oldValue, uint256 newValue) = _push( _accountCheckpoints[id][to], _add, SafeCast.toUint208(amount) ); emit VotesChanged(to, id, oldValue, newValue); } } } /** * @dev Get number of checkpoints for `account`. */ function _numCheckpoints(address account, uint256 id) internal view virtual returns (uint32) { return SafeCast.toUint32(_accountCheckpoints[id][account].length()); } /** * @dev Get the `pos`-th checkpoint for `account`. */ function _checkpoints( address account, uint256 id, uint32 pos ) internal view virtual returns (Checkpoints.Checkpoint208 memory) { return _accountCheckpoints[id][account].at(pos); } function _push( Checkpoints.Trace208 storage store, function(uint208, uint208) view returns (uint208) op, uint208 delta ) private returns (uint208, uint208) { return store.push(clock(), op(store.latest(), delta)); } function _add(uint208 a, uint208 b) private pure returns (uint208) { return a + b; } function _subtract(uint208 a, uint208 b) private pure returns (uint208) { return a - b; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { if (initialOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {Ownable} from "./Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC6372.sol) pragma solidity ^0.8.20; interface IERC6372 { /** * @dev Clock used for flagging checkpoints. Can be overridden to implement timestamp based checkpoints (and voting). */ function clock() external view returns (uint48); /** * @dev Description of the clock */ // solhint-disable-next-line func-name-mixedcase function CLOCK_MODE() external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.20; import {IERC1155} from "./IERC1155.sol"; import {IERC1155Receiver} from "./IERC1155Receiver.sol"; import {IERC1155MetadataURI} from "./extensions/IERC1155MetadataURI.sol"; import {Context} from "../../utils/Context.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {Arrays} from "../../utils/Arrays.sol"; import {IERC1155Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 */ abstract contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI, IERC1155Errors { using Arrays for uint256[]; using Arrays for address[]; mapping(uint256 id => mapping(address account => uint256)) private _balances; mapping(address account => mapping(address operator => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256 /* id */) public view virtual returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. */ function balanceOf(address account, uint256 id) public view virtual returns (uint256) { return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] memory accounts, uint256[] memory ids ) public view virtual returns (uint256[] memory) { if (accounts.length != ids.length) { revert ERC1155InvalidArrayLength(ids.length, accounts.length); } uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts.unsafeMemoryAccess(i), ids.unsafeMemoryAccess(i)); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeTransferFrom(from, to, id, value, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) public virtual { address sender = _msgSender(); if (from != sender && !isApprovedForAll(from, sender)) { revert ERC1155MissingApprovalForAll(sender, from); } _safeBatchTransferFrom(from, to, ids, values, data); } /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. Will mint (or burn) if `from` * (or `to`) is the zero address. * * Emits a {TransferSingle} event if the arrays contain one element, and {TransferBatch} otherwise. * * Requirements: * * - If `to` refers to a smart contract, it must implement either {IERC1155Receiver-onERC1155Received} * or {IERC1155Receiver-onERC1155BatchReceived} and return the acceptance magic value. * - `ids` and `values` must have the same length. * * NOTE: The ERC-1155 acceptance check is not performed in this function. See {_updateWithAcceptanceCheck} instead. */ function _update(address from, address to, uint256[] memory ids, uint256[] memory values) internal virtual { if (ids.length != values.length) { revert ERC1155InvalidArrayLength(ids.length, values.length); } address operator = _msgSender(); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids.unsafeMemoryAccess(i); uint256 value = values.unsafeMemoryAccess(i); if (from != address(0)) { uint256 fromBalance = _balances[id][from]; if (fromBalance < value) { revert ERC1155InsufficientBalance(from, fromBalance, value, id); } unchecked { // Overflow not possible: value <= fromBalance _balances[id][from] = fromBalance - value; } } if (to != address(0)) { _balances[id][to] += value; } } if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); emit TransferSingle(operator, from, to, id, value); } else { emit TransferBatch(operator, from, to, ids, values); } } /** * @dev Version of {_update} that performs the token acceptance check by calling * {IERC1155Receiver-onERC1155Received} or {IERC1155Receiver-onERC1155BatchReceived} on the receiver address if it * contains code (eg. is a smart contract at the moment of execution). * * IMPORTANT: Overriding this function is discouraged because it poses a reentrancy risk from the receiver. So any * update to the contract state after this function would break the check-effect-interaction pattern. Consider * overriding {_update} instead. */ function _updateWithAcceptanceCheck( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal virtual { _update(from, to, ids, values); if (to != address(0)) { address operator = _msgSender(); if (ids.length == 1) { uint256 id = ids.unsafeMemoryAccess(0); uint256 value = values.unsafeMemoryAccess(0); _doSafeTransferAcceptanceCheck(operator, from, to, id, value, data); } else { _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, values, data); } } } /** * @dev Transfers a `value` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. * - `ids` and `values` must have the same length. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, to, ids, values, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the values in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates a `value` amount of tokens of type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint(address to, uint256 id, uint256 value, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `values` must have the same length. * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch(address to, uint256[] memory ids, uint256[] memory values, bytes memory data) internal { if (to == address(0)) { revert ERC1155InvalidReceiver(address(0)); } _updateWithAcceptanceCheck(address(0), to, ids, values, data); } /** * @dev Destroys a `value` amount of tokens of type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. */ function _burn(address from, uint256 id, uint256 value) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } (uint256[] memory ids, uint256[] memory values) = _asSingletonArrays(id, value); _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `value` amount of tokens of type `id`. * - `ids` and `values` must have the same length. */ function _burnBatch(address from, uint256[] memory ids, uint256[] memory values) internal { if (from == address(0)) { revert ERC1155InvalidSender(address(0)); } _updateWithAcceptanceCheck(from, address(0), ids, values, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the zero address. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC1155InvalidOperator(address(0)); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Performs an acceptance check by calling {IERC1155-onERC1155Received} on the `to` address * if it contains code at the moment of execution. */ function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 value, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, value, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Performs a batch acceptance check by calling {IERC1155-onERC1155BatchReceived} on the `to` address * if it contains code at the moment of execution. */ function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory values, bytes memory data ) private { if (to.code.length > 0) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, values, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { // Tokens rejected revert ERC1155InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-ERC1155Receiver implementer revert ERC1155InvalidReceiver(to); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } } /** * @dev Creates an array in memory with only one value for each of the elements provided. */ function _asSingletonArrays( uint256 element1, uint256 element2 ) private pure returns (uint256[] memory array1, uint256[] memory array2) { /// @solidity memory-safe-assembly assembly { // Load the free memory pointer array1 := mload(0x40) // Set array length to 1 mstore(array1, 1) // Store the single element at the next word after the length (where content starts) mstore(add(array1, 0x20), element1) // Repeat for next array locating it right after the first array array2 := add(array1, 0x40) mstore(array2, 1) mstore(add(array2, 0x20), element2) // Update the free memory pointer by pointing after the second array mstore(0x40, add(array2, 0x40)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.20; import {IERC1155} from "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the value of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch( address[] calldata accounts, uint256[] calldata ids ) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155Received} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `value` amount. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * WARNING: This function can potentially allow a reentrancy attack when transferring tokens * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver. * Ensure to follow the checks-effects-interactions pattern and consider employing * reentrancy guards when interacting with untrusted contracts. * * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments. * * Requirements: * * - `ids` and `values` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Interface that must be implemented by smart contracts in order to receive * ERC-1155 token transfers. */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @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 or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * 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. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @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`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Arrays.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; import {Math} from "./math/Math.sol"; /** * @dev Collection of functions related to array types. */ library Arrays { using StorageSlot for bytes32; /** * @dev Searches a sorted `array` and returns the first index that contains * a value greater or equal to `element`. If no such index exists (i.e. all * values in the array are strictly less than `element`), the array length is * returned. Time complexity O(log n). * * `array` is expected to be sorted in ascending order, and to contain no * repeated elements. */ function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { uint256 low = 0; uint256 high = array.length; if (high == 0) { return 0; } while (low < high) { uint256 mid = Math.average(low, high); // Note that mid will always be strictly less than high (i.e. it will be a valid array index) // because Math.average rounds towards zero (it does integer division with truncation). if (unsafeAccess(array, mid).value > element) { high = mid; } else { low = mid + 1; } } // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. if (low > 0 && unsafeAccess(array, low - 1).value == element) { return low - 1; } else { return low; } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(address[] storage arr, uint256 pos) internal pure returns (StorageSlot.AddressSlot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getAddressSlot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(bytes32[] storage arr, uint256 pos) internal pure returns (StorageSlot.Bytes32Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getBytes32Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeAccess(uint256[] storage arr, uint256 pos) internal pure returns (StorageSlot.Uint256Slot storage) { bytes32 slot; // We use assembly to calculate the storage slot of the element at index `pos` of the dynamic array `arr` // following https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays. /// @solidity memory-safe-assembly assembly { mstore(0, arr.slot) slot := add(keccak256(0, 0x20), pos) } return slot.getUint256Slot(); } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(uint256[] memory arr, uint256 pos) internal pure returns (uint256 res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } /** * @dev Access an array in an "unsafe" way. Skips solidity "index-out-of-range" check. * * WARNING: Only use if you are certain `pos` is lower than the array length. */ function unsafeMemoryAccess(address[] memory arr, uint256 pos) internal pure returns (address res) { assembly { res := mload(add(add(arr, 0x20), mul(pos, 0x20))) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./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); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; 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_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/Checkpoints.sol) // This file was procedurally generated from scripts/generate/templates/Checkpoints.js. pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; /** * @dev This library defines the `Trace*` struct, for checkpointing values as they change at different points in * time, and later looking up past values by block number. See {Votes} as an example. * * To create a history of checkpoints define a variable type `Checkpoints.Trace*` in your contract, and store a new * checkpoint for the current transaction block using the {push} function. */ library Checkpoints { /** * @dev A value was attempted to be inserted on a past checkpoint. */ error CheckpointUnorderedInsertion(); struct Trace224 { Checkpoint224[] _checkpoints; } struct Checkpoint224 { uint32 _key; uint224 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace224 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint32).max` key set will disable the * library. */ function push(Trace224 storage self, uint32 key, uint224 value) internal returns (uint224, uint224) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace224 storage self, uint32 key) internal view returns (uint224) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace224 storage self) internal view returns (uint224) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace224 storage self) internal view returns (bool exists, uint32 _key, uint224 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint224 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace224 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace224 storage self, uint32 pos) internal view returns (Checkpoint224 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint224[] storage self, uint32 key, uint224 value) private returns (uint224, uint224) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint224 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint224({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint224({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint224[] storage self, uint32 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint224[] storage self, uint256 pos ) private pure returns (Checkpoint224 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } struct Trace208 { Checkpoint208[] _checkpoints; } struct Checkpoint208 { uint48 _key; uint208 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace208 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint48).max` key set will disable the * library. */ function push(Trace208 storage self, uint48 key, uint208 value) internal returns (uint208, uint208) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace208 storage self, uint48 key) internal view returns (uint208) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace208 storage self) internal view returns (uint208) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace208 storage self) internal view returns (bool exists, uint48 _key, uint208 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint208 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace208 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace208 storage self, uint32 pos) internal view returns (Checkpoint208 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint208[] storage self, uint48 key, uint208 value) private returns (uint208, uint208) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint208 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint208({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint208({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint208[] storage self, uint48 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint208[] storage self, uint256 pos ) private pure returns (Checkpoint208 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } struct Trace160 { Checkpoint160[] _checkpoints; } struct Checkpoint160 { uint96 _key; uint160 _value; } /** * @dev Pushes a (`key`, `value`) pair into a Trace160 so that it is stored as the checkpoint. * * Returns previous value and new value. * * IMPORTANT: Never accept `key` as a user input, since an arbitrary `type(uint96).max` key set will disable the * library. */ function push(Trace160 storage self, uint96 key, uint160 value) internal returns (uint160, uint160) { return _insert(self._checkpoints, key, value); } /** * @dev Returns the value in the first (oldest) checkpoint with key greater or equal than the search key, or zero if * there is none. */ function lowerLookup(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 pos = _lowerBinaryLookup(self._checkpoints, key, 0, len); return pos == len ? 0 : _unsafeAccess(self._checkpoints, pos)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. */ function upperLookup(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 pos = _upperBinaryLookup(self._checkpoints, key, 0, len); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the last (most recent) checkpoint with key lower or equal than the search key, or zero * if there is none. * * NOTE: This is a variant of {upperLookup} that is optimised to find "recent" checkpoint (checkpoints with high * keys). */ function upperLookupRecent(Trace160 storage self, uint96 key) internal view returns (uint160) { uint256 len = self._checkpoints.length; uint256 low = 0; uint256 high = len; if (len > 5) { uint256 mid = len - Math.sqrt(len); if (key < _unsafeAccess(self._checkpoints, mid)._key) { high = mid; } else { low = mid + 1; } } uint256 pos = _upperBinaryLookup(self._checkpoints, key, low, high); return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns the value in the most recent checkpoint, or zero if there are no checkpoints. */ function latest(Trace160 storage self) internal view returns (uint160) { uint256 pos = self._checkpoints.length; return pos == 0 ? 0 : _unsafeAccess(self._checkpoints, pos - 1)._value; } /** * @dev Returns whether there is a checkpoint in the structure (i.e. it is not empty), and if so the key and value * in the most recent checkpoint. */ function latestCheckpoint(Trace160 storage self) internal view returns (bool exists, uint96 _key, uint160 _value) { uint256 pos = self._checkpoints.length; if (pos == 0) { return (false, 0, 0); } else { Checkpoint160 memory ckpt = _unsafeAccess(self._checkpoints, pos - 1); return (true, ckpt._key, ckpt._value); } } /** * @dev Returns the number of checkpoint. */ function length(Trace160 storage self) internal view returns (uint256) { return self._checkpoints.length; } /** * @dev Returns checkpoint at given position. */ function at(Trace160 storage self, uint32 pos) internal view returns (Checkpoint160 memory) { return self._checkpoints[pos]; } /** * @dev Pushes a (`key`, `value`) pair into an ordered list of checkpoints, either by inserting a new checkpoint, * or by updating the last one. */ function _insert(Checkpoint160[] storage self, uint96 key, uint160 value) private returns (uint160, uint160) { uint256 pos = self.length; if (pos > 0) { // Copying to memory is important here. Checkpoint160 memory last = _unsafeAccess(self, pos - 1); // Checkpoint keys must be non-decreasing. if (last._key > key) { revert CheckpointUnorderedInsertion(); } // Update or push new checkpoint if (last._key == key) { _unsafeAccess(self, pos - 1)._value = value; } else { self.push(Checkpoint160({_key: key, _value: value})); } return (last._value, value); } else { self.push(Checkpoint160({_key: key, _value: value})); return (0, value); } } /** * @dev Return the index of the last (most recent) checkpoint with key lower or equal than the search key, or `high` * if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and exclusive * `high`. * * WARNING: `high` should not be greater than the array's length. */ function _upperBinaryLookup( Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key > key) { high = mid; } else { low = mid + 1; } } return high; } /** * @dev Return the index of the first (oldest) checkpoint with key is greater or equal than the search key, or * `high` if there is none. `low` and `high` define a section where to do the search, with inclusive `low` and * exclusive `high`. * * WARNING: `high` should not be greater than the array's length. */ function _lowerBinaryLookup( Checkpoint160[] storage self, uint96 key, uint256 low, uint256 high ) private view returns (uint256) { while (low < high) { uint256 mid = Math.average(low, high); if (_unsafeAccess(self, mid)._key < key) { low = mid + 1; } else { high = mid; } } return high; } /** * @dev Access an element of the array without performing bounds check. The position is assumed to be within bounds. */ function _unsafeAccess( Checkpoint160[] storage self, uint256 pos ) private pure returns (Checkpoint160 storage result) { assembly { mstore(0, self.slot) result.slot := add(keccak256(0, 0x20), pos) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/types/Time.sol) pragma solidity ^0.8.20; import {Math} from "../math/Math.sol"; import {SafeCast} from "../math/SafeCast.sol"; /** * @dev This library provides helpers for manipulating time-related objects. * * It uses the following types: * - `uint48` for timepoints * - `uint32` for durations * * While the library doesn't provide specific types for timepoints and duration, it does provide: * - a `Delay` type to represent duration that can be programmed to change value automatically at a given point * - additional helper functions */ library Time { using Time for *; /** * @dev Get the block timestamp as a Timepoint. */ function timestamp() internal view returns (uint48) { return SafeCast.toUint48(block.timestamp); } /** * @dev Get the block number as a Timepoint. */ function blockNumber() internal view returns (uint48) { return SafeCast.toUint48(block.number); } // ==================================================== Delay ===================================================== /** * @dev A `Delay` is a uint32 duration that can be programmed to change value automatically at a given point in the * future. The "effect" timepoint describes when the transitions happens from the "old" value to the "new" value. * This allows updating the delay applied to some operation while keeping some guarantees. * * In particular, the {update} function guarantees that if the delay is reduced, the old delay still applies for * some time. For example if the delay is currently 7 days to do an upgrade, the admin should not be able to set * the delay to 0 and upgrade immediately. If the admin wants to reduce the delay, the old delay (7 days) should * still apply for some time. * * * The `Delay` type is 112 bits long, and packs the following: * * ``` * | [uint48]: effect date (timepoint) * | | [uint32]: value before (duration) * ↓ ↓ ↓ [uint32]: value after (duration) * 0xAAAAAAAAAAAABBBBBBBBCCCCCCCC * ``` * * NOTE: The {get} and {withUpdate} functions operate using timestamps. Block number based delays are not currently * supported. */ type Delay is uint112; /** * @dev Wrap a duration into a Delay to add the one-step "update in the future" feature */ function toDelay(uint32 duration) internal pure returns (Delay) { return Delay.wrap(duration); } /** * @dev Get the value at a given timepoint plus the pending value and effect timepoint if there is a scheduled * change after this timepoint. If the effect timepoint is 0, then the pending value should not be considered. */ function _getFullAt(Delay self, uint48 timepoint) private pure returns (uint32, uint32, uint48) { (uint32 valueBefore, uint32 valueAfter, uint48 effect) = self.unpack(); return effect <= timepoint ? (valueAfter, 0, 0) : (valueBefore, valueAfter, effect); } /** * @dev Get the current value plus the pending value and effect timepoint if there is a scheduled change. If the * effect timepoint is 0, then the pending value should not be considered. */ function getFull(Delay self) internal view returns (uint32, uint32, uint48) { return _getFullAt(self, timestamp()); } /** * @dev Get the current value. */ function get(Delay self) internal view returns (uint32) { (uint32 delay, , ) = self.getFull(); return delay; } /** * @dev Update a Delay object so that it takes a new duration after a timepoint that is automatically computed to * enforce the old delay at the moment of the update. Returns the updated Delay object and the timestamp when the * new delay becomes effective. */ function withUpdate( Delay self, uint32 newValue, uint32 minSetback ) internal view returns (Delay updatedDelay, uint48 effect) { uint32 value = self.get(); uint32 setback = uint32(Math.max(minSetback, value > newValue ? value - newValue : 0)); effect = timestamp() + setback; return (pack(value, newValue, effect), effect); } /** * @dev Split a delay into its components: valueBefore, valueAfter and effect (transition timepoint). */ function unpack(Delay self) internal pure returns (uint32 valueBefore, uint32 valueAfter, uint48 effect) { uint112 raw = Delay.unwrap(self); valueAfter = uint32(raw); valueBefore = uint32(raw >> 32); effect = uint48(raw >> 64); return (valueBefore, valueAfter, effect); } /** * @dev pack the components into a Delay object. */ function pack(uint32 valueBefore, uint32 valueAfter, uint48 effect) internal pure returns (Delay) { return Delay.wrap((uint112(effect) << 64) | (uint112(valueBefore) << 32) | uint112(valueAfter)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Multicall.sol) pragma solidity ^0.8.20; import {Address} from "../libs/@openzeppelin/contracts/utils/Address.sol"; /** * @dev Provides a function to batch together multiple calls in a single external call. */ abstract contract Multicall { /** * @dev Receives and executes a batch of function calls on this contract. * @custom:oz-upgrades-unsafe-allow-reachable delegatecall */ function multicall(bytes[] calldata data) external view virtual returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { results[i] = Address.functionStaticCall(address(this), data[i]); } return results; } }
{ "optimizer": { "enabled": true, "runs": 200 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"initialOwner","type":"address"},{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"string","name":"baseURI","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[],"name":"CheckpointUnorderedInsertion","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC1155InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC1155InvalidApprover","type":"error"},{"inputs":[{"internalType":"uint256","name":"idsLength","type":"uint256"},{"internalType":"uint256","name":"valuesLength","type":"uint256"}],"name":"ERC1155InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC1155InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC1155InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC1155InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC1155MissingApprovalForAll","type":"error"},{"inputs":[],"name":"ERC6372InconsistentClock","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"IdFinalized","type":"error"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"IdNotExists","type":"error"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"IdNotFinalized","type":"error"},{"inputs":[{"internalType":"uint256","name":"length1","type":"uint256"},{"internalType":"uint256","name":"length2","type":"uint256"}],"name":"InvalidArrayLength","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotMinter","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NotOwnerOrMinter","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[{"internalType":"uint256","name":"timepoint","type":"uint256"},{"internalType":"uint48","name":"clock","type":"uint48"}],"name":"VotesFutureLookup","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"baseURI","type":"string"}],"name":"BaseURIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"bool","name":"flag","type":"bool"}],"name":"Finalized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"}],"name":"MinterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"minter","type":"address"}],"name":"MinterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"TransferBatch","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"TransferSingle","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"value","type":"string"},{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"URI","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"VotesChanged","type":"event"},{"inputs":[],"name":"CLOCK_MODE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"name":"addMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"}],"name":"balanceOfBatch","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"burnBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"clock","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"exists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"bool","name":"flag","type":"bool"}],"name":"finalize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"bool[]","name":"flags","type":"bool[]"}],"name":"finalizeBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBaseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint32","name":"pos","type":"uint32"}],"name":"getCheckPoints","outputs":[{"components":[{"internalType":"uint48","name":"_key","type":"uint48"},{"internalType":"uint208","name":"_value","type":"uint208"}],"internalType":"struct Checkpoints.Checkpoint208","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getExistingTokenAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExistingTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getExistingTokensCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getHolderAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getHolders","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getHoldersCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getHoldingTokenAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getHoldingTokens","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getHoldingTokensCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getMinterAt","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinterCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMinters","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getNumCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"timepoint","type":"uint256"}],"name":"getPastTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"timepoint","type":"uint256"}],"name":"getPastVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"isFinalized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"mintBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"}],"name":"removeMinter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"ids","type":"uint256[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeBatchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupplyAll","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"uri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60a0604052600060809081526012906100189082610224565b5034801561002557600080fd5b50604051613c62380380613c628339810160408190526100449161038f565b604080516020810190915260008152846001600160a01b03811661008257604051631e4fbdf760e01b81526000600482015260240160405180910390fd5b61008b816100c2565b50610095816100de565b5060106100a28482610224565b5060116100af8382610224565b506100b9816100ee565b50505050610477565b600180546001600160a01b03191690556100db81610135565b50565b60046100ea8282610224565b5050565b60126100fa8282610224565b507f5411e8ebf1636d9e83d5fc4900bf80cbac82e8790da2a4c94db4895e889eedf68160405161012a9190610444565b60405180910390a150565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806101af57607f821691505b6020821081036101cf57634e487b7160e01b600052602260045260246000fd5b50919050565b601f82111561021f57806000526020600020601f840160051c810160208510156101fc5750805b601f840160051c820191505b8181101561021c5760008155600101610208565b50505b505050565b81516001600160401b0381111561023d5761023d610185565b6102518161024b845461019b565b846101d5565b6020601f821160018114610285576000831561026d5750848201515b600019600385901b1c1916600184901b17845561021c565b600084815260208120601f198516915b828110156102b55787850151825560209485019460019092019101610295565b50848210156102d35786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60005b838110156102fd5781810151838201526020016102e5565b50506000910152565b600082601f83011261031757600080fd5b81516001600160401b0381111561033057610330610185565b604051601f8201601f19908116603f011681016001600160401b038111828210171561035e5761035e610185565b60405281815283820160200185101561037657600080fd5b6103878260208301602087016102e2565b949350505050565b600080600080608085870312156103a557600080fd5b84516001600160a01b03811681146103bc57600080fd5b60208601519094506001600160401b038111156103d857600080fd5b6103e487828801610306565b604087015190945090506001600160401b0381111561040257600080fd5b61040e87828801610306565b606087015190935090506001600160401b0381111561042c57600080fd5b61043887828801610306565b91505092959194509250565b60208152600082518060208401526104638160408501602087016102e2565b601f01601f19169190910160400192915050565b6137dc806104866000396000f3fe608060405234801561001057600080fd5b50600436106102f05760003560e01c8063731133e91161019d578063ac9650d8116100e9578063e30c3978116100a2578063ee550c661161007c578063ee550c66146106e3578063f242432a1461070b578063f2fde38b1461071e578063f5298aca1461073157600080fd5b8063e30c3978146106ac578063e985e9c5146106bd578063eb9019d4146106d057600080fd5b8063ac9650d81461060a578063aedede7a1461062a578063b1784f4514610632578063b42394f114610671578063bd85b03914610679578063cdd583501461069957600080fd5b806392ab723e1161015657806398c9be051161013057806398c9be05146105be578063a2088a17146105d1578063a22cb465146105e4578063aa271e1a146105f757600080fd5b806392ab723e1461059057806395d89b41146105a3578063983b2d56146105ab57600080fd5b8063731133e91461053357806379ba5097146105465780638da5cb5b1461054e5780638dbb94eb1461055f57806391ddadf414610567578063927078691461057d57600080fd5b806333727c4d1161025c5780634f558e79116102155780636b32810b116101ef5780636b32810b1461050657806370428ba11461051b578063714c539814610523578063715018a61461052b57600080fd5b80634f558e79146104be57806355f804b3146104e05780636b20c454146104f357600080fd5b806333727c4d14610425578063430695e8146104485780634ba885681461045b5780634bf5d7e91461046e5780634d6fb775146104985780634e1273f4146104ab57600080fd5b8063133159ed116102ae578063133159ed1461038e5780631f7fdffa146103b95780631ff06065146103cc57806320878df4146103df5780632eb2c2d6146103ff5780633092afd51461041257600080fd5b8062fdd58e146102f55780630175c92a1461031b57806301ffc9a71461033057806306fdde03146103535780630b3dd1df146103685780630e89341c1461037b575b600080fd5b610308610303366004612a6e565b610744565b6040519081526020015b60405180910390f35b61032e610329366004612aa8565b61076e565b005b61034361033e366004612aea565b6107ce565b6040519015158152602001610312565b61035b61081e565b6040516103129190612b57565b610308610376366004612b6a565b6108b0565b61035b610389366004612b85565b6108d1565b6103a161039c366004612b9e565b610935565b6040516001600160a01b039091168152602001610312565b61032e6103c7366004612d11565b610954565b6103a16103da366004612b85565b6109d3565b6103f26103ed366004612b6a565b6109e0565b6040516103129190612def565b61032e61040d366004612e02565b610a04565b61032e610420366004612b6a565b610a51565b610343610433366004612b85565b6000908152600f602052604090205460ff1690565b61032e610456366004612eb5565b610a9c565b610308610469366004612a6e565b610b58565b60408051808201909152600e81526d06d6f64653d74696d657374616d760941b602082015261035b565b6103086104a6366004612f7e565b610b7a565b6103f26104b9366004612fb1565b610bfc565b6103436104cc366004612b85565b600090815260056020526040902054151590565b61032e6104ee366004613078565b610cc8565b61032e6105013660046130c0565b610cdc565b61050e610d6c565b6040516103129190613137565b610308610d7d565b61035b610d89565b61032e610d98565b61032e610541366004613183565b610dac565b61032e610dd5565b6000546001600160a01b03166103a1565b610308610e16565b60405165ffffffffffff42168152602001610312565b61050e61058b366004612b85565b610e22565b61030861059e366004612b85565b610e3c565b61035b610e47565b61032e6105b9366004612b6a565b610e56565b6103086105cc366004612b85565b610ea1565b6103086105df366004612b9e565b610eb8565b61032e6105f23660046131cb565b610f25565b610343610605366004612b6a565b610f30565b61061d6106183660046131f5565b610f3d565b604051610312919061326a565b6103f2611026565b6106456106403660046132cf565b611032565b60408051825165ffffffffffff1681526020928301516001600160d01b03169281019290925201610312565b600654610308565b610308610687366004612b85565b60009081526005602052604090205490565b6103086106a7366004612b85565b611059565b6001546001600160a01b03166103a1565b6103436106cb366004613318565b611066565b6103086106de366004612a6e565b611094565b6106f66106f1366004612a6e565b6110cf565b60405163ffffffff9091168152602001610312565b61032e610719366004613342565b6110db565b61032e61072c366004612b6a565b6110f2565b61032e61073f366004612f7e565b611163565b60008181526002602090815260408083206001600160a01b03861684529091529020545b92915050565b6000546001600160a01b0316331480159061078f575061078d33610f30565b155b156107c057335b60405163d393669560e01b81526001600160a01b0390911660048201526024015b60405180910390fd5b6107ca82826111a3565b5050565b60006001600160e01b03198216636cdb3d1360e11b14806107ff57506001600160e01b031982166303a24d0760e21b145b8061076857506301ffc9a760e01b6001600160e01b0319831614610768565b60606010805461082d9061339a565b80601f01602080910402602001604051908101604052809291908181526020018280546108599061339a565b80156108a65780601f1061087b576101008083540402835291602001916108a6565b820191906000526020600020905b81548152906001019060200180831161088957829003601f168201915b5050505050905090565b6001600160a01b0381166000908152600860205260408120610768906111fa565b60008181526005602052604090205460609061090357604051635828116560e11b8152600481018390526024016107b7565b601261090e83611204565b60405160200161091f9291906133d4565b6040516020818303038152906040529050919050565b600082815260076020526040812061094d9083611296565b9392505050565b61095d33610f30565b61098857335b604051631b0e18f960e11b81526001600160a01b0390911660048201526024016107b7565b8260005b81518110156109bf576109b78282815181106109aa576109aa61345a565b60200260200101516112a2565b60010161098c565b506109cc858585856112d5565b5050505050565b6000610768600d83611296565b6001600160a01b03811660009081526008602052604090206060906107689061130d565b8260005b8151811015610a3b57610a33828281518110610a2657610a2661345a565b602002602001015161131a565b600101610a08565b50610a49868686868661134c565b505050505050565b610a596113ab565b610a64600d826113d8565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314801590610abd5750610abb33610f30565b155b15610ac85733610796565b8051825114610af75781518151604051633b5cfc6960e21b8152600481019290925260248201526044016107b7565b60005b8251811015610b53576000838281518110610b1757610b1761345a565b602002602001015190506000838381518110610b3557610b3561345a565b60200260200101519050610b4982826111a3565b5050600101610afa565b505050565b6001600160a01b038216600090815260086020526040812061094d9083611296565b60004265ffffffffffff81168310610bb65760405163d1980a7960e01b81526004810184905265ffffffffffff821660248201526044016107b7565b610bea610bc2846113ed565b6000868152600b602090815260408083206001600160a01b038b168452909152902090611424565b6001600160d01b031695945050505050565b60608151835114610c2d5781518351604051635b05999160e01b8152600481019290925260248201526044016107b7565b600083516001600160401b03811115610c4857610c48612bc0565b604051908082528060200260200182016040528015610c71578160200160208202803683370190505b50905060005b8451811015610cc057602080820286010151610c9b90602080840287010151610744565b828281518110610cad57610cad61345a565b6020908102919091010152600101610c77565b509392505050565b610cd06113ab565b610cd9816114da565b50565b8160005b8151811015610d0657610cfe828281518110610a2657610a2661345a565b600101610ce0565b506001600160a01b0384163314801590610d275750610d258433611066565b155b15610d5b57335b60405163711bec9160e11b81526001600160a01b03918216600482015290851660248201526044016107b7565b610d66848484611521565b50505050565b6060610d78600d61130d565b905090565b6000610d7860096111fa565b60606012805461082d9061339a565b610da06113ab565b610daa6000611567565b565b610db533610f30565b610dbf5733610963565b82610dc9816112a2565b6109cc85858585611580565b60015433906001600160a01b03168114610e0d5760405163118cdaa760e01b81526001600160a01b03821660048201526024016107b7565b610cd981611567565b6000610d78600d6111fa565b60008181526007602052604090206060906107689061130d565b6000610768826115dd565b60606011805461082d9061339a565b610e5e6113ab565b610e69600d82611603565b506040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b6000818152600760205260408120610768906111fa565b60004265ffffffffffff81168310610ef45760405163d1980a7960e01b81526004810184905265ffffffffffff821660248201526044016107b7565b610f14610f00846113ed565b6000868152600c6020526040902090611424565b6001600160d01b0316949350505050565b6107ca338383611618565b6000610768600d836116ae565b6060816001600160401b03811115610f5757610f57612bc0565b604051908082528060200260200182016040528015610f8a57816020015b6060815260200190600190039081610f755790505b50905060005b8281101561101f57610ffa30858584818110610fae57610fae61345a565b9050602002810190610fc09190613470565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506116d092505050565b82828151811061100c5761100c61345a565b6020908102919091010152600101610f90565b5092915050565b6060610d78600961130d565b6040805180820190915260008082526020820152611051848484611746565b949350505050565b6000610768600983611296565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205460ff1690565b6000818152600b602090815260408083206001600160a01b038616845290915281206110bf90611782565b6001600160d01b03169392505050565b600061094d83836117bb565b826110e58161131a565b610a4986868686866117e7565b6110fa6113ab565b600180546001600160a01b0383166001600160a01b0319909116811790915561112b6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8161116d8161131a565b6001600160a01b038416331480159061118d575061118b8433611066565b155b156111985733610d2e565b610d66848484611846565b6000828152600f6020908152604091829020805460ff1916841515908117909155915191825283917f82693b732f9696c8a914b820dd6c52544bd61b844bbd4c8707253df9340cf6b7910160405180910390a25050565b6000610768825490565b60606000611211836118ae565b60010190506000816001600160401b0381111561123057611230612bc0565b6040519080825280601f01601f19166020018201604052801561125a576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461126457509392505050565b600061094d8383611986565b6000818152600f602052604090205460ff1615610cd957604051632b4d0eef60e01b8152600481018290526024016107b7565b6001600160a01b0384166112ff57604051632bfa23e760e11b8152600060048201526024016107b7565b610d666000858585856119b0565b6060600061094d83611a03565b6000818152600f602052604090205460ff16610cd957604051637d80d8a560e01b8152600481018290526024016107b7565b336001600160a01b038616811480159061136d575061136b8682611066565b155b1561139e5760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044016107b7565b610a498686868686611a5f565b6000546001600160a01b03163314610daa5760405163118cdaa760e01b81523360048201526024016107b7565b600061094d836001600160a01b038416611abf565b600065ffffffffffff821115611420576040516306dfcc6560e41b815260306004820152602481018390526044016107b7565b5090565b81546000908181600581111561148357600061143f84611bb2565b61144990856134e9565b60008881526020902090915081015465ffffffffffff908116908716101561147357809150611481565b61147e8160016134fc565b92505b505b600061149187878585611c9a565b905080156114cc576114b6876114a86001846134e9565b600091825260209091200190565b54600160301b90046001600160d01b03166114cf565b60005b979650505050505050565b60126114e68282613556565b507f5411e8ebf1636d9e83d5fc4900bf80cbac82e8790da2a4c94db4895e889eedf6816040516115169190612b57565b60405180910390a150565b6001600160a01b03831661154a57604051626a0d4560e21b8152600060048201526024016107b7565b610b538360008484604051806020016040528060008152506119b0565b600180546001600160a01b0319169055610cd981611cf4565b6001600160a01b0384166115aa57604051632bfa23e760e11b8152600060048201526024016107b7565b60408051600180825260208201869052818301908152606082018590526080820190925290610a496000878484876119b0565b6000818152600c602052604081206115f490611782565b6001600160d01b031692915050565b600061094d836001600160a01b038416611d44565b6001600160a01b0382166116415760405162ced3e160e81b8152600060048201526024016107b7565b6001600160a01b03838116600081815260036020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0381166000908152600183016020526040812054151561094d565b6060600080846001600160a01b0316846040516116ed9190613614565b600060405180830381855afa9150503d8060008114611728576040519150601f19603f3d011682016040523d82523d6000602084013e61172d565b606091505b509150915061173d858383611d93565b95945050505050565b60408051808201825260008082526020808301829052858252600b81528382206001600160a01b03881683529052919091206110519083611def565b805460009080156117b25761179c836114a86001846134e9565b54600160301b90046001600160d01b031661094d565b60009392505050565b6000818152600b602090815260408083206001600160a01b038616845290915281205461094d90611e5f565b336001600160a01b038616811480159061180857506118068682611066565b155b156118395760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044016107b7565b610a498686868686611e90565b6001600160a01b03831661186f57604051626a0d4560e21b8152600060048201526024016107b7565b604080516001808252602082018590528183019081526060820184905260a082019092526000608082018181529192916109cc918791859085906119b0565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106118ed5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611919576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061193757662386f26fc10000830492506010015b6305f5e100831061194f576305f5e100830492506008015b612710831061196357612710830492506004015b60648310611975576064830492506002015b600a83106107685760010192915050565b600082600001828154811061199d5761199d61345a565b9060005260206000200154905092915050565b6119bc85858585611f1e565b6001600160a01b038416156109cc57825133906001036119f557602084810151908401516119ee838989858589611f2a565b5050610a49565b610a4981878787878761204e565b606081600001805480602002602001604051908101604052809291908181526020018280548015611a5357602002820191906000526020600020905b815481526020019060010190808311611a3f575b50505050509050919050565b6001600160a01b038416611a8957604051632bfa23e760e11b8152600060048201526024016107b7565b6001600160a01b038516611ab257604051626a0d4560e21b8152600060048201526024016107b7565b6109cc85858585856119b0565b60008181526001830160205260408120548015611ba8576000611ae36001836134e9565b8554909150600090611af7906001906134e9565b9050808214611b5c576000866000018281548110611b1757611b1761345a565b9060005260206000200154905080876000018481548110611b3a57611b3a61345a565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611b6d57611b6d613630565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610768565b6000915050610768565b600081600003611bc457506000919050565b60006001611bd184612137565b901c6001901b90506001818481611bea57611bea6134bd565b048201901c90506001818481611c0257611c026134bd565b048201901c90506001818481611c1a57611c1a6134bd565b048201901c90506001818481611c3257611c326134bd565b048201901c90506001818481611c4a57611c4a6134bd565b048201901c90506001818481611c6257611c626134bd565b048201901c90506001818481611c7a57611c7a6134bd565b048201901c905061094d81828581611c9457611c946134bd565b046121cb565b60005b81831015610cc0576000611cb184846121e1565b60008781526020902090915065ffffffffffff86169082015465ffffffffffff161115611ce057809250611cee565b611ceb8160016134fc565b93505b50611c9d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000818152600183016020526040812054611d8b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610768565b506000610768565b606082611da857611da3826121fc565b61094d565b8151158015611dbf57506001600160a01b0384163b155b15611de857604051639996b31560e01b81526001600160a01b03851660048201526024016107b7565b508061094d565b6040805180820190915260008082526020820152826000018263ffffffff1681548110611e1e57611e1e61345a565b60009182526020918290206040805180820190915291015465ffffffffffff81168252600160301b90046001600160d01b0316918101919091529392505050565b600063ffffffff821115611420576040516306dfcc6560e41b815260206004820152602481018390526044016107b7565b6001600160a01b038416611eba57604051632bfa23e760e11b8152600060048201526024016107b7565b6001600160a01b038516611ee357604051626a0d4560e21b8152600060048201526024016107b7565b60408051600180825260208201869052818301908152606082018590526080820190925290611f1587878484876119b0565b50505050505050565b610d6684848484612225565b6001600160a01b0384163b15610a495760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611f6e9089908990889088908890600401613646565b6020604051808303816000875af1925050508015611fa9575060408051601f3d908101601f19168201909252611fa691810190613680565b60015b612012573d808015611fd7576040519150601f19603f3d011682016040523d82523d6000602084013e611fdc565b606091505b50805160000361200a57604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b14611f1557604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b6001600160a01b0384163b15610a495760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612092908990899088908890889060040161369d565b6020604051808303816000875af19250505080156120cd575060408051601f3d908101601f191682019092526120ca91810190613680565b60015b6120fb573d808015611fd7576040519150601f19603f3d011682016040523d82523d6000602084013e611fdc565b6001600160e01b0319811663bc197c8160e01b14611f1557604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b600080608083901c1561214c57608092831c92015b604083901c1561215e57604092831c92015b602083901c1561217057602092831c92015b601083901c1561218257601092831c92015b600883901c1561219457600892831c92015b600483901c156121a657600492831c92015b600283901c156121b857600292831c92015b600183901c156107685760010192915050565b60008183106121da578161094d565b5090919050565b60006121f060028484186136fb565b61094d908484166134fc565b80511561220c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b61223184848484612283565b60005b82518110156109cc5761227b85858584815181106122545761225461345a565b602002602001015185858151811061226e5761226e61345a565b602002602001015161246a565b600101612234565b61228f848484846124d9565b60005b82518110156109cc5760008382815181106122af576122af61345a565b6020026020010151905060008383815181106122cd576122cd61345a565b6020026020010151905060006001600160a01b0316876001600160a01b031614612344576122fb8783610744565b60000361233f57600082815260076020526040902061231a90886113d8565b506001600160a01b038716600090815260086020526040902061233d90836126db565b505b6123a0565b600082815260056020526040812080548392906123629084906134fc565b909155505060008281526005602052604090205415612388576123866009836126e7565b505b806006600082825461239a91906134fc565b90915550505b6001600160a01b038616156124035760006123bb8784610744565b11156123fe5760008281526007602052604090206123d99087611603565b506001600160a01b03861660009081526008602052604090206123fc90836126e7565b505b612460565b600082815260056020526040812080548392906124219084906134e9565b90915550506000828152600560205260408120549003612448576124466009836126db565b505b806006600082825461245a91906134e9565b90915550505b5050600101612292565b6001600160a01b03841661249e576000828152600c6020526040902061249b906126f3612496846126ff565b612733565b50505b6001600160a01b0383166124cd576000828152600c602052604090206124ca90612765612496846126ff565b50505b610d6684848484612771565b80518251146125085781518151604051635b05999160e01b8152600481019290925260248201526044016107b7565b3360005b83518110156125fc576020818102858101820151908501909101516001600160a01b038816156125ab5760008281526002602090815260408083206001600160a01b038c1684529091529020548181101561258257888183856040516303dee4c560e01b81526004016107b7949392919061371d565b60008381526002602090815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b038716156125f25760008281526002602090815260408083206001600160a01b038b168452909152812080548392906125ec9084906134fc565b90915550505b505060010161250c565b50825160010361267d5760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62858560405161266e929190918252602082015260400190565b60405180910390a450506109cc565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516126cc929190613743565b60405180910390a45050505050565b600061094d8383611abf565b600061094d8383611d44565b600061094d8284613768565b60006001600160d01b03821115611420576040516306dfcc6560e41b815260d06004820152602481018390526044016107b7565b6000806127584261275061274688611782565b868863ffffffff16565b8791906128cf565b915091505b935093915050565b600061094d8284613787565b826001600160a01b0316846001600160a01b0316141580156127935750600081115b15610d66576001600160a01b03841615612831576000828152600b602090815260408083206001600160a01b0388168452909152812081906127db90612765612496866126ff565b6001600160d01b031691506001600160d01b031691507f9015ef8bf6882f1e524a4c1948f14ec3bdead0003a18918a9aa16857c6a57ea286858484604051612826949392919061371d565b60405180910390a150505b6001600160a01b03831615610d66576000828152600b602090815260408083206001600160a01b038716845290915281208190612874906126f3612496866126ff565b6001600160d01b031691506001600160d01b031691507f9015ef8bf6882f1e524a4c1948f14ec3bdead0003a18918a9aa16857c6a57ea2858584846040516128bf949392919061371d565b60405180910390a1505050505050565b6000806127588585858254600090819080156129f75760006128f6876114a86001856134e9565b60408051808201909152905465ffffffffffff808216808452600160301b9092046001600160d01b03166020840152919250908716101561294a57604051632520601d60e01b815260040160405180910390fd5b805165ffffffffffff808816911603612996578461296d886114a86001866134e9565b80546001600160d01b0392909216600160301b0265ffffffffffff9092169190911790556129e7565b6040805180820190915265ffffffffffff80881682526001600160d01b0380881660208085019182528b54600181018d5560008d81529190912094519151909216600160301b029216919091179101555b60200151925083915061275d9050565b50506040805180820190915265ffffffffffff80851682526001600160d01b0380851660208085019182528854600181018a5560008a815291822095519251909316600160301b02919093161792019190915590508161275d565b80356001600160a01b0381168114612a6957600080fd5b919050565b60008060408385031215612a8157600080fd5b612a8a83612a52565b946020939093013593505050565b80358015158114612a6957600080fd5b60008060408385031215612abb57600080fd5b82359150612acb60208401612a98565b90509250929050565b6001600160e01b031981168114610cd957600080fd5b600060208284031215612afc57600080fd5b813561094d81612ad4565b60005b83811015612b22578181015183820152602001612b0a565b50506000910152565b60008151808452612b43816020860160208601612b07565b601f01601f19169290920160200192915050565b60208152600061094d6020830184612b2b565b600060208284031215612b7c57600080fd5b61094d82612a52565b600060208284031215612b9757600080fd5b5035919050565b60008060408385031215612bb157600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612bfe57612bfe612bc0565b604052919050565b60006001600160401b03821115612c1f57612c1f612bc0565b5060051b60200190565b600082601f830112612c3a57600080fd5b8135612c4d612c4882612c06565b612bd6565b8082825260208201915060208360051b860101925085831115612c6f57600080fd5b602085015b83811015612c8c578035835260209283019201612c74565b5095945050505050565b6000806001600160401b03841115612cb057612cb0612bc0565b50601f8301601f1916602001612cc581612bd6565b915050828152838383011115612cda57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612d0257600080fd5b61094d83833560208501612c96565b60008060008060808587031215612d2757600080fd5b612d3085612a52565b935060208501356001600160401b03811115612d4b57600080fd5b612d5787828801612c29565b93505060408501356001600160401b03811115612d7357600080fd5b612d7f87828801612c29565b92505060608501356001600160401b03811115612d9b57600080fd5b612da787828801612cf1565b91505092959194509250565b600081518084526020840193506020830160005b82811015612de5578151865260209586019590910190600101612dc7565b5093949350505050565b60208152600061094d6020830184612db3565b600080600080600060a08688031215612e1a57600080fd5b612e2386612a52565b9450612e3160208701612a52565b935060408601356001600160401b03811115612e4c57600080fd5b612e5888828901612c29565b93505060608601356001600160401b03811115612e7457600080fd5b612e8088828901612c29565b92505060808601356001600160401b03811115612e9c57600080fd5b612ea888828901612cf1565b9150509295509295909350565b60008060408385031215612ec857600080fd5b82356001600160401b03811115612ede57600080fd5b612eea85828601612c29565b92505060208301356001600160401b03811115612f0657600080fd5b8301601f81018513612f1757600080fd5b8035612f25612c4882612c06565b8082825260208201915060208360051b850101925087831115612f4757600080fd5b6020840193505b82841015612f7057612f5f84612a98565b825260209384019390910190612f4e565b809450505050509250929050565b600080600060608486031215612f9357600080fd5b612f9c84612a52565b95602085013595506040909401359392505050565b60008060408385031215612fc457600080fd5b82356001600160401b03811115612fda57600080fd5b8301601f81018513612feb57600080fd5b8035612ff9612c4882612c06565b8082825260208201915060208360051b85010192508783111561301b57600080fd5b6020840193505b828410156130445761303384612a52565b825260209384019390910190613022565b945050505060208301356001600160401b0381111561306257600080fd5b61306e85828601612c29565b9150509250929050565b60006020828403121561308a57600080fd5b81356001600160401b038111156130a057600080fd5b8201601f810184136130b157600080fd5b61105184823560208401612c96565b6000806000606084860312156130d557600080fd5b6130de84612a52565b925060208401356001600160401b038111156130f957600080fd5b61310586828701612c29565b92505060408401356001600160401b0381111561312157600080fd5b61312d86828701612c29565b9150509250925092565b602080825282518282018190526000918401906040840190835b818110156131785783516001600160a01b0316835260209384019390920191600101613151565b509095945050505050565b6000806000806080858703121561319957600080fd5b6131a285612a52565b9350602085013592506040850135915060608501356001600160401b03811115612d9b57600080fd5b600080604083850312156131de57600080fd5b6131e783612a52565b9150612acb60208401612a98565b6000806020838503121561320857600080fd5b82356001600160401b0381111561321e57600080fd5b8301601f8101851361322f57600080fd5b80356001600160401b0381111561324557600080fd5b8560208260051b840101111561325a57600080fd5b6020919091019590945092505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156132c357603f198786030184526132ae858351612b2b565b94506020938401939190910190600101613292565b50929695505050505050565b6000806000606084860312156132e457600080fd5b6132ed84612a52565b925060208401359150604084013563ffffffff8116811461330d57600080fd5b809150509250925092565b6000806040838503121561332b57600080fd5b61333483612a52565b9150612acb60208401612a52565b600080600080600060a0868803121561335a57600080fd5b61336386612a52565b945061337160208701612a52565b9350604086013592506060860135915060808601356001600160401b03811115612e9c57600080fd5b600181811c908216806133ae57607f821691505b6020821081036133ce57634e487b7160e01b600052602260045260246000fd5b50919050565b60008084546133e28161339a565b6001821680156133f9576001811461340e5761343e565b60ff198316865281151582028601935061343e565b87600052602060002060005b838110156134365781548882015260019091019060200161341a565b505081860193505b5050508351613451818360208801612b07565b01949350505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261348757600080fd5b8301803591506001600160401b038211156134a157600080fd5b6020019150368190038213156134b657600080fd5b9250929050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610768576107686134d3565b80820180821115610768576107686134d3565b601f821115610b5357806000526020600020601f840160051c810160208510156135365750805b601f840160051c820191505b818110156109cc5760008155600101613542565b81516001600160401b0381111561356f5761356f612bc0565b6135838161357d845461339a565b8461350f565b6020601f8211600181146135b7576000831561359f5750848201515b600019600385901b1c1916600184901b1784556109cc565b600084815260208120601f198516915b828110156135e757878501518255602094850194600190920191016135c7565b50848210156136055786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60008251613626818460208701612b07565b9190910192915050565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906114cf90830184612b2b565b60006020828403121561369257600080fd5b815161094d81612ad4565b6001600160a01b0386811682528516602082015260a0604082018190526000906136c990830186612db3565b82810360608401526136db8186612db3565b905082810360808401526136ef8185612b2b565b98975050505050505050565b60008261371857634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6040815260006137566040830185612db3565b828103602084015261173d8185612db3565b6001600160d01b038181168382160190811115610768576107686134d3565b6001600160d01b038281168282160390811115610768576107686134d356fea2646970667358221220c4a122cbed7aeefa786336f41038711173a8f6e73a57fdf244840baa14d3b4ba64736f6c634300081a00330000000000000000000000006a36b387cff055720043e9529ebd5d53ab512fa6000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000018416c706861737461727465722043657274696669636174650000000000000000000000000000000000000000000000000000000000000000000000000000000c414c504841535441525445520000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a68747470733a2f2f6d657461646174612e616c706861737461727465722e696f2f70726f6a656374732f00000000000000000000000000000000000000000000
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106102f05760003560e01c8063731133e91161019d578063ac9650d8116100e9578063e30c3978116100a2578063ee550c661161007c578063ee550c66146106e3578063f242432a1461070b578063f2fde38b1461071e578063f5298aca1461073157600080fd5b8063e30c3978146106ac578063e985e9c5146106bd578063eb9019d4146106d057600080fd5b8063ac9650d81461060a578063aedede7a1461062a578063b1784f4514610632578063b42394f114610671578063bd85b03914610679578063cdd583501461069957600080fd5b806392ab723e1161015657806398c9be051161013057806398c9be05146105be578063a2088a17146105d1578063a22cb465146105e4578063aa271e1a146105f757600080fd5b806392ab723e1461059057806395d89b41146105a3578063983b2d56146105ab57600080fd5b8063731133e91461053357806379ba5097146105465780638da5cb5b1461054e5780638dbb94eb1461055f57806391ddadf414610567578063927078691461057d57600080fd5b806333727c4d1161025c5780634f558e79116102155780636b32810b116101ef5780636b32810b1461050657806370428ba11461051b578063714c539814610523578063715018a61461052b57600080fd5b80634f558e79146104be57806355f804b3146104e05780636b20c454146104f357600080fd5b806333727c4d14610425578063430695e8146104485780634ba885681461045b5780634bf5d7e91461046e5780634d6fb775146104985780634e1273f4146104ab57600080fd5b8063133159ed116102ae578063133159ed1461038e5780631f7fdffa146103b95780631ff06065146103cc57806320878df4146103df5780632eb2c2d6146103ff5780633092afd51461041257600080fd5b8062fdd58e146102f55780630175c92a1461031b57806301ffc9a71461033057806306fdde03146103535780630b3dd1df146103685780630e89341c1461037b575b600080fd5b610308610303366004612a6e565b610744565b6040519081526020015b60405180910390f35b61032e610329366004612aa8565b61076e565b005b61034361033e366004612aea565b6107ce565b6040519015158152602001610312565b61035b61081e565b6040516103129190612b57565b610308610376366004612b6a565b6108b0565b61035b610389366004612b85565b6108d1565b6103a161039c366004612b9e565b610935565b6040516001600160a01b039091168152602001610312565b61032e6103c7366004612d11565b610954565b6103a16103da366004612b85565b6109d3565b6103f26103ed366004612b6a565b6109e0565b6040516103129190612def565b61032e61040d366004612e02565b610a04565b61032e610420366004612b6a565b610a51565b610343610433366004612b85565b6000908152600f602052604090205460ff1690565b61032e610456366004612eb5565b610a9c565b610308610469366004612a6e565b610b58565b60408051808201909152600e81526d06d6f64653d74696d657374616d760941b602082015261035b565b6103086104a6366004612f7e565b610b7a565b6103f26104b9366004612fb1565b610bfc565b6103436104cc366004612b85565b600090815260056020526040902054151590565b61032e6104ee366004613078565b610cc8565b61032e6105013660046130c0565b610cdc565b61050e610d6c565b6040516103129190613137565b610308610d7d565b61035b610d89565b61032e610d98565b61032e610541366004613183565b610dac565b61032e610dd5565b6000546001600160a01b03166103a1565b610308610e16565b60405165ffffffffffff42168152602001610312565b61050e61058b366004612b85565b610e22565b61030861059e366004612b85565b610e3c565b61035b610e47565b61032e6105b9366004612b6a565b610e56565b6103086105cc366004612b85565b610ea1565b6103086105df366004612b9e565b610eb8565b61032e6105f23660046131cb565b610f25565b610343610605366004612b6a565b610f30565b61061d6106183660046131f5565b610f3d565b604051610312919061326a565b6103f2611026565b6106456106403660046132cf565b611032565b60408051825165ffffffffffff1681526020928301516001600160d01b03169281019290925201610312565b600654610308565b610308610687366004612b85565b60009081526005602052604090205490565b6103086106a7366004612b85565b611059565b6001546001600160a01b03166103a1565b6103436106cb366004613318565b611066565b6103086106de366004612a6e565b611094565b6106f66106f1366004612a6e565b6110cf565b60405163ffffffff9091168152602001610312565b61032e610719366004613342565b6110db565b61032e61072c366004612b6a565b6110f2565b61032e61073f366004612f7e565b611163565b60008181526002602090815260408083206001600160a01b03861684529091529020545b92915050565b6000546001600160a01b0316331480159061078f575061078d33610f30565b155b156107c057335b60405163d393669560e01b81526001600160a01b0390911660048201526024015b60405180910390fd5b6107ca82826111a3565b5050565b60006001600160e01b03198216636cdb3d1360e11b14806107ff57506001600160e01b031982166303a24d0760e21b145b8061076857506301ffc9a760e01b6001600160e01b0319831614610768565b60606010805461082d9061339a565b80601f01602080910402602001604051908101604052809291908181526020018280546108599061339a565b80156108a65780601f1061087b576101008083540402835291602001916108a6565b820191906000526020600020905b81548152906001019060200180831161088957829003601f168201915b5050505050905090565b6001600160a01b0381166000908152600860205260408120610768906111fa565b60008181526005602052604090205460609061090357604051635828116560e11b8152600481018390526024016107b7565b601261090e83611204565b60405160200161091f9291906133d4565b6040516020818303038152906040529050919050565b600082815260076020526040812061094d9083611296565b9392505050565b61095d33610f30565b61098857335b604051631b0e18f960e11b81526001600160a01b0390911660048201526024016107b7565b8260005b81518110156109bf576109b78282815181106109aa576109aa61345a565b60200260200101516112a2565b60010161098c565b506109cc858585856112d5565b5050505050565b6000610768600d83611296565b6001600160a01b03811660009081526008602052604090206060906107689061130d565b8260005b8151811015610a3b57610a33828281518110610a2657610a2661345a565b602002602001015161131a565b600101610a08565b50610a49868686868661134c565b505050505050565b610a596113ab565b610a64600d826113d8565b506040516001600160a01b038216907fe94479a9f7e1952cc78f2d6baab678adc1b772d936c6583def489e524cb6669290600090a250565b6000546001600160a01b03163314801590610abd5750610abb33610f30565b155b15610ac85733610796565b8051825114610af75781518151604051633b5cfc6960e21b8152600481019290925260248201526044016107b7565b60005b8251811015610b53576000838281518110610b1757610b1761345a565b602002602001015190506000838381518110610b3557610b3561345a565b60200260200101519050610b4982826111a3565b5050600101610afa565b505050565b6001600160a01b038216600090815260086020526040812061094d9083611296565b60004265ffffffffffff81168310610bb65760405163d1980a7960e01b81526004810184905265ffffffffffff821660248201526044016107b7565b610bea610bc2846113ed565b6000868152600b602090815260408083206001600160a01b038b168452909152902090611424565b6001600160d01b031695945050505050565b60608151835114610c2d5781518351604051635b05999160e01b8152600481019290925260248201526044016107b7565b600083516001600160401b03811115610c4857610c48612bc0565b604051908082528060200260200182016040528015610c71578160200160208202803683370190505b50905060005b8451811015610cc057602080820286010151610c9b90602080840287010151610744565b828281518110610cad57610cad61345a565b6020908102919091010152600101610c77565b509392505050565b610cd06113ab565b610cd9816114da565b50565b8160005b8151811015610d0657610cfe828281518110610a2657610a2661345a565b600101610ce0565b506001600160a01b0384163314801590610d275750610d258433611066565b155b15610d5b57335b60405163711bec9160e11b81526001600160a01b03918216600482015290851660248201526044016107b7565b610d66848484611521565b50505050565b6060610d78600d61130d565b905090565b6000610d7860096111fa565b60606012805461082d9061339a565b610da06113ab565b610daa6000611567565b565b610db533610f30565b610dbf5733610963565b82610dc9816112a2565b6109cc85858585611580565b60015433906001600160a01b03168114610e0d5760405163118cdaa760e01b81526001600160a01b03821660048201526024016107b7565b610cd981611567565b6000610d78600d6111fa565b60008181526007602052604090206060906107689061130d565b6000610768826115dd565b60606011805461082d9061339a565b610e5e6113ab565b610e69600d82611603565b506040516001600160a01b038216907f6ae172837ea30b801fbfcdd4108aa1d5bf8ff775444fd70256b44e6bf3dfc3f690600090a250565b6000818152600760205260408120610768906111fa565b60004265ffffffffffff81168310610ef45760405163d1980a7960e01b81526004810184905265ffffffffffff821660248201526044016107b7565b610f14610f00846113ed565b6000868152600c6020526040902090611424565b6001600160d01b0316949350505050565b6107ca338383611618565b6000610768600d836116ae565b6060816001600160401b03811115610f5757610f57612bc0565b604051908082528060200260200182016040528015610f8a57816020015b6060815260200190600190039081610f755790505b50905060005b8281101561101f57610ffa30858584818110610fae57610fae61345a565b9050602002810190610fc09190613470565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506116d092505050565b82828151811061100c5761100c61345a565b6020908102919091010152600101610f90565b5092915050565b6060610d78600961130d565b6040805180820190915260008082526020820152611051848484611746565b949350505050565b6000610768600983611296565b6001600160a01b03918216600090815260036020908152604080832093909416825291909152205460ff1690565b6000818152600b602090815260408083206001600160a01b038616845290915281206110bf90611782565b6001600160d01b03169392505050565b600061094d83836117bb565b826110e58161131a565b610a4986868686866117e7565b6110fa6113ab565b600180546001600160a01b0383166001600160a01b0319909116811790915561112b6000546001600160a01b031690565b6001600160a01b03167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e2270060405160405180910390a350565b8161116d8161131a565b6001600160a01b038416331480159061118d575061118b8433611066565b155b156111985733610d2e565b610d66848484611846565b6000828152600f6020908152604091829020805460ff1916841515908117909155915191825283917f82693b732f9696c8a914b820dd6c52544bd61b844bbd4c8707253df9340cf6b7910160405180910390a25050565b6000610768825490565b60606000611211836118ae565b60010190506000816001600160401b0381111561123057611230612bc0565b6040519080825280601f01601f19166020018201604052801561125a576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461126457509392505050565b600061094d8383611986565b6000818152600f602052604090205460ff1615610cd957604051632b4d0eef60e01b8152600481018290526024016107b7565b6001600160a01b0384166112ff57604051632bfa23e760e11b8152600060048201526024016107b7565b610d666000858585856119b0565b6060600061094d83611a03565b6000818152600f602052604090205460ff16610cd957604051637d80d8a560e01b8152600481018290526024016107b7565b336001600160a01b038616811480159061136d575061136b8682611066565b155b1561139e5760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044016107b7565b610a498686868686611a5f565b6000546001600160a01b03163314610daa5760405163118cdaa760e01b81523360048201526024016107b7565b600061094d836001600160a01b038416611abf565b600065ffffffffffff821115611420576040516306dfcc6560e41b815260306004820152602481018390526044016107b7565b5090565b81546000908181600581111561148357600061143f84611bb2565b61144990856134e9565b60008881526020902090915081015465ffffffffffff908116908716101561147357809150611481565b61147e8160016134fc565b92505b505b600061149187878585611c9a565b905080156114cc576114b6876114a86001846134e9565b600091825260209091200190565b54600160301b90046001600160d01b03166114cf565b60005b979650505050505050565b60126114e68282613556565b507f5411e8ebf1636d9e83d5fc4900bf80cbac82e8790da2a4c94db4895e889eedf6816040516115169190612b57565b60405180910390a150565b6001600160a01b03831661154a57604051626a0d4560e21b8152600060048201526024016107b7565b610b538360008484604051806020016040528060008152506119b0565b600180546001600160a01b0319169055610cd981611cf4565b6001600160a01b0384166115aa57604051632bfa23e760e11b8152600060048201526024016107b7565b60408051600180825260208201869052818301908152606082018590526080820190925290610a496000878484876119b0565b6000818152600c602052604081206115f490611782565b6001600160d01b031692915050565b600061094d836001600160a01b038416611d44565b6001600160a01b0382166116415760405162ced3e160e81b8152600060048201526024016107b7565b6001600160a01b03838116600081815260036020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b6001600160a01b0381166000908152600183016020526040812054151561094d565b6060600080846001600160a01b0316846040516116ed9190613614565b600060405180830381855afa9150503d8060008114611728576040519150601f19603f3d011682016040523d82523d6000602084013e61172d565b606091505b509150915061173d858383611d93565b95945050505050565b60408051808201825260008082526020808301829052858252600b81528382206001600160a01b03881683529052919091206110519083611def565b805460009080156117b25761179c836114a86001846134e9565b54600160301b90046001600160d01b031661094d565b60009392505050565b6000818152600b602090815260408083206001600160a01b038616845290915281205461094d90611e5f565b336001600160a01b038616811480159061180857506118068682611066565b155b156118395760405163711bec9160e11b81526001600160a01b038083166004830152871660248201526044016107b7565b610a498686868686611e90565b6001600160a01b03831661186f57604051626a0d4560e21b8152600060048201526024016107b7565b604080516001808252602082018590528183019081526060820184905260a082019092526000608082018181529192916109cc918791859085906119b0565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106118ed5772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef81000000008310611919576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061193757662386f26fc10000830492506010015b6305f5e100831061194f576305f5e100830492506008015b612710831061196357612710830492506004015b60648310611975576064830492506002015b600a83106107685760010192915050565b600082600001828154811061199d5761199d61345a565b9060005260206000200154905092915050565b6119bc85858585611f1e565b6001600160a01b038416156109cc57825133906001036119f557602084810151908401516119ee838989858589611f2a565b5050610a49565b610a4981878787878761204e565b606081600001805480602002602001604051908101604052809291908181526020018280548015611a5357602002820191906000526020600020905b815481526020019060010190808311611a3f575b50505050509050919050565b6001600160a01b038416611a8957604051632bfa23e760e11b8152600060048201526024016107b7565b6001600160a01b038516611ab257604051626a0d4560e21b8152600060048201526024016107b7565b6109cc85858585856119b0565b60008181526001830160205260408120548015611ba8576000611ae36001836134e9565b8554909150600090611af7906001906134e9565b9050808214611b5c576000866000018281548110611b1757611b1761345a565b9060005260206000200154905080876000018481548110611b3a57611b3a61345a565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080611b6d57611b6d613630565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610768565b6000915050610768565b600081600003611bc457506000919050565b60006001611bd184612137565b901c6001901b90506001818481611bea57611bea6134bd565b048201901c90506001818481611c0257611c026134bd565b048201901c90506001818481611c1a57611c1a6134bd565b048201901c90506001818481611c3257611c326134bd565b048201901c90506001818481611c4a57611c4a6134bd565b048201901c90506001818481611c6257611c626134bd565b048201901c90506001818481611c7a57611c7a6134bd565b048201901c905061094d81828581611c9457611c946134bd565b046121cb565b60005b81831015610cc0576000611cb184846121e1565b60008781526020902090915065ffffffffffff86169082015465ffffffffffff161115611ce057809250611cee565b611ceb8160016134fc565b93505b50611c9d565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000818152600183016020526040812054611d8b57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610768565b506000610768565b606082611da857611da3826121fc565b61094d565b8151158015611dbf57506001600160a01b0384163b155b15611de857604051639996b31560e01b81526001600160a01b03851660048201526024016107b7565b508061094d565b6040805180820190915260008082526020820152826000018263ffffffff1681548110611e1e57611e1e61345a565b60009182526020918290206040805180820190915291015465ffffffffffff81168252600160301b90046001600160d01b0316918101919091529392505050565b600063ffffffff821115611420576040516306dfcc6560e41b815260206004820152602481018390526044016107b7565b6001600160a01b038416611eba57604051632bfa23e760e11b8152600060048201526024016107b7565b6001600160a01b038516611ee357604051626a0d4560e21b8152600060048201526024016107b7565b60408051600180825260208201869052818301908152606082018590526080820190925290611f1587878484876119b0565b50505050505050565b610d6684848484612225565b6001600160a01b0384163b15610a495760405163f23a6e6160e01b81526001600160a01b0385169063f23a6e6190611f6e9089908990889088908890600401613646565b6020604051808303816000875af1925050508015611fa9575060408051601f3d908101601f19168201909252611fa691810190613680565b60015b612012573d808015611fd7576040519150601f19603f3d011682016040523d82523d6000602084013e611fdc565b606091505b50805160000361200a57604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b805181602001fd5b6001600160e01b0319811663f23a6e6160e01b14611f1557604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b6001600160a01b0384163b15610a495760405163bc197c8160e01b81526001600160a01b0385169063bc197c8190612092908990899088908890889060040161369d565b6020604051808303816000875af19250505080156120cd575060408051601f3d908101601f191682019092526120ca91810190613680565b60015b6120fb573d808015611fd7576040519150601f19603f3d011682016040523d82523d6000602084013e611fdc565b6001600160e01b0319811663bc197c8160e01b14611f1557604051632bfa23e760e11b81526001600160a01b03861660048201526024016107b7565b600080608083901c1561214c57608092831c92015b604083901c1561215e57604092831c92015b602083901c1561217057602092831c92015b601083901c1561218257601092831c92015b600883901c1561219457600892831c92015b600483901c156121a657600492831c92015b600283901c156121b857600292831c92015b600183901c156107685760010192915050565b60008183106121da578161094d565b5090919050565b60006121f060028484186136fb565b61094d908484166134fc565b80511561220c5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b61223184848484612283565b60005b82518110156109cc5761227b85858584815181106122545761225461345a565b602002602001015185858151811061226e5761226e61345a565b602002602001015161246a565b600101612234565b61228f848484846124d9565b60005b82518110156109cc5760008382815181106122af576122af61345a565b6020026020010151905060008383815181106122cd576122cd61345a565b6020026020010151905060006001600160a01b0316876001600160a01b031614612344576122fb8783610744565b60000361233f57600082815260076020526040902061231a90886113d8565b506001600160a01b038716600090815260086020526040902061233d90836126db565b505b6123a0565b600082815260056020526040812080548392906123629084906134fc565b909155505060008281526005602052604090205415612388576123866009836126e7565b505b806006600082825461239a91906134fc565b90915550505b6001600160a01b038616156124035760006123bb8784610744565b11156123fe5760008281526007602052604090206123d99087611603565b506001600160a01b03861660009081526008602052604090206123fc90836126e7565b505b612460565b600082815260056020526040812080548392906124219084906134e9565b90915550506000828152600560205260408120549003612448576124466009836126db565b505b806006600082825461245a91906134e9565b90915550505b5050600101612292565b6001600160a01b03841661249e576000828152600c6020526040902061249b906126f3612496846126ff565b612733565b50505b6001600160a01b0383166124cd576000828152600c602052604090206124ca90612765612496846126ff565b50505b610d6684848484612771565b80518251146125085781518151604051635b05999160e01b8152600481019290925260248201526044016107b7565b3360005b83518110156125fc576020818102858101820151908501909101516001600160a01b038816156125ab5760008281526002602090815260408083206001600160a01b038c1684529091529020548181101561258257888183856040516303dee4c560e01b81526004016107b7949392919061371d565b60008381526002602090815260408083206001600160a01b038d16845290915290209082900390555b6001600160a01b038716156125f25760008281526002602090815260408083206001600160a01b038b168452909152812080548392906125ec9084906134fc565b90915550505b505060010161250c565b50825160010361267d5760208301516000906020840151909150856001600160a01b0316876001600160a01b0316846001600160a01b03167fc3d58168c5ae7397731d063d5bbf3d657854427343f4c083240f7aacaa2d0f62858560405161266e929190918252602082015260400190565b60405180910390a450506109cc565b836001600160a01b0316856001600160a01b0316826001600160a01b03167f4a39dc06d4c0dbc64b70af90fd698a233a518aa5d07e595d983b8c0526c8f7fb86866040516126cc929190613743565b60405180910390a45050505050565b600061094d8383611abf565b600061094d8383611d44565b600061094d8284613768565b60006001600160d01b03821115611420576040516306dfcc6560e41b815260d06004820152602481018390526044016107b7565b6000806127584261275061274688611782565b868863ffffffff16565b8791906128cf565b915091505b935093915050565b600061094d8284613787565b826001600160a01b0316846001600160a01b0316141580156127935750600081115b15610d66576001600160a01b03841615612831576000828152600b602090815260408083206001600160a01b0388168452909152812081906127db90612765612496866126ff565b6001600160d01b031691506001600160d01b031691507f9015ef8bf6882f1e524a4c1948f14ec3bdead0003a18918a9aa16857c6a57ea286858484604051612826949392919061371d565b60405180910390a150505b6001600160a01b03831615610d66576000828152600b602090815260408083206001600160a01b038716845290915281208190612874906126f3612496866126ff565b6001600160d01b031691506001600160d01b031691507f9015ef8bf6882f1e524a4c1948f14ec3bdead0003a18918a9aa16857c6a57ea2858584846040516128bf949392919061371d565b60405180910390a1505050505050565b6000806127588585858254600090819080156129f75760006128f6876114a86001856134e9565b60408051808201909152905465ffffffffffff808216808452600160301b9092046001600160d01b03166020840152919250908716101561294a57604051632520601d60e01b815260040160405180910390fd5b805165ffffffffffff808816911603612996578461296d886114a86001866134e9565b80546001600160d01b0392909216600160301b0265ffffffffffff9092169190911790556129e7565b6040805180820190915265ffffffffffff80881682526001600160d01b0380881660208085019182528b54600181018d5560008d81529190912094519151909216600160301b029216919091179101555b60200151925083915061275d9050565b50506040805180820190915265ffffffffffff80851682526001600160d01b0380851660208085019182528854600181018a5560008a815291822095519251909316600160301b02919093161792019190915590508161275d565b80356001600160a01b0381168114612a6957600080fd5b919050565b60008060408385031215612a8157600080fd5b612a8a83612a52565b946020939093013593505050565b80358015158114612a6957600080fd5b60008060408385031215612abb57600080fd5b82359150612acb60208401612a98565b90509250929050565b6001600160e01b031981168114610cd957600080fd5b600060208284031215612afc57600080fd5b813561094d81612ad4565b60005b83811015612b22578181015183820152602001612b0a565b50506000910152565b60008151808452612b43816020860160208601612b07565b601f01601f19169290920160200192915050565b60208152600061094d6020830184612b2b565b600060208284031215612b7c57600080fd5b61094d82612a52565b600060208284031215612b9757600080fd5b5035919050565b60008060408385031215612bb157600080fd5b50508035926020909101359150565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612bfe57612bfe612bc0565b604052919050565b60006001600160401b03821115612c1f57612c1f612bc0565b5060051b60200190565b600082601f830112612c3a57600080fd5b8135612c4d612c4882612c06565b612bd6565b8082825260208201915060208360051b860101925085831115612c6f57600080fd5b602085015b83811015612c8c578035835260209283019201612c74565b5095945050505050565b6000806001600160401b03841115612cb057612cb0612bc0565b50601f8301601f1916602001612cc581612bd6565b915050828152838383011115612cda57600080fd5b828260208301376000602084830101529392505050565b600082601f830112612d0257600080fd5b61094d83833560208501612c96565b60008060008060808587031215612d2757600080fd5b612d3085612a52565b935060208501356001600160401b03811115612d4b57600080fd5b612d5787828801612c29565b93505060408501356001600160401b03811115612d7357600080fd5b612d7f87828801612c29565b92505060608501356001600160401b03811115612d9b57600080fd5b612da787828801612cf1565b91505092959194509250565b600081518084526020840193506020830160005b82811015612de5578151865260209586019590910190600101612dc7565b5093949350505050565b60208152600061094d6020830184612db3565b600080600080600060a08688031215612e1a57600080fd5b612e2386612a52565b9450612e3160208701612a52565b935060408601356001600160401b03811115612e4c57600080fd5b612e5888828901612c29565b93505060608601356001600160401b03811115612e7457600080fd5b612e8088828901612c29565b92505060808601356001600160401b03811115612e9c57600080fd5b612ea888828901612cf1565b9150509295509295909350565b60008060408385031215612ec857600080fd5b82356001600160401b03811115612ede57600080fd5b612eea85828601612c29565b92505060208301356001600160401b03811115612f0657600080fd5b8301601f81018513612f1757600080fd5b8035612f25612c4882612c06565b8082825260208201915060208360051b850101925087831115612f4757600080fd5b6020840193505b82841015612f7057612f5f84612a98565b825260209384019390910190612f4e565b809450505050509250929050565b600080600060608486031215612f9357600080fd5b612f9c84612a52565b95602085013595506040909401359392505050565b60008060408385031215612fc457600080fd5b82356001600160401b03811115612fda57600080fd5b8301601f81018513612feb57600080fd5b8035612ff9612c4882612c06565b8082825260208201915060208360051b85010192508783111561301b57600080fd5b6020840193505b828410156130445761303384612a52565b825260209384019390910190613022565b945050505060208301356001600160401b0381111561306257600080fd5b61306e85828601612c29565b9150509250929050565b60006020828403121561308a57600080fd5b81356001600160401b038111156130a057600080fd5b8201601f810184136130b157600080fd5b61105184823560208401612c96565b6000806000606084860312156130d557600080fd5b6130de84612a52565b925060208401356001600160401b038111156130f957600080fd5b61310586828701612c29565b92505060408401356001600160401b0381111561312157600080fd5b61312d86828701612c29565b9150509250925092565b602080825282518282018190526000918401906040840190835b818110156131785783516001600160a01b0316835260209384019390920191600101613151565b509095945050505050565b6000806000806080858703121561319957600080fd5b6131a285612a52565b9350602085013592506040850135915060608501356001600160401b03811115612d9b57600080fd5b600080604083850312156131de57600080fd5b6131e783612a52565b9150612acb60208401612a98565b6000806020838503121561320857600080fd5b82356001600160401b0381111561321e57600080fd5b8301601f8101851361322f57600080fd5b80356001600160401b0381111561324557600080fd5b8560208260051b840101111561325a57600080fd5b6020919091019590945092505050565b6000602082016020835280845180835260408501915060408160051b86010192506020860160005b828110156132c357603f198786030184526132ae858351612b2b565b94506020938401939190910190600101613292565b50929695505050505050565b6000806000606084860312156132e457600080fd5b6132ed84612a52565b925060208401359150604084013563ffffffff8116811461330d57600080fd5b809150509250925092565b6000806040838503121561332b57600080fd5b61333483612a52565b9150612acb60208401612a52565b600080600080600060a0868803121561335a57600080fd5b61336386612a52565b945061337160208701612a52565b9350604086013592506060860135915060808601356001600160401b03811115612e9c57600080fd5b600181811c908216806133ae57607f821691505b6020821081036133ce57634e487b7160e01b600052602260045260246000fd5b50919050565b60008084546133e28161339a565b6001821680156133f9576001811461340e5761343e565b60ff198316865281151582028601935061343e565b87600052602060002060005b838110156134365781548882015260019091019060200161341a565b505081860193505b5050508351613451818360208801612b07565b01949350505050565b634e487b7160e01b600052603260045260246000fd5b6000808335601e1984360301811261348757600080fd5b8301803591506001600160401b038211156134a157600080fd5b6020019150368190038213156134b657600080fd5b9250929050565b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b81810381811115610768576107686134d3565b80820180821115610768576107686134d3565b601f821115610b5357806000526020600020601f840160051c810160208510156135365750805b601f840160051c820191505b818110156109cc5760008155600101613542565b81516001600160401b0381111561356f5761356f612bc0565b6135838161357d845461339a565b8461350f565b6020601f8211600181146135b7576000831561359f5750848201515b600019600385901b1c1916600184901b1784556109cc565b600084815260208120601f198516915b828110156135e757878501518255602094850194600190920191016135c7565b50848210156136055786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b60008251613626818460208701612b07565b9190910192915050565b634e487b7160e01b600052603160045260246000fd5b6001600160a01b03868116825285166020820152604081018490526060810183905260a0608082018190526000906114cf90830184612b2b565b60006020828403121561369257600080fd5b815161094d81612ad4565b6001600160a01b0386811682528516602082015260a0604082018190526000906136c990830186612db3565b82810360608401526136db8186612db3565b905082810360808401526136ef8185612b2b565b98975050505050505050565b60008261371857634e487b7160e01b600052601260045260246000fd5b500490565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b6040815260006137566040830185612db3565b828103602084015261173d8185612db3565b6001600160d01b038181168382160190811115610768576107686134d3565b6001600160d01b038281168282160390811115610768576107686134d356fea2646970667358221220c4a122cbed7aeefa786336f41038711173a8f6e73a57fdf244840baa14d3b4ba64736f6c634300081a0033
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.