Contract Overview
Balance:
0 BTT
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x6eac2debab6b6722a0e6c1a7ce4d9f076e360b56d5223f1acad0516528f6501a | Add Pair | 14929313 | 74 days 9 hrs ago | 0x31003c2d5685c7d28d7174c3255307eb9a0f3015 | IN | 0x1913d37fca2119c9b23375604187bec90018ff6f | 0 BTT | 35.5752 | |
0x997784945200d712e65b99d163f189916adf0063736bda3fdfd3035fd691a376 | 0x61014060 | 14928313 | 74 days 10 hrs ago | 0x31003c2d5685c7d28d7174c3255307eb9a0f3015 | IN | Create: Periphery | 0 BTT | 1,076.5593 |
[ 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("BuyAction(address caller,Buy data)"); bytes32 private constant _REDEEM = keccak256("RedeemAction(address caller,Redeem data)"); bytes32 private constant _TOPUP = keccak256("TopUpAction(address caller,TopUp data)"); constructor( string memory name, string memory version ) EIP712(name, version) {} function _getSignerRedeemInvoice( address _caller, IPeriphery.Redeem calldata _redeem, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode(_REDEEM, _caller,_redeem) ) ).recover(_signature); } function _getSignerBuyInvoice( address _caller, IPeriphery.Buy calldata _invoice, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode(_BUY, _caller, _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, _caller, _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
6101406040523480156200001257600080fd5b506040516200436c3803806200436c83398181016040528101906200003891906200038d565b6040518060400160405280601681526020017f4d656d6265727368697020616e64204c6f79616c7479000000000000000000008152506040518060400160405280600981526020017f56657273696f6e20310000000000000000000000000000000000000000000000815250818160008280519060200120905060008280519060200120905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e081815250508161010081815250504660a081815250506200010f8184846200021b60201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff1681525050806101208181525050505050505050506200017a6200016e6200025760201b60201c565b6200025f60201b60201c565b81600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001600560008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550505062000478565b60008383834630604051602001620002389594939291906200041b565b6040516020818303038152906040528051906020012090509392505050565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003558262000328565b9050919050565b620003678162000348565b81146200037357600080fd5b50565b60008151905062000387816200035c565b92915050565b60008060408385031215620003a757620003a662000323565b5b6000620003b78582860162000376565b9250506020620003ca8582860162000376565b9150509250929050565b6000819050919050565b620003e981620003d4565b82525050565b6000819050919050565b6200040481620003ef565b82525050565b620004158162000348565b82525050565b600060a082019050620004326000830188620003de565b620004416020830187620003de565b620004506040830186620003de565b6200045f6060830185620003f9565b6200046e60808301846200040a565b9695505050505050565b60805160a05160c05160e0516101005161012051613ea4620004c8600039600061214701526000612189015260006121680152600061209d015260006120f30152600061211c0152613ea46000f3fe6080604052600436106100f35760003560e01c8063ab7a2c071161008a578063d2c83d8a11610059578063d2c83d8a14610319578063f1ec23cf14610335578063f2fde38b1461035e578063fbfb598714610387576100f3565b8063ab7a2c071461026e578063b27f74b314610297578063bdfea0d6146102d4578063ce36a5b8146102fd576100f3565b80636e3d9154116100c65780636e3d9154146101c6578063715018a6146101ef5780637ecebe00146102065780638da5cb5b14610243576100f3565b806309af7d86146100f857806361d027b3146101355780636bf66bc3146101605780636c82448714610189575b600080fd5b34801561010457600080fd5b5061011f600480360381019061011a91906126f9565b6103b0565b60405161012c9190612735565b60405180910390f35b34801561014157600080fd5b5061014a610419565b6040516101579190612735565b60405180910390f35b34801561016c57600080fd5b50610187600480360381019061018291906127ed565b61043f565b005b34801561019557600080fd5b506101b060048036038101906101ab91906126f9565b610686565b6040516101bd9190612870565b60405180910390f35b3480156101d257600080fd5b506101ed60048036038101906101e891906126f9565b6106a6565b005b3480156101fb57600080fd5b506102046107ee565b005b34801561021257600080fd5b5061022d600480360381019061022891906126f9565b610802565b60405161023a91906128a4565b60405180910390f35b34801561024f57600080fd5b5061025861081a565b6040516102659190612735565b60405180910390f35b34801561027a57600080fd5b50610295600480360381019061029091906126f9565b610843565b005b3480156102a357600080fd5b506102be60048036038101906102b991906126f9565b6109d8565b6040516102cb9190612870565b60405180910390f35b3480156102e057600080fd5b506102fb60048036038101906102f691906128bf565b6109f8565b005b6103176004803603810190610312919061299a565b610aab565b005b610333600480360381019061032e9190612a1c565b610c5b565b005b34801561034157600080fd5b5061035c60048036038101906103579190612a7e565b610e24565b005b34801561036a57600080fd5b50610385600480360381019061038091906126f9565b611116565b005b34801561039357600080fd5b506103ae60048036038101906103a99190612af0565b61119a565b005b6000600260008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61044761128b565b83600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156104d75750600073ffffffffffffffffffffffffffffffffffffffff166104be826103b0565b73ffffffffffffffffffffffffffffffffffffffff1614155b610516576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161050d90612bae565b60405180910390fd5b60008484905090506000805b8281101561067c5786868281811061053d5761053c612bce565b5b905060200201602081019061055291906126f9565b915084156105b1576105ab82600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061130990919063ffffffff16565b50610604565b61060282600360008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061133990919063ffffffff16565b505b8173ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff167fa3dc6f84978ec45c7aa4a93448811c5c607b9f815af61466a2bedeebdd9f7248876040516106619190612870565b60405180910390a3808061067490612c2c565b915050610522565b5050505050505050565b60056020528060005260406000206000915054906101000a900460ff1681565b6106ae61128b565b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1661073a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161073190612cc1565b60405180910390fd5b600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81549060ff0219169055610792816103b0565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f2ef82a929ca200bcfdf95dec72ea691570ae7f78d47534fb8a60ca19da7c61f060405160405180910390a350565b6107f661128b565b6108006000611369565b565b60066020528060005260406000206000915090505481565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61084b61128b565b80600460008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161580156108db5750600073ffffffffffffffffffffffffffffffffffffffff166108c2826103b0565b73ffffffffffffffffffffffffffffffffffffffff1614155b61091a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161091190612bae565b60405180910390fd5b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061097b826103b0565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167ff6f1d52d1692e0af84084c6bb2e415a100c41428f61b15106c6361cbf643736760405160405180910390a35050565b60046020528060005260406000206000915054906101000a900460ff1681565b610a0061128b565b600083839050905060005b81811015610aa4578260056000878785818110610a2b57610a2a612bce565b5b9050602002016020810190610a4091906126f9565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080610a9c90612c2c565b915050610a0b565b5050505050565b6000339050610b048185610100016020810190610ac89190612d29565b6fffffffffffffffffffffffffffffffff168660e0016020810190610aed9190612d29565b6fffffffffffffffffffffffffffffffff1661142d565b610b37846000016020810190610b1a91906126f9565b856020016020810190610b2d91906126f9565b86604001356114f6565b50610b44818585856116c6565b600073ffffffffffffffffffffffffffffffffffffffff168460a0016020810190610b6f91906126f9565b73ffffffffffffffffffffffffffffffffffffffff161415610bd2578360c001353414610bd1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bc890612da2565b60405180910390fd5b5b610bf38460a0016020810190610be891906126f9565b828660c001356116e0565b610c21846020016020810190610c0991906126f9565b856060016020810190610c1c91906126f9565b61177f565b610c5581856000016020810190610c3891906126f9565b866060016020810190610c4b91906126f9565b8760800135611813565b50505050565b6000339050610cb3818560e0016020810190610c779190612d29565b6fffffffffffffffffffffffffffffffff168660c0016020810190610c9c9190612d29565b6fffffffffffffffffffffffffffffffff1661142d565b6000610ce8856000016020810190610ccb91906126f9565b866020016020810190610cde91906126f9565b87604001356114f6565b9050610cf6828686866118de565b600073ffffffffffffffffffffffffffffffffffffffff16856060016020810190610d2191906126f9565b73ffffffffffffffffffffffffffffffffffffffff161415610d84578460a001353414610d83576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d7a90612da2565b60405180910390fd5b5b610da5856060016020810190610d9a91906126f9565b838760a001356116e0565b600660008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610df590612c2c565b9190505550610e1d81866000016020810190610e1191906126f9565b876080013560016118f8565b5050505050565b610e2c61128b565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1614158015610e965750600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1614155b610ed5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ecc90612e0e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16610ef6846103b0565b73ffffffffffffffffffffffffffffffffffffffff1614610f4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f4390612e7a565b60405180910390fd5b81600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146110b75761104f81600360008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002061130990919063ffffffff16565b508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fa3dc6f84978ec45c7aa4a93448811c5c607b9f815af61466a2bedeebdd9f724860016040516110ae9190612870565b60405180910390a35b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f2ef82a929ca200bcfdf95dec72ea691570ae7f78d47534fb8a60ca19da7c61f060405160405180910390a3505050565b61111e61128b565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561118e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161118590612f0c565b60405180910390fd5b61119781611369565b50565b60003390506111f2818560c00160208101906111b69190612d29565b6fffffffffffffffffffffffffffffffff168660a00160208101906111db9190612d29565b6fffffffffffffffffffffffffffffffff1661142d565b60006112158286600001602081019061120b91906126f9565b87602001356114f6565b90506112238286868661196d565b6112348183876040013560006118f8565b61126285600001602081019061124a91906126f9565b86606001602081019061125d91906126f9565b61177f565b611284828387606001602081019061127a91906126f9565b8860800135611813565b5050505050565b611293611987565b73ffffffffffffffffffffffffffffffffffffffff166112b161081a565b73ffffffffffffffffffffffffffffffffffffffff1614611307576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112fe90612f78565b60405180910390fd5b565b6000611331836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61198f565b905092915050565b6000611361836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6119ff565b905092915050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b81421115611470576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146790612fe4565b60405180910390fd5b600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205481146114f1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e890613050565b60405180910390fd5b505050565b6000611501836103b0565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415801561158a5750600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16155b6115c9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115c0906130bc565b60405180910390fd5b8373ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16636352211e846040518263ffffffff1660e01b815260040161161991906128a4565b60206040518083038186803b15801561163157600080fd5b505afa158015611645573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166991906130f1565b73ffffffffffffffffffffffffffffffffffffffff16146116bf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116b690613190565b60405180910390fd5b9392505050565b6116da6116d585858585611b13565b611bc8565b50505050565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff16141561174b576117468183611c57565b611779565b6117788382848773ffffffffffffffffffffffffffffffffffffffff16611d4b909392919063ffffffff16565b5b50505050565b6117d081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020611dd490919063ffffffff16565b61180f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611806906131fc565b60405180910390fd5b5050565b600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061186390612c2c565b91905055508173ffffffffffffffffffffffffffffffffffffffff16637d37eb9d848360016040518463ffffffff1660e01b81526004016118a69392919061321c565b600060405180830381600087803b1580156118c057600080fd5b505af11580156118d4573d6000803e3d6000fd5b5050505050505050565b6118f26118ed85858585611e04565b611bc8565b50505050565b8373ffffffffffffffffffffffffffffffffffffffff166328a013678484846040518463ffffffff1660e01b81526004016119359392919061321c565b600060405180830381600087803b15801561194f57600080fd5b505af1158015611963573d6000803e3d6000fd5b5050505050505050565b61198161197c85858585611eb9565b611bc8565b50505050565b600033905090565b600061199b8383611f6e565b6119f45782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506119f9565b600090505b92915050565b60008083600101600084815260200190815260200160002054905060008114611b07576000600182611a319190613253565b9050600060018660000180549050611a499190613253565b9050818114611ab8576000866000018281548110611a6a57611a69612bce565b5b9060005260206000200154905080876000018481548110611a8e57611a8d612bce565b5b90600052602060002001819055508387600101600083815260200190815260200160002081905550505b85600001805480611acc57611acb613287565b5b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050611b0d565b60009150505b92915050565b6000611bbe83838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611bb07f6372a4b52cd32b5033940c9114477f7412f5c31138b1c9f1867cefff85412e038888604051602001611b959392919061346c565b60405160208183030381529060405280519060200120611f91565b611fab90919063ffffffff16565b9050949350505050565b600560008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611c54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c4b906134f0565b60405180910390fd5b50565b80471015611c9a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c919061355c565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff1682604051611cc0906135ad565b60006040518083038185875af1925050503d8060008114611cfd576040519150601f19603f3d011682016040523d82523d6000602084013e611d02565b606091505b5050905080611d46576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d3d90613634565b60405180910390fd5b505050565b611dce846323b872dd60e01b858585604051602401611d6c93929190613654565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611fd2565b50505050565b6000611dfc836000018373ffffffffffffffffffffffffffffffffffffffff1660001b611f6e565b905092915050565b6000611eaf83838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611ea17fc2acc2fbeb016cc967272dc9d1db0da7ee03a0aaf2c98acc1ad05957943c291d8888604051602001611e869392919061376d565b60405160208183030381529060405280519060200120611f91565b611fab90919063ffffffff16565b9050949350505050565b6000611f6483838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611f567fe93fcdbde8d56651914e60df7729d2fda37117e071546b9ed1f8a97074d51edb8888604051602001611f3b9392919061386b565b60405160208183030381529060405280519060200120611f91565b611fab90919063ffffffff16565b9050949350505050565b600080836001016000848152602001908152602001600020541415905092915050565b6000611fa4611f9e612099565b836121b3565b9050919050565b6000806000611fba85856121e6565b91509150611fc781612238565b819250505092915050565b6000612034826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166123a69092919063ffffffff16565b9050600081511115612094578080602001905181019061205491906138b8565b612093576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161208a90613957565b60405180910390fd5b5b505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561211557507f000000000000000000000000000000000000000000000000000000000000000046145b15612142577f000000000000000000000000000000000000000000000000000000000000000090506121b0565b6121ad7f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000006123be565b90505b90565b600082826040516020016121c89291906139ef565b60405160208183030381529060405280519060200120905092915050565b6000806041835114156122285760008060006020860151925060408601519150606086015160001a905061221c878285856123f8565b94509450505050612231565b60006002915091505b9250929050565b6000600481111561224c5761224b613a26565b5b81600481111561225f5761225e613a26565b5b141561226a576123a3565b6001600481111561227e5761227d613a26565b5b81600481111561229157612290613a26565b5b14156122d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122c990613aa1565b60405180910390fd5b600260048111156122e6576122e5613a26565b5b8160048111156122f9576122f8613a26565b5b141561233a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161233190613b0d565b60405180910390fd5b6003600481111561234e5761234d613a26565b5b81600481111561236157612360613a26565b5b14156123a2576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161239990613b9f565b60405180910390fd5b5b50565b60606123b584846000856124db565b90509392505050565b600083838346306040516020016123d9959493929190613bbf565b6040516020818303038152906040528051906020012090509392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c11156124335760006003915091506124d2565b6000600187878787604051600081526020016040526040516124589493929190613c2e565b6020604051602081039080840390855afa15801561247a573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156124c9576000600192509250506124d2565b80600092509250505b94509492505050565b606082471015612520576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161251790613ce5565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff1685876040516125499190613d74565b60006040518083038185875af1925050503d8060008114612586576040519150601f19603f3d011682016040523d82523d6000602084013e61258b565b606091505b509150915061259c878383876125a8565b92505050949350505050565b6060831561260b57600083511415612603576125c38561261e565b612602576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125f990613dd7565b60405180910390fd5b5b829050612616565b6126158383612641565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6000825111156126545781518083602001fd5b806040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016126889190613e4c565b60405180910390fd5b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006126c68261269b565b9050919050565b6126d6816126bb565b81146126e157600080fd5b50565b6000813590506126f3816126cd565b92915050565b60006020828403121561270f5761270e612691565b5b600061271d848285016126e4565b91505092915050565b61272f816126bb565b82525050565b600060208201905061274a6000830184612726565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f84011261277557612774612750565b5b8235905067ffffffffffffffff81111561279257612791612755565b5b6020830191508360208202830111156127ae576127ad61275a565b5b9250929050565b60008115159050919050565b6127ca816127b5565b81146127d557600080fd5b50565b6000813590506127e7816127c1565b92915050565b6000806000806060858703121561280757612806612691565b5b6000612815878288016126e4565b945050602085013567ffffffffffffffff81111561283657612835612696565b5b6128428782880161275f565b93509350506040612855878288016127d8565b91505092959194509250565b61286a816127b5565b82525050565b60006020820190506128856000830184612861565b92915050565b6000819050919050565b61289e8161288b565b82525050565b60006020820190506128b96000830184612895565b92915050565b6000806000604084860312156128d8576128d7612691565b5b600084013567ffffffffffffffff8111156128f6576128f5612696565b5b6129028682870161275f565b93509350506020612915868287016127d8565b9150509250925092565b600080fd5b6000610120828403121561293b5761293a61291f565b5b81905092915050565b60008083601f84011261295a57612959612750565b5b8235905067ffffffffffffffff81111561297757612976612755565b5b6020830191508360018202830111156129935761299261275a565b5b9250929050565b600080600061014084860312156129b4576129b3612691565b5b60006129c286828701612924565b93505061012084013567ffffffffffffffff8111156129e4576129e3612696565b5b6129f086828701612944565b92509250509250925092565b60006101008284031215612a1357612a1261291f565b5b81905092915050565b60008060006101208486031215612a3657612a35612691565b5b6000612a44868287016129fc565b93505061010084013567ffffffffffffffff811115612a6657612a65612696565b5b612a7286828701612944565b92509250509250925092565b600080600060608486031215612a9757612a96612691565b5b6000612aa5868287016126e4565b9350506020612ab6868287016126e4565b9250506040612ac7868287016126e4565b9150509250925092565b600060e08284031215612ae757612ae661291f565b5b81905092915050565b60008060006101008486031215612b0a57612b09612691565b5b6000612b1886828701612ad1565b93505060e084013567ffffffffffffffff811115612b3957612b38612696565b5b612b4586828701612944565b92509250509250925092565b600082825260208201905092915050565b7f556e61626c6520746f2064697361626c65000000000000000000000000000000600082015250565b6000612b98601183612b51565b9150612ba382612b62565b602082019050919050565b60006020820190508181036000830152612bc781612b8b565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000612c378261288b565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415612c6a57612c69612bfd565b5b600182019050919050565b7f556e61626c6520746f20656e61626c6500000000000000000000000000000000600082015250565b6000612cab601083612b51565b9150612cb682612c75565b602082019050919050565b60006020820190508181036000830152612cda81612c9e565b9050919050565b60006fffffffffffffffffffffffffffffffff82169050919050565b612d0681612ce1565b8114612d1157600080fd5b50565b600081359050612d2381612cfd565b92915050565b600060208284031215612d3f57612d3e612691565b5b6000612d4d84828501612d14565b91505092915050565b7f496e76616c6964207061796d656e740000000000000000000000000000000000600082015250565b6000612d8c600f83612b51565b9150612d9782612d56565b602082019050919050565b60006020820190508181036000830152612dbb81612d7f565b9050919050565b7f5a65726f20416464726573730000000000000000000000000000000000000000600082015250565b6000612df8600c83612b51565b9150612e0382612dc2565b602082019050919050565b60006020820190508181036000830152612e2781612deb565b9050919050565b7f4d656d6265727368697020616c72656164792070616972656400000000000000600082015250565b6000612e64601983612b51565b9150612e6f82612e2e565b602082019050919050565b60006020820190508181036000830152612e9381612e57565b9050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000612ef6602683612b51565b9150612f0182612e9a565b604082019050919050565b60006020820190508181036000830152612f2581612ee9565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000612f62602083612b51565b9150612f6d82612f2c565b602082019050919050565b60006020820190508181036000830152612f9181612f55565b9050919050565b7f5369676e61747572652069732065787069726564000000000000000000000000600082015250565b6000612fce601483612b51565b9150612fd982612f98565b602082019050919050565b60006020820190508181036000830152612ffd81612fc1565b9050919050565b7f496e76616c6964206e6f6e636500000000000000000000000000000000000000600082015250565b600061303a600d83612b51565b915061304582613004565b602082019050919050565b600060208201905081810360008301526130698161302d565b9050919050565b7f556e737570706f72742074686973206d656d6265727368697020747970650000600082015250565b60006130a6601e83612b51565b91506130b182613070565b602082019050919050565b600060208201905081810360008301526130d581613099565b9050919050565b6000815190506130eb816126cd565b92915050565b60006020828403121561310757613106612691565b5b6000613115848285016130dc565b91505092915050565b7f42656e656669636961727920616e64206d656d6265724964206e6f74206d617460008201527f6368000000000000000000000000000000000000000000000000000000000000602082015250565b600061317a602283612b51565b91506131858261311e565b604082019050919050565b600060208201905081810360008301526131a98161316d565b9050919050565b7f556e737570706f7274207468697320766f756368657220747970650000000000600082015250565b60006131e6601b83612b51565b91506131f1826131b0565b602082019050919050565b60006020820190508181036000830152613215816131d9565b9050919050565b60006060820190506132316000830186612726565b61323e6020830185612895565b61324b6040830184612861565b949350505050565b600061325e8261288b565b91506132698361288b565b92508282101561327c5761327b612bfd565b5b828203905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b6000819050919050565b6132c9816132b6565b82525050565b60006132de60208401846126e4565b905092915050565b6132ef816126bb565b82525050565b6132fe8161288b565b811461330957600080fd5b50565b60008135905061331b816132f5565b92915050565b6000613330602084018461330c565b905092915050565b6133418161288b565b82525050565b60006133566020840184612d14565b905092915050565b61336781612ce1565b82525050565b610120820161337f60008301836132cf565b61338c60008501826132e6565b5061339a60208301836132cf565b6133a760208501826132e6565b506133b56040830183613321565b6133c26040850182613338565b506133d060608301836132cf565b6133dd60608501826132e6565b506133eb6080830183613321565b6133f86080850182613338565b5061340660a08301836132cf565b61341360a08501826132e6565b5061342160c0830183613321565b61342e60c0850182613338565b5061343c60e0830183613347565b61344960e085018261335e565b50613458610100830183613347565b61346661010085018261335e565b50505050565b60006101608201905061348260008301866132c0565b61348f6020830185612726565b61349c604083018461336d565b949350505050565b7f556e617574686f72697a6564207369676e617475726500000000000000000000600082015250565b60006134da601683612b51565b91506134e5826134a4565b602082019050919050565b60006020820190508181036000830152613509816134cd565b9050919050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b6000613546601d83612b51565b915061355182613510565b602082019050919050565b6000602082019050818103600083015261357581613539565b9050919050565b600081905092915050565b50565b600061359760008361357c565b91506135a282613587565b600082019050919050565b60006135b88261358a565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b600061361e603a83612b51565b9150613629826135c2565b604082019050919050565b6000602082019050818103600083015261364d81613611565b9050919050565b60006060820190506136696000830186612726565b6136766020830185612726565b6136836040830184612895565b949350505050565b610100820161369d60008301836132cf565b6136aa60008501826132e6565b506136b860208301836132cf565b6136c560208501826132e6565b506136d36040830183613321565b6136e06040850182613338565b506136ee60608301836132cf565b6136fb60608501826132e6565b506137096080830183613321565b6137166080850182613338565b5061372460a0830183613321565b61373160a0850182613338565b5061373f60c0830183613347565b61374c60c085018261335e565b5061375a60e0830183613347565b61376760e085018261335e565b50505050565b60006101408201905061378360008301866132c0565b6137906020830185612726565b61379d604083018461368b565b949350505050565b60e082016137b660008301836132cf565b6137c360008501826132e6565b506137d16020830183613321565b6137de6020850182613338565b506137ec6040830183613321565b6137f96040850182613338565b5061380760608301836132cf565b61381460608501826132e6565b506138226080830183613321565b61382f6080850182613338565b5061383d60a0830183613347565b61384a60a085018261335e565b5061385860c0830183613347565b61386560c085018261335e565b50505050565b60006101208201905061388160008301866132c0565b61388e6020830185612726565b61389b60408301846137a5565b949350505050565b6000815190506138b2816127c1565b92915050565b6000602082840312156138ce576138cd612691565b5b60006138dc848285016138a3565b91505092915050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b6000613941602a83612b51565b915061394c826138e5565b604082019050919050565b6000602082019050818103600083015261397081613934565b9050919050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b60006139b8600283613977565b91506139c382613982565b600282019050919050565b6000819050919050565b6139e96139e4826132b6565b6139ce565b82525050565b60006139fa826139ab565b9150613a0682856139d8565b602082019150613a1682846139d8565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000613a8b601883612b51565b9150613a9682613a55565b602082019050919050565b60006020820190508181036000830152613aba81613a7e565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000613af7601f83612b51565b9150613b0282613ac1565b602082019050919050565b60006020820190508181036000830152613b2681613aea565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000613b89602283612b51565b9150613b9482613b2d565b604082019050919050565b60006020820190508181036000830152613bb881613b7c565b9050919050565b600060a082019050613bd460008301886132c0565b613be160208301876132c0565b613bee60408301866132c0565b613bfb6060830185612895565b613c086080830184612726565b9695505050505050565b600060ff82169050919050565b613c2881613c12565b82525050565b6000608082019050613c4360008301876132c0565b613c506020830186613c1f565b613c5d60408301856132c0565b613c6a60608301846132c0565b95945050505050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000613ccf602683612b51565b9150613cda82613c73565b604082019050919050565b60006020820190508181036000830152613cfe81613cc2565b9050919050565b600081519050919050565b60005b83811015613d2e578082015181840152602081019050613d13565b83811115613d3d576000848401525b50505050565b6000613d4e82613d05565b613d58818561357c565b9350613d68818560208601613d10565b80840191505092915050565b6000613d808284613d43565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000613dc1601d83612b51565b9150613dcc82613d8b565b602082019050919050565b60006020820190508181036000830152613df081613db4565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000613e1e82613df7565b613e288185612b51565b9350613e38818560208601613d10565b613e4181613e02565b840191505092915050565b60006020820190508181036000830152613e668184613e13565b90509291505056fea2646970667358221220c2f51e085da2536cffbbdb258d7ffe2602644bd70607618e685875a97887890e64736f6c6343000809003300000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f301500000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
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 |
---|