Polygon Sponsored slots available. Book your slot here!
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 313,224 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Create Order Ite... | 66696142 | 5 mins ago | IN | 0 POL | 0.00524835 | ||||
Create Order Ite... | 66696108 | 7 mins ago | IN | 0 POL | 0.00539235 | ||||
Create Order Ite... | 66696081 | 7 mins ago | IN | 0 POL | 0.00539199 | ||||
Create Order Ite... | 66696009 | 10 mins ago | IN | 0 POL | 0.00524799 | ||||
Create Order Ite... | 66695952 | 12 mins ago | IN | 0 POL | 0.00524835 | ||||
Create Order Ite... | 66695891 | 14 mins ago | IN | 0 POL | 0.00539199 | ||||
Create Order Ite... | 66695827 | 16 mins ago | IN | 0 POL | 0.00524835 | ||||
Create Order Ite... | 66695743 | 19 mins ago | IN | 0 POL | 0.00524835 | ||||
Cancel Order Ite... | 66695728 | 20 mins ago | IN | 0 POL | 0.00190755 | ||||
Cancel Order Ite... | 66695720 | 20 mins ago | IN | 0 POL | 0.00190755 | ||||
Cancel Order Ite... | 66695713 | 21 mins ago | IN | 0 POL | 0.00190755 | ||||
Create Order Ite... | 66695679 | 22 mins ago | IN | 0 POL | 0.00539235 | ||||
Cancel Order Ite... | 66695665 | 22 mins ago | IN | 0 POL | 0.00190755 | ||||
Create Order Ite... | 66695645 | 23 mins ago | IN | 0 POL | 0.00539235 | ||||
Create Order Ite... | 66695621 | 24 mins ago | IN | 0 POL | 0.00524799 | ||||
Cancel Order Ite... | 66695565 | 26 mins ago | IN | 0 POL | 0.00231768 | ||||
Create Order Ite... | 66695546 | 26 mins ago | IN | 0 POL | 0.00539235 | ||||
Cancel Order Ite... | 66695382 | 33 mins ago | IN | 0 POL | 0.00231768 | ||||
Create Order Ite... | 66695365 | 33 mins ago | IN | 0 POL | 0.00524763 | ||||
Cancel Order Ite... | 66695332 | 35 mins ago | IN | 0 POL | 0.00231768 | ||||
Create Order Ite... | 66694805 | 55 mins ago | IN | 0 POL | 0.00524835 | ||||
Create Order Ite... | 66694609 | 1 hr ago | IN | 0 POL | 0.00524835 | ||||
Create Order Ite... | 66694595 | 1 hr ago | IN | 0 POL | 0.00524835 | ||||
Cancel Order Ite... | 66694572 | 1 hr ago | IN | 0 POL | 0.00231795 | ||||
Buy Item | 66693974 | 1 hr ago | IN | 0 POL | 0.00606996 |
Loading...
Loading
Contract Name:
GensoMarketERC1155
Compiler Version
v0.8.4+commit.c7e474f2
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol"; import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "./MarketStorage.sol"; import "./interface/IConsumptionItem.sol"; import "./common/TransferHelper.sol"; import "./common/AccessController.sol"; contract GensoMarketERC1155 is AccessController, ERC1155Holder, ReentrancyGuard, Pausable { using ECDSA for bytes32; using Counters for Counters.Counter; MarketStorage private _storageAddress; IERC1155[] private _erc1155Addresses; mapping(uint256 => uint256) private creatorFeeByNftType; mapping(uint256 => address) private creatorAddressByNftType; mapping(uint256 => address) private commissionAddressByNftType; mapping(uint256 => Counters.Counter) private _orderERC1155Ids; struct PriceByTimestamp { uint256 currentPrice; uint256 timestamp; } struct BuyItemInfo { uint256 nftId; uint256 ranking; uint256 sellOrder; uint256 amount; uint256 currencyType; string orderId; bytes signature; bytes nftSignature; address creator; } struct OrderERC1155 { uint256 id; uint256 itemId; address seller; uint256 ranking; uint256 amount; } mapping(uint256 => mapping(uint256 => OrderERC1155)) public sellOrderByNftTypeById; constructor(address _storage) { _storageAddress = MarketStorage(_storage); _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); } event Erc1155OrderCreated(uint256 orderId, uint256 nftId, uint256 price, address seller, uint256 nftType, uint256 quantity, uint256 timeStampm, uint256 currencyType, bool isExchangePrice); event Erc1155OrderFullfilled(uint256 orderId, uint256 nftId, uint256 price, address seller, uint256 quantity, uint256 currencyType, address buyer, uint256 nftType, uint256 transactionFee, uint256 timeStamp); event Erc1155OrderCancelled(uint256 orderId, uint256 nftId, address seller, uint256 nftType, uint256 quantity, uint256 timeStamp); function pause() external onlyAdmin { _pause(); } function unpause() external onlyAdmin { _unpause(); } function setErc1155Address(IERC1155[] calldata _addresses) external onlyAdmin { for(uint index = 0; index < _addresses.length; index++) { _erc1155Addresses.push(_addresses[index]); } } function reloadErc1155Address(IERC1155[] calldata _addresses) external onlyAdmin { for(uint index = 0; index < _addresses.length; index++) { _erc1155Addresses[index] = _addresses[index]; } } function setCreatorFeeByNftType(uint256[] calldata _nftTypes, uint256[] calldata _creatorFees, address[] calldata _creatorAddresses) external onlyAdmin { require(_nftTypes.length == _creatorFees.length && _nftTypes.length == _creatorAddresses.length, "Invalid Input: Array length mismatch"); for(uint256 index = 0; index < _nftTypes.length; index++){ require(_creatorFees[index] > 0 && _creatorAddresses[index] != address(0) , "Invalid input") ; creatorFeeByNftType[_nftTypes[index]] = _creatorFees[index]; creatorAddressByNftType[_nftTypes[index]] = _creatorAddresses[index]; } } function setCommissionByNftType(uint256[] calldata _nftTypes, address[] calldata _commissionAddresses) external onlyAdmin { require(_nftTypes.length == _commissionAddresses.length, "Invalid Input: Array length mismatch"); for(uint256 index = 0; index < _nftTypes.length; index++){ require(_commissionAddresses[index] != address(0) , "Invalid input") ; commissionAddressByNftType[_nftTypes[index]] = _commissionAddresses[index]; } } function createOrderItem( uint256 _nftId, uint256 _price, uint256 _amount, uint256 _currencyType, bool isExchangePrice, uint256 _nftType ) external nonReentrant whenNotPaused { MarketStorage.StorageInfor memory info = _storageAddress.getInfor(); require(_currencyType < info.countCurrency, "Invalid currency type"); require(_nftId > 0, "Token id must be greater than 0"); IERC1155 item = _erc1155Addresses[_nftType]; require(item.balanceOf(_msgSender(), _nftId) >= _amount, "NOT_ENOUGH_AMOUNT"); require(_storageAddress.isBlockAddress(_msgSender()) == false, "Address: Address can not impact it!"); require(_price > 0, "Order price must be greater than 0"); _orderERC1155Ids[_nftType].increment(); uint256 orderId = _orderERC1155Ids[_nftType].current(); sellOrderByNftTypeById[_nftType][orderId] = OrderERC1155({ id: orderId, itemId: _nftId, seller: _msgSender(), ranking: 0, amount: _amount }); _transferNFT(item, _nftId, _msgSender(), address(this), _amount); emit Erc1155OrderCreated(orderId, _nftId, _price, _msgSender(), _nftType, _amount, block.timestamp, _currencyType, isExchangePrice); } function buyItem( BuyItemInfo calldata buyInfo, uint256 _nftType, PriceByTimestamp calldata priceByTimestamp ) external nonReentrant whenNotPaused { require(buyInfo.nftId > 0, "Index must be greater than 0"); MarketStorage.StorageInfor memory info = _storageAddress.getInfor(); require(priceByTimestamp.timestamp + info.maxWaitingTime > block.timestamp, "EXCEED_WAITING_TIME"); require(_storageAddress.isExecutedOrder(buyInfo.orderId) == false, "ORDER_IS_EXECUTED"); require(_validatorSignature(buyInfo.ranking, buyInfo.amount, buyInfo.orderId, buyInfo.signature, _msgSender(), buyInfo.currencyType, priceByTimestamp.currentPrice, priceByTimestamp.timestamp, info.adminVerify), "INVALID_PARAM"); require(_validatorNftSignature(buyInfo.nftId, _nftType, buyInfo.sellOrder, buyInfo.creator, buyInfo.orderId, buyInfo.nftSignature, info.adminVerify), "INVALID_PARAM"); require(_storageAddress.isBlockAddress(_msgSender()) == false, "Address: Address can not impact it!"); address buyer = _msgSender(); _storageAddress.setExecutedOrder(buyInfo.orderId, true); OrderERC1155 memory order = sellOrderByNftTypeById[_nftType][buyInfo.sellOrder]; (address token, uint256 fees) = _storageAddress.getCurrencyExchangeAndFee(buyInfo.currencyType); require(order.id != 0 && order.itemId == buyInfo.nftId, "Order does not exist or invalid order"); require(buyInfo.ranking >= order.ranking, "Ranking: not enough!"); require(order.seller != address(0), "Invalid seller"); require(order.seller != buyer, "Buy by seller"); require(priceByTimestamp.currentPrice > 0, "Current price must be greater than 0"); TransferHelper.safeEnoughTokenApproved(token, _msgSender(), address(this), priceByTimestamp.currentPrice); sellOrderByNftTypeById[_nftType][buyInfo.sellOrder].id = 0; delete sellOrderByNftTypeById[_nftType][buyInfo.sellOrder]; _payment(_nftType, commissionAddressByNftType[_nftType], token, priceByTimestamp.currentPrice, buyer, order.seller, fees, buyInfo.creator); IERC1155 item = _erc1155Addresses[_nftType]; _transferNFT(item, buyInfo.nftId, address(this), buyer, buyInfo.amount); emit Erc1155OrderFullfilled(order.id, buyInfo.nftId, priceByTimestamp.currentPrice, order.seller, buyInfo.amount, buyInfo.currencyType, buyer, _nftType, fees, block.timestamp); } function cancelOrderItem(uint256 _nftId, uint256 _sellOrder, uint256 _nftType) external nonReentrant whenNotPaused { require(_nftId > 0, "Index must be greater than 0"); OrderERC1155 memory order = sellOrderByNftTypeById[_nftType][_sellOrder]; require(order.id != 0 && order.itemId == _nftId, "Order does not exist or invalid order"); require(order.seller == _msgSender(), "The sender must be the seller"); sellOrderByNftTypeById[_nftType][_sellOrder].id = 0; delete sellOrderByNftTypeById[_nftType][_sellOrder]; IERC1155 item = _erc1155Addresses[_nftType]; _transferNFT(item, _nftId, address(this), order.seller, order.amount); emit Erc1155OrderCancelled(order.id, _nftId, order.seller, _nftType, order.amount, block.timestamp); } function _payment( uint256 nftType, address receiveAddress, address currencyExchange, uint paymentValue, address sender, address seller, uint256 fees, address creator ) private { uint tax = paymentValue * fees / 1000; TransferHelper.safeTransferFrom(currencyExchange, sender, receiveAddress, tax); if(creatorFeeByNftType[nftType] != 0){ uint256 creatorFee = paymentValue * creatorFeeByNftType[nftType] / 1000; if(creator != address(0)){ TransferHelper.safeTransferFrom(currencyExchange, sender, creatorAddressByNftType[nftType], creatorFee / 2); TransferHelper.safeTransferFrom(currencyExchange, sender, creator, creatorFee / 2); TransferHelper.safeTransferFrom(currencyExchange, sender, seller, paymentValue - tax - creatorFee); } else { TransferHelper.safeTransferFrom(currencyExchange, sender, creatorAddressByNftType[nftType], creatorFee); TransferHelper.safeTransferFrom(currencyExchange, sender, seller, paymentValue - tax - creatorFee); } } else { TransferHelper.safeTransferFrom(currencyExchange, sender, seller, paymentValue - tax); } } function _transferNFT( IERC1155 item, uint256 nftId, address from, address to, uint256 _amount ) private { return item.safeTransferFrom(from, to, nftId, _amount, ""); } function _validatorSignature( uint256 _ranking, uint256 _amount, string calldata _orderId, bytes calldata signature, address _wallet, uint256 _currencyType, uint256 _price, uint256 timestamp, address verifyAddress ) private pure returns (bool) { bytes32 hashValue = keccak256(abi.encodePacked(_orderId, _ranking, _amount, _wallet, _price, _currencyType, timestamp)); address recover = hashValue.toEthSignedMessageHash().recover(signature); return recover == verifyAddress; } function _validatorNftSignature( uint256 _nftId, uint256 _nftType, uint256 _sellOrder, address _creator, string calldata _orderId, bytes calldata signature, address verifyAddress ) private pure returns (bool) { bytes32 hashValue = keccak256(abi.encodePacked(_orderId, _nftId, _nftType, _sellOrder, _creator)); address recover = hashValue.toEthSignedMessageHash().recover(signature); return recover == verifyAddress; } function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, ERC1155Receiver) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155 is IERC165 { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/utils/ERC1155Holder.sol) pragma solidity ^0.8.0; import "./ERC1155Receiver.sol"; /** * Simple implementation of `ERC1155Receiver` that will allow a contract to hold ERC1155 tokens. * * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be * stuck. * * @dev _Available since v3.1._ */ contract ERC1155Holder is ERC1155Receiver { function onERC1155Received( address, address, uint256, uint256, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155Received.selector; } function onERC1155BatchReceived( address, address, uint256[] memory, uint256[] memory, bytes memory ) public virtual override returns (bytes4) { return this.onERC1155BatchReceived.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../Strings.sol"; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library Counters { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "./nft/TicketItem.sol"; import "./IEnums.sol"; contract MarketStorage is AccessControl, ReentrancyGuard, Pausable { using Counters for Counters.Counter; using SafeERC20 for IERC20; using Address for address; using SafeMath for uint256; using ECDSA for bytes32; uint256 private _maxWaitingTime; address[] private _currencyExchanges; uint256[] private _feePerCurrency; address private _receiveAddress; bytes32 private constant OPERATOR = keccak256("OPERATOR"); bytes32 private constant MARKET = keccak256("MARKET"); bytes32 private constant USER_MANAGEMENT = keccak256("USER_MANAGEMENT"); address public adminVerify; mapping(address => bool) private _addressLocked; mapping(string => bool) private _executedOrderIds; mapping(uint256 => Counters.Counter) private _orderIds; mapping(IEnums.MarketType => mapping(uint256 => Counters.Counter)) private _orderERC1155Ids; IERC721[] private _nftAddress; address private _officalAddress; address private _commonItem; constructor() { _receiveAddress = msg.sender; adminVerify = msg.sender; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); _setupRole(USER_MANAGEMENT, msg.sender); } struct OrderItem { uint256 id; uint256 itemId; uint256 nftType; uint256 unitPrice; address seller; uint256 ranking; } struct OrderERC1155 { uint256 id; uint256 itemId; uint256 unitPrice; address seller; uint256 ranking; uint256 amount; } struct StorageInfor { uint256 countNft; address receiveAddress; uint256 maxWaitingTime; address adminVerify; address officalAddress; uint256 countCurrency; } mapping(uint256 => mapping(uint256 => OrderItem)) public orders; mapping(uint256 => mapping(uint256 => mapping(uint256 => OrderERC1155))) public orderERC1155; modifier onlyUserManagement() { require(hasRole(USER_MANAGEMENT, msg.sender), "Restricted to user management."); _; } modifier onlyOperator() { require(hasRole(OPERATOR, msg.sender), "Restricted to OPERATOR."); _; } modifier onlyAdmin() { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Restricted to admin."); _; } modifier onlyMarket() { require(hasRole(MARKET, msg.sender), "Restricted to market."); _; } function setCurrencyExchangesAndFee(address[] memory currencyExchanges, uint256[] memory feePerCurrency) external onlyAdmin { require(currencyExchanges.length == feePerCurrency.length, "Invalid input"); for(uint256 index =0; index < currencyExchanges.length; index++){ _currencyExchanges.push(currencyExchanges[index]); _feePerCurrency.push(feePerCurrency[index]); } } function reloadExchangesAndFee(address[] memory currencyExchanges, uint256[] memory feePerCurrency) external onlyAdmin { require(currencyExchanges.length > 0, "INVALD_WALLET"); require(_currencyExchanges.length >= currencyExchanges.length, "INVALD_PARAMS"); for(uint256 i = 0; i < currencyExchanges.length; i++) { _currencyExchanges[i] = currencyExchanges[i]; _feePerCurrency[i] = feePerCurrency[i]; } } function setNftAddress(IERC721[] memory nftAddresses) external onlyAdmin { for(uint index = 0;index < nftAddresses.length;index++) { _nftAddress.push(nftAddresses[index]); } } function reloadNftAddress(IERC721[] memory nftAddresses) external onlyAdmin { require(nftAddresses.length > 0, "INVALD_WALLET"); require(_nftAddress.length >= nftAddresses.length, "INVALD_PARAMS"); for(uint256 i = 0; i < nftAddresses.length; i++) { _nftAddress[i] = nftAddresses[i]; } } function setMaxWaitingTime(uint256 maxWaitingTime) external onlyAdmin { _maxWaitingTime = maxWaitingTime; } function setReceiveAddress(address receiveAddress) external onlyAdmin { _receiveAddress = receiveAddress; } function setAdminVerify(address admin) external onlyAdmin { adminVerify = admin; } function setOperator(address _operator) external onlyAdmin { _setupRole(OPERATOR, _operator); } function setUserManagement(address _user) external onlyAdmin { _setupRole(USER_MANAGEMENT, _user); } function setMarket(address _market) external onlyAdmin { _setupRole(MARKET, _market); } function setOfficalAddress(address _wallet) external onlyAdmin { _officalAddress = _wallet; } function setCommonItem(address _address) external onlyAdmin { _commonItem = _address; } function blockUser(address _addressBlock) external onlyUserManagement { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(USER_MANAGEMENT, msg.sender), "PERMISSION_DENIED"); require(_addressBlock != address(0), "INVALID_ADDRESS"); require(_addressLocked[_addressBlock] == false, "ADDRESS_LOCKED"); _addressLocked[_addressBlock] = true; } function unlockUser(address _addressBlock) external onlyUserManagement { require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(USER_MANAGEMENT, msg.sender), "PERMISSION_DENIED"); require(_addressBlock != address(0), "INVALID_ADDRESS"); require(_addressLocked[_addressBlock] == true, "ADDRESS_NOT_FOUND"); _addressLocked[_addressBlock] = false; delete _addressLocked[_addressBlock]; } function isBlockAddress(address userWallet) external view returns (bool) { return _addressLocked[userWallet]; } function createItemOrder( uint256 _nftId, uint256 _price, uint256 _nftType, address _seller ) external onlyMarket nonReentrant whenNotPaused returns (OrderItem memory) { OrderItem memory existedOrder = orders[_nftId][_nftType]; require(existedOrder.id == 0, "Sell order is already existed"); _orderIds[_nftType].increment(); uint256 orderId = _orderIds[_nftType].current(); orders[_nftId][_nftType] = OrderItem({ id: orderId, unitPrice: _price, nftType: _nftType, itemId: _nftId, seller: _seller, ranking: 0 }); return orders[_nftId][_nftType]; } function createOrderERC1155( uint256 _nftId, uint256 _price, uint256 _nftType, uint256 _amount, uint256 _ranking, address _seller, IEnums.MarketType _type ) external onlyMarket nonReentrant whenNotPaused returns (OrderERC1155 memory) { _orderERC1155Ids[_type][_nftType].increment(); uint256 orderId = _orderERC1155Ids[_type][_nftType].current(); orderERC1155[_nftType][orderId][_nftId] = OrderERC1155({ id: orderId, unitPrice: _price, itemId: _nftId, seller: _seller, ranking: _ranking, amount: _amount }); return orderERC1155[_nftType][orderId][_nftId]; } function deleteSellOrder(uint256 _nftId, uint256 _nftType) external onlyMarket { orders[_nftId][_nftType].id = 0; delete orders[_nftId][_nftType]; } function deleteSellOrderERC1155(uint256 _nftId, uint256 _nftType, uint256 _sellOrder) external onlyMarket { orderERC1155[_nftType][_sellOrder][_nftId].id = 0; delete orderERC1155[_nftType][_sellOrder][_nftId]; } function getNftAddress(uint256 _nftType) external onlyMarket view returns (IERC721) { return _nftAddress[_nftType]; } function getCurrencyExchangeAndFee(uint256 currencyType) external onlyMarket view returns (address, uint256) { return (_currencyExchanges[currencyType], _feePerCurrency[currencyType]); } function getCurrencyExchange(uint256 currencyType) external view returns (address) { return _currencyExchanges[currencyType]; } function isExecutedOrder(string memory _orderId) external onlyMarket view returns (bool) { return _executedOrderIds[_orderId]; } function getOrder(uint256 _nftId, uint256 _nftType) external onlyMarket view returns (OrderItem memory) { return orders[_nftId][_nftType]; } function getOrderERC1155(uint256 _nftType, uint256 _sellOrder, uint256 _nftId) external onlyMarket view returns (OrderERC1155 memory) { return orderERC1155[_nftType][_sellOrder][_nftId]; } function setExecutedOrder(string memory _orderId, bool _status) external onlyMarket { _executedOrderIds[_orderId] = _status; } function getInfor() external onlyMarket view returns (StorageInfor memory) { StorageInfor memory info = StorageInfor({ countNft: _nftAddress.length, receiveAddress: _receiveAddress, maxWaitingTime: _maxWaitingTime, adminVerify: adminVerify, officalAddress: _officalAddress, countCurrency: _currencyExchanges.length }); return info; } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; interface IConsumptionItem { function mintItem(uint256 _nftId, uint256 _amount, address _wallet, bool _isUGC) external; function burnItem(uint256 _nftId, uint256 _amount, address _wallet) external; function transfer(address _from, address _to, uint256 _nftId, uint256 amount) external; function getBalance(address _wallet, uint256 _nftId) external view returns (uint256); function getCreatorOfConsumption(uint256 _nftId) external view returns (address); }
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library TransferHelper { function safeApprove( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('approve(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeApprove: approve failed' ); } function safeTransfer( address token, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transfer(address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::safeTransfer: transfer failed' ); } function safeTransferFrom( address token, address from, address to, uint256 value ) internal { // bytes4(keccak256(bytes('transferFrom(address,address,uint256)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value)); require( success && (data.length == 0 || abi.decode(data, (bool))), 'TransferHelper::transferFrom: transferFrom failed' ); } function safeEnoughTokenApproved( address token, address owner, address spender, uint256 amount ) internal { // bytes4(keccak256(bytes('allowance(address,address)'))); (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xdd62ed3e, owner, spender)); require( success && (abi.decode(data, (uint256)) >= amount), "Exchange currency allowance of user is too low"); safeEnoughBalance(token, owner, amount); } function safeEnoughBalance( address token, address owner, uint256 amount ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x70a08231, owner)); require( success && (abi.decode(data, (uint256)) >= amount), "Exchange currency balance of user is too low"); } }
// SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/access/AccessControl.sol"; contract AccessController is AccessControl { bytes32 public constant OPERATOR = keccak256("OPERATOR"); modifier onlyAdmin() { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not the admin"); _; } modifier onlyOperator() { require(hasRole(OPERATOR, _msgSender()), "Caller is not the operator"); _; } modifier onlyOperatorOrAdmin() { require(hasRole(OPERATOR, _msgSender()) || hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller must be operator or admin"); _; } function addOperator(address operator) external onlyAdmin { _setupRole(OPERATOR, operator); } function removeOperator(address operator) external onlyAdmin { revokeRole(OPERATOR, operator); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/utils/ERC1155Receiver.sol) pragma solidity ^0.8.0; import "../IERC1155Receiver.sol"; import "../../../utils/introspection/ERC165.sol"; /** * @dev _Available since v3.1._ */ abstract contract ERC1155Receiver is ERC165, IERC1155Receiver { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155Receiver is IERC165 { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: 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 Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ 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) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the 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) { return a + b; } /** * @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) { 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) { return a * b; } /** * @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. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { 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) { 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) { unchecked { 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. * * 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) { unchecked { 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) { unchecked { require(b > 0, errorMessage); return a % b; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(uint160(account), 20), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.4; import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "../common/AccessController.sol"; contract TicketItem is ERC1155, AccessController { using ECDSA for bytes32; mapping(uint256 => uint256) public limitAmountByNftId; mapping(uint256 => uint256) public mintedAmountByNftId; uint256[] private _mintedAddress; string private baseUri; constructor(string memory _uri) ERC1155(_uri) { baseUri = _uri; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); } function setBaseUri(string calldata _baseUri) external onlyAdmin { baseUri = _baseUri; } function setLimitAmountByNftId(uint256[] calldata nftIds, uint256[] calldata limit) external onlyAdmin { require(nftIds.length == limit.length, "Invalid input"); for(uint256 index = 0; index < nftIds.length; index++){ limitAmountByNftId[nftIds[index]] = limit[index]; } } function mintItemFromMarket(uint256 _nftId, uint256 _amount, address _wallet) external onlyOperator { require(mintedAmountByNftId[_nftId] + _amount <= limitAmountByNftId[_nftId], "Exceed maximum item supply of nftId"); _mint(_wallet, _nftId, _amount, ""); mintedAmountByNftId[_nftId] += _amount; if (existedId(_nftId) != true) { _mintedAddress.push(_nftId); } } function existedId(uint256 _nftId) private view returns (bool) { bool isExisted = false; for (uint256 i = 0; i < _mintedAddress.length; i++) { if (_mintedAddress[i] == _nftId) { isExisted = true; } } return isExisted; } function burnItem(uint256 _nftId, uint256 _amount, address _wallet) external { require(hasRole(OPERATOR, _msgSender()) || hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "PERMISSION_DENIED"); _burn(_wallet, _nftId, _amount); } function uri(uint256 _tokenId) override public view returns (string memory) { return string( abi.encodePacked(baseUri, Strings.toString(_tokenId)) ); } function name() public pure returns(string memory) { return "GENSO.EC-Ticket"; } function getTokensOfUser(address _user) external view returns (uint256[] memory, uint256[] memory, string[] memory) { uint256 _counter; for (uint256 i = 0; i < _mintedAddress.length; i++) { if (balanceOf(_user, _mintedAddress[i]) != 0) { _counter++; } } uint256[] memory ticketIds = new uint256[](_counter); string[] memory metadata = new string[](_counter); uint256[] memory balances = new uint256[](_counter); uint256 index; for (uint256 i = 0; i < _mintedAddress.length; i++) { uint256 balance = balanceOf(_user, _mintedAddress[i]); if (balance != 0) { ticketIds[index] = _mintedAddress[i]; metadata[index] = uri(_mintedAddress[i]); balances[index] = balance; index++; } } return (ticketIds, balances, metadata); } function supportsInterface(bytes4 interfaceId) public view virtual override(AccessControl, ERC1155) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.4; interface IEnums { enum MarketType { Ticket, Consumption } enum GachaGacha { Normal, Rare } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155.sol"; import "./IERC1155Receiver.sol"; import "./extensions/IERC1155MetadataURI.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/introspection/ERC165.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155 is Context, ERC165, IERC1155, IERC1155MetadataURI { using Address for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ constructor(string memory uri_) { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC1155).interfaceId || interfaceId == type(IERC1155MetadataURI).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner nor approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155Receiver.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155Receiver(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155Receiver.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURI is IERC1155 { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_storage","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeStamp","type":"uint256"}],"name":"Erc1155OrderCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeStampm","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currencyType","type":"uint256"},{"indexed":false,"internalType":"bool","name":"isExchangePrice","type":"bool"}],"name":"Erc1155OrderCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"orderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"nftId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"uint256","name":"quantity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"currencyType","type":"uint256"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"nftType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"transactionFee","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timeStamp","type":"uint256"}],"name":"Erc1155OrderFullfilled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"addOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"uint256","name":"ranking","type":"uint256"},{"internalType":"uint256","name":"sellOrder","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"currencyType","type":"uint256"},{"internalType":"string","name":"orderId","type":"string"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"bytes","name":"nftSignature","type":"bytes"},{"internalType":"address","name":"creator","type":"address"}],"internalType":"struct GensoMarketERC1155.BuyItemInfo","name":"buyInfo","type":"tuple"},{"internalType":"uint256","name":"_nftType","type":"uint256"},{"components":[{"internalType":"uint256","name":"currentPrice","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"}],"internalType":"struct GensoMarketERC1155.PriceByTimestamp","name":"priceByTimestamp","type":"tuple"}],"name":"buyItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftId","type":"uint256"},{"internalType":"uint256","name":"_sellOrder","type":"uint256"},{"internalType":"uint256","name":"_nftType","type":"uint256"}],"name":"cancelOrderItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_nftId","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_currencyType","type":"uint256"},{"internalType":"bool","name":"isExchangePrice","type":"bool"},{"internalType":"uint256","name":"_nftType","type":"uint256"}],"name":"createOrderItem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155BatchReceived","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC1155Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC1155[]","name":"_addresses","type":"address[]"}],"name":"reloadErc1155Address","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"removeOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"sellOrderByNftTypeById","outputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"uint256","name":"itemId","type":"uint256"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint256","name":"ranking","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nftTypes","type":"uint256[]"},{"internalType":"address[]","name":"_commissionAddresses","type":"address[]"}],"name":"setCommissionByNftType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_nftTypes","type":"uint256[]"},{"internalType":"uint256[]","name":"_creatorFees","type":"uint256[]"},{"internalType":"address[]","name":"_creatorAddresses","type":"address[]"}],"name":"setCreatorFeeByNftType","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC1155[]","name":"_addresses","type":"address[]"}],"name":"setErc1155Address","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":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b50604051620035b5380380620035b5833981016040819052620000349162000122565b60018055600280546001600160a81b0319166101006001600160a01b038416021790556200006b6000620000653390565b62000072565b5062000152565b6200007e828262000082565b5050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff166200007e576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620000de3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006020828403121562000134578081fd5b81516001600160a01b03811681146200014b578182fd5b9392505050565b61345380620001626000396000f3fe608060405234801561001057600080fd5b506004361061014d5760003560e01c80637e5c67b7116100c3578063a217fddf1161007c578063a217fddf14610335578063ac8a584a1461033d578063bc197c8114610350578063d4dfc39714610388578063d547741f1461039b578063f23a6e61146103ae57600080fd5b80637e5c67b7146102ba5780638456cb59146102cd57806391d14854146102d5578063983d2737146102e85780639870d7fe1461030f578063a0c5a5d11461032257600080fd5b806336568abe1161011557806336568abe146101e65780633f4ba83a146101f9578063486c392e1461020157806353c188d9146102145780635c7754301461029c5780635c975abb146102af57600080fd5b806301ffc9a714610152578063118347b41461017a5780631c2421061461018f578063248a9ca3146101a25780632f2ff15d146101d3575b600080fd5b610165610160366004612dcd565b6103cd565b60405190151581526020015b60405180910390f35b61018d610188366004612f22565b6103de565b005b61018d61019d366004612c2e565b610654565b6101c56101b0366004612d86565b60009081526020819052604090206001015490565b604051908152602001610171565b61018d6101e1366004612d9e565b610706565b61018d6101f4366004612d9e565b61072b565b61018d6107a9565b61018d61020f366004612f4d565b6107da565b610266610222366004612f01565b600860209081526000928352604080842090915290825290208054600182015460028301546003840154600490940154929391926001600160a01b03909116919085565b6040805195865260208601949094526001600160a01b03909216928401929092526060830191909152608082015260a001610171565b61018d6102aa366004612c6d565b610c5f565b60025460ff16610165565b61018d6102c8366004612c2e565b610dda565b61018d610e9d565b6101656102e3366004612d9e565b610ecc565b6101c57f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c81565b61018d61031d366004612ad6565b610ef5565b61018d610330366004612cd5565b610f49565b6101c5600081565b61018d61034b366004612ad6565b611167565b61036f61035e366004612af2565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610171565b61018d610396366004612df5565b6111b8565b61018d6103a9366004612d9e565b611a34565b61036f6103bc366004612b9b565b63f23a6e6160e01b95945050505050565b60006103d882611a59565b92915050565b6002600154141561040a5760405162461bcd60e51b81526004016104019061320e565b60405180910390fd5b6002600155610417611a7e565b600083116104675760405162461bcd60e51b815260206004820152601c60248201527f496e646578206d7573742062652067726561746572207468616e2030000000006044820152606401610401565b6000818152600860209081526040808320858452825291829020825160a081018452815480825260018301549382019390935260028201546001600160a01b03169381019390935260038101546060840152600401546080830152158015906104d35750838160200151145b6104ef5760405162461bcd60e51b815260040161040190613245565b60408101516001600160a01b0316331461054b5760405162461bcd60e51b815260206004820152601d60248201527f5468652073656e646572206d757374206265207468652073656c6c65720000006044820152606401610401565b60008281526008602090815260408083208684529091528120818155600181018290556002810180546001600160a01b0319169055600380820183905560049091018290558054849081106105b057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031690506105e581863085604001518660800151611ac4565b81516040808401516080808601518351948552602085018a90526001600160a01b0390921684840152606084018790528301524260a0830152517f0be8c31a9e720626c8176335c47ba8e29b25b89a16fa05579c0634a3e40da2829181900360c00190a1505060018055505050565b61065f600033610ecc565b61067b5760405162461bcd60e51b815260040161040190613193565b60005b818110156107015760038383838181106106a857634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106bd9190612ad6565b81546001810183556000928352602090922090910180546001600160a01b0319166001600160a01b03909216919091179055806106f9816133b3565b91505061067e565b505050565b60008281526020819052604090206001015461072181611b4a565b6107018383611b54565b6001600160a01b038116331461079b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610401565b6107a58282611bd8565b5050565b6107b4600033610ecc565b6107d05760405162461bcd60e51b815260040161040190613193565b6107d8611c3d565b565b600260015414156107fd5760405162461bcd60e51b81526004016104019061320e565b600260015561080a611a7e565b6000600260019054906101000a90046001600160a01b03166001600160a01b031663f2b677fe6040518163ffffffff1660e01b815260040160c06040518083038186803b15801561085a57600080fd5b505afa15801561086e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108929190612e59565b90508060a0015184106108df5760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642063757272656e6379207479706560581b6044820152606401610401565b6000871161092f5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e206964206d7573742062652067726561746572207468616e2030006044820152606401610401565b60006003838154811061095257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03169050858162fdd58e336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018c905260440160206040518083038186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ee9190612ee9565b1015610a305760405162461bcd60e51b81526020600482015260116024820152701393d517d15393d551d217d05353d55395607a1b6044820152606401610401565b60025461010090046001600160a01b031663e75658fb336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015610a8657600080fd5b505afa158015610a9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abe9190612d6a565b15610adb5760405162461bcd60e51b815260040161040190613150565b60008711610b365760405162461bcd60e51b815260206004820152602260248201527f4f72646572207072696365206d7573742062652067726561746572207468616e604482015261020360f41b6064820152608401610401565b600083815260076020908152604091829020805460010190819055825160a0810184528181529182018b9052918101336001600160a01b0390811682526000602080840182905260409384018c90528882526008815283822086835281529083902084518155908401516001820155918301516002830180546001600160a01b0319169190921617905560608201516003820155608090910151600490910155610be3828a33308b611ac4565b60408051828152602081018b90529081018990523360608201526080810185905260a081018890524260c082015260e081018790528515156101008201527fe8f357d3ae630dbaac7ab7d145cd0249a27a8303ebfdff2c08212f31155879d690610120015b60405180910390a150506001805550505050505050565b610c6a600033610ecc565b610c865760405162461bcd60e51b815260040161040190613193565b828114610ca55760405162461bcd60e51b8152600401610401906131ca565b60005b83811015610dd3576000838383818110610cd257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610ce79190612ad6565b6001600160a01b03161415610d2e5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610401565b828282818110610d4e57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d639190612ad6565b60066000878785818110610d8757634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080610dcb906133b3565b915050610ca8565b5050505050565b610de5600033610ecc565b610e015760405162461bcd60e51b815260040161040190613193565b60005b8181101561070157828282818110610e2c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610e419190612ad6565b60038281548110610e6257634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905580610e95816133b3565b915050610e04565b610ea8600033610ecc565b610ec45760405162461bcd60e51b815260040161040190613193565b6107d8611c8f565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610f00600033610ecc565b610f1c5760405162461bcd60e51b815260040161040190613193565b610f467f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c82611ccc565b50565b610f54600033610ecc565b610f705760405162461bcd60e51b815260040161040190613193565b8483148015610f7e57508481145b610f9a5760405162461bcd60e51b8152600401610401906131ca565b60005b8581101561115e576000858583818110610fc757634e487b7160e01b600052603260045260246000fd5b9050602002013511801561101957506000838383818110610ff857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061100d9190612ad6565b6001600160a01b031614155b6110555760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610401565b84848281811061107557634e487b7160e01b600052603260045260246000fd5b90506020020135600460008989858181106110a057634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020819055508282828181106110d957634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110ee9190612ad6565b6005600089898581811061111257634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080611156906133b3565b915050610f9d565b50505050505050565b611172600033610ecc565b61118e5760405162461bcd60e51b815260040161040190613193565b610f467f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c82611a34565b600260015414156111db5760405162461bcd60e51b81526004016104019061320e565b60026001556111e8611a7e565b82356112365760405162461bcd60e51b815260206004820152601c60248201527f496e646578206d7573742062652067726561746572207468616e2030000000006044820152606401610401565b6000600260019054906101000a90046001600160a01b03166001600160a01b031663f2b677fe6040518163ffffffff1660e01b815260040160c06040518083038186803b15801561128657600080fd5b505afa15801561129a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112be9190612e59565b905042816040015183602001356112d591906132fe565b116113185760405162461bcd60e51b81526020600482015260136024820152724558434545445f57414954494e475f54494d4560681b6044820152606401610401565b60025461010090046001600160a01b031663a58394f861133b60a087018761328a565b6040518363ffffffff1660e01b81526004016113589291906130db565b60206040518083038186803b15801561137057600080fd5b505afa158015611384573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a89190612d6a565b156113e95760405162461bcd60e51b815260206004820152601160248201527013d491115497d254d7d1561150d5551151607a1b6044820152606401610401565b61142a6020850135606086013561140360a088018861328a565b61141060c08a018a61328a565b338b608001358a600001358b602001358b60600151611cd6565b6114665760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f504152414d60981b6044820152606401610401565b6114a7843584604087013561148361012089016101008a01612ad6565b61149060a08a018a61328a565b61149d60e08c018c61328a565b8960600151611d7f565b6114e35760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f504152414d60981b6044820152606401610401565b60025461010090046001600160a01b031663e75658fb336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561153957600080fd5b505afa15801561154d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115719190612d6a565b1561158e5760405162461bcd60e51b815260040161040190613150565b600254339061010090046001600160a01b0316631652fc0f6115b360a088018861328a565b60016040518463ffffffff1660e01b81526004016115d3939291906130f7565b600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505060008581526008602090815260408083208982013584528252808320815160a081018352815481526001820154938101939093526002808201546001600160a01b03908116858501526003830154606086015260049283015460808087019190915291549351635f56302b60e11b81529496508594610100909404169263beac605692611699928d0135910190815260200190565b604080518083038186803b1580156116b057600080fd5b505afa1580156116c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e89190612c01565b8451919350915015801590611701575060208301518835145b61171d5760405162461bcd60e51b815260040161040190613245565b82606001518860200135101561176c5760405162461bcd60e51b815260206004820152601460248201527352616e6b696e673a206e6f7420656e6f7567682160601b6044820152606401610401565b60408301516001600160a01b03166117b75760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b63632b960911b6044820152606401610401565b836001600160a01b031683604001516001600160a01b0316141561180d5760405162461bcd60e51b815260206004820152600d60248201526c213abc90313c9039b2b63632b960991b6044820152606401610401565b85356118675760405162461bcd60e51b8152602060048201526024808201527f43757272656e74207072696365206d75737420626520677265617465722074686044820152630616e20360e41b6064820152608401610401565b6118748233308935611e1c565b60006008600089815260200190815260200160002060008a604001358152602001908152602001600020600001819055506008600088815260200190815260200160002060008960400135815260200190815260200160002060008082016000905560018201600090556002820160006101000a8154906001600160a01b03021916905560038201600090556004820160009055505061195b87600660008a815260200190815260200160002060009054906101000a90046001600160a01b0316848960000135888860400151878f6101000160208101906119569190612ad6565b611f59565b60006003888154811061197e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031690506119a7818a35308860608e0135611ac4565b835160408086015181519283528b3560208401528935918301919091526001600160a01b039081166060838101919091528b01356080838101919091528b013560a0830152861660c082015260e081018990526101008101839052426101208201527ff64794059de89314ca2ceed4975b06846c466f7f363efeb5559bc29807ad95159061014001610c48565b600082815260208190526040902060010154611a4f81611b4a565b6107018383611bd8565b60006001600160e01b03198216630271189760e51b14806103d857506103d88261207a565b60025460ff16156107d85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610401565b604051637921219560e11b81526001600160a01b0384811660048301528381166024830152604482018690526064820183905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b158015611b2b57600080fd5b505af1158015611b3f573d6000803e3d6000fd5b505050505050505050565b610f4681336120af565b611b5e8282610ecc565b6107a5576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055611b943390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611be28282610ecc565b156107a5576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b611c45612113565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b611c97611a7e565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611c723390565b6107a58282611b54565b6000808a8a8e8e8a898b8a604051602001611cf8989796959493929190612fe6565b6040516020818303038152906040528051906020012090506000611d5d8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d57925086915061215c9050565b906121af565b6001600160a01b0390811690851614925050509b9a5050505050505050505050565b60008086868c8c8c8c604051602001611d9d9695949392919061302c565b6040516020818303038152906040528051906020012090506000611dfc86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d57925086915061215c9050565b6001600160a01b0390811690851614925050509998505050505050505050565b604080516001600160a01b03858116602483015284811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b1790529151600092839290881691611e7c9190612fca565b6000604051808303816000865af19150503d8060008114611eb9576040519150601f19603f3d011682016040523d82523d6000602084013e611ebe565b606091505b5091509150818015611ee357508281806020019051810190611ee09190612ee9565b10155b611f465760405162461bcd60e51b815260206004820152602e60248201527f45786368616e67652063757272656e637920616c6c6f77616e6365206f66207560448201526d73657220697320746f6f206c6f7760901b6064820152608401610401565b611f518686856121d3565b505050505050565b60006103e8611f688488613336565b611f729190613316565b9050611f8087868a846122f3565b6000898152600460205260409020541561206a576000898152600460205260408120546103e890611fb19089613336565b611fbb9190613316565b90506001600160a01b0383161561202d5760008a815260056020526040902054611ffc90899088906001600160a01b0316611ff7600286613316565b6122f3565b61200d888785611ff7600286613316565b6120288887878461201e878d613355565b611ff79190613355565b612064565b60008a81526005602052604090205461205390899088906001600160a01b0316846122f3565b6120648887878461201e878d613355565b50611b3f565b611b3f878686611ff7858b613355565b60006001600160e01b03198216637965db0b60e01b14806103d857506301ffc9a760e01b6001600160e01b03198316146103d8565b6120b98282610ecc565b6107a5576120d1816001600160a01b03166014612429565b6120dc836020612429565b6040516020016120ed929190613066565b60408051601f198184030181529082905262461bcd60e51b82526104019160040161311d565b60025460ff166107d85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610401565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b60008060006121be8585612611565b915091506121cb81612681565b509392505050565b604080516001600160a01b0384811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b179052915160009283929087169161222b9190612fca565b6000604051808303816000865af19150503d8060008114612268576040519150601f19603f3d011682016040523d82523d6000602084013e61226d565b606091505b50915091508180156122925750828180602001905181019061228f9190612ee9565b10155b610dd35760405162461bcd60e51b815260206004820152602c60248201527f45786368616e67652063757272656e63792062616c616e6365206f662075736560448201526b7220697320746f6f206c6f7760a01b6064820152608401610401565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916123579190612fca565b6000604051808303816000865af19150503d8060008114612394576040519150601f19603f3d011682016040523d82523d6000602084013e612399565b606091505b50915091508180156123c35750805115806123c35750808060200190518101906123c39190612d6a565b611f515760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610401565b60606000612438836002613336565b6124439060026132fe565b6001600160401b0381111561246857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612492576020820181803683370190505b509050600360fc1b816000815181106124bb57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106124f857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061251c846002613336565b6125279060016132fe565b90505b60018111156125bb576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256957634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061258d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936125b48161339c565b905061252a565b50831561260a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610401565b9392505050565b6000808251604114156126485760208301516040840151606085015160001a61263c87828585612882565b9450945050505061267a565b825160401415612672576020830151604084015161266786838361296f565b93509350505061267a565b506000905060025b9250929050565b60008160048111156126a357634e487b7160e01b600052602160045260246000fd5b14156126ac5750565b60018160048111156126ce57634e487b7160e01b600052602160045260246000fd5b141561271c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610401565b600281600481111561273e57634e487b7160e01b600052602160045260246000fd5b141561278c5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610401565b60038160048111156127ae57634e487b7160e01b600052602160045260246000fd5b14156128075760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610401565b600481600481111561282957634e487b7160e01b600052602160045260246000fd5b1415610f465760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610401565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156128b95750600090506003612966565b8460ff16601b141580156128d157508460ff16601c14155b156128e25750600090506004612966565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612936573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661295f57600060019250925050612966565b9150600090505b94509492505050565b6000806001600160ff1b0383168161298c60ff86901c601b6132fe565b905061299a87828885612882565b935093505050935093915050565b60008083601f8401126129b9578182fd5b5081356001600160401b038111156129cf578182fd5b6020830191508360208260051b850101111561267a57600080fd5b600082601f8301126129fa578081fd5b813560206001600160401b03821115612a1557612a156133e4565b8160051b612a248282016132ce565b838152828101908684018388018501891015612a3e578687fd5b8693505b85841015612a60578035835260019390930192918401918401612a42565b50979650505050505050565b600082601f830112612a7c578081fd5b81356001600160401b03811115612a9557612a956133e4565b612aa8601f8201601f19166020016132ce565b818152846020838601011115612abc578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612ae7578081fd5b813561260a816133fa565b600080600080600060a08688031215612b09578081fd5b8535612b14816133fa565b94506020860135612b24816133fa565b935060408601356001600160401b0380821115612b3f578283fd5b612b4b89838a016129ea565b94506060880135915080821115612b60578283fd5b612b6c89838a016129ea565b93506080880135915080821115612b81578283fd5b50612b8e88828901612a6c565b9150509295509295909350565b600080600080600060a08688031215612bb2578081fd5b8535612bbd816133fa565b94506020860135612bcd816133fa565b9350604086013592506060860135915060808601356001600160401b03811115612bf5578182fd5b612b8e88828901612a6c565b60008060408385031215612c13578182fd5b8251612c1e816133fa565b6020939093015192949293505050565b60008060208385031215612c40578182fd5b82356001600160401b03811115612c55578283fd5b612c61858286016129a8565b90969095509350505050565b60008060008060408587031215612c82578182fd5b84356001600160401b0380821115612c98578384fd5b612ca4888389016129a8565b90965094506020870135915080821115612cbc578384fd5b50612cc9878288016129a8565b95989497509550505050565b60008060008060008060608789031215612ced578384fd5b86356001600160401b0380821115612d03578586fd5b612d0f8a838b016129a8565b90985096506020890135915080821115612d27578586fd5b612d338a838b016129a8565b90965094506040890135915080821115612d4b578283fd5b50612d5889828a016129a8565b979a9699509497509295939492505050565b600060208284031215612d7b578081fd5b815161260a8161340f565b600060208284031215612d97578081fd5b5035919050565b60008060408385031215612db0578182fd5b823591506020830135612dc2816133fa565b809150509250929050565b600060208284031215612dde578081fd5b81356001600160e01b03198116811461260a578182fd5b60008060008385036080811215612e0a578182fd5b84356001600160401b03811115612e1f578283fd5b85016101208188031215612e31578283fd5b9350602085013592506040603f1982011215612e4b578182fd5b506040840190509250925092565b600060c08284031215612e6a578081fd5b60405160c081018181106001600160401b0382111715612e8c57612e8c6133e4565b604052825181526020830151612ea1816133fa565b6020820152604083810151908201526060830151612ebe816133fa565b60608201526080830151612ed1816133fa565b608082015260a0928301519281019290925250919050565b600060208284031215612efa578081fd5b5051919050565b60008060408385031215612f13578182fd5b50508035926020909101359150565b600080600060608486031215612f36578081fd5b505081359360208301359350604090920135919050565b60008060008060008060c08789031215612f65578384fd5b863595506020870135945060408701359350606087013592506080870135612f8c8161340f565b8092505060a087013590509295509295509295565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008251612fdc81846020870161336c565b9190910192915050565b87898237909601948552602085019390935260609190911b6bffffffffffffffffffffffff1916604084015260548301526074820152609481019190915260b401919050565b8587823790940192835260208301919091526040820152606091821b6bffffffffffffffffffffffff191691810191909152607401919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161309e81601785016020880161336c565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516130cf81602884016020880161336c565b01602801949350505050565b6020815260006130ef602083018486612fa1565b949350505050565b60408152600061310b604083018587612fa1565b90508215156020830152949350505050565b602081526000825180602084015261313c81604085016020870161336c565b601f01601f19169190910160400192915050565b60208082526023908201527f416464726573733a20416464726573732063616e206e6f7420696d706163742060408201526269742160e81b606082015260800190565b60208082526017908201527f43616c6c6572206973206e6f74207468652061646d696e000000000000000000604082015260600190565b60208082526024908201527f496e76616c696420496e7075743a204172726179206c656e677468206d69736d6040820152630c2e8c6d60e31b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526025908201527f4f7264657220646f6573206e6f74206578697374206f7220696e76616c69642060408201526437b93232b960d91b606082015260800190565b6000808335601e198436030181126132a0578283fd5b8301803591506001600160401b038211156132b9578283fd5b60200191503681900382131561267a57600080fd5b604051601f8201601f191681016001600160401b03811182821017156132f6576132f66133e4565b604052919050565b60008219821115613311576133116133ce565b500190565b60008261333157634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613350576133506133ce565b500290565b600082821015613367576133676133ce565b500390565b60005b8381101561338757818101518382015260200161336f565b83811115613396576000848401525b50505050565b6000816133ab576133ab6133ce565b506000190190565b60006000198214156133c7576133c76133ce565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f4657600080fd5b8015158114610f4657600080fdfea2646970667358221220e004f2493ee62af0c5a4fe5bd55f3069b600e27579f08e322ae3567636eb00c564736f6c634300080400330000000000000000000000004b4151c1e9ecfb837695623fe7fc7a7c5f62a9bc
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061014d5760003560e01c80637e5c67b7116100c3578063a217fddf1161007c578063a217fddf14610335578063ac8a584a1461033d578063bc197c8114610350578063d4dfc39714610388578063d547741f1461039b578063f23a6e61146103ae57600080fd5b80637e5c67b7146102ba5780638456cb59146102cd57806391d14854146102d5578063983d2737146102e85780639870d7fe1461030f578063a0c5a5d11461032257600080fd5b806336568abe1161011557806336568abe146101e65780633f4ba83a146101f9578063486c392e1461020157806353c188d9146102145780635c7754301461029c5780635c975abb146102af57600080fd5b806301ffc9a714610152578063118347b41461017a5780631c2421061461018f578063248a9ca3146101a25780632f2ff15d146101d3575b600080fd5b610165610160366004612dcd565b6103cd565b60405190151581526020015b60405180910390f35b61018d610188366004612f22565b6103de565b005b61018d61019d366004612c2e565b610654565b6101c56101b0366004612d86565b60009081526020819052604090206001015490565b604051908152602001610171565b61018d6101e1366004612d9e565b610706565b61018d6101f4366004612d9e565b61072b565b61018d6107a9565b61018d61020f366004612f4d565b6107da565b610266610222366004612f01565b600860209081526000928352604080842090915290825290208054600182015460028301546003840154600490940154929391926001600160a01b03909116919085565b6040805195865260208601949094526001600160a01b03909216928401929092526060830191909152608082015260a001610171565b61018d6102aa366004612c6d565b610c5f565b60025460ff16610165565b61018d6102c8366004612c2e565b610dda565b61018d610e9d565b6101656102e3366004612d9e565b610ecc565b6101c57f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c81565b61018d61031d366004612ad6565b610ef5565b61018d610330366004612cd5565b610f49565b6101c5600081565b61018d61034b366004612ad6565b611167565b61036f61035e366004612af2565b63bc197c8160e01b95945050505050565b6040516001600160e01b03199091168152602001610171565b61018d610396366004612df5565b6111b8565b61018d6103a9366004612d9e565b611a34565b61036f6103bc366004612b9b565b63f23a6e6160e01b95945050505050565b60006103d882611a59565b92915050565b6002600154141561040a5760405162461bcd60e51b81526004016104019061320e565b60405180910390fd5b6002600155610417611a7e565b600083116104675760405162461bcd60e51b815260206004820152601c60248201527f496e646578206d7573742062652067726561746572207468616e2030000000006044820152606401610401565b6000818152600860209081526040808320858452825291829020825160a081018452815480825260018301549382019390935260028201546001600160a01b03169381019390935260038101546060840152600401546080830152158015906104d35750838160200151145b6104ef5760405162461bcd60e51b815260040161040190613245565b60408101516001600160a01b0316331461054b5760405162461bcd60e51b815260206004820152601d60248201527f5468652073656e646572206d757374206265207468652073656c6c65720000006044820152606401610401565b60008281526008602090815260408083208684529091528120818155600181018290556002810180546001600160a01b0319169055600380820183905560049091018290558054849081106105b057634e487b7160e01b600052603260045260246000fd5b9060005260206000200160009054906101000a90046001600160a01b031690506105e581863085604001518660800151611ac4565b81516040808401516080808601518351948552602085018a90526001600160a01b0390921684840152606084018790528301524260a0830152517f0be8c31a9e720626c8176335c47ba8e29b25b89a16fa05579c0634a3e40da2829181900360c00190a1505060018055505050565b61065f600033610ecc565b61067b5760405162461bcd60e51b815260040161040190613193565b60005b818110156107015760038383838181106106a857634e487b7160e01b600052603260045260246000fd5b90506020020160208101906106bd9190612ad6565b81546001810183556000928352602090922090910180546001600160a01b0319166001600160a01b03909216919091179055806106f9816133b3565b91505061067e565b505050565b60008281526020819052604090206001015461072181611b4a565b6107018383611b54565b6001600160a01b038116331461079b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610401565b6107a58282611bd8565b5050565b6107b4600033610ecc565b6107d05760405162461bcd60e51b815260040161040190613193565b6107d8611c3d565b565b600260015414156107fd5760405162461bcd60e51b81526004016104019061320e565b600260015561080a611a7e565b6000600260019054906101000a90046001600160a01b03166001600160a01b031663f2b677fe6040518163ffffffff1660e01b815260040160c06040518083038186803b15801561085a57600080fd5b505afa15801561086e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108929190612e59565b90508060a0015184106108df5760405162461bcd60e51b8152602060048201526015602482015274496e76616c69642063757272656e6379207479706560581b6044820152606401610401565b6000871161092f5760405162461bcd60e51b815260206004820152601f60248201527f546f6b656e206964206d7573742062652067726561746572207468616e2030006044820152606401610401565b60006003838154811061095257634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b03169050858162fdd58e336040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602481018c905260440160206040518083038186803b1580156109b657600080fd5b505afa1580156109ca573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109ee9190612ee9565b1015610a305760405162461bcd60e51b81526020600482015260116024820152701393d517d15393d551d217d05353d55395607a1b6044820152606401610401565b60025461010090046001600160a01b031663e75658fb336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b158015610a8657600080fd5b505afa158015610a9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610abe9190612d6a565b15610adb5760405162461bcd60e51b815260040161040190613150565b60008711610b365760405162461bcd60e51b815260206004820152602260248201527f4f72646572207072696365206d7573742062652067726561746572207468616e604482015261020360f41b6064820152608401610401565b600083815260076020908152604091829020805460010190819055825160a0810184528181529182018b9052918101336001600160a01b0390811682526000602080840182905260409384018c90528882526008815283822086835281529083902084518155908401516001820155918301516002830180546001600160a01b0319169190921617905560608201516003820155608090910151600490910155610be3828a33308b611ac4565b60408051828152602081018b90529081018990523360608201526080810185905260a081018890524260c082015260e081018790528515156101008201527fe8f357d3ae630dbaac7ab7d145cd0249a27a8303ebfdff2c08212f31155879d690610120015b60405180910390a150506001805550505050505050565b610c6a600033610ecc565b610c865760405162461bcd60e51b815260040161040190613193565b828114610ca55760405162461bcd60e51b8152600401610401906131ca565b60005b83811015610dd3576000838383818110610cd257634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610ce79190612ad6565b6001600160a01b03161415610d2e5760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610401565b828282818110610d4e57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d639190612ad6565b60066000878785818110610d8757634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080610dcb906133b3565b915050610ca8565b5050505050565b610de5600033610ecc565b610e015760405162461bcd60e51b815260040161040190613193565b60005b8181101561070157828282818110610e2c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610e419190612ad6565b60038281548110610e6257634e487b7160e01b600052603260045260246000fd5b600091825260209091200180546001600160a01b0319166001600160a01b039290921691909117905580610e95816133b3565b915050610e04565b610ea8600033610ecc565b610ec45760405162461bcd60e51b815260040161040190613193565b6107d8611c8f565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b610f00600033610ecc565b610f1c5760405162461bcd60e51b815260040161040190613193565b610f467f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c82611ccc565b50565b610f54600033610ecc565b610f705760405162461bcd60e51b815260040161040190613193565b8483148015610f7e57508481145b610f9a5760405162461bcd60e51b8152600401610401906131ca565b60005b8581101561115e576000858583818110610fc757634e487b7160e01b600052603260045260246000fd5b9050602002013511801561101957506000838383818110610ff857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061100d9190612ad6565b6001600160a01b031614155b6110555760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a59081a5b9c1d5d609a1b6044820152606401610401565b84848281811061107557634e487b7160e01b600052603260045260246000fd5b90506020020135600460008989858181106110a057634e487b7160e01b600052603260045260246000fd5b905060200201358152602001908152602001600020819055508282828181106110d957634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110ee9190612ad6565b6005600089898581811061111257634e487b7160e01b600052603260045260246000fd5b90506020020135815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b031602179055508080611156906133b3565b915050610f9d565b50505050505050565b611172600033610ecc565b61118e5760405162461bcd60e51b815260040161040190613193565b610f467f523a704056dcd17bcf83bed8b68c59416dac1119be77755efe3bde0a64e46e0c82611a34565b600260015414156111db5760405162461bcd60e51b81526004016104019061320e565b60026001556111e8611a7e565b82356112365760405162461bcd60e51b815260206004820152601c60248201527f496e646578206d7573742062652067726561746572207468616e2030000000006044820152606401610401565b6000600260019054906101000a90046001600160a01b03166001600160a01b031663f2b677fe6040518163ffffffff1660e01b815260040160c06040518083038186803b15801561128657600080fd5b505afa15801561129a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112be9190612e59565b905042816040015183602001356112d591906132fe565b116113185760405162461bcd60e51b81526020600482015260136024820152724558434545445f57414954494e475f54494d4560681b6044820152606401610401565b60025461010090046001600160a01b031663a58394f861133b60a087018761328a565b6040518363ffffffff1660e01b81526004016113589291906130db565b60206040518083038186803b15801561137057600080fd5b505afa158015611384573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113a89190612d6a565b156113e95760405162461bcd60e51b815260206004820152601160248201527013d491115497d254d7d1561150d5551151607a1b6044820152606401610401565b61142a6020850135606086013561140360a088018861328a565b61141060c08a018a61328a565b338b608001358a600001358b602001358b60600151611cd6565b6114665760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f504152414d60981b6044820152606401610401565b6114a7843584604087013561148361012089016101008a01612ad6565b61149060a08a018a61328a565b61149d60e08c018c61328a565b8960600151611d7f565b6114e35760405162461bcd60e51b815260206004820152600d60248201526c494e56414c49445f504152414d60981b6044820152606401610401565b60025461010090046001600160a01b031663e75658fb336040516001600160e01b031960e084901b1681526001600160a01b03909116600482015260240160206040518083038186803b15801561153957600080fd5b505afa15801561154d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115719190612d6a565b1561158e5760405162461bcd60e51b815260040161040190613150565b600254339061010090046001600160a01b0316631652fc0f6115b360a088018861328a565b60016040518463ffffffff1660e01b81526004016115d3939291906130f7565b600060405180830381600087803b1580156115ed57600080fd5b505af1158015611601573d6000803e3d6000fd5b50505060008581526008602090815260408083208982013584528252808320815160a081018352815481526001820154938101939093526002808201546001600160a01b03908116858501526003830154606086015260049283015460808087019190915291549351635f56302b60e11b81529496508594610100909404169263beac605692611699928d0135910190815260200190565b604080518083038186803b1580156116b057600080fd5b505afa1580156116c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e89190612c01565b8451919350915015801590611701575060208301518835145b61171d5760405162461bcd60e51b815260040161040190613245565b82606001518860200135101561176c5760405162461bcd60e51b815260206004820152601460248201527352616e6b696e673a206e6f7420656e6f7567682160601b6044820152606401610401565b60408301516001600160a01b03166117b75760405162461bcd60e51b815260206004820152600e60248201526d24b73b30b634b21039b2b63632b960911b6044820152606401610401565b836001600160a01b031683604001516001600160a01b0316141561180d5760405162461bcd60e51b815260206004820152600d60248201526c213abc90313c9039b2b63632b960991b6044820152606401610401565b85356118675760405162461bcd60e51b8152602060048201526024808201527f43757272656e74207072696365206d75737420626520677265617465722074686044820152630616e20360e41b6064820152608401610401565b6118748233308935611e1c565b60006008600089815260200190815260200160002060008a604001358152602001908152602001600020600001819055506008600088815260200190815260200160002060008960400135815260200190815260200160002060008082016000905560018201600090556002820160006101000a8154906001600160a01b03021916905560038201600090556004820160009055505061195b87600660008a815260200190815260200160002060009054906101000a90046001600160a01b0316848960000135888860400151878f6101000160208101906119569190612ad6565b611f59565b60006003888154811061197e57634e487b7160e01b600052603260045260246000fd5b6000918252602090912001546001600160a01b031690506119a7818a35308860608e0135611ac4565b835160408086015181519283528b3560208401528935918301919091526001600160a01b039081166060838101919091528b01356080838101919091528b013560a0830152861660c082015260e081018990526101008101839052426101208201527ff64794059de89314ca2ceed4975b06846c466f7f363efeb5559bc29807ad95159061014001610c48565b600082815260208190526040902060010154611a4f81611b4a565b6107018383611bd8565b60006001600160e01b03198216630271189760e51b14806103d857506103d88261207a565b60025460ff16156107d85760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610401565b604051637921219560e11b81526001600160a01b0384811660048301528381166024830152604482018690526064820183905260a06084830152600060a483015286169063f242432a9060c401600060405180830381600087803b158015611b2b57600080fd5b505af1158015611b3f573d6000803e3d6000fd5b505050505050505050565b610f4681336120af565b611b5e8282610ecc565b6107a5576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055611b943390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b611be28282610ecc565b156107a5576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b611c45612113565b6002805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b611c97611a7e565b6002805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258611c723390565b6107a58282611b54565b6000808a8a8e8e8a898b8a604051602001611cf8989796959493929190612fe6565b6040516020818303038152906040528051906020012090506000611d5d8a8a8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d57925086915061215c9050565b906121af565b6001600160a01b0390811690851614925050509b9a5050505050505050505050565b60008086868c8c8c8c604051602001611d9d9695949392919061302c565b6040516020818303038152906040528051906020012090506000611dfc86868080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250611d57925086915061215c9050565b6001600160a01b0390811690851614925050509998505050505050505050565b604080516001600160a01b03858116602483015284811660448084019190915283518084039091018152606490920183526020820180516001600160e01b0316636eb1769f60e11b1790529151600092839290881691611e7c9190612fca565b6000604051808303816000865af19150503d8060008114611eb9576040519150601f19603f3d011682016040523d82523d6000602084013e611ebe565b606091505b5091509150818015611ee357508281806020019051810190611ee09190612ee9565b10155b611f465760405162461bcd60e51b815260206004820152602e60248201527f45786368616e67652063757272656e637920616c6c6f77616e6365206f66207560448201526d73657220697320746f6f206c6f7760901b6064820152608401610401565b611f518686856121d3565b505050505050565b60006103e8611f688488613336565b611f729190613316565b9050611f8087868a846122f3565b6000898152600460205260409020541561206a576000898152600460205260408120546103e890611fb19089613336565b611fbb9190613316565b90506001600160a01b0383161561202d5760008a815260056020526040902054611ffc90899088906001600160a01b0316611ff7600286613316565b6122f3565b61200d888785611ff7600286613316565b6120288887878461201e878d613355565b611ff79190613355565b612064565b60008a81526005602052604090205461205390899088906001600160a01b0316846122f3565b6120648887878461201e878d613355565b50611b3f565b611b3f878686611ff7858b613355565b60006001600160e01b03198216637965db0b60e01b14806103d857506301ffc9a760e01b6001600160e01b03198316146103d8565b6120b98282610ecc565b6107a5576120d1816001600160a01b03166014612429565b6120dc836020612429565b6040516020016120ed929190613066565b60408051601f198184030181529082905262461bcd60e51b82526104019160040161311d565b60025460ff166107d85760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610401565b6040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b60008060006121be8585612611565b915091506121cb81612681565b509392505050565b604080516001600160a01b0384811660248084019190915283518084039091018152604490920183526020820180516001600160e01b03166370a0823160e01b179052915160009283929087169161222b9190612fca565b6000604051808303816000865af19150503d8060008114612268576040519150601f19603f3d011682016040523d82523d6000602084013e61226d565b606091505b50915091508180156122925750828180602001905181019061228f9190612ee9565b10155b610dd35760405162461bcd60e51b815260206004820152602c60248201527f45786368616e67652063757272656e63792062616c616e6365206f662075736560448201526b7220697320746f6f206c6f7760a01b6064820152608401610401565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17905291516000928392908816916123579190612fca565b6000604051808303816000865af19150503d8060008114612394576040519150601f19603f3d011682016040523d82523d6000602084013e612399565b606091505b50915091508180156123c35750805115806123c35750808060200190518101906123c39190612d6a565b611f515760405162461bcd60e51b815260206004820152603160248201527f5472616e7366657248656c7065723a3a7472616e7366657246726f6d3a207472604482015270185b9cd9995c919c9bdb4819985a5b1959607a1b6064820152608401610401565b60606000612438836002613336565b6124439060026132fe565b6001600160401b0381111561246857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612492576020820181803683370190505b509050600360fc1b816000815181106124bb57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106124f857634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061251c846002613336565b6125279060016132fe565b90505b60018111156125bb576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061256957634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061258d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936125b48161339c565b905061252a565b50831561260a5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610401565b9392505050565b6000808251604114156126485760208301516040840151606085015160001a61263c87828585612882565b9450945050505061267a565b825160401415612672576020830151604084015161266786838361296f565b93509350505061267a565b506000905060025b9250929050565b60008160048111156126a357634e487b7160e01b600052602160045260246000fd5b14156126ac5750565b60018160048111156126ce57634e487b7160e01b600052602160045260246000fd5b141561271c5760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610401565b600281600481111561273e57634e487b7160e01b600052602160045260246000fd5b141561278c5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610401565b60038160048111156127ae57634e487b7160e01b600052602160045260246000fd5b14156128075760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610401565b600481600481111561282957634e487b7160e01b600052602160045260246000fd5b1415610f465760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610401565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156128b95750600090506003612966565b8460ff16601b141580156128d157508460ff16601c14155b156128e25750600090506004612966565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612936573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661295f57600060019250925050612966565b9150600090505b94509492505050565b6000806001600160ff1b0383168161298c60ff86901c601b6132fe565b905061299a87828885612882565b935093505050935093915050565b60008083601f8401126129b9578182fd5b5081356001600160401b038111156129cf578182fd5b6020830191508360208260051b850101111561267a57600080fd5b600082601f8301126129fa578081fd5b813560206001600160401b03821115612a1557612a156133e4565b8160051b612a248282016132ce565b838152828101908684018388018501891015612a3e578687fd5b8693505b85841015612a60578035835260019390930192918401918401612a42565b50979650505050505050565b600082601f830112612a7c578081fd5b81356001600160401b03811115612a9557612a956133e4565b612aa8601f8201601f19166020016132ce565b818152846020838601011115612abc578283fd5b816020850160208301379081016020019190915292915050565b600060208284031215612ae7578081fd5b813561260a816133fa565b600080600080600060a08688031215612b09578081fd5b8535612b14816133fa565b94506020860135612b24816133fa565b935060408601356001600160401b0380821115612b3f578283fd5b612b4b89838a016129ea565b94506060880135915080821115612b60578283fd5b612b6c89838a016129ea565b93506080880135915080821115612b81578283fd5b50612b8e88828901612a6c565b9150509295509295909350565b600080600080600060a08688031215612bb2578081fd5b8535612bbd816133fa565b94506020860135612bcd816133fa565b9350604086013592506060860135915060808601356001600160401b03811115612bf5578182fd5b612b8e88828901612a6c565b60008060408385031215612c13578182fd5b8251612c1e816133fa565b6020939093015192949293505050565b60008060208385031215612c40578182fd5b82356001600160401b03811115612c55578283fd5b612c61858286016129a8565b90969095509350505050565b60008060008060408587031215612c82578182fd5b84356001600160401b0380821115612c98578384fd5b612ca4888389016129a8565b90965094506020870135915080821115612cbc578384fd5b50612cc9878288016129a8565b95989497509550505050565b60008060008060008060608789031215612ced578384fd5b86356001600160401b0380821115612d03578586fd5b612d0f8a838b016129a8565b90985096506020890135915080821115612d27578586fd5b612d338a838b016129a8565b90965094506040890135915080821115612d4b578283fd5b50612d5889828a016129a8565b979a9699509497509295939492505050565b600060208284031215612d7b578081fd5b815161260a8161340f565b600060208284031215612d97578081fd5b5035919050565b60008060408385031215612db0578182fd5b823591506020830135612dc2816133fa565b809150509250929050565b600060208284031215612dde578081fd5b81356001600160e01b03198116811461260a578182fd5b60008060008385036080811215612e0a578182fd5b84356001600160401b03811115612e1f578283fd5b85016101208188031215612e31578283fd5b9350602085013592506040603f1982011215612e4b578182fd5b506040840190509250925092565b600060c08284031215612e6a578081fd5b60405160c081018181106001600160401b0382111715612e8c57612e8c6133e4565b604052825181526020830151612ea1816133fa565b6020820152604083810151908201526060830151612ebe816133fa565b60608201526080830151612ed1816133fa565b608082015260a0928301519281019290925250919050565b600060208284031215612efa578081fd5b5051919050565b60008060408385031215612f13578182fd5b50508035926020909101359150565b600080600060608486031215612f36578081fd5b505081359360208301359350604090920135919050565b60008060008060008060c08789031215612f65578384fd5b863595506020870135945060408701359350606087013592506080870135612f8c8161340f565b8092505060a087013590509295509295509295565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60008251612fdc81846020870161336c565b9190910192915050565b87898237909601948552602085019390935260609190911b6bffffffffffffffffffffffff1916604084015260548301526074820152609481019190915260b401919050565b8587823790940192835260208301919091526040820152606091821b6bffffffffffffffffffffffff191691810191909152607401919050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161309e81601785016020880161336c565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516130cf81602884016020880161336c565b01602801949350505050565b6020815260006130ef602083018486612fa1565b949350505050565b60408152600061310b604083018587612fa1565b90508215156020830152949350505050565b602081526000825180602084015261313c81604085016020870161336c565b601f01601f19169190910160400192915050565b60208082526023908201527f416464726573733a20416464726573732063616e206e6f7420696d706163742060408201526269742160e81b606082015260800190565b60208082526017908201527f43616c6c6572206973206e6f74207468652061646d696e000000000000000000604082015260600190565b60208082526024908201527f496e76616c696420496e7075743a204172726179206c656e677468206d69736d6040820152630c2e8c6d60e31b606082015260800190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60208082526025908201527f4f7264657220646f6573206e6f74206578697374206f7220696e76616c69642060408201526437b93232b960d91b606082015260800190565b6000808335601e198436030181126132a0578283fd5b8301803591506001600160401b038211156132b9578283fd5b60200191503681900382131561267a57600080fd5b604051601f8201601f191681016001600160401b03811182821017156132f6576132f66133e4565b604052919050565b60008219821115613311576133116133ce565b500190565b60008261333157634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615613350576133506133ce565b500290565b600082821015613367576133676133ce565b500390565b60005b8381101561338757818101518382015260200161336f565b83811115613396576000848401525b50505050565b6000816133ab576133ab6133ce565b506000190190565b60006000198214156133c7576133c76133ce565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114610f4657600080fd5b8015158114610f4657600080fdfea2646970667358221220e004f2493ee62af0c5a4fe5bd55f3069b600e27579f08e322ae3567636eb00c564736f6c63430008040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000004b4151c1e9ecfb837695623fe7fc7a7c5f62a9bc
-----Decoded View---------------
Arg [0] : _storage (address): 0x4b4151c1E9eCfb837695623fE7fC7a7c5F62a9bc
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000004b4151c1e9ecfb837695623fe7fc7a7c5f62a9bc
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.