Contract Overview
Balance:
0 BTT
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x101088ebb6929e14daae1e17e158e2037e7ecd855b5043c102cea30bfdb01a51 | Add Pair | 14937182 | 74 days 3 hrs ago | 0x31003c2d5685c7d28d7174c3255307eb9a0f3015 | IN | 0x4972f5297a3b676c267325131f765cb45a394a67 | 0 BTT | 35.5752 | |
0x1c9136404532fad1c2686e33c06534aa4ef03b1e24898b0067e2cfc32480d39f | 0x61014060 | 14937040 | 74 days 3 hrs ago | 0x31003c2d5685c7d28d7174c3255307eb9a0f3015 | IN | Create: Periphery | 0 BTT | 1,085.8857 |
[ Download CSV Export ]
Contract Name:
Periphery
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
No with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/draft-IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; function safeTransfer( IERC20 token, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } function safeTransferFrom( IERC20 token, address from, address to, uint256 value ) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove( IERC20 token, address spender, uint256 value ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } function safeIncreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; // EIP-712 is Final as of 2022-08-11. This file is deprecated. import "./EIP712.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.0; import "./ECDSA.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712 { /* solhint-disable var-name-mixedcase */ // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _CACHED_DOMAIN_SEPARATOR; uint256 private immutable _CACHED_CHAIN_ID; address private immutable _CACHED_THIS; bytes32 private immutable _HASHED_NAME; bytes32 private immutable _HASHED_VERSION; bytes32 private immutable _TYPE_HASH; /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); bytes32 typeHash = keccak256( "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; _CACHED_CHAIN_ID = block.chainid; _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion); _CACHED_THIS = address(this); _TYPE_HASH = typeHash; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash); } }
// 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.8.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) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 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 10, 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 * 8) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.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 `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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.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. * * ``` * 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; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @title ILoyalty contract @dev Provide an interface that other contracts can integrate with Loyalty contract */ interface ILoyalty { /** @notice Update loyalty points of `_account` @dev Caller must be Operator @param _account Account address will be updated loyalty points @param _amount Amount of points will be updated @param _isAdded Boolean flag (Add = True, Deduct = False) */ function updatePoint(address _account, uint256 _amount, bool _isAdded) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; /** @title IMembership contract @dev Provide interfaces that other contracts can integrate with Membership contract */ interface IMembership is IERC721Enumerable { /** @notice Add new membership @dev Caller must be Operator @param _account Account address to be added @param _memberId Assigning member id */ function addMembership(address _account, uint256 _memberId) external; /** @notice Cancel current membership @dev Caller must be Operator @param _memberId Assigning member id */ function cancelMembership(uint256 _memberId) external; /** @notice Upgrade `_account` to next tier @dev Caller must be Operator @param _account Account address to be added @param _memberId Current member id @param _nextTier Upcoming tier will be upgraded Note: Checking requiring points, as qualification, could either be done off-chain or on-chain */ function upgrade(address _account, uint256 _memberId, uint256 _nextTier) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @title IPeriphery contract @dev Provide interfaces that other contracts can integrate with Periphery contract */ interface IPeriphery { struct Redeem { address membership; uint256 memberId; uint256 point; address voucher; uint256 value; uint128 nonce; uint128 expiry; } struct Buy { address beneficiary; address membership; uint256 memberId; address paymentToken; uint256 point; uint256 totalPayment; uint128 nonce; uint128 expiry; } struct TopUp { address beneficiary; address membership; uint256 memberId; address voucher; uint256 value; address paymentToken; uint256 totalPayment; uint128 nonce; uint128 expiry; } /** @notice Return corresponding `_loyalty` contract to `_membership` contract @dev Caller can be ANY */ function getLoyalty(address _membership) external view returns (address); /** @notice Checking whether `_membership` contract is disabled @dev Caller can be ANY */ function disabled(address _membership) external view returns (bool); /** @notice Redeem loyalty points to voucher's value @dev Caller can be ANY @param _invoice Redeem invoice struct - membership (address) Address of Membership contract - memberId (uint256) Member id of `msg.sender` - point (uint256) Amount of point to redeem - voucher (address) Address of Voucher contract to receive a value - value (uint256) Additional value to receive after redemption - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function redeem( Redeem calldata _invoice, bytes calldata _signature ) external; /** @notice Purchase/Topup voucher's value @dev Caller can be ANY @param _invoice Topup invoice struct - beneficiary (address) Address of Beneficiary that receives a voucher's value - membership (address) Address of Membership contract - memberId (uint256) Beneficiary's member id - voucher (address) Address of Voucher contract to receive a value - value (uint256) Additional value to receive after topup request - paymentToken (address) Address of payment token (0x00 for Native coin) - totalPayment (uint256) Total payment amount - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function topup( TopUp calldata _invoice, bytes calldata _signature ) external payable; /** @notice Buy loyaly points @dev Caller can be ANY @param _invoice Buy invoice struct - beneficiary (address) Address of Beneficiary that receives additional loyalty points - membership (address) Address of Membership contract - memberId (uint256) Beneficiary's member id - paymentToken (address) Address of payment token (0x00 for Native coin) - point (uint256) Additional value to receive after buy request - totalPayment (uint256) Total payment amount - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function buy( Buy calldata _invoice, bytes calldata _signature ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** @title IVoucher contract @dev Provide interfaces that other contracts can integrate with Voucher contract */ interface IVoucher { /** @notice Update voucher's value of `_account` @dev Caller must be Operator @param _account Account address will be updated voucher's value @param _amount Amount of values will be updated @param _isAdded Boolean flag (Add = True, Deduct = False) */ function updateValue(address _account, uint256 _amount, bool _isAdded) external; }
// SPDX-License-Identifier: None pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IMembership.sol"; import "./interfaces/ILoyalty.sol"; import "./interfaces/IVoucher.sol"; import "./utils/Signer.sol"; /** @title Periphery contract @dev This contract provide additional features and external interfaces on top of Membership, Loyalty and Voucher contracts - Add a method to buy loyalty points using crypto currency - Add a method to redeem loyalty points (loyalty points -> voucher's value) - Add a method to purchase/topup a voucher/gift card Note: Contract using EIP-712 for a signing scheme */ contract Periphery is IPeriphery, Signer, Ownable { using SafeERC20 for IERC20; using EnumerableSet for EnumerableSet.AddressSet; // Address to receive payments address public treasury; // Mapping address of Membership contract to a group/pair id mapping(address => address) private membershipToLoyalty; // Mapping Membership to supporting vouchers mapping(address => EnumerableSet.AddressSet) private vouchers; // A list of Memberships has been disabled mapping(address => bool) public disabled; // A list of Verifiers who sign a request to authorize mapping(address => bool) public verifiers; // Counting a number of requests (from each of accounts) that has been proceeded mapping(address => uint256) public nonces; event Disabled(address indexed membership, address indexed loyalty); event Enabled(address indexed membership, address indexed loyalty); event Updated(address indexed membership, address indexed voucher, bool isAdded); modifier checkStatus(address _membership) { require( !disabled[_membership] && getLoyalty(_membership) != address(0), "Unable to disable" ); _; } constructor(address _treasury, address _verifier) Signer("Membership and Loyalty", "Version 1") Ownable() { treasury = _treasury; verifiers[_verifier] = true; } /** @notice Return corresponding `_loyalty` contract to `_membership` contract @dev Caller can be ANY */ function getLoyalty(address _membership) public view returns (address) { return membershipToLoyalty[_membership]; } /** @notice Set/Unset `verifier` of the Periphery contract @dev Caller must be Owner @param _verifiers A list of addresses will be set/unset a verifier role @param _isAdded Boolean flag (Set = True, Unset = False) Note: `verifier` is a special role that has authority to provide a request's authorizing signature */ function setVerifiers(address[] calldata _verifiers, bool _isAdded) external onlyOwner { uint256 _len = _verifiers.length; for (uint256 i; i < _len; i++) verifiers[_verifiers[i]] = _isAdded; } /** @notice Register a pair of `_membership` and `_loyalty` contracts @dev Caller must be Owner @param _membership Address of `_membership` contract @param _loyalty Address of `_loyalty` contract @param _voucher Address of `_voucher` contract (optional) Note: - `_voucher` will be optional. Should leave it 0x00 when it's not set - For each pair of Membership and Loyalty, it comes along with a list of `_voucher` contracts that are allowed to redeem */ function addPair(address _membership, address _loyalty, address _voucher) external onlyOwner { require(_membership != address(0) && _loyalty != address(0), "Zero Address"); require(getLoyalty(_membership) == address(0), "Membership already paired"); membershipToLoyalty[_membership] = _loyalty; if (_voucher != address(0)) { vouchers[_membership].add(_voucher); emit Updated(_membership, _voucher, true); } emit Enabled(_membership, _loyalty); } /** @notice Disable a pair of `_membership` and `_loyalty` contracts @dev Caller must be Owner @param _membership Address of `_membership` contract Note: - When a pair is disabled, operations relate to `_membership`, `_loyalty` will also be disabled - A list of supporting `_voucher` for this pair is set by using EnumerableSet.AddressSet, it pretty costs to delete/remove them when a `_membership` contract is disabled. Thus, just mark this pair as `disabled` - When re-enabling a pair, make sure checking and updating a list of supporting `_voucher` */ function disablePair(address _membership) external onlyOwner checkStatus(_membership) { disabled[_membership] = true; emit Disabled(_membership, getLoyalty(_membership)); } /** @notice Re-enable a pair of `_membership` and `_loyalty` contracts @dev Caller must be Owner @param _membership Address of `_membership` contract Note: - After disabling a pair, a list of supporting `_voucher` is not deleted Thus, make sure checking and updating this list when re-enabling, */ function enablePair(address _membership) external onlyOwner { require(disabled[_membership], "Unable to enable"); delete disabled[_membership]; emit Enabled(_membership, getLoyalty(_membership)); } /** @notice Add/Remove support `_voucher` contract for a `_membership` @dev Caller must be Owner @param _membership Address of `_membership` contract @param _vouchers A list of `_voucher` contracts @param _isAdded Boolean flag (Add = True, Remove = False) Note: `_membership` is disabled, `_voucher` list cannot be updated */ function updateVouchers(address _membership, address[] calldata _vouchers, bool _isAdded) external onlyOwner checkStatus(_membership) { uint256 _len = _vouchers.length; address _voucher; for (uint256 i; i < _len; i++) { _voucher = _vouchers[i]; if (_isAdded) vouchers[_membership].add(_voucher); else vouchers[_membership].remove(_voucher); emit Updated(_membership, _voucher, _isAdded); } } /** @notice Redeem loyalty points to voucher's value @dev Caller can be ANY @param _invoice Redeem invoice struct - membership (address) Address of Membership contract - memberId (uint256) Member id of `msg.sender` - point (uint256) Amount of point to redeem - voucher (address) Address of Voucher contract to receive a value - value (uint256) Additional value to receive after redemption - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function redeem(Redeem calldata _invoice, bytes calldata _signature) external override { address _caller = msg.sender; _precheck(_caller, _invoice.expiry, _invoice.nonce); address _loyalty = _checkMembership(_caller, _invoice.membership, _invoice.memberId); _checkRedeemInvoiceSig(_caller, _invoice, _signature); _updatePoint(_loyalty, _caller, _invoice.point, false); _validateVoucher(_invoice.membership, _invoice.voucher); _topup(_caller, _caller, _invoice.voucher, _invoice.value); } /** @notice Purchase/Topup voucher's value @dev Caller can be ANY @param _invoice Topup invoice struct - beneficiary (address) Address of Beneficiary that receives a voucher's value - membership (address) Address of Membership contract - memberId (uint256) Beneficiary's member id - voucher (address) Address of Voucher contract to receive a value - value (uint256) Additional value to receive after topup request - paymentToken (address) Address of payment token (0x00 for Native coin) - totalPayment (uint256) Total payment amount - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function topup(TopUp calldata _invoice, bytes calldata _signature) external payable { address _caller = msg.sender; _precheck(_caller, _invoice.expiry, _invoice.nonce); _checkMembership(_invoice.beneficiary, _invoice.membership, _invoice.memberId); _checkTopUpInvoiceSig(_caller, _invoice, _signature); if (_invoice.paymentToken == address(0)) require(msg.value == _invoice.totalPayment, "Invalid payment"); _makePayment(_invoice.paymentToken, _caller, _invoice.totalPayment); _validateVoucher(_invoice.membership, _invoice.voucher); _topup(_caller, _invoice.beneficiary, _invoice.voucher, _invoice.value); } /** @notice Buy loyaly points @dev Caller can be ANY @param _invoice Buy invoice struct - beneficiary (address) Address of Beneficiary that receives additional loyalty points - membership (address) Address of Membership contract - memberId (uint256) Beneficiary's member id - paymentToken (address) Address of payment token (0x00 for Native coin) - point (uint256) Additional value to receive after buy request - totalPayment (uint256) Total payment amount - nonce (uint128) Current counter of `msg.sender` - expiry (uint128) Expiring time of authorizing signature @param _signature Authorizing signature provided by Verifier */ function buy( Buy calldata _invoice, bytes calldata _signature ) external payable override { address _caller = msg.sender; _precheck(_caller, _invoice.expiry, _invoice.nonce); address _loyalty = _checkMembership(_invoice.beneficiary, _invoice.membership, _invoice.memberId); _checkBuyInvoiceSig(_caller, _invoice, _signature); if (_invoice.paymentToken == address(0)) require(msg.value == _invoice.totalPayment, "Invalid payment"); _makePayment(_invoice.paymentToken, _caller, _invoice.totalPayment); nonces[_caller]++; _updatePoint(_loyalty, _invoice.beneficiary, _invoice.point, true); } function _precheck( address _caller, uint256 _expiry, uint256 _nonce ) private view { require(block.timestamp <= _expiry, "Signature is expired"); require(_nonce == nonces[_caller], "Invalid nonce"); } function _checkMembership( address _beneficiary, address _membership, uint256 _memberId ) private view returns (address _loyalty) { _loyalty = getLoyalty(_membership); require( _loyalty != address(0) && !disabled[_membership], "Unsupport this membership type" ); require( IMembership(_membership).ownerOf(_memberId) == _beneficiary, "Beneficiary and memberId not match" ); } function _validateVoucher(address _membership, address _voucher) private view { require(vouchers[_membership].contains(_voucher), "Unsupport this voucher type"); } function _checkRedeemInvoiceSig( address _caller, Redeem calldata _invoice, bytes calldata _signature ) private view { _isAuthorizer(Signer._getSignerRedeemInvoice(_caller, _invoice, _signature)); } function _checkBuyInvoiceSig( address _caller, Buy calldata _invoice, bytes calldata _signature ) private view { _isAuthorizer(Signer._getSignerBuyInvoice(_caller, _invoice, _signature)); } function _checkTopUpInvoiceSig( address _caller, TopUp calldata _invoice, bytes calldata _signature ) private view { _isAuthorizer(Signer._getSignerTopUpInvoice(_caller, _invoice, _signature)); } function _isAuthorizer(address _signer) private view { require(verifiers[_signer], "Unauthorized signature"); } function _updatePoint(address _loyalty, address _account, uint256 _point, bool _opt) private { ILoyalty(_loyalty).updatePoint(_account, _point, _opt); } function _topup( address _caller, address _beneficiary, address _voucher, uint256 _value ) private { nonces[_caller]++; IVoucher(_voucher).updateValue(_beneficiary, _value, true); } function _makePayment(address _token, address _from, uint256 _amount) private { address _treasury = treasury; if (_token == address(0)) Address.sendValue(payable(_treasury), _amount); else IERC20(_token).safeTransferFrom(_from, _treasury, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "../interfaces/IPeriphery.sol"; contract Signer is EIP712 { using ECDSA for bytes32; bytes32 private constant _BUY = keccak256("Buy(address beneficiary,address membership,uint256 memberId,address paymentToken,uint256 point,uint256 totalPayment,uint128 nonce,uint128 expiry)"); bytes32 private constant _BUY_ACTION = keccak256("BuyAction(address caller,Buy data)"); bytes32 private constant _REDEEM = keccak256("Redeem(address membership,uint256 memberId,uint256 point,address voucher,uint256 value,uint128 nonce,uint128 expiry)"); bytes32 private constant _REDEEM_ACTION = keccak256("RedeemAction(address caller,Redeem data)"); bytes32 private constant _TOPUP = keccak256("TopUp(address beneficiary,address membership,uint256 memberId,address voucher,uint256 value,address paymentToken,uint256 totalPayment,uint128 nonce,uint128 expiry)"); bytes32 private constant _TOPUP_ACTION = keccak256("TopUpAction(address caller,TopUp data)"); constructor( string memory name, string memory version ) EIP712(name, version) {} function _getSignerRedeemInvoice( address _caller, IPeriphery.Redeem calldata _invoice, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode(_REDEEM_ACTION, _caller, _REDEEM, _invoice) ) ).recover(_signature); } function _getSignerBuyInvoice( address _caller, IPeriphery.Buy calldata _invoice, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode(_BUY_ACTION, _caller, _BUY, _invoice) ) ).recover(_signature); } function _getSignerTopUpInvoice( address _caller, IPeriphery.TopUp calldata _invoice, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode(_TOPUP_ACTION, _caller, _TOPUP, _invoice) ) ).recover(_signature); } }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_verifier","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"membership","type":"address"},{"indexed":true,"internalType":"address","name":"loyalty","type":"address"}],"name":"Disabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"membership","type":"address"},{"indexed":true,"internalType":"address","name":"loyalty","type":"address"}],"name":"Enabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"membership","type":"address"},{"indexed":true,"internalType":"address","name":"voucher","type":"address"},{"indexed":false,"internalType":"bool","name":"isAdded","type":"bool"}],"name":"Updated","type":"event"},{"inputs":[{"internalType":"address","name":"_membership","type":"address"},{"internalType":"address","name":"_loyalty","type":"address"},{"internalType":"address","name":"_voucher","type":"address"}],"name":"addPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"membership","type":"address"},{"internalType":"uint256","name":"memberId","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"point","type":"uint256"},{"internalType":"uint256","name":"totalPayment","type":"uint256"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"uint128","name":"expiry","type":"uint128"}],"internalType":"struct IPeriphery.Buy","name":"_invoice","type":"tuple"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_membership","type":"address"}],"name":"disablePair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"disabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_membership","type":"address"}],"name":"enablePair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_membership","type":"address"}],"name":"getLoyalty","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"membership","type":"address"},{"internalType":"uint256","name":"memberId","type":"uint256"},{"internalType":"uint256","name":"point","type":"uint256"},{"internalType":"address","name":"voucher","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"uint128","name":"expiry","type":"uint128"}],"internalType":"struct IPeriphery.Redeem","name":"_invoice","type":"tuple"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_verifiers","type":"address[]"},{"internalType":"bool","name":"_isAdded","type":"bool"}],"name":"setVerifiers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"address","name":"membership","type":"address"},{"internalType":"uint256","name":"memberId","type":"uint256"},{"internalType":"address","name":"voucher","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"totalPayment","type":"uint256"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"uint128","name":"expiry","type":"uint128"}],"internalType":"struct IPeriphery.TopUp","name":"_invoice","type":"tuple"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"topup","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_membership","type":"address"},{"internalType":"address[]","name":"_vouchers","type":"address[]"},{"internalType":"bool","name":"_isAdded","type":"bool"}],"name":"updateVouchers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"verifiers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101406040523480156200001257600080fd5b50604051620043fc380380620043fc83398181016040528101906200003891906200038d565b6040518060400160405280601681526020017f4d656d6265727368697020616e64204c6f79616c7479000000000000000000008152506040518060400160405280600981526020017f56657273696f6e20310000000000000000000000000000000000000000000000815250818160008280519060200120905060008280519060200120905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e081815250508161010081815250504660a081815250506200010f8184846200021b60201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff1681525050806101208181525050505050505050506200017a6200016e6200025760201b60201c565b6200025f60201b60201c565b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505062000478565b60008383834630604051602001620002389594939291906200041b565b6040516020818303038152906040528051906020012090509392505050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003558262000328565b9050919050565b620003678162000348565b81146200037357600080fd5b50565b60008151905062000387816200035c565b92915050565b60008060408385031215620003a757620003a662000323565b5b6000620003b78582860162000376565b9250506020620003ca8582860162000376565b9150509250929050565b6000819050919050565b620003e981620003d4565b82525050565b6000819050919050565b6200040481620003ef565b82525050565b620004158162000348565b82525050565b600060a082019050620004326000830188620003de565b620004416020830187620003de565b620004506040830186620003de565b6200045f6060830185620003f9565b6200046e60808301846200040a565b9695505050505050565b60805160a05160c05160e0516101005161012051613f34620004c860003960006121ad015260006121ef015260006121ce0152600061210301526000612159015260006121820152613f346000f3fe6080604052600436106100f35760003560e01c8063ab7a2c071161008a578063d2c83d8a11610059578063d2c83d8a14610319578063f1ec23cf14610335578063f2fde38b1461035e578063fbfb598714610387576100f3565b8063ab7a2c071461026e578063b27f74b314610297578063bdfea0d6146102d4578063ce36a5b8146102fd576100f3565b80636e3d9154116100c65780636e3d9154146101c6578063715018a6146101ef5780637ecebe00146102065780638da5cb5b14610243576100f3565b806309af7d86146100f857806361d027b3146101355780636bf66bc3146101605780636c82448714610189575b600080fd5b34801561010457600080fd5b5061011f600480360381019061011a919061275f565b6103b0565b60405161012c919061279b565b60405180910390f35b34801561014157600080fd5b5061014a610419565b604051610157919061279b565b60405180910390f35b34801561016c57600080fd5b5061018760048036038101906101829190612853565b61043f565b005b34801561019557600080fd5b506101b060048036038101906101ab919061275f565b610686565b6040516101bd91906128d6565b60405180910390f35b3480156101d257600080fd5b506101ed60048036038101906101e8919061275f565b6106a6565b005b3480156101fb57600080fd5b506102046107ee565b005b34801561021257600080fd5b5061022d6004803603810190610228919061275f565b610802565b60405161023a919061290a565b60405180910390f35b34801561024f57600080fd5b5061025861081a565b604051610265919061279b565b60405180910390f35b34801561027a57600080fd5b506102956004803603810190610290919061275f565b610843565b005b3480156102a357600080fd5b506102be60048036038101906102b9919061275f565b6109d8565b6040516102cb91906128d6565b60405180910390f35b3480156102e057600080fd5b506102fb60048036038101906102f69190612925565b6109f8565b005b61031760048036038101906103129190612a00565b610aab565b005b610333600480360381019061032e9190612a82565b610c5b565b005b34801561034157600080fd5b5061035c60048036038101906103579190612ae4565b610e24565b005b34801561036a57600080fd5b506103856004803603810190610380919061275f565b611116565b005b34801561039357600080fd5b506103ae60048036038101906103a99190612b56565b61119a565b005b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61044761128b565b83600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156104d75750600073ffffffffffffffffffffffffffffffffffffffff166104be826103b0565b73ffffffffffffffffffffffffffffffffffffffff1614155b610516576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050d90612c14565b60405180910390fd5b60008484905090506000805b8281101561067c5786868281811061053d5761053c612c34565b5b9050602002016020810190610552919061275f565b915084156105b1576105ab82600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061130990919063ffffffff16565b50610604565b61060282600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061133990919063ffffffff16565b505b8173ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fa3dc6f84978ec45c7aa4a93448811c5c607b9f815af61466a2bedeebdd9f72488760405161066191906128d6565b60405180910390a3808061067490612c92565b915050610522565b5050505050505050565b60056020528060005260406000206000915054906101000a900460ff1681565b6106ae61128b565b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073190612d27565b60405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff0219169055610792816103b0565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f2ef82a929ca200bcfdf95dec72ea691570ae7f78d47534fb8a60ca19da7c61f060405160405180910390a350565b6107f661128b565b6108006000611369565b565b60066020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61084b61128b565b80600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156108db5750600073ffffffffffffffffffffffffffffffffffffffff166108c2826103b0565b73ffffffffffffffffffffffffffffffffffffffff1614155b61091a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091190612c14565b60405180910390fd5b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061097b826103b0565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167ff6f1d52d1692e0af84084c6bb2e415a100c41428f61b15106c6361cbf643736760405160405180910390a35050565b60046020528060005260406000206000915054906101000a900460ff1681565b610a0061128b565b600083839050905060005b81811015610aa4578260056000878785818110610a2b57610a2a612c34565b5b9050602002016020810190610a40919061275f565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9c90612c92565b915050610a0b565b5050505050565b6000339050610b048185610100016020810190610ac89190612d8f565b6fffffffffffffffffffffffffffffffff168660e0016020810190610aed9190612d8f565b6fffffffffffffffffffffffffffffffff1661142d565b610b37846000016020810190610b1a919061275f565b856020016020810190610b2d919061275f565b86604001356114f6565b50610b44818585856116c6565b600073ffffffffffffffffffffffffffffffffffffffff168460a0016020810190610b6f919061275f565b73ffffffffffffffffffffffffffffffffffffffff161415610bd2578360c001353414610bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc890612e08565b60405180910390fd5b5b610bf38460a0016020810190610be8919061275f565b828660c001356116e0565b610c21846020016020810190610c09919061275f565b856060016020810190610c1c919061275f565b61177f565b610c5581856000016020810190610c38919061275f565b866060016020810190610c4b919061275f565b8760800135611813565b50505050565b6000339050610cb3818560e0016020810190610c779190612d8f565b6fffffffffffffffffffffffffffffffff168660c0016020810190610c9c9190612d8f565b6fffffffffffffffffffffffffffffffff1661142d565b6000610ce8856000016020810190610ccb919061275f565b866020016020810190610cde919061275f565b87604001356114f6565b9050610cf6828686866118de565b600073ffffffffffffffffffffffffffffffffffffffff16856060016020810190610d21919061275f565b73ffffffffffffffffffffffffffffffffffffffff161415610d84578460a001353414610d83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7a90612e08565b60405180910390fd5b5b610da5856060016020810190610d9a919061275f565b838760a001356116e0565b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610df590612c92565b9190505550610e1d81866000016020810190610e11919061275f565b876080013560016118f8565b5050505050565b610e2c61128b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015610e965750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ed5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ecc90612e74565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610ef6846103b0565b73ffffffffffffffffffffffffffffffffffffffff1614610f4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4390612ee0565b60405180910390fd5b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146110b75761104f81600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061130990919063ffffffff16565b508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fa3dc6f84978ec45c7aa4a93448811c5c607b9f815af61466a2bedeebdd9f724860016040516110ae91906128d6565b60405180910390a35b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f2ef82a929ca200bcfdf95dec72ea691570ae7f78d47534fb8a60ca19da7c61f060405160405180910390a3505050565b61111e61128b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561118e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118590612f72565b60405180910390fd5b61119781611369565b50565b60003390506111f2818560c00160208101906111b69190612d8f565b6fffffffffffffffffffffffffffffffff168660a00160208101906111db9190612d8f565b6fffffffffffffffffffffffffffffffff1661142d565b60006112158286600001602081019061120b919061275f565b87602001356114f6565b90506112238286868661196d565b6112348183876040013560006118f8565b61126285600001602081019061124a919061275f565b86606001602081019061125d919061275f565b61177f565b611284828387606001602081019061127a919061275f565b8860800135611813565b5050505050565b611293611987565b73ffffffffffffffffffffffffffffffffffffffff166112b161081a565b73ffffffffffffffffffffffffffffffffffffffff1614611307576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fe90612fde565b60405180910390fd5b565b6000611331836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61198f565b905092915050565b6000611361836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6119ff565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b81421115611470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114679061304a565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481146114f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e8906130b6565b60405180910390fd5b505050565b6000611501836103b0565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561158a5750600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6115c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c090613122565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16636352211e846040518263ffffffff1660e01b8152600401611619919061290a565b60206040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116699190613157565b73ffffffffffffffffffffffffffffffffffffffff16146116bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b6906131f6565b60405180910390fd5b9392505050565b6116da6116d585858585611b13565b611bea565b50505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561174b576117468183611c79565b611779565b6117788382848773ffffffffffffffffffffffffffffffffffffffff16611d6d909392919063ffffffff16565b5b50505050565b6117d081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611df690919063ffffffff16565b61180f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180690613262565b60405180910390fd5b5050565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061186390612c92565b91905055508173ffffffffffffffffffffffffffffffffffffffff16637d37eb9d848360016040518463ffffffff1660e01b81526004016118a693929190613282565b600060405180830381600087803b1580156118c057600080fd5b505af11580156118d4573d6000803e3d6000fd5b5050505050505050565b6118f26118ed85858585611e26565b611bea565b50505050565b8373ffffffffffffffffffffffffffffffffffffffff166328a013678484846040518463ffffffff1660e01b815260040161193593929190613282565b600060405180830381600087803b15801561194f57600080fd5b505af1158015611963573d6000803e3d6000fd5b5050505050505050565b61198161197c85858585611efd565b611bea565b50505050565b600033905090565b600061199b8383611fd4565b6119f45782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506119f9565b600090505b92915050565b60008083600101600084815260200190815260200160002054905060008114611b07576000600182611a3191906132b9565b9050600060018660000180549050611a4991906132b9565b9050818114611ab8576000866000018281548110611a6a57611a69612c34565b5b9060005260206000200154905080876000018481548110611a8e57611a8d612c34565b5b90600052602060002001819055508387600101600083815260200190815260200160002081905550505b85600001805480611acc57611acb6132ed565b5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611b0d565b60009150505b92915050565b6000611be083838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611bd27f6372a4b52cd32b5033940c9114477f7412f5c31138b1c9f1867cefff85412e03887f07645fc09bdfd4a87ca22cb5b77d9483e01f029e8522513b1c3a1fb7d5d6e92b89604051602001611bb794939291906134d2565b60405160208183030381529060405280519060200120611ff7565b61201190919063ffffffff16565b9050949350505050565b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611c76576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c6d90613564565b60405180910390fd5b50565b80471015611cbc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cb3906135d0565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051611ce290613621565b60006040518083038185875af1925050503d8060008114611d1f576040519150601f19603f3d011682016040523d82523d6000602084013e611d24565b606091505b5050905080611d68576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d5f906136a8565b60405180910390fd5b505050565b611df0846323b872dd60e01b858585604051602401611d8e939291906136c8565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612038565b50505050565b6000611e1e836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611fd4565b905092915050565b6000611ef383838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611ee57fc2acc2fbeb016cc967272dc9d1db0da7ee03a0aaf2c98acc1ad05957943c291d887f5466339a37ac2c50ff55d404e4b45c46f3fb2a75de6510d5da1f926bd8543e5d89604051602001611eca94939291906137e1565b60405160208183030381529060405280519060200120611ff7565b61201190919063ffffffff16565b9050949350505050565b6000611fca83838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611fbc7fe93fcdbde8d56651914e60df7729d2fda37117e071546b9ed1f8a97074d51edb887fd18120b3c7a5e5dc9787ce64e906368c973e03b3a00c2fa957bfa4703a7a348089604051602001611fa194939291906138ed565b60405160208183030381529060405280519060200120611ff7565b61201190919063ffffffff16565b9050949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b600061200a6120046120ff565b83612219565b9050919050565b6000806000612020858561224c565b9150915061202d8161229e565b819250505092915050565b600061209a826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661240c9092919063ffffffff16565b90506000815111156120fa57808060200190518101906120ba9190613948565b6120f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016120f0906139e7565b60405180910390fd5b5b505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561217b57507f000000000000000000000000000000000000000000000000000000000000000046145b156121a8577f00000000000000000000000000000000000000000000000000000000000000009050612216565b6122137f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000612424565b90505b90565b6000828260405160200161222e929190613a7f565b60405160208183030381529060405280519060200120905092915050565b60008060418351141561228e5760008060006020860151925060408601519150606086015160001a90506122828782858561245e565b94509450505050612297565b60006002915091505b9250929050565b600060048111156122b2576122b1613ab6565b5b8160048111156122c5576122c4613ab6565b5b14156122d057612409565b600160048111156122e4576122e3613ab6565b5b8160048111156122f7576122f6613ab6565b5b1415612338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161232f90613b31565b60405180910390fd5b6002600481111561234c5761234b613ab6565b5b81600481111561235f5761235e613ab6565b5b14156123a0576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239790613b9d565b60405180910390fd5b600360048111156123b4576123b3613ab6565b5b8160048111156123c7576123c6613ab6565b5b1415612408576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123ff90613c2f565b60405180910390fd5b5b50565b606061241b8484600085612541565b90509392505050565b6000838383463060405160200161243f959493929190613c4f565b6040516020818303038152906040528051906020012090509392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c1115612499576000600391509150612538565b6000600187878787604051600081526020016040526040516124be9493929190613cbe565b6020604051602081039080840390855afa1580156124e0573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561252f57600060019250925050612538565b80600092509250505b94509492505050565b606082471015612586576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161257d90613d75565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516125af9190613e04565b60006040518083038185875af1925050503d80600081146125ec576040519150601f19603f3d011682016040523d82523d6000602084013e6125f1565b606091505b50915091506126028783838761260e565b92505050949350505050565b60608315612671576000835114156126695761262985612684565b612668576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161265f90613e67565b60405180910390fd5b5b82905061267c565b61267b83836126a7565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6000825111156126ba5781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126ee9190613edc565b60405180910390fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061272c82612701565b9050919050565b61273c81612721565b811461274757600080fd5b50565b60008135905061275981612733565b92915050565b600060208284031215612775576127746126f7565b5b60006127838482850161274a565b91505092915050565b61279581612721565b82525050565b60006020820190506127b0600083018461278c565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f8401126127db576127da6127b6565b5b8235905067ffffffffffffffff8111156127f8576127f76127bb565b5b602083019150836020820283011115612814576128136127c0565b5b9250929050565b60008115159050919050565b6128308161281b565b811461283b57600080fd5b50565b60008135905061284d81612827565b92915050565b6000806000806060858703121561286d5761286c6126f7565b5b600061287b8782880161274a565b945050602085013567ffffffffffffffff81111561289c5761289b6126fc565b5b6128a8878288016127c5565b935093505060406128bb8782880161283e565b91505092959194509250565b6128d08161281b565b82525050565b60006020820190506128eb60008301846128c7565b92915050565b6000819050919050565b612904816128f1565b82525050565b600060208201905061291f60008301846128fb565b92915050565b60008060006040848603121561293e5761293d6126f7565b5b600084013567ffffffffffffffff81111561295c5761295b6126fc565b5b612968868287016127c5565b9350935050602061297b8682870161283e565b9150509250925092565b600080fd5b600061012082840312156129a1576129a0612985565b5b81905092915050565b60008083601f8401126129c0576129bf6127b6565b5b8235905067ffffffffffffffff8111156129dd576129dc6127bb565b5b6020830191508360018202830111156129f9576129f86127c0565b5b9250929050565b60008060006101408486031215612a1a57612a196126f7565b5b6000612a288682870161298a565b93505061012084013567ffffffffffffffff811115612a4a57612a496126fc565b5b612a56868287016129aa565b92509250509250925092565b60006101008284031215612a7957612a78612985565b5b81905092915050565b60008060006101208486031215612a9c57612a9b6126f7565b5b6000612aaa86828701612a62565b93505061010084013567ffffffffffffffff811115612acc57612acb6126fc565b5b612ad8868287016129aa565b92509250509250925092565b600080600060608486031215612afd57612afc6126f7565b5b6000612b0b8682870161274a565b9350506020612b1c8682870161274a565b9250506040612b2d8682870161274a565b9150509250925092565b600060e08284031215612b4d57612b4c612985565b5b81905092915050565b60008060006101008486031215612b7057612b6f6126f7565b5b6000612b7e86828701612b37565b93505060e084013567ffffffffffffffff811115612b9f57612b9e6126fc565b5b612bab868287016129aa565b92509250509250925092565b600082825260208201905092915050565b7f556e61626c6520746f2064697361626c65000000000000000000000000000000600082015250565b6000612bfe601183612bb7565b9150612c0982612bc8565b602082019050919050565b60006020820190508181036000830152612c2d81612bf1565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612c9d826128f1565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612cd057612ccf612c63565b5b600182019050919050565b7f556e61626c6520746f20656e61626c6500000000000000000000000000000000600082015250565b6000612d11601083612bb7565b9150612d1c82612cdb565b602082019050919050565b60006020820190508181036000830152612d4081612d04565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b612d6c81612d47565b8114612d7757600080fd5b50565b600081359050612d8981612d63565b92915050565b600060208284031215612da557612da46126f7565b5b6000612db384828501612d7a565b91505092915050565b7f496e76616c6964207061796d656e740000000000000000000000000000000000600082015250565b6000612df2600f83612bb7565b9150612dfd82612dbc565b602082019050919050565b60006020820190508181036000830152612e2181612de5565b9050919050565b7f5a65726f20416464726573730000000000000000000000000000000000000000600082015250565b6000612e5e600c83612bb7565b9150612e6982612e28565b602082019050919050565b60006020820190508181036000830152612e8d81612e51565b9050919050565b7f4d656d6265727368697020616c72656164792070616972656400000000000000600082015250565b6000612eca601983612bb7565b9150612ed582612e94565b602082019050919050565b60006020820190508181036000830152612ef981612ebd565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612f5c602683612bb7565b9150612f6782612f00565b604082019050919050565b60006020820190508181036000830152612f8b81612f4f565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612fc8602083612bb7565b9150612fd382612f92565b602082019050919050565b60006020820190508181036000830152612ff781612fbb565b9050919050565b7f5369676e61747572652069732065787069726564000000000000000000000000600082015250565b6000613034601483612bb7565b915061303f82612ffe565b602082019050919050565b6000602082019050818103600083015261306381613027565b9050919050565b7f496e76616c6964206e6f6e636500000000000000000000000000000000000000600082015250565b60006130a0600d83612bb7565b91506130ab8261306a565b602082019050919050565b600060208201905081810360008301526130cf81613093565b9050919050565b7f556e737570706f72742074686973206d656d6265727368697020747970650000600082015250565b600061310c601e83612bb7565b9150613117826130d6565b602082019050919050565b6000602082019050818103600083015261313b816130ff565b9050919050565b60008151905061315181612733565b92915050565b60006020828403121561316d5761316c6126f7565b5b600061317b84828501613142565b91505092915050565b7f42656e656669636961727920616e64206d656d6265724964206e6f74206d617460008201527f6368000000000000000000000000000000000000000000000000000000000000602082015250565b60006131e0602283612bb7565b91506131eb82613184565b604082019050919050565b6000602082019050818103600083015261320f816131d3565b9050919050565b7f556e737570706f7274207468697320766f756368657220747970650000000000600082015250565b600061324c601b83612bb7565b915061325782613216565b602082019050919050565b6000602082019050818103600083015261327b8161323f565b9050919050565b6000606082019050613297600083018661278c565b6132a460208301856128fb565b6132b160408301846128c7565b949350505050565b60006132c4826128f1565b91506132cf836128f1565b9250828210156132e2576132e1612c63565b5b828203905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000819050919050565b61332f8161331c565b82525050565b6000613344602084018461274a565b905092915050565b61335581612721565b82525050565b613364816128f1565b811461336f57600080fd5b50565b6000813590506133818161335b565b92915050565b60006133966020840184613372565b905092915050565b6133a7816128f1565b82525050565b60006133bc6020840184612d7a565b905092915050565b6133cd81612d47565b82525050565b61012082016133e56000830183613335565b6133f2600085018261334c565b506134006020830183613335565b61340d602085018261334c565b5061341b6040830183613387565b613428604085018261339e565b506134366060830183613335565b613443606085018261334c565b506134516080830183613387565b61345e608085018261339e565b5061346c60a0830183613335565b61347960a085018261334c565b5061348760c0830183613387565b61349460c085018261339e565b506134a260e08301836133ad565b6134af60e08501826133c4565b506134be6101008301836133ad565b6134cc6101008501826133c4565b50505050565b6000610180820190506134e86000830187613326565b6134f5602083018661278c565b6135026040830185613326565b61350f60608301846133d3565b95945050505050565b7f556e617574686f72697a6564207369676e617475726500000000000000000000600082015250565b600061354e601683612bb7565b915061355982613518565b602082019050919050565b6000602082019050818103600083015261357d81613541565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b60006135ba601d83612bb7565b91506135c582613584565b602082019050919050565b600060208201905081810360008301526135e9816135ad565b9050919050565b600081905092915050565b50565b600061360b6000836135f0565b9150613616826135fb565b600082019050919050565b600061362c826135fe565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b6000613692603a83612bb7565b915061369d82613636565b604082019050919050565b600060208201905081810360008301526136c181613685565b9050919050565b60006060820190506136dd600083018661278c565b6136ea602083018561278c565b6136f760408301846128fb565b949350505050565b61010082016137116000830183613335565b61371e600085018261334c565b5061372c6020830183613335565b613739602085018261334c565b506137476040830183613387565b613754604085018261339e565b506137626060830183613335565b61376f606085018261334c565b5061377d6080830183613387565b61378a608085018261339e565b5061379860a0830183613387565b6137a560a085018261339e565b506137b360c08301836133ad565b6137c060c08501826133c4565b506137ce60e08301836133ad565b6137db60e08501826133c4565b50505050565b6000610160820190506137f76000830187613326565b613804602083018661278c565b6138116040830185613326565b61381e60608301846136ff565b95945050505050565b60e082016138386000830183613335565b613845600085018261334c565b506138536020830183613387565b613860602085018261339e565b5061386e6040830183613387565b61387b604085018261339e565b506138896060830183613335565b613896606085018261334c565b506138a46080830183613387565b6138b1608085018261339e565b506138bf60a08301836133ad565b6138cc60a08501826133c4565b506138da60c08301836133ad565b6138e760c08501826133c4565b50505050565b6000610140820190506139036000830187613326565b613910602083018661278c565b61391d6040830185613326565b61392a6060830184613827565b95945050505050565b60008151905061394281612827565b92915050565b60006020828403121561395e5761395d6126f7565b5b600061396c84828501613933565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b60006139d1602a83612bb7565b91506139dc82613975565b604082019050919050565b60006020820190508181036000830152613a00816139c4565b9050919050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b6000613a48600283613a07565b9150613a5382613a12565b600282019050919050565b6000819050919050565b613a79613a748261331c565b613a5e565b82525050565b6000613a8a82613a3b565b9150613a968285613a68565b602082019150613aa68284613a68565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000613b1b601883612bb7565b9150613b2682613ae5565b602082019050919050565b60006020820190508181036000830152613b4a81613b0e565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000613b87601f83612bb7565b9150613b9282613b51565b602082019050919050565b60006020820190508181036000830152613bb681613b7a565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000613c19602283612bb7565b9150613c2482613bbd565b604082019050919050565b60006020820190508181036000830152613c4881613c0c565b9050919050565b600060a082019050613c646000830188613326565b613c716020830187613326565b613c7e6040830186613326565b613c8b60608301856128fb565b613c98608083018461278c565b9695505050505050565b600060ff82169050919050565b613cb881613ca2565b82525050565b6000608082019050613cd36000830187613326565b613ce06020830186613caf565b613ced6040830185613326565b613cfa6060830184613326565b95945050505050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613d5f602683612bb7565b9150613d6a82613d03565b604082019050919050565b60006020820190508181036000830152613d8e81613d52565b9050919050565b600081519050919050565b60005b83811015613dbe578082015181840152602081019050613da3565b83811115613dcd576000848401525b50505050565b6000613dde82613d95565b613de881856135f0565b9350613df8818560208601613da0565b80840191505092915050565b6000613e108284613dd3565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613e51601d83612bb7565b9150613e5c82613e1b565b602082019050919050565b60006020820190508181036000830152613e8081613e44565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613eae82613e87565b613eb88185612bb7565b9350613ec8818560208601613da0565b613ed181613e92565b840191505092915050565b60006020820190508181036000830152613ef68184613ea3565b90509291505056fea2646970667358221220814969d6ff803afc0a36f36b16bce002caafe5ad8fcf86c099ab123c47187b4d64736f6c6343000809003300000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f301500000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f301500000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
-----Decoded View---------------
Arg [0] : _treasury (address): 0x31003c2d5685c7d28d7174c3255307eb9a0f3015
Arg [1] : _verifier (address): 0x31003c2d5685c7d28d7174c3255307eb9a0f3015
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 00000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
Arg [1] : 00000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|