Contract Overview
Balance:
0 BTT
My Name Tag:
Not Available
Txn Hash | Method |
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0x0d67fc0d15e2d882d3323fbbc5fc9be492c688d7cff82ec71bac9f8e74aa3364 | 0x61018060 | 14842208 | 76 days 10 hrs ago | 0x31003c2d5685c7d28d7174c3255307eb9a0f3015 | IN | Create: Periphery | 0 BTT | 811.0008 |
[ 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 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 (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 pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import "@openzeppelin/contracts/token/ERC721/IERC721.sol"; /** * @title ERC-3525 Semi-Fungible Token Standard * @dev See https://eips.ethereum.org/EIPS/eip-3525 * Note: the ERC-165 identifier for this interface is 0xc97ae3d5. */ interface IERC3525 is IERC165, IERC721 { /** * @dev MUST emit when value of a token is transferred to another token with the same slot, * including zero value transfers (_value == 0) as well as transfers when tokens are created * (`_fromTokenId` == 0) or destroyed (`_toTokenId` == 0). * @param _fromTokenId The token id to transfer value from * @param _toTokenId The token id to transfer value to * @param _value The transferred value */ event TransferValue( uint256 indexed _fromTokenId, uint256 indexed _toTokenId, uint256 _value ); /** * @dev MUST emits when the approval value of a token is set or changed. * @param _tokenId The token to approve * @param _operator The operator to approve for * @param _value The maximum value that `_operator` is allowed to manage */ event ApprovalValue( uint256 indexed _tokenId, address indexed _operator, uint256 _value ); /** * @dev MUST emit when the slot of a token is set or changed. * @param _tokenId The token of which slot is set or changed * @param _oldSlot The previous slot of the token * @param _newSlot The updated slot of the token */ event SlotChanged( uint256 indexed _tokenId, uint256 indexed _oldSlot, uint256 indexed _newSlot ); /** * @notice Get the number of decimals the token uses for value - e.g. 6, means the user * representation of the value of a token can be calculated by dividing it by 1,000,000. * Considering the compatibility with third-party wallets, this function is defined as * `valueDecimals()` instead of `decimals()` to avoid conflict with ERC20 tokens. * @return The number of decimals for value */ function valueDecimals() external view returns (uint8); /** * @notice Get the value of a token. * @param _tokenId The token for which to query the balance * @return The value of `_tokenId` */ function balanceOf(uint256 _tokenId) external view returns (uint256); /** * @notice Get the slot of a token. * @param _tokenId The identifier for a token * @return The slot of the token */ function slotOf(uint256 _tokenId) external view returns (uint256); /** * @notice Allow an operator to manage the value of a token, up to the `_value` amount. * @dev MUST revert unless caller is the current owner, an authorized operator, or the approved * address for `_tokenId`. * MUST emit ApprovalValue event. * @param _tokenId The token to approve * @param _operator The operator to be approved * @param _value The maximum value of `_toTokenId` that `_operator` is allowed to manage */ function approve( uint256 _tokenId, address _operator, uint256 _value ) external; /** * @notice Get the maximum value of a token that an operator is allowed to manage. * @param _tokenId The token for which to query the allowance * @param _operator The address of an operator * @return The current approval value of `_tokenId` that `_operator` is allowed to manage */ function allowance( uint256 _tokenId, address _operator ) external view returns (uint256); /** * @notice Transfer value from a specified token to another specified token with the same slot. * @dev Caller MUST be the current owner, an authorized operator or an operator who has been * approved the whole `_fromTokenId` or part of it. * MUST revert if `_fromTokenId` or `_toTokenId` is zero token id or does not exist. * MUST revert if slots of `_fromTokenId` and `_toTokenId` do not match. * MUST revert if `_value` exceeds the balance of `_fromTokenId` or its allowance to the * operator. * MUST emit `TransferValue` event. * @param _fromTokenId The token to transfer value from * @param _toTokenId The token to transfer value to * @param _value The transferred value */ function transferFrom( uint256 _fromTokenId, uint256 _toTokenId, uint256 _value ) external; /** * @notice Transfer value from a specified token to an address. The caller should confirm that * `_to` is capable of receiving ERC3525 tokens. * @dev This function MUST create a new ERC3525 token with the same slot for `_to` to receive * the transferred value. * MUST revert if `_fromTokenId` is zero token id or does not exist. * MUST revert if `_to` is zero address. * MUST revert if `_value` exceeds the balance of `_fromTokenId` or its allowance to the * operator. * MUST emit `Transfer` and `TransferValue` events. * @param _fromTokenId The token to transfer value from * @param _to The address to transfer value to * @param _value The transferred value * @return ID of the new token created for `_to` which receives the transferred value */ function transferFrom( uint256 _fromTokenId, address _to, uint256 _value ) external returns (uint256); }
// SPDX-License-Identifier: None pragma solidity ^0.8.0; /** @title IManagement contract @dev Provide interfaces that allow interaction to Management contract */ interface IManagement { function treasury() external view returns (address); function hasRole( bytes32 role, address account ) external view returns (bool); function paymentTokens(address _token) external view returns (bool); function paused() external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "./IERC3525.sol"; interface IMembership is IERC721Enumerable, IERC3525 { function addMembership( address _account, uint256 _memberId, uint256 _type, uint256 _value ) external; function updatePoint( uint256 _memberId, uint256 _value, bool _isAdded ) external; function cancelMembership(uint256 _memberId) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IPeriphery { struct Redeem { uint256 memberId; uint256 point; uint256 ticketId; uint256 typeOf; uint256 value; uint128 nonce; uint128 expiry; } struct Buy { address beneficiary; uint256 memberId; address paymentToken; uint256 point; uint256 totalPayment; uint128 nonce; uint128 expiry; } struct TopUp { address beneficiary; uint256 ticketId; uint256 typeOf; uint256 value; address paymentToken; uint256 totalPayment; uint128 nonce; uint128 expiry; } function redeem( Redeem calldata _redeem, bytes calldata _signature ) external; function buy( Buy calldata _invoice, bytes calldata _signature ) external payable; function topup( TopUp calldata _invoice, bytes calldata _signature ) external payable; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; interface IVoucher { function issue( address _account, uint256 _ticketId, uint256 _type, uint256 _value ) external; function updateValue( uint256 _ticketId, uint256 _value, bool _isAdded ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/Address.sol"; import "./interfaces/IManagement.sol"; import "./interfaces/IMembership.sol"; import "./interfaces/IERC3525.sol"; import "./interfaces/IVoucher.sol"; import "./utils/Signer.sol"; contract Periphery is IPeriphery, Signer { using SafeERC20 for IERC20; bytes32 private constant MANAGER_ROLE = keccak256("MANAGER_ROLE"); bytes32 private constant VERIFIER_ROLE = keccak256("VERIFIER_ROLE"); address public immutable MEMBERSHIP; address public immutable VOUCHER; address public treasury; IManagement public management; // Counting a number of requests (from each of accounts) that has been proceeded mapping(address => uint256) public nonces; string private constant NAME = "Membership and Loyalty"; string private constant VERSION = "Version 1"; modifier onlyManager() { require(management.hasRole(MANAGER_ROLE, msg.sender), "Only Manager"); _; } constructor( IManagement _management, address _membership, address _voucher, address _treasury ) Signer(NAME, VERSION) { MEMBERSHIP = _membership; VOUCHER = _voucher; management = _management; treasury = _treasury; } function setManagement(address _management) external onlyManager { require(_management != address(0), "Set zero address"); management = IManagement(_management); } function tryGetOwnerOf( address _contract, uint256 _id ) external view returns (address) { return IMembership(_contract).ownerOf(_id); } function redeem( Redeem calldata _redeem, bytes calldata _signature ) external override { address _caller = msg.sender; _precheck(_caller, _redeem.expiry, _redeem.nonce); _checkOwnership(_caller, _redeem.memberId); _checkRedeemSig(_caller, _redeem, _signature); _updatePoint(_redeem.memberId, _redeem.point, false); _topup( _caller, _caller, _redeem.ticketId, _redeem.typeOf, _redeem.value ); } function topup( TopUp calldata _invoice, bytes calldata _signature ) external payable { address _caller = msg.sender; _precheck(_caller, _invoice.expiry, _invoice.nonce); _checkTopUpInvoiceSig(_caller, _invoice, _signature); if (_invoice.paymentToken == address(0)) require(msg.value == _invoice.totalPayment, "Invalid payment"); _makePayment(_invoice.paymentToken, _caller, _invoice.totalPayment); _topup( _caller, _invoice.beneficiary, _invoice.ticketId, _invoice.typeOf, _invoice.value ); } function buy( Buy calldata _invoice, bytes calldata _signature ) external payable override { address _caller = msg.sender; _precheck(_caller, _invoice.expiry, _invoice.nonce); _checkOwnership(_invoice.beneficiary, _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(_invoice.memberId, _invoice.point, true); } function _checkOwnership( address _beneficiary, uint256 _memberId ) private view { require( this.tryGetOwnerOf(MEMBERSHIP, _memberId) == _beneficiary, "Beneficiary and MemberId not match" ); } function _precheck( address _caller, uint256 _expiry, uint256 _nonce ) private view { require(block.timestamp <= _expiry, "Signature is expired"); require(_nonce == nonces[_caller], "Invalid nonce"); } function _checkRedeemSig( address _caller, Redeem calldata _redeem, bytes calldata _signature ) private view { _isAuthorizer(Signer._getSignerRedeem(_caller, _redeem, _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( management.hasRole(VERIFIER_ROLE, _signer), "Unauthorized signature" ); } function _updatePoint( uint256 _memberId, uint256 _point, bool _opt ) private { IMembership(MEMBERSHIP).updatePoint(_memberId, _point, _opt); } function _topup( address _caller, address _beneficiary, uint256 _ticketId, uint256 _typeOf, uint256 _value ) private { nonces[_caller]++; address _voucher = VOUCHER; try this.tryGetOwnerOf(_voucher, _ticketId) returns (address _owner) { require( _beneficiary == _owner && IERC3525(_voucher).slotOf(_ticketId) == _typeOf, "Invalid request" ); IVoucher(_voucher).updateValue(_ticketId, _value, true); } catch { IVoucher(_voucher).issue(_beneficiary, _ticketId, _typeOf, _value); } } function _makePayment( address _token, address _from, uint256 _amount ) private { address _treasury = treasury; if (_token == address(0)) Address.sendValue(payable(_treasury), _amount); else IERC20(_token).safeTransferFrom(_from, _treasury, _amount); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; import "../interfaces/IPeriphery.sol"; contract Signer is EIP712 { using ECDSA for bytes32; bytes32 private constant _BUY = keccak256( "Buy(address caller,address beneficiary,uint256 memberId,address paymentToken,uint256 point,uint256 totalPayment,uint128 nonce,uint128 expiry)" ); bytes32 private constant _REDEEM = keccak256( "Redeem(address caller,uint256 memberId,uint256 point,uint256 ticketId,uint256 typeOf,uint256 value,uint128 nonce,uint128 expiry)" ); bytes32 private constant _TOPUP = keccak256( "TopUp(address caller,address beneficiary,uint256 ticketId,uint256 typeOf,uint256 value,address paymentToken,uint256 totalPayment,uint128 nonce,uint128 expiry)" ); constructor( string memory name, string memory version ) EIP712(name, version) {} function _getSignerRedeem( address _caller, IPeriphery.Redeem calldata _redeem, bytes calldata _signature ) internal view returns (address _signer) { _signer = _hashTypedDataV4( keccak256( abi.encode( _REDEEM, _caller, _redeem.memberId, _redeem.point, _redeem.ticketId, _redeem.typeOf, _redeem.value, _redeem.nonce, _redeem.expiry ) ) ).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.beneficiary, _invoice.memberId, _invoice.paymentToken, _invoice.point, _invoice.totalPayment, _invoice.nonce, _invoice.expiry ) ) ).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.beneficiary, _invoice.ticketId, _invoice.typeOf, _invoice.value, _invoice.paymentToken, _invoice.totalPayment, _invoice.nonce, _invoice.expiry ) ) ).recover(_signature); } }
{ "optimizer": { "enabled": false, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
[{"inputs":[{"internalType":"contract IManagement","name":"_management","type":"address"},{"internalType":"address","name":"_membership","type":"address"},{"internalType":"address","name":"_voucher","type":"address"},{"internalType":"address","name":"_treasury","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"MEMBERSHIP","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VOUCHER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"beneficiary","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":[],"name":"management","outputs":[{"internalType":"contract IManagement","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":[{"components":[{"internalType":"uint256","name":"memberId","type":"uint256"},{"internalType":"uint256","name":"point","type":"uint256"},{"internalType":"uint256","name":"ticketId","type":"uint256"},{"internalType":"uint256","name":"typeOf","type":"uint256"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint128","name":"nonce","type":"uint128"},{"internalType":"uint128","name":"expiry","type":"uint128"}],"internalType":"struct IPeriphery.Redeem","name":"_redeem","type":"tuple"},{"internalType":"bytes","name":"_signature","type":"bytes"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_management","type":"address"}],"name":"setManagement","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"ticketId","type":"uint256"},{"internalType":"uint256","name":"typeOf","type":"uint256"},{"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":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"tryGetOwnerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101806040523480156200001257600080fd5b50604051620033cd380380620033cd83398181016040528101906200003891906200033a565b6040518060400160405280601681526020017f4d656d6265727368697020616e64204c6f79616c7479000000000000000000008152506040518060400160405280600981526020017f56657273696f6e20310000000000000000000000000000000000000000000000815250818160008280519060200120905060008280519060200120905060007f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f90508260e081815250508161010081815250504660a081815250506200010f8184846200024f60201b60201c565b608081815250503073ffffffffffffffffffffffffffffffffffffffff1660c08173ffffffffffffffffffffffffffffffffffffffff1681525050806101208181525050505050505050508273ffffffffffffffffffffffffffffffffffffffff166101408173ffffffffffffffffffffffffffffffffffffffff16815250508173ffffffffffffffffffffffffffffffffffffffff166101608173ffffffffffffffffffffffffffffffffffffffff168152505083600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050505062000450565b600083838346306040516020016200026c959493929190620003f3565b6040516020818303038152906040528051906020012090509392505050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620002bd8262000290565b9050919050565b6000620002d182620002b0565b9050919050565b620002e381620002c4565b8114620002ef57600080fd5b50565b6000815190506200030381620002d8565b92915050565b6200031481620002b0565b81146200032057600080fd5b50565b600081519050620003348162000309565b92915050565b600080600080608085870312156200035757620003566200028b565b5b60006200036787828801620002f2565b94505060206200037a8782880162000323565b93505060406200038d8782880162000323565b9250506060620003a08782880162000323565b91505092959194509250565b6000819050919050565b620003c181620003ac565b82525050565b6000819050919050565b620003dc81620003c7565b82525050565b620003ed81620002b0565b82525050565b600060a0820190506200040a6000830188620003b6565b620004196020830187620003b6565b620004286040830186620003b6565b620004376060830185620003d1565b620004466080830184620003e2565b9695505050505050565b60805160a05160c05160e05161010051610120516101405161016051612f02620004cb600039600081816102480152610bba0152600081816104b7015281816109cc0152610acf01526000611691015260006116d3015260006116b2015260006115e70152600061163d015260006116660152612f026000f3fe6080604052600436106100915760003560e01c806388a8d6021161005957806388a8d6021461016e57806389df51f114610199578063acf7f290146101c4578063d4a22bde146101e0578063ea06b8941461020957610091565b80634918cf6a146100965780635881f680146100c15780635a87e0d2146100ea57806361d027b3146101065780637ecebe0014610131575b600080fd5b3480156100a257600080fd5b506100ab610246565b6040516100b89190611c1c565b60405180910390f35b3480156100cd57600080fd5b506100e860048036038101906100e39190611cca565b61026a565b005b61010460048036038101906100ff9190611d4b565b61030f565b005b34801561011257600080fd5b5061011b610453565b6040516101289190611c1c565b60405180910390f35b34801561013d57600080fd5b5061015860048036038101906101539190611dd9565b610477565b6040516101659190611e1f565b60405180910390f35b34801561017a57600080fd5b5061018361048f565b6040516101909190611e99565b60405180910390f35b3480156101a557600080fd5b506101ae6104b5565b6040516101bb9190611c1c565b60405180910390f35b6101de60048036038101906101d99190611ed3565b6104d9565b005b3480156101ec57600080fd5b5061020760048036038101906102029190611dd9565b61067b565b005b34801561021557600080fd5b50610230600480360381019061022b9190611f60565b61083b565b60405161023d9190611c1c565b60405180910390f35b7f000000000000000000000000000000000000000000000000000000000000000081565b60003390506102c2818560c00160208101906102869190611fe8565b6fffffffffffffffffffffffffffffffff168660a00160208101906102ab9190611fe8565b6fffffffffffffffffffffffffffffffff166108ce565b6102d0818560000135610997565b6102dc81858585610ab3565b6102f0846000013585602001356000610acd565b6103098182866040013587606001358860800135610b61565b50505050565b6000339050610367818560e001602081019061032b9190611fe8565b6fffffffffffffffffffffffffffffffff168660c00160208101906103509190611fe8565b6fffffffffffffffffffffffffffffffff166108ce565b61037381858585610e54565b600073ffffffffffffffffffffffffffffffffffffffff1684608001602081019061039e9190611dd9565b73ffffffffffffffffffffffffffffffffffffffff161415610401578360a001353414610400576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103f790612072565b60405180910390fd5b5b6104228460800160208101906104179190611dd9565b828660a00135610e6e565b61044d818560000160208101906104399190611dd9565b866020013587604001358860600135610b61565b50505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60026020528060005260406000206000915090505481565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b7f000000000000000000000000000000000000000000000000000000000000000081565b6000339050610531818560c00160208101906104f59190611fe8565b6fffffffffffffffffffffffffffffffff168660a001602081019061051a9190611fe8565b6fffffffffffffffffffffffffffffffff166108ce565b6105518460000160208101906105479190611dd9565b8560200135610997565b61055d81858585610f0c565b600073ffffffffffffffffffffffffffffffffffffffff168460400160208101906105889190611dd9565b73ffffffffffffffffffffffffffffffffffffffff1614156105eb57836080013534146105ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e190612072565b60405180910390fd5b5b61060c8460400160208101906106019190611dd9565b828660800135610e6e565b600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600081548092919061065c906120c1565b9190505550610675846020013585606001356001610acd565b50505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166391d148547f241ecf16d79d0f8dbfb92cbc07fe17840425976cf0667f022fe9877caa831b08336040518363ffffffff1660e01b81526004016106f8929190612123565b60206040518083038186803b15801561071057600080fd5b505afa158015610724573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107489190612184565b610787576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161077e906121fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614156107f7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107ee90612269565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b60008273ffffffffffffffffffffffffffffffffffffffff16636352211e836040518263ffffffff1660e01b81526004016108769190611e1f565b60206040518083038186803b15801561088e57600080fd5b505afa1580156108a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108c6919061229e565b905092915050565b81421115610911576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161090890612317565b60405180910390fd5b600260008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548114610992576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161098990612383565b60405180910390fd5b505050565b8173ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1663ea06b8947f0000000000000000000000000000000000000000000000000000000000000000846040518363ffffffff1660e01b8152600401610a099291906123a3565b60206040518083038186803b158015610a2157600080fd5b505afa158015610a35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a59919061229e565b73ffffffffffffffffffffffffffffffffffffffff1614610aaf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aa69061243e565b60405180910390fd5b5050565b610ac7610ac285858585610f26565b61101f565b50505050565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff1663d0a9e1f38484846040518463ffffffff1660e01b8152600401610b2a9392919061246d565b600060405180830381600087803b158015610b4457600080fd5b505af1158015610b58573d6000803e3d6000fd5b50505050505050565b600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000815480929190610bb1906120c1565b919050555060007f000000000000000000000000000000000000000000000000000000000000000090503073ffffffffffffffffffffffffffffffffffffffff1663ea06b89482866040518363ffffffff1660e01b8152600401610c169291906123a3565b60206040518083038186803b158015610c2e57600080fd5b505afa925050508015610c5f57506040513d601f19601f82011682018060405250810190610c5c919061229e565b60015b610cd9578073ffffffffffffffffffffffffffffffffffffffff166347401a93868686866040518563ffffffff1660e01b8152600401610ca294939291906124a4565b600060405180830381600087803b158015610cbc57600080fd5b505af1158015610cd0573d6000803e3d6000fd5b50505050610e4c565b8073ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16148015610d9b5750838273ffffffffffffffffffffffffffffffffffffffff1663263f3e7e876040518263ffffffff1660e01b8152600401610d499190611e1f565b60206040518083038186803b158015610d6157600080fd5b505afa158015610d75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9991906124fe565b145b610dda576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd190612577565b60405180910390fd5b8173ffffffffffffffffffffffffffffffffffffffff16636e23218f868560016040518463ffffffff1660e01b8152600401610e189392919061246d565b600060405180830381600087803b158015610e3257600080fd5b505af1158015610e46573d6000803e3d6000fd5b50505050505b505050505050565b610e68610e638585858561112e565b61101f565b50505050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161415610ed857610ed38183611249565b610f06565b610f058382848773ffffffffffffffffffffffffffffffffffffffff1661133d909392919063ffffffff16565b5b50505050565b610f20610f1b858585856113c6565b61101f565b50505050565b600061101583838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506110077f38214088d212983e4986c4ff12f8baa4757e8c7ebe71d272b809af6ad485d59f88886000013589602001358a604001358b606001358c608001358d60a0016020810190610fc19190611fe8565b8e60c0016020810190610fd49190611fe8565b604051602001610fec999897969594939291906125a6565b604051602081830303815290604052805190602001206114db565b6114f590919063ffffffff16565b9050949350505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166391d148547f0ce23c3e399818cfee81a7ab0880f714e53d7672b08df0fa62f2843416e1ea09836040518363ffffffff1660e01b815260040161109c929190612123565b60206040518083038186803b1580156110b457600080fd5b505afa1580156110c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ec9190612184565b61112b576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111229061267f565b60405180910390fd5b50565b600061123f83838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506112317fd3092638394f26f0b2ca3ae036f38477b8ecd57bb7356029f62fe23053afaf41888860000160208101906111b09190611dd9565b89602001358a604001358b606001358c60800160208101906111d29190611dd9565b8d60a001358e60c00160208101906111ea9190611fe8565b8f60e00160208101906111fd9190611fe8565b6040516020016112169a9998979695949392919061269f565b604051602081830303815290604052805190602001206114db565b6114f590919063ffffffff16565b9050949350505050565b8047101561128c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161128390612787565b60405180910390fd5b60008273ffffffffffffffffffffffffffffffffffffffff16826040516112b2906127d8565b60006040518083038185875af1925050503d80600081146112ef576040519150601f19603f3d011682016040523d82523d6000602084013e6112f4565b606091505b5050905080611338576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132f9061285f565b60405180910390fd5b505050565b6113c0846323b872dd60e01b85858560405160240161135e9392919061287f565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505061151c565b50505050565b60006114d183838080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050506114c37f62770ffef98b0d2f30cc43588fd6021fc5ed5cb372aa55a83ee6ed6268e829f3888860000160208101906114489190611dd9565b89602001358a60400160208101906114609190611dd9565b8b606001358c608001358d60a001602081019061147d9190611fe8565b8e60c00160208101906114909190611fe8565b6040516020016114a8999897969594939291906128b6565b604051602081830303815290604052805190602001206114db565b6114f590919063ffffffff16565b9050949350505050565b60006114ee6114e86115e3565b836116fd565b9050919050565b60008060006115048585611730565b9150915061151181611782565b819250505092915050565b600061157e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff166118f09092919063ffffffff16565b90506000815111156115de578080602001905181019061159e9190612184565b6115dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115d4906129b5565b60405180910390fd5b5b505050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff163073ffffffffffffffffffffffffffffffffffffffff1614801561165f57507f000000000000000000000000000000000000000000000000000000000000000046145b1561168c577f000000000000000000000000000000000000000000000000000000000000000090506116fa565b6116f77f00000000000000000000000000000000000000000000000000000000000000007f00000000000000000000000000000000000000000000000000000000000000007f0000000000000000000000000000000000000000000000000000000000000000611908565b90505b90565b60008282604051602001611712929190612a4d565b60405160208183030381529060405280519060200120905092915050565b6000806041835114156117725760008060006020860151925060408601519150606086015160001a905061176687828585611942565b9450945050505061177b565b60006002915091505b9250929050565b6000600481111561179657611795612a84565b5b8160048111156117a9576117a8612a84565b5b14156117b4576118ed565b600160048111156117c8576117c7612a84565b5b8160048111156117db576117da612a84565b5b141561181c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181390612aff565b60405180910390fd5b600260048111156118305761182f612a84565b5b81600481111561184357611842612a84565b5b1415611884576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187b90612b6b565b60405180910390fd5b6003600481111561189857611897612a84565b5b8160048111156118ab576118aa612a84565b5b14156118ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118e390612bfd565b60405180910390fd5b5b50565b60606118ff8484600085611a25565b90509392505050565b60008383834630604051602001611923959493929190612c1d565b6040516020818303038152906040528051906020012090509392505050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08360001c111561197d576000600391509150611a1c565b6000600187878787604051600081526020016040526040516119a29493929190612c8c565b6020604051602081039080840390855afa1580156119c4573d6000803e3d6000fd5b505050602060405103519050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611a1357600060019250925050611a1c565b80600092509250505b94509492505050565b606082471015611a6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6190612d43565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611a939190612dd2565b60006040518083038185875af1925050503d8060008114611ad0576040519150601f19603f3d011682016040523d82523d6000602084013e611ad5565b606091505b5091509150611ae687838387611af2565b92505050949350505050565b60608315611b5557600083511415611b4d57611b0d85611b68565b611b4c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b4390612e35565b60405180910390fd5b5b829050611b60565b611b5f8383611b8b565b5b949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b600082511115611b9e5781518083602001fd5b806040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bd29190612eaa565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611c0682611bdb565b9050919050565b611c1681611bfb565b82525050565b6000602082019050611c316000830184611c0d565b92915050565b600080fd5b600080fd5b600080fd5b600060e08284031215611c5c57611c5b611c41565b5b81905092915050565b600080fd5b600080fd5b600080fd5b60008083601f840112611c8a57611c89611c65565b5b8235905067ffffffffffffffff811115611ca757611ca6611c6a565b5b602083019150836001820283011115611cc357611cc2611c6f565b5b9250929050565b60008060006101008486031215611ce457611ce3611c37565b5b6000611cf286828701611c46565b93505060e084013567ffffffffffffffff811115611d1357611d12611c3c565b5b611d1f86828701611c74565b92509250509250925092565b60006101008284031215611d4257611d41611c41565b5b81905092915050565b60008060006101208486031215611d6557611d64611c37565b5b6000611d7386828701611d2b565b93505061010084013567ffffffffffffffff811115611d9557611d94611c3c565b5b611da186828701611c74565b92509250509250925092565b611db681611bfb565b8114611dc157600080fd5b50565b600081359050611dd381611dad565b92915050565b600060208284031215611def57611dee611c37565b5b6000611dfd84828501611dc4565b91505092915050565b6000819050919050565b611e1981611e06565b82525050565b6000602082019050611e346000830184611e10565b92915050565b6000819050919050565b6000611e5f611e5a611e5584611bdb565b611e3a565b611bdb565b9050919050565b6000611e7182611e44565b9050919050565b6000611e8382611e66565b9050919050565b611e9381611e78565b82525050565b6000602082019050611eae6000830184611e8a565b92915050565b600060e08284031215611eca57611ec9611c41565b5b81905092915050565b60008060006101008486031215611eed57611eec611c37565b5b6000611efb86828701611eb4565b93505060e084013567ffffffffffffffff811115611f1c57611f1b611c3c565b5b611f2886828701611c74565b92509250509250925092565b611f3d81611e06565b8114611f4857600080fd5b50565b600081359050611f5a81611f34565b92915050565b60008060408385031215611f7757611f76611c37565b5b6000611f8585828601611dc4565b9250506020611f9685828601611f4b565b9150509250929050565b60006fffffffffffffffffffffffffffffffff82169050919050565b611fc581611fa0565b8114611fd057600080fd5b50565b600081359050611fe281611fbc565b92915050565b600060208284031215611ffe57611ffd611c37565b5b600061200c84828501611fd3565b91505092915050565b600082825260208201905092915050565b7f496e76616c6964207061796d656e740000000000000000000000000000000000600082015250565b600061205c600f83612015565b915061206782612026565b602082019050919050565b6000602082019050818103600083015261208b8161204f565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006120cc82611e06565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8214156120ff576120fe612092565b5b600182019050919050565b6000819050919050565b61211d8161210a565b82525050565b60006040820190506121386000830185612114565b6121456020830184611c0d565b9392505050565b60008115159050919050565b6121618161214c565b811461216c57600080fd5b50565b60008151905061217e81612158565b92915050565b60006020828403121561219a57612199611c37565b5b60006121a88482850161216f565b91505092915050565b7f4f6e6c79204d616e616765720000000000000000000000000000000000000000600082015250565b60006121e7600c83612015565b91506121f2826121b1565b602082019050919050565b60006020820190508181036000830152612216816121da565b9050919050565b7f536574207a65726f206164647265737300000000000000000000000000000000600082015250565b6000612253601083612015565b915061225e8261221d565b602082019050919050565b6000602082019050818103600083015261228281612246565b9050919050565b60008151905061229881611dad565b92915050565b6000602082840312156122b4576122b3611c37565b5b60006122c284828501612289565b91505092915050565b7f5369676e61747572652069732065787069726564000000000000000000000000600082015250565b6000612301601483612015565b915061230c826122cb565b602082019050919050565b60006020820190508181036000830152612330816122f4565b9050919050565b7f496e76616c6964206e6f6e636500000000000000000000000000000000000000600082015250565b600061236d600d83612015565b915061237882612337565b602082019050919050565b6000602082019050818103600083015261239c81612360565b9050919050565b60006040820190506123b86000830185611c0d565b6123c56020830184611e10565b9392505050565b7f42656e656669636961727920616e64204d656d6265724964206e6f74206d617460008201527f6368000000000000000000000000000000000000000000000000000000000000602082015250565b6000612428602283612015565b9150612433826123cc565b604082019050919050565b600060208201905081810360008301526124578161241b565b9050919050565b6124678161214c565b82525050565b60006060820190506124826000830186611e10565b61248f6020830185611e10565b61249c604083018461245e565b949350505050565b60006080820190506124b96000830187611c0d565b6124c66020830186611e10565b6124d36040830185611e10565b6124e06060830184611e10565b95945050505050565b6000815190506124f881611f34565b92915050565b60006020828403121561251457612513611c37565b5b6000612522848285016124e9565b91505092915050565b7f496e76616c696420726571756573740000000000000000000000000000000000600082015250565b6000612561600f83612015565b915061256c8261252b565b602082019050919050565b6000602082019050818103600083015261259081612554565b9050919050565b6125a081611fa0565b82525050565b6000610120820190506125bc600083018c612114565b6125c9602083018b611c0d565b6125d6604083018a611e10565b6125e36060830189611e10565b6125f06080830188611e10565b6125fd60a0830187611e10565b61260a60c0830186611e10565b61261760e0830185612597565b612625610100830184612597565b9a9950505050505050505050565b7f556e617574686f72697a6564207369676e617475726500000000000000000000600082015250565b6000612669601683612015565b915061267482612633565b602082019050919050565b600060208201905081810360008301526126988161265c565b9050919050565b6000610140820190506126b5600083018d612114565b6126c2602083018c611c0d565b6126cf604083018b611c0d565b6126dc606083018a611e10565b6126e96080830189611e10565b6126f660a0830188611e10565b61270360c0830187611c0d565b61271060e0830186611e10565b61271e610100830185612597565b61272c610120830184612597565b9b9a5050505050505050505050565b7f416464726573733a20696e73756666696369656e742062616c616e6365000000600082015250565b6000612771601d83612015565b915061277c8261273b565b602082019050919050565b600060208201905081810360008301526127a081612764565b9050919050565b600081905092915050565b50565b60006127c26000836127a7565b91506127cd826127b2565b600082019050919050565b60006127e3826127b5565b9150819050919050565b7f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260008201527f6563697069656e74206d61792068617665207265766572746564000000000000602082015250565b6000612849603a83612015565b9150612854826127ed565b604082019050919050565b600060208201905081810360008301526128788161283c565b9050919050565b60006060820190506128946000830186611c0d565b6128a16020830185611c0d565b6128ae6040830184611e10565b949350505050565b6000610120820190506128cc600083018c612114565b6128d9602083018b611c0d565b6128e6604083018a611c0d565b6128f36060830189611e10565b6129006080830188611c0d565b61290d60a0830187611e10565b61291a60c0830186611e10565b61292760e0830185612597565b612935610100830184612597565b9a9950505050505050505050565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b600061299f602a83612015565b91506129aa82612943565b604082019050919050565b600060208201905081810360008301526129ce81612992565b9050919050565b600081905092915050565b7f1901000000000000000000000000000000000000000000000000000000000000600082015250565b6000612a166002836129d5565b9150612a21826129e0565b600282019050919050565b6000819050919050565b612a47612a428261210a565b612a2c565b82525050565b6000612a5882612a09565b9150612a648285612a36565b602082019150612a748284612a36565b6020820191508190509392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fd5b7f45434453413a20696e76616c6964207369676e61747572650000000000000000600082015250565b6000612ae9601883612015565b9150612af482612ab3565b602082019050919050565b60006020820190508181036000830152612b1881612adc565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265206c656e67746800600082015250565b6000612b55601f83612015565b9150612b6082612b1f565b602082019050919050565b60006020820190508181036000830152612b8481612b48565b9050919050565b7f45434453413a20696e76616c6964207369676e6174757265202773272076616c60008201527f7565000000000000000000000000000000000000000000000000000000000000602082015250565b6000612be7602283612015565b9150612bf282612b8b565b604082019050919050565b60006020820190508181036000830152612c1681612bda565b9050919050565b600060a082019050612c326000830188612114565b612c3f6020830187612114565b612c4c6040830186612114565b612c596060830185611e10565b612c666080830184611c0d565b9695505050505050565b600060ff82169050919050565b612c8681612c70565b82525050565b6000608082019050612ca16000830187612114565b612cae6020830186612c7d565b612cbb6040830185612114565b612cc86060830184612114565b95945050505050565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b6000612d2d602683612015565b9150612d3882612cd1565b604082019050919050565b60006020820190508181036000830152612d5c81612d20565b9050919050565b600081519050919050565b60005b83811015612d8c578082015181840152602081019050612d71565b83811115612d9b576000848401525b50505050565b6000612dac82612d63565b612db681856127a7565b9350612dc6818560208601612d6e565b80840191505092915050565b6000612dde8284612da1565b915081905092915050565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b6000612e1f601d83612015565b9150612e2a82612de9565b602082019050919050565b60006020820190508181036000830152612e4e81612e12565b9050919050565b600081519050919050565b6000601f19601f8301169050919050565b6000612e7c82612e55565b612e868185612015565b9350612e96818560208601612d6e565b612e9f81612e60565b840191505092915050565b60006020820190508181036000830152612ec48184612e71565b90509291505056fea2646970667358221220254eec2f34295b7bdcc2ac638b060e48534cb8e730811a5ff77f07a21767571864736f6c634300080900330000000000000000000000002f295e191147d406bc7c1b732243ff5d437ce716000000000000000000000000c3d01e6f6b1edf8383ca3ba6940f212baed28ea60000000000000000000000009586b2201344ad1c9c1a63fb3f8340acc7af1be300000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000002f295e191147d406bc7c1b732243ff5d437ce716000000000000000000000000c3d01e6f6b1edf8383ca3ba6940f212baed28ea60000000000000000000000009586b2201344ad1c9c1a63fb3f8340acc7af1be300000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
-----Decoded View---------------
Arg [0] : _management (address): 0x2f295e191147d406bc7c1b732243ff5d437ce716
Arg [1] : _membership (address): 0xc3d01e6f6b1edf8383ca3ba6940f212baed28ea6
Arg [2] : _voucher (address): 0x9586b2201344ad1c9c1a63fb3f8340acc7af1be3
Arg [3] : _treasury (address): 0x31003c2d5685c7d28d7174c3255307eb9a0f3015
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000002f295e191147d406bc7c1b732243ff5d437ce716
Arg [1] : 000000000000000000000000c3d01e6f6b1edf8383ca3ba6940f212baed28ea6
Arg [2] : 0000000000000000000000009586b2201344ad1c9c1a63fb3f8340acc7af1be3
Arg [3] : 00000000000000000000000031003c2d5685c7d28d7174c3255307eb9a0f3015
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|