Polygon Sponsored slots available. Book your slot here!
More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
0x09f3a06ca165fa4e9e0f0a322899cd4be175bfb7144f5cbf5e6ade1b62e8a885 | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
0x0a6ba45a9abec045014d7b9baf1fa25c55561cc5a8e2f3fbc77acba3badd79dd | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
0x4becd05aec7c7fd0bdb0b3ba9d602ee8e98936b8465c7a7a0cfc9af1afc8f40f | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
0xf1f1f6401ae29e95cc7ef6d77508b373f4ca3c5a19fef016a4b7869df8230a91 | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
0x297047ebcf9374a356286aac528155e24c6df4275175ba0f2539b7c78342531a | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
0x6494f7d875927289dd1ab95d69295c4b18268bff4b9b2656baf94409d12738de | - | (pending) | 4 secs ago | IN | 0 POL | (Pending) | |||
Open Sbt | 70647422 | 12 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647422 | 12 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647422 | 12 secs ago | IN | 0 POL | 0.0081939 | ||||
Open Sbt | 70647421 | 14 secs ago | IN | 0 POL | 0.00682552 | ||||
Open Sbt | 70647421 | 14 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647420 | 16 secs ago | IN | 0 POL | 0.00694552 | ||||
Open Sbt | 70647420 | 16 secs ago | IN | 0 POL | 0.00819063 | ||||
Open Sbt | 70647420 | 16 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647419 | 18 secs ago | IN | 0 POL | 0.00819063 | ||||
Open Sbt | 70647419 | 18 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647419 | 18 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647418 | 20 secs ago | IN | 0 POL | 0.00833463 | ||||
Open Sbt | 70647417 | 22 secs ago | IN | 0 POL | 0.00682552 | ||||
Open Sbt | 70647417 | 22 secs ago | IN | 0 POL | 0.00694552 | ||||
Open Sbt | 70647417 | 22 secs ago | IN | 0 POL | 0.00694552 | ||||
Open Sbt | 70647416 | 24 secs ago | IN | 0 POL | 0.00833427 | ||||
Open Sbt | 70647414 | 28 secs ago | IN | 0 POL | 0.00694552 | ||||
Open Sbt | 70647413 | 30 secs ago | IN | 0 POL | 0.00694552 | ||||
Open Sbt | 70647413 | 30 secs ago | IN | 0 POL | 0.00833427 |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x31e530E5...4Fd715ea7 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
LUCK_DRAW
Compiler Version
v0.8.17+commit.8df45f5f
Optimization Enabled:
Yes with 99999 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/structs/EnumerableMap.sol"; import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; // import "hardhat/console.sol"; interface ISbt { function tokenIdOf(address from) external view returns (uint256); function updateSubAmount( uint256 tokenId, uint256 deadline, uint256 amount, uint256 serialNo, bytes memory signature ) external; } contract LUCK_DRAW is AccessControl { bytes32 public constant ROLE_SUPER_ADMIN = keccak256("SUPER_ADMIN_ROLE"); bytes32 public constant ROLE_ADMIN = keccak256("ADMIN_ROLE"); bytes32 public constant ROLE_SIGN = keccak256("SIGN_ROLE"); using EnumerableMap for EnumerableMap.Bytes32ToUintMap; using EnumerableMap for EnumerableMap.UintToUintMap; using ECDSA for bytes32; EnumerableMap.Bytes32ToUintMap private _signMap; EnumerableMap.UintToUintMap private avaliableBoxIdMap; address public sbtAddress; address public assetAddress; struct Box { uint boxId; string name; uint boxType;// 0:point 1:nft 2:usdt bool isOpen; uint256 rewardNum; uint256 availableNum; uint256 usedNum; address contractAddress; uint tokenIndex; uint256[] tokenIds; } Box[] public boxes; mapping(uint => uint) public boxIdMap; mapping(uint256 => uint256) public awardMap; event SEND_REWARD(address sender, uint boxIndex,uint boxType,uint256 rewardNum,uint256 serialNo); string public constant PROVENANCE = "CoreSBT-Polygon"; string public constant OPEN_METHOD = "openBox"; constructor(address superAdmin, address signer, address admin) { _setupRole(ROLE_SUPER_ADMIN, superAdmin); _setupRole(ROLE_ADMIN, admin); _setupRole(ROLE_SIGN, signer); _setRoleAdmin(ROLE_SUPER_ADMIN, ROLE_SUPER_ADMIN); _setRoleAdmin(ROLE_ADMIN, ROLE_SUPER_ADMIN); boxes.push(Box(0, "", 0 ,false ,0 ,0 ,0 , address(0) ,0,new uint256[](0))); } function setSbtAddress(address _sbtAddress)public onlyRole(ROLE_SUPER_ADMIN){ sbtAddress = _sbtAddress; } function setAssetAddress(address _assetAddress)public onlyRole(ROLE_SUPER_ADMIN){ assetAddress = _assetAddress; } function viewAvaliableKey() public view returns(uint256[] memory){ uint256[] memory keys = avaliableBoxIdMap.keys(); return keys; } function changeOpen(uint boxId)public onlyRole(ROLE_ADMIN){ uint boxIndex = boxIdMap[boxId]; boxes[boxIndex].isOpen = !boxes[boxIndex].isOpen; if(boxes[boxIndex].isOpen && (boxes[boxIndex].availableNum - boxes[boxIndex].usedNum > 0)){ avaliableBoxIdMap.set(boxIndex,boxId); }else if(!boxes[boxIndex].isOpen){ avaliableBoxIdMap.remove( boxIndex); } } function addBox( uint _boxId, string calldata _name, uint _boxType, uint256 _rewardNum, uint256 _availableNum, address _contractAddress, uint256[] calldata _tokenIds) public onlyRole(ROLE_ADMIN){ require(boxIdMap[_boxId] == 0, "exist boxid"); if(_boxType == 1 || _boxType == 2){ require(_contractAddress != address(0), "box type can't blank contract address"); } Box memory box = Box(_boxId,_name, _boxType,false,_rewardNum,_availableNum,0,_contractAddress,0,_tokenIds); boxes.push(box); uint boxesLength = boxes.length; boxIdMap[_boxId] = boxesLength-1; } function isExistsBox(uint boxId) public view returns (bool) { uint boxIndex = boxIdMap[boxId]; if(boxes[boxIndex].boxId > 0){ return true; } return false; } function getBoxNameById(uint boxId)public view returns(string memory){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].name; } function getBoxTypeById(uint boxId)public view returns(uint){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].boxType; } function getBoxOpenById(uint boxId)public view returns(bool){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].isOpen; } function getBoxAvailableNumById(uint boxId)public view returns(uint256){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].availableNum - boxes[boxIndex].usedNum; } function getBoxUsedNumById(uint boxId)public view returns(uint256){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].usedNum; } function getBoxRewardNumById(uint boxId)public view returns(uint256){ uint boxIndex = boxIdMap[boxId]; return boxes[boxIndex].rewardNum; } function setOpenTrue (uint boxId)public onlyRole(ROLE_ADMIN){ uint boxIndex = boxIdMap[boxId]; boxes[boxIndex].isOpen = true; if(boxes[boxIndex].availableNum - boxes[boxIndex].usedNum > 0){ avaliableBoxIdMap.set(boxIndex,boxId); } } function setOpenFalse (uint boxId)public onlyRole(ROLE_ADMIN){ uint boxIndex = boxIdMap[boxId]; boxes[boxIndex].isOpen = false; avaliableBoxIdMap.remove( boxIndex); } function batchIsExistsBox(uint[] calldata boxIds)public view returns ( bool[] memory){ bool[] memory retResult = new bool[](boxIds.length); for(uint i=0;i<boxIds.length;i++){ uint boxId = boxIds[i]; bool isExist = isExistsBox(boxId); retResult[i] = isExist; } return retResult; } function batchGetUsedNum(uint[] calldata boxIds)public view returns ( uint256[] memory){ uint256[] memory retResult = new uint256[](boxIds.length); for(uint i=0;i<boxIds.length;i++){ uint boxId = boxIds[i]; uint256 usedNum = getBoxUsedNumById(boxId); retResult[i] = usedNum; } return retResult; } function batchGetBoxOpen(uint[] calldata boxIds)public view returns ( bool[] memory){ bool[] memory retResult = new bool[](boxIds.length); for(uint i=0;i<boxIds.length;i++){ uint boxId = boxIds[i]; bool isExist = getBoxOpenById(boxId); retResult[i] = isExist; } return retResult; } function batchGetAward(uint256[] calldata serialNos)public view returns ( uint256[] memory){ uint256[] memory retResult = new uint256[](serialNos.length); for(uint i=0;i<serialNos.length;i++){ uint256 serialNo = serialNos[i]; uint256 boxId = awardMap[serialNo]; retResult[i] = boxId; } return retResult; } function openScore( uint256 deadline, uint256 amount, uint256 serialNo, bytes memory signature)public{ bytes32 signHash = keccak256(signature); require(!_signMap.contains(signHash), "Invalid signature"); require(verifySign( 0,deadline, amount, serialNo, signature),"verify error"); _signMap.set(signHash, 1); open(serialNo); } function openSbt( uint256 tokenId, uint256 deadline, uint256 amount, uint256 serialNo, bytes memory signature )public{ bytes32 signHash = keccak256(signature); require(!_signMap.contains(signHash), "Invalid signature"); require(verifySign(tokenId, deadline, amount, serialNo, signature),"verify error"); _signMap.set(signHash, 1); ISbt(sbtAddress).updateSubAmount(tokenId,deadline, amount, serialNo,signature); open(serialNo); } function getSelectKeyIndex(uint keyLength,uint256 serialNo)public view returns(uint256){ bytes32 randomBytes = keccak256(abi.encodePacked(blockhash(block.number-1), msg.sender, block.timestamp,serialNo)); return uint256(randomBytes) % keyLength; } function open(uint256 serialNo)private { // Box[] memory tboxes = getAvailableBoxIndex(); uint256[] memory keys = avaliableBoxIdMap.keys(); uint keyLength = keys.length; require(keyLength > 0, "box is empty"); uint256 selectKeyIndex = getSelectKeyIndex(keyLength,serialNo); uint256 selectBoxIndex = keys[selectKeyIndex]; awardMap[serialNo] = boxes[selectBoxIndex].boxId; uint boxType = boxes[selectBoxIndex].boxType; uint256 rewardNum = boxes[selectBoxIndex].rewardNum; boxes[selectBoxIndex].usedNum++; if(boxes[selectBoxIndex].availableNum <= boxes[selectBoxIndex].usedNum){ EnumerableMap.remove(avaliableBoxIdMap, selectBoxIndex); } if(boxType == 1){ require(boxes[selectBoxIndex].tokenIds.length > boxes[selectBoxIndex].tokenIndex, "box nft no have"); uint256 tokenId = boxes[selectBoxIndex].tokenIds[boxes[selectBoxIndex].tokenIndex]; IERC721(boxes[selectBoxIndex].contractAddress).transferFrom(assetAddress, msg.sender, tokenId); boxes[selectBoxIndex].tokenIndex++; }else if(boxType == 2){ IERC20(boxes[selectBoxIndex].contractAddress).transferFrom(assetAddress,msg.sender, rewardNum); } emit SEND_REWARD(msg.sender,selectBoxIndex,boxType,rewardNum,serialNo); } function verifySign( uint256 tokenId, uint256 deadline, uint256 amount, uint256 serialNo, bytes memory signature ) internal view returns (bool) { require(block.timestamp < deadline, "The sign deadline error"); bytes32 messageHash = keccak256( abi.encodePacked( PROVENANCE, msg.sender, tokenId, deadline, amount, serialNo, 'updateAmount' ) ); address sysAddress = messageHash.recover(signature); return hasRole(ROLE_SIGN, sysAddress); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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: * * ```solidity * 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}: * * ```solidity * 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. We recommend using {AccessControlDefaultAdminRules} * to enforce additional security measures for this role. */ 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(account), " 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 // 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.9.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.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (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; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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 // Deprecated in v4.8 } 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"); } } /** * @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) { 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 { 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 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 message) { // 32 is the length in bytes of hash, // enforced by the type signature above /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") mstore(0x1c, hash) message := keccak256(0x00, 0x3c) } } /** * @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 data) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, "\x19\x01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) data := keccak256(ptr, 0x42) } } /** * @dev Returns an Ethereum Signed Data with intended validator, created from a * `validator` and `data` according to the version 0 of EIP-191. * * See {recover}. */ function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x00", validator, data)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.0; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; import "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toString(int256 value) internal pure returns (string memory) { return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableMap.js. pragma solidity ^0.8.0; import "./EnumerableSet.sol"; /** * @dev Library for managing an enumerable variant of Solidity's * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`] * type. * * Maps have the following properties: * * - Entries are added, removed, and checked for existence in constant time * (O(1)). * - Entries are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableMap for EnumerableMap.UintToAddressMap; * * // Declare a set state variable * EnumerableMap.UintToAddressMap private myMap; * } * ``` * * The following map types are supported: * * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0 * - `address -> uint256` (`AddressToUintMap`) since v4.6.0 * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0 * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0 * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0 * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableMap. * ==== */ library EnumerableMap { using EnumerableSet for EnumerableSet.Bytes32Set; // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Map type with // bytes32 keys and values. // The Map implementation uses private functions, and user-facing // implementations (such as Uint256ToAddressMap) are just wrappers around // the underlying Map. // This means that we can only create new EnumerableMaps for types that fit // in bytes32. struct Bytes32ToBytes32Map { // Storage of keys EnumerableSet.Bytes32Set _keys; mapping(bytes32 => bytes32) _values; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) { map._values[key] = value; return map._keys.add(key); } /** * @dev Removes a key-value pair from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) { delete map._values[key]; return map._keys.remove(key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) { return map._keys.contains(key); } /** * @dev Returns the number of key-value pairs in the map. O(1). */ function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) { return map._keys.length(); } /** * @dev Returns the key-value pair stored at position `index` in the map. O(1). * * Note that there are no guarantees on the ordering of entries inside the * array, and it may change when more entries are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) { bytes32 key = map._keys.at(index); return (key, map._values[key]); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) { bytes32 value = map._values[key]; if (value == bytes32(0)) { return (contains(map, key), bytes32(0)); } else { return (true, value); } } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), "EnumerableMap: nonexistent key"); return value; } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( Bytes32ToBytes32Map storage map, bytes32 key, string memory errorMessage ) internal view returns (bytes32) { bytes32 value = map._values[key]; require(value != 0 || contains(map, key), errorMessage); return value; } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) { return map._keys.values(); } // UintToUintMap struct UintToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToUintMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) { return uint256(get(map._inner, bytes32(key), errorMessage)); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToUintMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintToAddressMap struct UintToAddressMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) { return set(map._inner, bytes32(key), bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) { return remove(map._inner, bytes32(key)); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) { return contains(map._inner, bytes32(key)); } /** * @dev Returns the number of elements in the map. O(1). */ function length(UintToAddressMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) { (bytes32 key, bytes32 value) = at(map._inner, index); return (uint256(key), address(uint160(uint256(value)))); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(key)); return (success, address(uint160(uint256(value)))); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(UintToAddressMap storage map, uint256 key) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( UintToAddressMap storage map, uint256 key, string memory errorMessage ) internal view returns (address) { return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage)))); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) { bytes32[] memory store = keys(map._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressToUintMap struct AddressToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) { return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(AddressToUintMap storage map, address key) internal returns (bool) { return remove(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(AddressToUintMap storage map, address key) internal view returns (bool) { return contains(map._inner, bytes32(uint256(uint160(key)))); } /** * @dev Returns the number of elements in the map. O(1). */ function length(AddressToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (address(uint160(uint256(key))), uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key)))); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(AddressToUintMap storage map, address key) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))))); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( AddressToUintMap storage map, address key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage)); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(AddressToUintMap storage map) internal view returns (address[] memory) { bytes32[] memory store = keys(map._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // Bytes32ToUintMap struct Bytes32ToUintMap { Bytes32ToBytes32Map _inner; } /** * @dev Adds a key-value pair to a map, or updates the value for an existing * key. O(1). * * Returns true if the key was added to the map, that is if it was not * already present. */ function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) { return set(map._inner, key, bytes32(value)); } /** * @dev Removes a value from a map. O(1). * * Returns true if the key was removed from the map, that is if it was present. */ function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) { return remove(map._inner, key); } /** * @dev Returns true if the key is in the map. O(1). */ function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) { return contains(map._inner, key); } /** * @dev Returns the number of elements in the map. O(1). */ function length(Bytes32ToUintMap storage map) internal view returns (uint256) { return length(map._inner); } /** * @dev Returns the element stored at position `index` in the map. O(1). * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) { (bytes32 key, bytes32 value) = at(map._inner, index); return (key, uint256(value)); } /** * @dev Tries to returns the value associated with `key`. O(1). * Does not revert if `key` is not in the map. */ function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) { (bool success, bytes32 value) = tryGet(map._inner, key); return (success, uint256(value)); } /** * @dev Returns the value associated with `key`. O(1). * * Requirements: * * - `key` must be in the map. */ function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) { return uint256(get(map._inner, key)); } /** * @dev Same as {get}, with a custom error message when `key` is not in the map. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryGet}. */ function get( Bytes32ToUintMap storage map, bytes32 key, string memory errorMessage ) internal view returns (uint256) { return uint256(get(map._inner, key, errorMessage)); } /** * @dev Return the an array containing all the keys * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block. */ function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) { bytes32[] memory store = keys(map._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 99999 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"superAdmin","type":"address"},{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"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":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"boxIndex","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"boxType","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewardNum","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"serialNo","type":"uint256"}],"name":"SEND_REWARD","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPEN_METHOD","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PROVENANCE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_SIGN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ROLE_SUPER_ADMIN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_boxId","type":"uint256"},{"internalType":"string","name":"_name","type":"string"},{"internalType":"uint256","name":"_boxType","type":"uint256"},{"internalType":"uint256","name":"_rewardNum","type":"uint256"},{"internalType":"uint256","name":"_availableNum","type":"uint256"},{"internalType":"address","name":"_contractAddress","type":"address"},{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"}],"name":"addBox","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"assetAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"awardMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"serialNos","type":"uint256[]"}],"name":"batchGetAward","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"boxIds","type":"uint256[]"}],"name":"batchGetBoxOpen","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"boxIds","type":"uint256[]"}],"name":"batchGetUsedNum","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"boxIds","type":"uint256[]"}],"name":"batchIsExistsBox","outputs":[{"internalType":"bool[]","name":"","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"boxIdMap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"boxes","outputs":[{"internalType":"uint256","name":"boxId","type":"uint256"},{"internalType":"string","name":"name","type":"string"},{"internalType":"uint256","name":"boxType","type":"uint256"},{"internalType":"bool","name":"isOpen","type":"bool"},{"internalType":"uint256","name":"rewardNum","type":"uint256"},{"internalType":"uint256","name":"availableNum","type":"uint256"},{"internalType":"uint256","name":"usedNum","type":"uint256"},{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"uint256","name":"tokenIndex","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"changeOpen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxAvailableNumById","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxNameById","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxOpenById","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxRewardNumById","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxTypeById","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"getBoxUsedNumById","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"keyLength","type":"uint256"},{"internalType":"uint256","name":"serialNo","type":"uint256"}],"name":"getSelectKeyIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":"uint256","name":"boxId","type":"uint256"}],"name":"isExistsBox","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"serialNo","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"openSbt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"serialNo","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"openScore","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":[],"name":"sbtAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_assetAddress","type":"address"}],"name":"setAssetAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"setOpenFalse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"boxId","type":"uint256"}],"name":"setOpenTrue","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sbtAddress","type":"address"}],"name":"setSbtAddress","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":"viewAvaliableKey","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"}]
Deployed Bytecode
0x608080604052600436101561001357600080fd5b600090813560e01c90816301ffc9a714611e3857508063082dcd1b14611df85780630840e4ad14611daf578063100c369a14611d5a5780631ba46cfd14611d085780631e8bd5f014611c63578063235611f714611596578063248a9ca31461154c5780632f2ff15d1461145657806336568abe146113715780633740a177146112da5780634cf182cd1461129d5780634eb2c8df146110b45780634ed3faf214610ec057806354683cac14610e3e5780635b01c2a114610de55780636373a6b114610dab578063667eac6014610d1e5780636777af0714610cd75780636c0a434214610c8f5780636cc8bb4914610c36578063770e09fd14610bb45780638489a21c14610a9e57806390a5d658146109fe57806391d148541461098c578063989147b31461093a578063a217fddf14610900578063a994216a14610896578063b15eb14d1461081a578063b85b76eb14610786578063c0ecc402146106dd578063c6b6a2e714610678578063d391014b1461061f578063d547741f146105c4578063d7bd1518146102fb578063d9a7ffed14610252578063e5596a371461020d5763f76d1963146101c357600080fd5b3461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760406020916004358152600a83522054604051908152f35b80fd5b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57602061024a600435612e47565b604051908152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760043567ffffffffffffffff81116102f7576102a2903690600401611f41565b6102ab81612e65565b925b8181106102c657604051806102c286826122f9565b0390f35b806102de6102d86102f2938587612ee1565b35612e00565b6102e88287612ef1565b9015159052612eb4565b6102ad565b5080fd5b503461020a5760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576064359060243567ffffffffffffffff6044356004356084358381116105c0576103599036906004016120ba565b938451602090818701209061038461037e836000526002602052604060002054151590565b15612f05565b824210156105625761042991600361048f926104218a8d8a61041960c08b8d6103ab6122c0565b956040519586938b6103c68187019a8b81519384920161225a565b8501933360601b8d86015260348501526054840152607483015260948201527f757064617465416d6f756e74000000000000000000000000000000000000000060b48201520360a0810184520182612014565b5190206136e8565b95909561354f565b7ffbd6b3ad612c81ecfcef77ba888ef41173779a71e0dbe944f953d7c64fd9dc5d8b528a815260408b2073ffffffffffffffffffffffffffffffffffffffff8096168c52815261047f60ff60408d205416612f6a565b828b5252600160408a2055612b53565b506007541691823b1561055e579086809493926104f8604051988996879586947f1b05ef5f0000000000000000000000000000000000000000000000000000000086526004860152602485015260448401528b606484015260a0608484015260a483019061227d565b03925af1801561055357610514575b8261051185613075565b80f35b81116105265760405261051138610507565b6024827f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b6040513d85823e3d90fd5b8680fd5b606490604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152601760248201527f546865207369676e20646561646c696e65206572726f720000000000000000006044820152fd5b8580fd5b503461020a5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57610511600435610602611ef6565b908084528360205261061a6001604086200154612756565b612891565b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760206040517fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217758152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5761024a60406020926004358152600a8452205460066106d460056106cb846120d8565b500154926120d8565b50015490612ac8565b503461020a576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102f75760043567ffffffffffffffff81116107825761072e903690600401611f41565b92909161073a84612e65565b93825b81811061075257604051806102c28882611f72565b8061076161077d928488612ee1565b358552600b845260408520546107778289612ef1565b52612eb4565b61073d565b8280fd5b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576107be612336565b6004358152600a602052610816604082205460036107db826120d8565b50017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690558083526006602052826040812055612c7e565b5080f35b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576102c260405161085881611fad565b600781527f6f70656e426f7800000000000000000000000000000000000000000000000000602082015260405191829160208352602083019061227d565b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576108ec60016108e560406102c2946004358152600a60205220546120d8565b5001612195565b60405191829160208352602083019061227d565b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57602090604051908152f35b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57602073ffffffffffffffffffffffffffffffffffffffff60075416604051908152f35b503461020a5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760ff60406020926109cb611ef6565b600435825281855273ffffffffffffffffffffffffffffffffffffffff8383209116825284522054166040519015158152f35b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57604051600480548083529083526020808301937f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b92915b828210610a87576102c285610a7b81890382612014565b60405191829182611f72565b835486529485019460019384019390910190610a64565b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57600435610ad9612336565b808252600a602052604082205490610b3960ff6003610af7856120d8565b50015416156003610b07856120d8565b50019060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b60ff6003610b46846120d8565b5001541680610b90575b15610b5e5761081691612b04565b5060ff6003610b6c836120d8565b5001541615610b79575080f35b806108169183526006602052826040812055612c7e565b50610bad6005610b9f846120d8565b50015460066106d4856120d8565b1515610b50565b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5773ffffffffffffffffffffffffffffffffffffffff610c01611f1e565b610c096125e0565b167fffffffffffffffffffffffff0000000000000000000000000000000000000000600854161760085580f35b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760206040517f7613a25ecc738585a232ad50a301178f12b3ba8887d13e138b523c4269c476898152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760406020916004358152600b83522054604051908152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576020610d14600435612e26565b6040519015158152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760043567ffffffffffffffff81116102f757610d6e903690600401611f41565b610d7781612e65565b925b818110610d8e57604051806102c286826122f9565b806102de610da0610da6938587612ee1565b35612e26565b610d79565b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576102c26108ec6122c0565b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760206040517ffbd6b3ad612c81ecfcef77ba888ef41173779a71e0dbe944f953d7c64fd9dc5d8152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5773ffffffffffffffffffffffffffffffffffffffff610e8b611f1e565b610e936125e0565b167fffffffffffffffffffffffff0000000000000000000000000000000000000000600754161760075580f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576004356009548110156102f7576009600a925202807f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0154610f537f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b08301612195565b917f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b18101549060ff7f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b282015416907f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b38101547f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b48201547f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b5830154917f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b773ffffffffffffffffffffffffffffffffffffffff7f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7b68601541694015494611089604051998a998a526101208060208c01528a019061227d565b96604089015215156060880152608087015260a086015260c085015260e08401526101008301520390f35b503461020a5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576004359060443560643567ffffffffffffffff81116107825761110b9036906004016120ba565b92835193602094858201209161113161037e846000526002602052604060002054151590565b8042101561123f5784956111d46111cc61123995946003946105119961041960c061115a6122c0565b936040519384918a611175818501988981519384920161225a565b8301913360601b8c8401526034830152605482015260243560748201528d60948201527f757064617465416d6f756e74000000000000000000000000000000000000000060b48201520360a0810184520182612014565b91909161354f565b7ffbd6b3ad612c81ecfcef77ba888ef41173779a71e0dbe944f953d7c64fd9dc5d885287825273ffffffffffffffffffffffffffffffffffffffff6040892091168852815261122960ff604089205416612f6a565b8287525260016040862055612b53565b50613075565b606486604051907f08c379a00000000000000000000000000000000000000000000000000000000082526004820152601760248201527f546865207369676e20646561646c696e65206572726f720000000000000000006044820152fd5b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576020610d14600435612e00565b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760043567ffffffffffffffff81116102f75761132a903690600401611f41565b61133381612e65565b925b81811061134a57604051806102c28682611f72565b8061136261135c61136c938587612ee1565b35612e47565b6107778287612ef1565b611335565b503461020a5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576113a9611ef6565b3373ffffffffffffffffffffffffffffffffffffffff8216036113d25761051190600435612891565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152fd5b503461020a5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57600435611491611ef6565b818352826020526114a86001604085200154612756565b8183528260205273ffffffffffffffffffffffffffffffffffffffff6040842091169081845260205260ff604084205416156114e2578280f35b81835282602052604083208184526020526040832060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905533917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d8480a438808280f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57600160406020926004358152808452200154604051908152f35b503461020a5760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a5760243567ffffffffffffffff81116102f757366023820112156102f75780600401359067ffffffffffffffff82116107825736602483830101116107825760443560a43573ffffffffffffffffffffffffffffffffffffffff8116809103611c5f5760c43567ffffffffffffffff81116105c057611648903690600401611f41565b929093611653612336565b6004358752600a6020526040872054611c0157600182148015611bf7575b611b6e575b60405195610140870187811067ffffffffffffffff821117611b415760405260043587526116a991369190602401612055565b60208601526040850152846060850152606435608085015260843560a08501528460c085015260e0840152836101008401526116e481612dd1565b916116f26040519384612014565b8183526020830190368360051b8201116105c05780915b8360051b82018310611b31575050505061012082015260095468010000000000000000811015611b045780600161174392016009556120d8565b611ad85781518155602082015180519067ffffffffffffffff8211611aab5761176f6001840154612142565b601f8111611a6d575b50602090601f83116001146119a057918061012094926009948892611995575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161760018201555b6040840151600282015561181560608501511515600383019060ff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0083541691151516179055565b6080840151600482015560a0840151600582015560c084015160068201556007810173ffffffffffffffffffffffffffffffffffffffff60e0860151167fffffffffffffffffffffffff00000000000000000000000000000000000000008254161790556101008401516008820155019101519081519167ffffffffffffffff83116119685768010000000000000000831161196857602090825484845580851061194e575b500190835260208320835b83811061193a57846009547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff810190811161190d576004358252600a602052604082205580f35b6024827f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6001906020845194019381840155016118c6565b838652828620611962918101908601612de9565b386118bb565b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b015190503880611798565b906001840186526020862091865b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe085168110611a555750926101209492600192600995837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0811610611a1e575b505050811b0160018201556117cd565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c19169055388080611a0e565b919260206001819286850151815501940192016119ae565b611a9b9060018501875260208720601f850160051c81019160208610611aa1575b601f0160051c0190612de9565b38611778565b9091508190611a8e565b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b6024837f4e487b7100000000000000000000000000000000000000000000000000000000815280600452fd5b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b8235815260209283019201611709565b6024897f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b826116765760846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602560248201527f626f7820747970652063616e277420626c616e6b20636f6e747261637420616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152fd5b5060028214611671565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600b60248201527f657869737420626f7869640000000000000000000000000000000000000000006044820152fd5b8480fd5b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57600435611c9e612336565b808252600a6020526040822054906003611cb7836120d8565b500160017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00825416179055611cf06005610b9f846120d8565b611cf8578280f35b611d0191612b04565b5038808280f35b503461020a57807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57602073ffffffffffffffffffffffffffffffffffffffff60085416604051908152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576002611da460406020936004358152600a855220546120d8565b500154604051908152f35b503461020a5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a576004611da4604060209383358152600a855220546120d8565b503461020a5760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261020a57602061024a602435600435612fcf565b9050346102f75760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102f7576004357fffffffff00000000000000000000000000000000000000000000000000000000811680910361078257602092507f7965db0b000000000000000000000000000000000000000000000000000000008114908115611ecc575b5015158152f35b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501438611ec5565b6024359073ffffffffffffffffffffffffffffffffffffffff82168203611f1957565b600080fd5b6004359073ffffffffffffffffffffffffffffffffffffffff82168203611f1957565b9181601f84011215611f195782359167ffffffffffffffff8311611f19576020808501948460051b010111611f1957565b6020908160408183019282815285518094520193019160005b828110611f99575050505090565b835185529381019392810192600101611f8b565b6040810190811067ffffffffffffffff821117611fc957604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6080810190811067ffffffffffffffff821117611fc957604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117611fc957604052565b92919267ffffffffffffffff8211611fc9576040519161209d60207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8401160184612014565b829481845281830111611f19578281602093846000960137010152565b9080601f83011215611f19578160206120d593359101612055565b90565b60095481101561211357600a906009600052027f6e1540171b6c0c960b71a7020d9f60077f6af931a8bbf590da0223dacf75c7af0190600090565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b90600182811c9216801561218b575b602083101461215c57565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b91607f1691612151565b90604051918260008254926121a984612142565b90818452600194858116908160001461221857506001146121d5575b50506121d392500383612014565b565b9093915060005260209081600020936000915b8183106122005750506121d3935082010138806121c5565b855488840185015294850194879450918301916121e8565b90506121d39550602093507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b82010138806121c5565b60005b83811061226d5750506000910152565b818101518382015260200161225d565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f6020936122b98151809281875287808801910161225a565b0116010190565b604051906122cd82611fad565b600f82527f436f72655342542d506f6c79676f6e00000000000000000000000000000000006020830152565b6020908160408183019282815285518094520193019160005b828110612320575050505090565b8351151585529381019392810192600101612312565b3360009081527f7d7ffb7a348e1c6a02869081a26547b49160dd3df72d1d75a570eb9b698292ec602090815260408083205490927fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c217759160ff161561239a5750505050565b6123a333612942565b918451906123b082611ff8565b604282528482019260603685378251156125b357603084538251906001918210156125b35790607860218501536041915b818311612515575050506124b95760486124b593869361247f9361247098519889937f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008a86015261243b815180928c60378901910161225a565b8401917f206973206d697373696e6720726f6c652000000000000000000000000000000060378401525180938684019061225a565b01036028810187520185612014565b519283927f08c379a00000000000000000000000000000000000000000000000000000000084526004840152602483019061227d565b0390fd5b6064848651907f08c379a000000000000000000000000000000000000000000000000000000000825280600483015260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b909192600f81166010811015612586577f3031323334353637383961626364656600000000000000000000000000000000901a6125528587612931565b5360041c92801561190d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191906123e1565b6024837f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b807f4e487b7100000000000000000000000000000000000000000000000000000000602492526032600452fd5b3360009081527f2155616cb3971b66bf28f1af4ff3722784e6d7a4b2b25bc9fe623232dcd690c8602090815260408083205490927f7613a25ecc738585a232ad50a301178f12b3ba8887d13e138b523c4269c476899160ff16156126445750505050565b61264d33612942565b9184519061265a82611ff8565b604282528482019260603685378251156125b357603084538251906001918210156125b35790607860218501536041915b8183116126e5575050506124b95760486124b593869361247f9361247098519889937f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008a86015261243b815180928c60378901910161225a565b909192600f81166010811015612586577f3031323334353637383961626364656600000000000000000000000000000000901a6127228587612931565b5360041c92801561190d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01919061268b565b600090808252602090828252604092838120338252835260ff84822054161561277f5750505050565b61278833612942565b9184519061279582611ff8565b604282528482019260603685378251156125b357603084538251906001918210156125b35790607860218501536041915b818311612820575050506124b95760486124b593869361247f9361247098519889937f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008a86015261243b815180928c60378901910161225a565b909192600f81166010811015612586577f3031323334353637383961626364656600000000000000000000000000000000901a61285d8587612931565b5360041c92801561190d577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0191906127c6565b906000918083528260205273ffffffffffffffffffffffffffffffffffffffff6040842092169182845260205260ff6040842054166128cf57505050565b8083528260205260408320828452602052604083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541690557ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b339380a4565b908151811015612113570160200190565b604051906060820182811067ffffffffffffffff821117611fc957604052602a82526020820160403682378251156121135760309053815160019081101561211357607860218401536029905b8082116129fd57505061299f5790565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602060248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152fd5b9091600f81166010811015612a9a577f3031323334353637383961626364656600000000000000000000000000000000901a612a398486612931565b5360041c918015612a6c577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff019061298f565b602460007f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b602460007f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b91908203918211612ad557565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6120d591816000526006602052604060002055612bf5565b6004548110156121135760046000527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b0190600090565b600081815260026020526040812054612bf05760015468010000000000000000811015610526576001810180600155811015612bc35790826040927fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6015560015492815260026020522055600190565b6024827f4e487b710000000000000000000000000000000000000000000000000000000081526032600452fd5b905090565b600081815260056020526040812054612bf05760045468010000000000000000811015610526579082612c6a612c3384600160409601600455612b1c565b819391549060031b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff811b9283911b169119161790565b905560045492815260056020522055600190565b6000818152600560205260408120549091908015612dcc577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff90818101818111612d9f5760045490838201918211612d7257808203612d3e575b5050506004548015612d1157810190612cf082612b1c565b909182549160031b1b19169055600455815260056020526040812055600190565b6024847f4e487b710000000000000000000000000000000000000000000000000000000081526031600452fd5b612d5c612d4d612c3393612b1c565b90549060031b1c928392612b1c565b9055845260056020526040842055388080612cd8565b6024867f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b6024857f4e487b710000000000000000000000000000000000000000000000000000000081526011600452fd5b505090565b67ffffffffffffffff8111611fc95760051b60200190565b818110612df4575050565b60008155600101612de9565b600052600a602052612e166040600020546120d8565b5054612e2157600090565b600190565b600052600a60205260ff6003612e406040600020546120d8565b5001541690565b600052600a6020526006612e5f6040600020546120d8565b50015490565b90612e6f82612dd1565b612e7c6040519182612014565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0612eaa8294612dd1565b0190602036910137565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114612ad55760010190565b91908110156121135760051b0190565b80518210156121135760209160051b010190565b15612f0c57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601160248201527f496e76616c6964207369676e61747572650000000000000000000000000000006044820152fd5b15612f7157565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f766572696679206572726f7200000000000000000000000000000000000000006044820152fd5b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff430190438211612ad5576040519060208201924083523360601b604083015242605483015260748201526074815260a0810181811067ffffffffffffffff821117611fc9576040525190208115613046570690565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60409081519182600491825491828652602080960192816000948686527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b92865b8a828210613539575050506130cd92500382612014565b805180156134dd57906130e3866130e993612fcf565b90612ef1565b516130f3816120d8565b5054858452600b875282842055600261310b826120d8565b5001549284613119836120d8565b500154946006613128846120d8565b50016131348154612eb4565b90556005613141846120d8565b500154600661314f856120d8565b50015410156134c2575b600185036133aa57600961316c846120d8565b500154600861317a856120d8565b500154101561334e57600961318e846120d8565b5001600861319b856120d8565b500154908054821015613322578352888320015460076131ba856120d8565b50015460085473ffffffffffffffffffffffffffffffffffffffff9182169116813b15611c5f5786517f23b872dd00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff90911681850190815233602082015260408101939093529392918391859182908490829060600103925af18015613318576132b0575b505050917f1c456d7176d6813a10147357145351294ed8f1eda0a3ba9092921335ba9d1dfb95939183600861328860a098966120d8565b50016132948154612eb4565b90555b81519533875286015284015260608301526080820152a1565b67ffffffffffffffff83116132ec57505082528160a07f1c456d7176d6813a10147357145351294ed8f1eda0a3ba9092921335ba9d1dfb613251565b9060416024927f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b85513d84823e3d90fd5b6024846032857f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b606490888551917f08c379a0000000000000000000000000000000000000000000000000000000008352820152600f60248201527f626f78206e6674206e6f206861766500000000000000000000000000000000006044820152fd5b600285146133e3575b5050917f1c456d7176d6813a10147357145351294ed8f1eda0a3ba9092921335ba9d1dfb95939160a09593613297565b8786600761347693856133f5886120d8565b5073ffffffffffffffffffffffffffffffffffffffff93849101541692600854168951968795869485937f23b872dd0000000000000000000000000000000000000000000000000000000085523391850160409194939294606082019573ffffffffffffffffffffffffffffffffffffffff80921683521660208201520152565b03925af180156134b857156133b3578781813d83116134b1575b61349a8183612014565b810103126102f757518015150361020a57806133b3565b503d613490565b84513d84823e3d90fd5b8282526006885281848120556134d783612c7e565b50613159565b606485888551917f08c379a0000000000000000000000000000000000000000000000000000000008352820152600c60248201527f626f7820697320656d70747900000000000000000000000000000000000000006044820152fd5b85548452600195860195879550930192016130b6565b60058110156136b957806135605750565b600181036135c65760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152fd5b6002810361362c5760646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152fd5b60031461363557565b60846040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b90604181511460001461371657613712916020820151906060604084015193015160001a90613720565b9091565b5050600090600290565b9291907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083116137b05791608094939160ff602094604051948552168484015260408301526060820152600093849182805260015afa156137a357815173ffffffffffffffffffffffffffffffffffffffff81161561379d579190565b50600190565b50604051903d90823e3d90fd5b5050505060009060039056fea2646970667358221220feb226759323115e1122be1a243f48b962736151684920a27536f62102b3a98264736f6c63430008110033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 34 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.