Polygon Sponsored slots available. Book your slot here!
ERC-721
Overview
Max Total Supply
413 DCL-GLWSCKS
Holders
179
Market
Volume (24H)
N/A
Min Price (24H)
N/A
Max Price (24H)
N/A
Other Info
Token Contract
Balance
1 DCL-GLWSCKSLoading...
Loading
Loading...
Loading
Loading...
Loading
Minimal Proxy Contract for 0x006080c6061c4af79b39da0842a3a22a7b3f185e
Contract Name:
ERC721CollectionV2
Compiler Version
v0.7.6+commit.7338295f
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "./ERC721BaseCollectionV2.sol"; contract ERC721CollectionV2 is ERC721BaseCollectionV2 { constructor() {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "../interfaces/ICollectionManager.sol"; import "../commons/OwnableInitializable.sol"; import "../commons/NativeMetaTransaction.sol"; import "../libs/String.sol"; contract Rarities is OwnableInitializable, NativeMetaTransaction { using String for string; struct Rarity { string name; uint256 maxSupply; uint256 price; } Rarity[] public rarities; /// @dev indexes will start in 1 mapping(bytes32 => uint256) rarityIndex; event AddRarity(Rarity _rarity); event UpdatePrice(string _name, uint256 _price); /** * @notice Create the contract * @param _owner - owner of the contract */ constructor(address _owner, Rarity[] memory _rarities) { // EIP712 init _initializeEIP712('Decentraland Rarities', '1'); // Ownable init _initOwnable(); transferOwnership(_owner); for (uint256 i = 0 ; i < _rarities.length; i++) { _addRarity(_rarities[i]); } } function updatePrices(string[] calldata _names, uint256[] calldata _prices) external onlyOwner { require(_names.length == _prices.length, "Rarities#updatePrices: LENGTH_MISMATCH"); for (uint256 i = 0; i < _names.length; i++) { string memory name = _names[i]; uint256 price = _prices[i]; bytes32 rarityKey = keccak256(bytes(name.toLowerCase())); uint256 index = rarityIndex[rarityKey]; require(rarityIndex[rarityKey] > 0, "Rarities#updatePrices: INVALID_RARITY"); rarities[index - 1].price = price; emit UpdatePrice(name, price); } } function addRarities(Rarity[] memory _rarities) external onlyOwner { for (uint256 i = 0; i < _rarities.length; i++) { _addRarity(_rarities[i]); } } function _addRarity(Rarity memory _rarity) internal { uint256 rarityLength = bytes(_rarity.name).length; require(rarityLength > 0 && rarityLength <= 32, "Rarities#_addRarity: INVALID_LENGTH"); bytes32 rarityKey = keccak256(bytes(_rarity.name.toLowerCase())); require(rarityIndex[rarityKey] == 0, "Rarities#_addRarity: RARITY_ALREADY_ADDED"); rarities.push(_rarity); rarityIndex[rarityKey] = rarities.length; emit AddRarity(_rarity); } /** * @notice Returns the amount of item in the collection * @return Amount of items in the collection */ function raritiesCount() external view returns (uint256) { return rarities.length; } /** * @notice Returns a rarity * @dev will revert if the rarity is out of bounds * @return rarity for the given index */ function getRarityByName(string memory _rarity) public view returns (Rarity memory) { bytes32 rarityKey = keccak256(bytes(_rarity.toLowerCase())); uint256 index = rarityIndex[rarityKey]; require(rarityIndex[rarityKey] > 0, "Rarities#getRarityByName: INVALID_RARITY"); return rarities[index - 1]; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; interface ICollectionManager { function manageCollection(address _forwarder, address _collection, bytes calldata _data) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "./ContextMixin.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableInitializable is ContextMixin { address internal _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function _initOwnable () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import {SafeMath} from "@openzeppelin/contracts/math/SafeMath.sol"; import { EIP712Base } from "./EIP712Base.sol"; contract NativeMetaTransaction is EIP712Base { using SafeMath for uint256; bytes32 private constant META_TRANSACTION_TYPEHASH = keccak256( bytes( "MetaTransaction(uint256 nonce,address from,bytes functionSignature)" ) ); event MetaTransactionExecuted( address userAddress, address relayerAddress, bytes functionSignature ); mapping(address => uint256) nonces; struct MetaTransaction { uint256 nonce; address from; bytes functionSignature; } function executeMetaTransaction( address userAddress, bytes memory functionSignature, bytes32 sigR, bytes32 sigS, uint8 sigV ) external payable returns (bytes memory) { MetaTransaction memory metaTx = MetaTransaction({ nonce: nonces[userAddress], from: userAddress, functionSignature: functionSignature }); require( verify(userAddress, metaTx, sigR, sigS, sigV), "NMT#executeMetaTransaction: SIGNER_AND_SIGNATURE_DO_NOT_MATCH" ); // increase nonce for user (to avoid re-use) nonces[userAddress] = nonces[userAddress].add(1); emit MetaTransactionExecuted( userAddress, msg.sender, functionSignature ); // Append userAddress and relayer address at the end to extract it from calling context (bool success, bytes memory returnData) = address(this).call{value: msg.value}( abi.encodePacked(functionSignature, userAddress) ); require(success, "NMT#executeMetaTransaction: CALL_FAILED"); return returnData; } function hashMetaTransaction(MetaTransaction memory metaTx) internal pure returns (bytes32) { return keccak256( abi.encode( META_TRANSACTION_TYPEHASH, metaTx.nonce, metaTx.from, keccak256(metaTx.functionSignature) ) ); } function getNonce(address user) external view returns (uint256 nonce) { nonce = nonces[user]; } function verify( address signer, MetaTransaction memory metaTx, bytes32 sigR, bytes32 sigS, uint8 sigV ) internal view returns (bool) { require(signer != address(0), "NMT#verify: INVALID_SIGNER"); return signer == ecrecover( toTypedMessageHash(hashMetaTransaction(metaTx)), sigV, sigR, sigS ); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; library String { /** * @dev Convert bytes32 to string. * @param _x - to be converted to string. * @return string */ function bytes32ToString(bytes32 _x) internal pure returns (string memory) { bytes memory bytesString = new bytes(32); uint charCount = 0; for (uint j = 0; j < 32; j++) { bytes1 currentChar = bytes1(bytes32(uint(_x) * 2 ** (8 * j))); if (currentChar != 0) { bytesString[charCount] = currentChar; charCount++; } } bytes memory bytesStringTrimmed = new bytes(charCount); for (uint j = 0; j < charCount; j++) { bytesStringTrimmed[j] = bytesString[j]; } return string(bytesStringTrimmed); } /** * @dev Convert uint to string. * @param _i - uint256 to be converted to string. * @return _uintAsString uint in string */ function uintToString(uint _i) internal pure returns (string memory _uintAsString) { uint i = _i; if (i == 0) { return "0"; } uint j = i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (i != 0) { bstr[k--] = bytes1(uint8(48 + i % 10)); i /= 10; } return string(bstr); } /** * @dev Convert an address to string. * @param _x - address to be converted to string. * @return string representation of the address */ function addressToString(address _x) internal pure returns (string memory) { bytes memory s = new bytes(40); for (uint i = 0; i < 20; i++) { bytes1 b = bytes1(uint8(uint160(_x) / (2**(8*(19 - i))))); bytes1 hi = bytes1(uint8(b) / 16); bytes1 lo = bytes1(uint8(b) - 16 * uint8(hi)); s[2*i] = char(hi); s[2*i+1] = char(lo); } return string(s); } function char(bytes1 b) internal pure returns (bytes1 c) { if (uint8(b) < 10) return bytes1(uint8(b) + 0x30); else return bytes1(uint8(b) + 0x57); } /** * @dev Lowercase a string. * @param _str - to be converted to string. * @return string */ function toLowerCase(string memory _str) internal pure returns (string memory) { bytes memory bStr = bytes(_str); bytes memory bLower = new bytes(bStr.length); for (uint i = 0; i < bStr.length; i++) { // Uppercase character... if ((bStr[i] >= 0x41) && (bStr[i] <= 0x5A)) { // So we add 0x20 to make it lowercase bLower[i] = bytes1(uint8(bStr[i]) + 0x20); } else { bLower[i] = bStr[i]; } } return string(bLower); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; abstract contract ContextMixin { function _msgSender() internal view virtual returns (address payable sender) { if (msg.sender == address(this)) { bytes memory array = msg.data; uint256 index = msg.data.length; assembly { // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. sender := and( mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff ) } } else { sender = msg.sender; } return sender; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when 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 SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b > a) return (false, 0); return (true, a - b); } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { // 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. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { 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. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { if (b == 0) return (false, 0); return (true, a % b); } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a, "SafeMath: subtraction overflow"); return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) return 0; uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: division by zero"); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { require(b > 0, "SafeMath: modulo by zero"); return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); return a - b; } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryDiv}. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; contract EIP712Base { struct EIP712Domain { string name; string version; address verifyingContract; bytes32 salt; } bytes32 internal constant EIP712_DOMAIN_TYPEHASH = keccak256( bytes( "EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)" ) ); bytes32 public domainSeparator; // supposed to be called once while initializing. // one of the contractsa that inherits this contract follows proxy pattern // so it is not possible to do this in a constructor function _initializeEIP712( string memory name, string memory version ) internal { domainSeparator = keccak256( abi.encode( EIP712_DOMAIN_TYPEHASH, keccak256(bytes(name)), keccak256(bytes(version)), address(this), bytes32(getChainId()) ) ); } function getChainId() public pure returns (uint256) { uint256 id; assembly { id := chainid() } return id; } /** * Accept message hash and returns hash message in EIP712 compatible form * So that it can be used to recover signer from signature signed using EIP712 formatted data * https://eips.ethereum.org/EIPS/eip-712 * "\\x19" makes the encoding deterministic * "\\x01" is the version byte to make it compatible to EIP-191 */ function toTypedMessageHash(bytes32 messageHash) internal view returns (bytes32) { return keccak256( abi.encodePacked("\x19\x01", domainSeparator, messageHash) ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../../interfaces/IERC20.sol"; import "../../interfaces/IERC721CollectionV2.sol"; import "../../commons/OwnableInitializable.sol"; import "../../commons/NativeMetaTransaction.sol"; contract CollectionStore is OwnableInitializable, NativeMetaTransaction { using SafeMath for uint256; struct ItemToBuy { IERC721CollectionV2 collection; uint256[] ids; uint256[] prices; address[] beneficiaries; } uint256 constant public BASE_FEE = 1000000; IERC20 public acceptedToken; uint256 public fee; address public feeOwner; event Bought(ItemToBuy[] _itemsToBuy); event SetFee(uint256 _oldFee, uint256 _newFee); event SetFeeOwner(address indexed _oldFeeOwner, address indexed _newFeeOwner); /** * @notice Constructor of the contract. * @param _acceptedToken - Address of the ERC20 token accepted * @param _feeOwner - address where fees will be transferred * @param _fee - fee to charge for each sale */ constructor(address _owner, IERC20 _acceptedToken, address _feeOwner, uint256 _fee) { // EIP712 init _initializeEIP712('Decentraland Collection Store', '1'); // Ownable init _initOwnable(); acceptedToken = _acceptedToken; feeOwner = _feeOwner; setFee(_fee); transferOwnership(_owner); } /** * @notice Buy collection's items. * @dev There is a maximum amount of NFTs that can be issued per call by the block's limit. * @param _itemsToBuy - items to buy */ function buy(ItemToBuy[] memory _itemsToBuy) external { uint256 totalFee = 0; address sender = _msgSender(); for (uint256 i = 0; i < _itemsToBuy.length; i++) { ItemToBuy memory itemToBuy = _itemsToBuy[i]; IERC721CollectionV2 collection = itemToBuy.collection; uint256 amountOfItems = itemToBuy.ids.length; require(amountOfItems == itemToBuy.prices.length, "CollectionStore#buy: LENGTH_MISMATCH"); for (uint256 j = 0; j < amountOfItems; j++) { uint256 itemId = itemToBuy.ids[j]; uint256 price = itemToBuy.prices[j]; (uint256 itemPrice, address itemBeneficiary) = getItemBuyData(collection, itemId); require(price == itemPrice, "CollectionStore#buy: ITEM_PRICE_MISMATCH"); if (itemPrice > 0) { // Calculate sale share uint256 saleShareAmount = itemPrice.mul(fee).div(BASE_FEE); totalFee = totalFee.add(saleShareAmount); // Transfer sale amount to the item beneficiary require( acceptedToken.transferFrom(sender, itemBeneficiary, itemPrice.sub(saleShareAmount)), "CollectionStore#buy: TRANSFER_PRICE_FAILED" ); } } // Mint Token collection.issueTokens(itemToBuy.beneficiaries, itemToBuy.ids); } if (totalFee > 0) { // Transfer share amount for fees owner require( acceptedToken.transferFrom(sender, feeOwner, totalFee), "CollectionStore#buy: TRANSFER_FEES_FAILED" ); } emit Bought(_itemsToBuy); } /** * @notice Get item's price and beneficiary * @param _collection - collection address * @param _itemId - item id * @return uint256 of the item's price * @return address of the item's beneficiary */ function getItemBuyData(IERC721CollectionV2 _collection, uint256 _itemId) public view returns (uint256, address) { (,,,uint256 price, address beneficiary,,) = _collection.items(_itemId); return (price, beneficiary); } // Owner functions /** * @notice Sets the fee of the contract that's charged to the seller on each sale * @param _newFee - Fee from 0 to 999,999 */ function setFee(uint256 _newFee) public onlyOwner { require(_newFee < BASE_FEE, "CollectionStore#setFee: FEE_SHOULD_BE_LOWER_THAN_BASE_FEE"); require(_newFee != fee, "CollectionStore#setFee: SAME_FEE"); emit SetFee(fee, _newFee); fee = _newFee; } /** * @notice Set a new fee owner. * @param _newFeeOwner - Address of the new fee owner */ function setFeeOwner(address _newFeeOwner) external onlyOwner { require(_newFeeOwner != address(0), "CollectionStore#setFeeOwner: INVALID_ADDRESS"); require(_newFeeOwner != feeOwner, "CollectionStore#setFeeOwner: SAME_FEE_OWNER"); emit SetFeeOwner(feeOwner, _newFeeOwner); feeOwner = _newFeeOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.12; interface IERC20 { function balanceOf(address from) external view returns (uint256); function transferFrom(address from, address to, uint tokens) external returns (bool); function transfer(address to, uint tokens) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function burn(uint256 amount) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; interface IERC721CollectionV2 { function COLLECTION_HASH() external view returns (bytes32); struct ItemParam { string rarity; uint256 price; address beneficiary; string metadata; } function issueTokens(address[] calldata _beneficiaries, uint256[] calldata _itemIds) external; function setApproved(bool _value) external; /// @dev For some reason using the Struct Item as an output parameter fails, but works as an input parameter function initialize( string memory _name, string memory _symbol, string memory _baseURI, address _creator, bool _shouldComplete, bool _isApproved, address _rarities, ItemParam[] memory _items ) external; function items(uint256 _itemId) external view returns (string memory, uint256, uint256, uint256, address, string memory, string memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "../markets/v2/CollectionStore.sol"; interface EventsInterface { event Issue(address indexed _beneficiary, uint256 indexed _tokenId, uint256 indexed _itemId, uint256 _issuedId, address _caller); event Transfer(address indexed _from, address indexed _to, uint256 _value); } contract DummyCollectionStore is EventsInterface, CollectionStore { constructor ( address _owner, IERC20 _acceptedToken, address _feeOwner, uint256 _fee ) CollectionStore(_owner, _acceptedToken, _feeOwner, _fee) {} }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "../interfaces/ICollectionManager.sol"; import "../commons/OwnableInitializable.sol"; import "../commons/NativeMetaTransaction.sol"; contract Committee is OwnableInitializable, NativeMetaTransaction { mapping(address => bool) public members; event MemberSet(address indexed _member, bool _value); /** * @notice Create the contract * @param _owner - owner of the contract * @param _members - members to be added at contract creation */ constructor(address _owner, address[] memory _members) { // EIP712 init _initializeEIP712('Decentraland Collection Committee', '1'); // Ownable init _initOwnable(); transferOwnership(_owner); for (uint256 i = 0; i < _members.length; i++) { _setMember(_members[i], true); } } /** * @notice Set members * @param _members - members to be added * @param _values - whether the members should be added or removed */ function setMembers(address[] calldata _members, bool[] calldata _values) external onlyOwner { require(_members.length == _values.length, "Committee#setMembers: LENGTH_MISMATCH"); for (uint256 i = 0; i < _members.length; i++) { _setMember(_members[i], _values[i]); } } /** * @notice Set members * @param _member - member to be added * @param _value - whether the member should be added or removed */ function _setMember(address _member, bool _value) internal { members[_member] = _value; emit MemberSet(_member, _value); } /** * @notice Manage collection * @param _collectionManager - collection manager * @param _forwarder - forwarder contract owner of the collection * @param _collection - collection to be managed * @param _data - call data to be used */ function manageCollection(ICollectionManager _collectionManager, address _forwarder, address _collection, bytes memory _data) external { require(members[_msgSender()], "Committee#manageCollection: UNAUTHORIZED_SENDER"); _collectionManager.manageCollection(_forwarder, _collection, _data); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../interfaces/IForwarder.sol"; import "../interfaces/IERC20.sol"; import "../interfaces/IERC721CollectionV2.sol"; import "../interfaces/IERC721CollectionFactoryV2.sol"; import "../interfaces/IRarities.sol"; import "../commons/OwnableInitializable.sol"; import "../commons/NativeMetaTransaction.sol"; contract CollectionManager is OwnableInitializable, NativeMetaTransaction { using SafeMath for uint256; IERC20 public acceptedToken; IRarities public rarities; address public committee; address public feesCollector; uint256 public pricePerItem; mapping(bytes4 => bool) public allowedCommitteeMethods; event AcceptedTokenSet(IERC20 indexed _oldAcceptedToken, IERC20 indexed _newAcceptedToken); event CommitteeSet(address indexed _oldCommittee, address indexed _newCommittee); event CommitteeMethodSet(bytes4 indexed _method, bool _isAllowed); event FeesCollectorSet(address indexed _oldFeesCollector, address indexed _newFeesCollector); event RaritiesSet(IRarities indexed _oldRarities, IRarities indexed _newRarities); /** * @notice Create the contract * @param _owner - owner of the contract * @param _acceptedToken - accepted ERC20 token for collection deployment * @param _committee - committee contract * @param _feesCollector - fees collector * @param _rarities - rarities contract * @param _committeeMethods - method selectors * @param _committeeValues - whether the method is allowed or not */ constructor( address _owner, IERC20 _acceptedToken, address _committee, address _feesCollector, IRarities _rarities, bytes4[] memory _committeeMethods, bool[] memory _committeeValues ) { // EIP712 init _initializeEIP712('Decentraland Collection Manager', '1'); // Ownable init _initOwnable(); setAcceptedToken(_acceptedToken); // Committee setCommittee(_committee); setCommitteeMethods(_committeeMethods, _committeeValues); setFeesCollector(_feesCollector); setRarities(_rarities); transferOwnership(_owner); } /** * @notice Set the accepted token * @param _newAcceptedToken - accepted ERC20 token for collection deployment */ function setAcceptedToken(IERC20 _newAcceptedToken) onlyOwner public { require(address(_newAcceptedToken) != address(0), "CollectionManager#setAcceptedToken: INVALID_ACCEPTED_TOKEN"); emit AcceptedTokenSet(acceptedToken, _newAcceptedToken); acceptedToken = _newAcceptedToken; } /** * @notice Set the committee * @param _newCommittee - committee contract */ function setCommittee(address _newCommittee) onlyOwner public { require(_newCommittee != address(0), "CollectionManager#setCommittee: INVALID_COMMITTEE"); emit CommitteeSet(committee, _newCommittee); committee = _newCommittee; } /** * @notice Set methods to be allowed by the committee * @param _methods - method selectors * @param _values - whether the method is allowed or not */ function setCommitteeMethods(bytes4[] memory _methods, bool[] memory _values) onlyOwner public { uint256 length = _methods.length; require(length > 0 && length == _values.length, "CollectionManager#setCommitteeMethods: EMPTY_METHODS"); for (uint256 i = 0; i < length; i++) { bytes4 method = _methods[i]; bool value = _values[i]; allowedCommitteeMethods[method] = value; emit CommitteeMethodSet(method, value); } } /** * @notice Set the fees collector * @param _newFeesCollector - fees collector */ function setFeesCollector(address _newFeesCollector) onlyOwner public { require(_newFeesCollector != address(0), "CollectionManager#setFeesCollector: INVALID_FEES_COLLECTOR"); emit FeesCollectorSet(feesCollector, _newFeesCollector); feesCollector = _newFeesCollector; } /** * @notice Set the rarities * @param _newRarities - price per item */ function setRarities(IRarities _newRarities) onlyOwner public { require(address(_newRarities) != address(0), "CollectionManager#setRarities: INVALID_RARITIES"); emit RaritiesSet(rarities, _newRarities); rarities = _newRarities; } /** * @notice Create a collection * @param _forwarder - forwarder contract owner of the collection factory * @param _factory - collection factory * @param _salt - arbitrary 32 bytes hexa * @param _name - name of the contract * @param _symbol - symbol of the contract * @param _baseURI - base URI for token URIs * @param _creator - creator address * @param _items - items to be added */ function createCollection( IForwarder _forwarder, IERC721CollectionFactoryV2 _factory, bytes32 _salt, string memory _name, string memory _symbol, string memory _baseURI, address _creator, IERC721CollectionV2.ItemParam[] memory _items ) external { require(address(_forwarder) != address(this), "CollectionManager#createCollection: FORWARDER_CANT_BE_THIS"); uint256 amount = 0; for (uint256 i = 0; i < _items.length; i++) { IERC721CollectionV2.ItemParam memory item = _items[i]; IRarities.Rarity memory rarity = rarities.getRarityByName(item.rarity); amount = amount.add(rarity.price); } // Transfer fees to collector if (amount > 0) { require( acceptedToken.transferFrom(_msgSender(), feesCollector, amount), "CollectionManager#createCollection: TRANSFER_FEES_FAILED" ); } bytes memory data = abi.encodeWithSelector( IERC721CollectionV2.initialize.selector, _name, _symbol, _baseURI, _creator, true, // Collection should be completed false, // Collection should start disapproved rarities, _items ); (bool success,) = _forwarder.forwardCall(address(_factory), abi.encodeWithSelector(_factory.createCollection.selector, _salt, data)); require( success, "CollectionManager#createCollection: FORWARD_FAILED" ); } /** * @notice Manage a collection * @param _forwarder - forwarder contract owner of the collection factory * @param _collection - collection to be managed * @param _data - call data to be used */ function manageCollection(IForwarder _forwarder, IERC721CollectionV2 _collection, bytes calldata _data) external { require(address(_forwarder) != address(this), "CollectionManager#manageCollection: FORWARDER_CANT_BE_THIS"); require( _msgSender() == committee, "CollectionManager#manageCollection: UNAUTHORIZED_SENDER" ); (bytes4 method) = abi.decode(_data, (bytes4)); require(allowedCommitteeMethods[method], "CollectionManager#manageCollection: COMMITTEE_METHOD_NOT_ALLOWED"); bool success; bytes memory res; (success, res) = address(_collection).staticcall(abi.encodeWithSelector(_collection.COLLECTION_HASH.selector)); require( success && abi.decode(res, (bytes32)) == keccak256("Decentraland Collection"), "CollectionManager#manageCollection: INVALID_COLLECTION" ); (success,) = _forwarder.forwardCall(address(_collection), _data); require( success, "CollectionManager#manageCollection: FORWARD_FAILED" ); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; interface IForwarder { function forwardCall(address _address, bytes calldata _data) external returns (bool, bytes memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; interface IERC721CollectionFactoryV2 { function createCollection(bytes32 _salt, bytes memory _data) external returns (address addr); function transferOwnership(address newOwner) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; interface IRarities { struct Rarity { string name; uint256 maxSupply; uint256 price; } function getRarityByName(string calldata rarity) external view returns (Rarity memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; pragma experimental ABIEncoderV2; import "@openzeppelin/contracts/math/SafeMath.sol"; import "../../interfaces/IRarities.sol"; import "../../commons//OwnableInitializable.sol"; import "../../commons//NativeMetaTransaction.sol"; import "../../tokens/ERC721Initializable.sol"; import "../../libs/String.sol"; abstract contract ERC721BaseCollectionV2 is OwnableInitializable, ERC721Initializable, NativeMetaTransaction { using String for bytes32; using String for uint256; using String for address; using SafeMath for uint256; bytes32 constant public COLLECTION_HASH = keccak256("Decentraland Collection"); uint8 constant public ITEM_ID_BITS = 40; uint8 constant public ISSUED_ID_BITS = 216; uint40 constant public MAX_ITEM_ID = type(uint40).max; uint216 constant public MAX_ISSUED_ID = type(uint216).max; bytes32 constant internal EMPTY_CONTENT = bytes32(0); struct ItemParam { string rarity; uint256 price; address beneficiary; string metadata; } struct Item { string rarity; uint256 maxSupply; // max supply uint256 totalSupply; // current supply uint256 price; address beneficiary; string metadata; string contentHash; // used for safe purposes } IRarities public rarities; // Roles address public creator; mapping(address => bool) public globalMinters; mapping(address => bool) public globalManagers; mapping(uint256 => mapping (address => uint256)) public itemMinters; mapping(uint256 => mapping (address => bool)) public itemManagers; Item[] public items; // Status uint256 public createdAt; bool public isInitialized; bool public isCompleted; bool public isEditable; bool public isApproved; event BaseURI(string _oldBaseURI, string _newBaseURI); event SetGlobalMinter(address indexed _minter, bool _value); event SetGlobalManager(address indexed _manager, bool _value); event SetItemMinter(uint256 indexed _itemId, address indexed _minter, uint256 _value); event SetItemManager(uint256 indexed _itemId, address indexed _manager, bool _value); event AddItem(uint256 indexed _itemId, Item _item); event RescueItem(uint256 indexed _itemId, string _contentHash, string _metadata); event Issue(address indexed _beneficiary, uint256 indexed _tokenId, uint256 indexed _itemId, uint256 _issuedId, address _caller); event UpdateItemData(uint256 indexed _itemId, uint256 _price, address _beneficiary, string _metadata); event CreatorshipTransferred(address indexed _previousCreator, address indexed _newCreator); event SetApproved(bool _previousValue, bool _newValue); event SetEditable(bool _previousValue, bool _newValue); event Complete(); /* * Init functions */ /** * @notice Init the contract */ function initImplementation() public { require(!isInitialized, "initialize: ALREADY_INITIALIZED"); isInitialized = true; } /** * @notice Create the contract * @param _name - name of the contract * @param _symbol - symbol of the contract * @param _baseURI - base URI for token URIs * @param _creator - creator address * @param _shouldComplete - Whether the collection should be completed by the end of this call * @param _isApproved - Whether the collection should be approved by the end of this call * @param _rarities - rarities address * @param _items - items to be added */ function initialize( string memory _name, string memory _symbol, string memory _baseURI, address _creator, bool _shouldComplete, bool _isApproved, IRarities _rarities, ItemParam[] memory _items ) external virtual { initImplementation(); require(_creator != address(0), "initialize: INVALID_CREATOR"); require(address(_rarities) != address(0), "initialize: INVALID_RARITIES"); // Ownable init _initOwnable(); // EIP712 init _initializeEIP712('Decentraland Collection', '2'); // ERC721 init _initERC721(_name, _symbol); // Base URI init setBaseURI(_baseURI); // Creator init creator = _creator; // Rarities init rarities = _rarities; // Items init _addItems(_items); if (_shouldComplete) { _completeCollection(); } isApproved = _isApproved; isEditable = true; createdAt = block.timestamp; } /* * Roles checkers */ function _isCreator() internal view returns (bool) { return creator == _msgSender(); } function _isManager(uint256 _itemId) internal view returns (bool) { address sender = _msgSender(); return globalManagers[sender] || itemManagers[_itemId][sender]; } modifier onlyCreator() { require( _isCreator(), "onlyCreator: CALLER_IS_NOT_CREATOR" ); _; } /* * Role functions */ /** * @notice Set allowed account to manage items. * @param _minters - minter addresses * @param _values - values array */ function setMinters(address[] calldata _minters, bool[] calldata _values) external onlyCreator { require( _minters.length == _values.length, "setMinters: LENGTH_MISMATCH" ); for (uint256 i = 0; i < _minters.length; i++) { address minter = _minters[i]; bool value = _values[i]; require(minter != address(0), "setMinters: INVALID_MINTER_ADDRESS"); require(globalMinters[minter] != value, "setMinters: VALUE_IS_THE_SAME"); globalMinters[minter] = value; emit SetGlobalMinter(minter, value); } } /** * @notice Set allowed account to mint items. * @param _itemIds - item ids * @param _minters - minter addresses * @param _values - values array */ function setItemsMinters( uint256[] calldata _itemIds, address[] calldata _minters, uint256[] calldata _values ) external onlyCreator { require( _itemIds.length == _minters.length && _minters.length == _values.length, "setItemsMinters: LENGTH_MISMATCH" ); for (uint256 i = 0; i < _minters.length; i++) { address minter = _minters[i]; uint256 itemId = _itemIds[i]; uint256 value = _values[i]; require(minter != address(0), "setItemsMinters: INVALID_MINTER_ADDRESS"); require(itemId < items.length, "setItemsMinters: ITEM_DOES_NOT_EXIST"); require(itemMinters[itemId][minter] != value, "setItemsMinters: VALUE_IS_THE_SAME"); itemMinters[itemId][minter] = value; emit SetItemMinter(itemId, minter, value); } } /** * @notice Set allowed account to manage items. * @param _managers - Address allowed to manage items * @param _values - Whether is allowed or not */ function setManagers(address[] calldata _managers, bool[] calldata _values) external onlyCreator { require( _managers.length == _values.length, "setManagers: LENGTH_MISMATCH" ); for (uint256 i = 0; i < _managers.length; i++) { address manager = _managers[i]; bool value = _values[i]; require(manager != address(0), "setManagers: INVALID_MANAGER_ADDRESS"); require(globalManagers[manager] != value, "setManagers: VALUE_IS_THE_SAME"); globalManagers[manager] = value; emit SetGlobalManager(manager, value); } } /** * @notice Set allowed account to manage items. * @param _itemIds - item ids to set managers * @param _managers - Addresses allowed to manage items * @param _values - Whether is allowed or not */ function setItemsManagers( uint256[] calldata _itemIds, address[] calldata _managers, bool[] calldata _values ) external onlyCreator { require( _itemIds.length == _managers.length && _managers.length == _values.length, "setItemsManagers: LENGTH_MISMATCH" ); for (uint256 i = 0; i < _managers.length; i++) { address manager = _managers[i]; uint256 itemId = _itemIds[i]; bool value = _values[i]; require(manager != address(0), "setItemsManagers: INVALID_MANAGER_ADDRESS"); require(itemId < items.length, "setItemsManagers: ITEM_DOES_NOT_EXIST"); require(itemManagers[itemId][manager] != value, "setItemsManagers: VALUE_IS_THE_SAME"); itemManagers[itemId][manager] = value; emit SetItemManager(itemId, manager, value); } } /** * @notice Transfers ownership of the contract to a new account (`newOwner`). * @dev Forced owner to check against msg.sender always */ function transferCreatorship(address _newCreator) external virtual { address sender = _msgSender(); require(sender == owner() || sender == creator, "transferCreatorship: CALLER_IS_NOT_OWNER_OR_CREATOR"); require(_newCreator != address(0), "transferCreatorship: INVALID_CREATOR_ADDRESS"); emit CreatorshipTransferred(creator, _newCreator); creator = _newCreator; } /* * Items functions */ /** * @notice Add items to the collection. * @param _items - items to add */ function addItems(ItemParam[] memory _items) external virtual onlyOwner { require(!isCompleted, "_addItem: COLLECTION_COMPLETED"); _addItems(_items); } /** * @notice Edit items * @param _itemIds - items ids to edit * @param _prices - new prices * @param _beneficiaries - new beneficiaries */ function editItemsData( uint256[] calldata _itemIds, uint256[] calldata _prices, address[] calldata _beneficiaries, string[] calldata _metadatas ) external virtual { // Check lengths require( _itemIds.length == _prices.length && _prices.length == _beneficiaries.length && _beneficiaries.length == _metadatas.length, "editItemsData: LENGTH_MISMATCH" ); require( isEditable, "editItemsData: COLLECTION_NOT_EDITABLE" ); // Check item id for (uint256 i = 0; i < _itemIds.length; i++) { uint256 itemId = _itemIds[i]; uint256 price = _prices[i]; address beneficiary = _beneficiaries[i]; string memory metadata = _metadatas[i]; require(_isCreator() || _isManager(itemId), "editItemsData: CALLER_IS_NOT_CREATOR_OR_MANAGER"); require(itemId < items.length, "editItemsData: ITEM_DOES_NOT_EXIST"); require( price > 0 && beneficiary != address(0) || price == 0 && beneficiary == address(0), "editItemsData: INVALID_PRICE_AND_BENEFICIARY" ); require(bytes(metadata).length > 0, "editItemsData: EMPTY_METADATA"); Item storage item = items[itemId]; require( !isApproved || keccak256(abi.encode(item.metadata)) == keccak256(abi.encode(metadata)), "editItemsData: CAN_NOT_EDIT_METADATA" ); item.price = price; item.beneficiary = beneficiary; item.metadata = metadata; emit UpdateItemData(itemId, price, beneficiary, metadata); } } /** * @notice Add new items to the collection. * @dev The item should follow: * rarity: should be one of the RARITY enum * totalSupply: starts in 0 * metadata: shouldn't be empty * price & beneficiary: is the price is > 0, a beneficiary should be passed. If not, price and * beneficiary should be empty. * contentHash: starts empty * @param _items - items to add */ function _addItems(ItemParam[] memory _items) internal { require(_items.length > 0, "_addItems: EMPTY_ITEMS"); IRarities.Rarity memory rarity; bytes32 lastRarityKey; for (uint256 i = 0; i < _items.length; i++) { ItemParam memory _item = _items[i]; bytes32 rarityKey = keccak256(bytes(_item.rarity)); if (lastRarityKey != rarityKey) { rarity = rarities.getRarityByName(_item.rarity); lastRarityKey = rarityKey; require( rarity.maxSupply > 0 && rarity.maxSupply <= MAX_ISSUED_ID, "_addItem: INVALID_RARITY" ); } require(bytes(_item.metadata).length > 0, "_addItem: EMPTY_METADATA"); require( _item.price > 0 && _item.beneficiary != address(0) || _item.price == 0 && _item.beneficiary == address(0), "_addItem: INVALID_PRICE_AND_BENEFICIARY" ); uint256 newItemId = items.length; require(newItemId < MAX_ITEM_ID, "_addItem: MAX_ITEM_ID_REACHED"); Item memory item = Item({ rarity: rarity.name, maxSupply: rarity.maxSupply, totalSupply: 0, price: _item.price, beneficiary: _item.beneficiary, metadata: _item.metadata, contentHash: '' }); items.push(item); emit AddItem(newItemId, item); } } /** * @notice Issue tokens by item ids. * @dev Will throw if the items have reached its maximum or is invalid * @param _beneficiaries - owner of the tokens * @param _itemIds - item ids */ function issueTokens(address[] calldata _beneficiaries, uint256[] calldata _itemIds) external virtual { require(isMintingAllowed(), "issueTokens: MINT_NOT_ALLOWED"); require(_beneficiaries.length == _itemIds.length, "issueTokens: LENGTH_MISMATCH"); address sender = _msgSender(); for (uint256 i = 0; i < _itemIds.length; i++) { _issueToken(_beneficiaries[i], _itemIds[i], sender); } } /** * @notice Issue a new token of the specified item. * @dev Will throw if the item has reached its maximum or is invalid * @param _beneficiary - owner of the token * @param _itemId - item id * @param _sender - transaction sender */ function _issueToken(address _beneficiary, uint256 _itemId, address _sender) internal virtual { if (!(_isCreator() || globalMinters[_sender])) { uint256 allowance = itemMinters[_itemId][_sender]; require(allowance > 0, "_issueToken: CALLER_CAN_NOT_MINT"); if (allowance != type(uint256).max) { itemMinters[_itemId][_sender]--; } } // Check item id require(_itemId < items.length, "_issueToken: ITEM_DOES_NOT_EXIST"); Item storage item = items[_itemId]; uint256 currentIssuance = item.totalSupply.add(1); // Check issuance require(currentIssuance <= item.maxSupply, "_issueToken: ITEM_EXHAUSTED"); // Encode token id uint256 tokenId = encodeTokenId(_itemId, currentIssuance); // Increase issuance item.totalSupply = currentIssuance; // Mint token to beneficiary super._mint(_beneficiary, tokenId); // Log emit Issue(_beneficiary, tokenId, _itemId, currentIssuance, _sender); } /** * @notice Rescue an item by providing new metadata and/or content hash * @dev Only the owner can rescue an item. This function should be used * to resolve a dispute or fix a broken metadata or hashContent item * @param _itemIds - Item ids to be fixed * @param _contentHashes - New items content hash * @param _metadatas - New items metadata */ function rescueItems( uint256[] calldata _itemIds, string[] calldata _contentHashes, string[] calldata _metadatas ) external onlyOwner { // Check lengths require( _itemIds.length == _contentHashes.length && _contentHashes.length == _metadatas.length, "rescueItems: LENGTH_MISMATCH" ); for (uint256 i = 0; i < _itemIds.length; i++) { uint256 itemId = _itemIds[i]; require(itemId < items.length, "rescueItems: ITEM_DOES_NOT_EXIST"); Item storage item = items[itemId]; string memory contentHash = _contentHashes[i]; string memory metadata = _metadatas[i]; item.contentHash = contentHash; if (bytes(metadata).length > 0) { item.metadata = metadata; } emit RescueItem(itemId, contentHash, item.metadata); } } /** * @notice Returns the amount of item in the collection * @return Amount of items in the collection */ function itemsCount() external view returns (uint256) { return items.length; } /* * Status functions */ /** * @notice Get whether minting is allowed * @return boolean whether minting is allowed or not */ function isMintingAllowed() public view returns (bool) { return isCompleted && isApproved; } /** * @notice Complete the collection. * @dev Disable forever the possibility of adding new items in the collection. * The issuance is still allowed. */ function completeCollection() external onlyCreator { require(!isCompleted, "completeCollection: COLLECTION_ALREADY_COMPLETED"); _completeCollection(); } /** * @notice Complete the collection. * @dev Internal. Disable forever the possibility of adding new items in the collection. * The issuance is still allowed. */ function _completeCollection() internal { isCompleted = true; emit Complete(); } /** * @notice Approve a collection */ function setApproved(bool _value) external virtual onlyOwner { require(isApproved != _value, "setApproved: VALUE_IS_THE_SAME"); emit SetApproved(isApproved, _value); isApproved = _value; } /** * @notice Set whether the collection can be editable or not. * @dev This property is used off-chain to check whether the items of the collection * can be updated or not * @param _value - Value to set */ function setEditable(bool _value) external onlyOwner { require(isEditable != _value, "setEditable: VALUE_IS_THE_SAME"); emit SetEditable(isEditable, _value); isEditable = _value; } /* * URI functions */ /** * @notice Set Base URI * @param _baseURI - base URI for token URIs */ function setBaseURI(string memory _baseURI) public onlyOwner { emit BaseURI(baseURI(), _baseURI); _setBaseURI(_baseURI); } /** * @notice Returns an URI for a given token ID. * Throws if the token ID does not exist. May return an empty string. * @param _tokenId - uint256 ID of the token queried * @return token URI */ function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) { require(_exists(_tokenId), "tokenURI: INVALID_TOKEN_ID"); (uint256 itemId, uint256 issuedId) = decodeTokenId(_tokenId); uint256 id; assembly { id := chainid() } return string( abi.encodePacked( baseURI(), id.uintToString(), "/", "0x", address(this).addressToString(), "/", itemId.uintToString(), "/", issuedId.uintToString() ) ); } /* * Batch Transfer functions */ /** * @notice Transfers the ownership of given tokens ID to another address. * Usage of this method is discouraged, use {safeBatchTransferFrom} whenever possible. * Requires the msg.sender to be the owner, approved, or operator. * @param _from current owner of the token * @param _to address to receive the ownership of the given token ID * @param _tokenIds uint256 ID of the token to be transferred */ function batchTransferFrom(address _from, address _to, uint256[] calldata _tokenIds) external { for (uint256 i = 0; i < _tokenIds.length; i++) { transferFrom(_from, _to, _tokenIds[i]); } } /** * @notice Safely transfers the ownership of given token IDs to another address * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, * which is called upon a safe transfer, and return the magic value * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, * the transfer is reverted. * Requires the msg.sender to be the owner, approved, or operator * @param _from - current owner of the token * @param _to - address to receive the ownership of the given token ID * @param _tokenIds - uint256 ID of the tokens to be transferred * @param _data bytes data to send along with a safe transfer check */ function safeBatchTransferFrom(address _from, address _to, uint256[] memory _tokenIds, bytes memory _data) external { for (uint256 i = 0; i < _tokenIds.length; i++) { safeTransferFrom(_from, _to, _tokenIds[i], _data); } } /* * Token Utils functions */ /** * @notice Encode token id * @dev itemId (`itemIdBits` bits) + issuedId (`issuedIdBits` bits) * @param _itemId - item id * @param _issuedId - issued id * @return id uint256 of the encoded id */ function encodeTokenId(uint256 _itemId, uint256 _issuedId) public pure returns (uint256 id) { require(_itemId <= MAX_ITEM_ID, "encodeTokenId: INVALID_ITEM_ID"); require(_issuedId <= MAX_ISSUED_ID, "encodeTokenId: INVALID_ISSUED_ID"); // solium-disable-next-line security/no-inline-assembly assembly { id := or(shl(ISSUED_ID_BITS, _itemId), _issuedId) } } /** * @notice Decode token id * @dev itemId (`itemIdBits` bits) + issuedId (`issuedIdBits` bits) * @param _id - token id * @return itemId uint256 of the item id * @return issuedId uint256 of the issued id */ function decodeTokenId(uint256 _id) public pure returns (uint256 itemId, uint256 issuedId) { uint256 mask = MAX_ISSUED_ID; // solium-disable-next-line security/no-inline-assembly assembly { itemId := shr(ISSUED_ID_BITS, _id) issuedId := and(mask, _id) } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import "@openzeppelin/contracts/introspection/ERC165.sol"; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/EnumerableSet.sol"; import "@openzeppelin/contracts/utils/EnumerableMap.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "../commons/ContextMixin.sol"; /** * @title ERC721 Non-Fungible Token Standard basic implementation * This is the same contract at `openzeppelin/contracts 3.1.0` but `tokenURI` was changed to virtual override * @dev see https://eips.ethereum.org/EIPS/eip-721 */ abstract contract ERC721Initializable is ContextMixin, ERC165, IERC721, IERC721Metadata, IERC721Enumerable { using SafeMath for uint256; using Address for address; using EnumerableSet for EnumerableSet.UintSet; using EnumerableMap for EnumerableMap.UintToAddressMap; using Strings for uint256; // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // Mapping from holder address to their (enumerable) set of owned tokens mapping (address => EnumerableSet.UintSet) private _holderTokens; // Enumerable mapping from token ids to their owners EnumerableMap.UintToAddressMap private _tokenOwners; // Mapping from token ID to approved address mapping (uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping (address => mapping (address => bool)) private _operatorApprovals; // Token name string private _name; // Token symbol string private _symbol; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; // Base URI string private _baseURI; /* * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde * * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd */ bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; /* * bytes4(keccak256('name()')) == 0x06fdde03 * bytes4(keccak256('symbol()')) == 0x95d89b41 * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd * * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f */ bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; /* * bytes4(keccak256('totalSupply()')) == 0x18160ddd * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 * * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 */ bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; constructor() {} /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function _initERC721(string memory __name, string memory __symbol) internal { _name = __name; _symbol = __symbol; // register the supported interfaces to conform to ERC721 via ERC165 _registerInterface(_INTERFACE_ID_ERC721); _registerInterface(_INTERFACE_ID_ERC721_METADATA); _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _holderTokens[owner].length(); } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view override returns (address) { return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token"); } /** * @dev See {IERC721Metadata-name}. */ function name() public view override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory _tokenURI = _tokenURIs[tokenId]; // If there is no base URI, return the token URI. if (bytes(_baseURI).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(_baseURI, _tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(_baseURI, tokenId.toString())); } /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view returns (string memory) { return _baseURI; } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) { return _holderTokens[owner].at(index); } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view override returns (uint256) { // _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds return _tokenOwners.length(); } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view override returns (uint256) { (uint256 tokenId, ) = _tokenOwners.at(index); return tokenId; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { require(operator != _msgSender(), "ERC721: approve to caller"); _operatorApprovals[_msgSender()][operator] = approved; emit ApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mecanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view returns (bool) { return _tokenOwners.contains(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: d* * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual { _mint(to, tokenId); require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); // Clear metadata (if any) if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } _holderTokens[owner].remove(tokenId); _tokenOwners.remove(tokenId); emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal virtual { require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _holderTokens[from].remove(tokenId); _holderTokens[to].add(tokenId); _tokenOwners.set(tokenId, to); emit Transfer(from, to, tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) private returns (bool) { if (!to.isContract()) { return true; } bytes memory returndata = to.functionCall(abi.encodeWithSelector( IERC721Receiver(to).onERC721Received.selector, _msgSender(), from, tokenId, _data ), "ERC721: transfer to non ERC721Receiver implementer"); bytes4 retval = abi.decode(returndata, (bytes4)); return (retval == _ERC721_RECEIVED); } function _approve(address to, uint256 tokenId) private { _tokenApprovals[tokenId] = to; emit Approval(ownerOf(tokenId), to, tokenId); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` cannot be the zero address. * - `to` cannot be the zero address. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165 is IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; constructor () internal { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @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. * * ``` * 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. */ 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 of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @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._indexes[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 read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 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 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[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._indexes[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) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // 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); } // 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)))); } // 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 on 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)); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are * supported. */ library EnumerableMap { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct MapEntry { bytes32 _key; bytes32 _value; } struct Map { // Storage of map keys and values MapEntry[] _entries; // Position of the entry defined by a key in the `entries` array, plus 1 // because index 0 means a key is not in the map. mapping (bytes32 => uint256) _indexes; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) { // Equivalent to !contains(map, key) map._entries.push(MapEntry({ _key: key, _value: value })); // The entry is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value map._indexes[key] = map._entries.length; return true; } else { map._entries[keyIndex - 1]._value = value; return false; } } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function _remove(Map storage map, bytes32 key) private returns (bool) { // We read and store the key's index to prevent multiple reads from the same storage slot uint256 keyIndex = map._indexes[key]; if (keyIndex != 0) { // Equivalent to contains(map, key) // To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one // in the array, and then remove the last entry (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = keyIndex - 1; uint256 lastIndex = map._entries.length - 1; // When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. MapEntry storage lastEntry = map._entries[lastIndex]; // Move the last entry to the index where the entry to delete is map._entries[toDeleteIndex] = lastEntry; // Update the index for the moved entry map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved entry was stored map._entries.pop(); // Delete the index for the deleted slot delete map._indexes[key]; return true; } else { return false; } } /** * @dev Returns true if the key is in the map. O(1). */ function _contains(Map storage map, bytes32 key) private view returns (bool) { return map._indexes[key] != 0; } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function _length(Map storage map) private view returns (uint256) { return map._entries.length; } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) { require(map._entries.length > index, "EnumerableMap: index out of bounds"); MapEntry storage entry = map._entries[index]; return (entry._key, entry._value); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) { uint256 keyIndex = map._indexes[key]; if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key) return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function _get(Map storage map, bytes32 key) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } /** * @dev Same as {_get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {_tryGet}. */ function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) { uint256 keyIndex = map._indexes[key]; require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key) return map._entries[keyIndex - 1]._value; // All indexes are 1-based } // UintToAddressMap struct UintToAddressMap { Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return _remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return _contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return _length(map._inner); } /** * @dev Returns the element 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(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = _at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. * * _Available since v3.4._ */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = _tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) { return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage)))); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev String operations. */ library Strings { /** * @dev Converts a `uint256` to its ASCII `string` representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); uint256 index = digits - 1; temp = value; while (temp != 0) { buffer[index--] = bytes1(uint8(48 + temp % 10)); temp /= 10; } return string(buffer); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "@openzeppelin/contracts/utils/Address.sol"; contract MinimalProxyFactory { using Address for address; address public implementation; bytes public code; bytes32 public codeHash; event ProxyCreated(address indexed _address, bytes32 _salt); event ImplementationSet(address indexed _implementation, bytes32 _codeHash, bytes _code); /** * @notice Create the contract * @param _implementation - contract implementation */ constructor(address _implementation) { _setImplementation(_implementation); } /** * @notice Create a contract * @param _salt - arbitrary 32 bytes hexa * @param _data - call data used to call the contract already created if passed * @return addr - address of the contract created */ function _createProxy(bytes32 _salt, bytes memory _data) internal virtual returns (address addr) { bytes memory slotcode = code; bytes32 salt = keccak256(abi.encodePacked(_salt, msg.sender, _data)); // solium-disable-next-line security/no-inline-assembly assembly { addr := create2(0, add(slotcode, 0x20), mload(slotcode), salt) } require(addr != address(0), "MinimalProxyFactory#createProxy: CREATION_FAILED"); emit ProxyCreated(addr, _salt); if (_data.length > 0) { (bool success,) = addr.call(_data); require(success, "MinimalProxyFactory#createProxy: CALL_FAILED"); } } /** * @notice Get a deterministics contract address * @param _salt - arbitrary 32 bytes hexa * @param _address - supposed sender of the transaction * @return address of the deterministic contract */ function getAddress(bytes32 _salt, address _address, bytes calldata _data) external view returns (address) { return address( uint256( keccak256( abi.encodePacked( byte(0xff), address(this), keccak256(abi.encodePacked(_salt, _address, _data)), codeHash ) ) ) ); } /** * @notice Set the contract implementation * @param _implementation - contract implementation */ function _setImplementation(address _implementation) internal { require( _implementation != address(0) && _implementation.isContract(), "MinimalProxyFactoryV2#_setImplementation: INVALID_IMPLEMENTATION" ); // Adapted from https://github.com/optionality/clone-factory/blob/32782f82dfc5a00d103a7e61a17a5dedbd1e8e9d/contracts/CloneFactory.sol code = abi.encodePacked( hex"3d602d80600a3d3981f3363d3d373d3d3d363d73", _implementation, hex"5af43d82803e903d91602b57fd5bf3" ); codeHash = keccak256(code); implementation = _implementation; emit ImplementationSet(implementation, codeHash, code); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "@openzeppelin/contracts/access/Ownable.sol"; import "../../commons/MinimalProxyFactory.sol"; contract ERC721CollectionFactoryV2 is Ownable, MinimalProxyFactory { address[] public collections; mapping(address => bool) public isCollectionFromFactory; /** * @notice Create the contract * @param _owner - contract owner * @param _implementation - contract implementation */ constructor(address _owner, address _implementation) MinimalProxyFactory(_implementation) { transferOwnership(_owner); } /** * @notice Create a collection * @param _salt - arbitrary 32 bytes hexa * @param _data - call data used to call the contract already created if passed * @return addr - address of the contract created */ function createCollection(bytes32 _salt, bytes memory _data) external onlyOwner returns (address addr) { // Deploy a new collection addr = _createProxy(_salt, _data); // Transfer ownership to the owner after deployment Ownable(addr).transferOwnership(owner()); // Set variables for handle data faster // This use storage and therefore make deployments expensive. collections.push(addr); isCollectionFromFactory[addr] = true; } /** * @notice Get the amount of collections deployed * @return amount of collections deployed */ function collectionsSize() external view returns (uint256) { return collections.length; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () internal { address msgSender = _msgSender(); _owner = msgSender; emit OwnershipTransferred(address(0), msgSender); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN 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 payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @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, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.6; import "@openzeppelin/contracts/access/Ownable.sol"; contract Forwarder is Ownable { address public caller; event CallerSet(address indexed _oldCaller, address indexed _newCaller); /** * @notice Create the contract * @param _owner - contract owner * @param _caller - target address to call */ constructor(address _owner, address _caller) { setCaller(_caller); transferOwnership(_owner); } /** * @notice Set the caller allowed to forward calls * @param _newCaller - target address to call */ function setCaller(address _newCaller) public onlyOwner { emit CallerSet(caller, _newCaller); caller = _newCaller; } /** * @notice Forward a call * @param _target - target address to call * @param _data - call data to be used * @return whether the call was a success or not * @return response in bytes if any */ function forwardCall(address _target, bytes calldata _data) external payable returns (bool, bytes memory) { require( msg.sender == caller || msg.sender == owner(), "Owner#forwardCall: UNAUTHORIZED_SENDER" ); return _target.call{value: msg.value}(_data); } }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; import "../utils/Context.sol";
{ "optimizer": { "enabled": true, "runs": 1 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } } }
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"components":[{"internalType":"string","name":"rarity","type":"string"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"string","name":"metadata","type":"string"},{"internalType":"string","name":"contentHash","type":"string"}],"indexed":false,"internalType":"struct ERC721BaseCollectionV2.Item","name":"_item","type":"tuple"}],"name":"AddItem","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"_oldBaseURI","type":"string"},{"indexed":false,"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"BaseURI","type":"event"},{"anonymous":false,"inputs":[],"name":"Complete","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_previousCreator","type":"address"},{"indexed":true,"internalType":"address","name":"_newCreator","type":"address"}],"name":"CreatorshipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_issuedId","type":"uint256"},{"indexed":false,"internalType":"address","name":"_caller","type":"address"}],"name":"Issue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"userAddress","type":"address"},{"indexed":false,"internalType":"address","name":"relayerAddress","type":"address"},{"indexed":false,"internalType":"bytes","name":"functionSignature","type":"bytes"}],"name":"MetaTransactionExecuted","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":"uint256","name":"_itemId","type":"uint256"},{"indexed":false,"internalType":"string","name":"_contentHash","type":"string"},{"indexed":false,"internalType":"string","name":"_metadata","type":"string"}],"name":"RescueItem","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_previousValue","type":"bool"},{"indexed":false,"internalType":"bool","name":"_newValue","type":"bool"}],"name":"SetApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"_previousValue","type":"bool"},{"indexed":false,"internalType":"bool","name":"_newValue","type":"bool"}],"name":"SetEditable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_manager","type":"address"},{"indexed":false,"internalType":"bool","name":"_value","type":"bool"}],"name":"SetGlobalManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":false,"internalType":"bool","name":"_value","type":"bool"}],"name":"SetGlobalMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_manager","type":"address"},{"indexed":false,"internalType":"bool","name":"_value","type":"bool"}],"name":"SetItemManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_minter","type":"address"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"SetItemMinter","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_itemId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_price","type":"uint256"},{"indexed":false,"internalType":"address","name":"_beneficiary","type":"address"},{"indexed":false,"internalType":"string","name":"_metadata","type":"string"}],"name":"UpdateItemData","type":"event"},{"inputs":[],"name":"COLLECTION_HASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ISSUED_ID_BITS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ITEM_ID_BITS","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ISSUED_ID","outputs":[{"internalType":"uint216","name":"","type":"uint216"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_ITEM_ID","outputs":[{"internalType":"uint40","name":"","type":"uint40"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"string","name":"rarity","type":"string"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"string","name":"metadata","type":"string"}],"internalType":"struct ERC721BaseCollectionV2.ItemParam[]","name":"_items","type":"tuple[]"}],"name":"addItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"batchTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"completeCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"createdAt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"creator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"decodeTokenId","outputs":[{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"uint256","name":"issuedId","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"},{"internalType":"address[]","name":"_beneficiaries","type":"address[]"},{"internalType":"string[]","name":"_metadatas","type":"string[]"}],"name":"editItemsData","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_itemId","type":"uint256"},{"internalType":"uint256","name":"_issuedId","type":"uint256"}],"name":"encodeTokenId","outputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"userAddress","type":"address"},{"internalType":"bytes","name":"functionSignature","type":"bytes"},{"internalType":"bytes32","name":"sigR","type":"bytes32"},{"internalType":"bytes32","name":"sigS","type":"bytes32"},{"internalType":"uint8","name":"sigV","type":"uint8"}],"name":"executeMetaTransaction","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getNonce","outputs":[{"internalType":"uint256","name":"nonce","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"globalManagers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"globalMinters","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_baseURI","type":"string"},{"internalType":"address","name":"_creator","type":"address"},{"internalType":"bool","name":"_shouldComplete","type":"bool"},{"internalType":"bool","name":"_isApproved","type":"bool"},{"internalType":"contract IRarities","name":"_rarities","type":"address"},{"components":[{"internalType":"string","name":"rarity","type":"string"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"string","name":"metadata","type":"string"}],"internalType":"struct ERC721BaseCollectionV2.ItemParam[]","name":"_items","type":"tuple[]"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isEditable","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isMintingAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_beneficiaries","type":"address[]"},{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"}],"name":"issueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"itemManagers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"itemMinters","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"items","outputs":[{"internalType":"string","name":"rarity","type":"string"},{"internalType":"uint256","name":"maxSupply","type":"uint256"},{"internalType":"uint256","name":"totalSupply","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"string","name":"metadata","type":"string"},{"internalType":"string","name":"contentHash","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"itemsCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rarities","outputs":[{"internalType":"contract IRarities","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"string[]","name":"_contentHashes","type":"string[]"},{"internalType":"string[]","name":"_metadatas","type":"string[]"}],"name":"rescueItems","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","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":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_value","type":"bool"}],"name":"setApproved","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_value","type":"bool"}],"name":"setEditable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"address[]","name":"_managers","type":"address[]"},{"internalType":"bool[]","name":"_values","type":"bool[]"}],"name":"setItemsManagers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_itemIds","type":"uint256[]"},{"internalType":"address[]","name":"_minters","type":"address[]"},{"internalType":"uint256[]","name":"_values","type":"uint256[]"}],"name":"setItemsMinters","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_managers","type":"address[]"},{"internalType":"bool[]","name":"_values","type":"bool[]"}],"name":"setManagers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_minters","type":"address[]"},{"internalType":"bool[]","name":"_values","type":"bool[]"}],"name":"setMinters","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":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newCreator","type":"address"}],"name":"transferCreatorship","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
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.