Address Details
contract
0x0E5B7FC2574e34e312372354e1538eEe55a41Be6
- Contract Name
- UserMintStations
- Creator
- 0x5db7b2–57d2c7 at 0xd22b2f–66905a
- Balance
- 0 CELO ( )
- Locked CELO Balance
- 0.00 CELO
- Voting CELO Balance
- 0.00 CELO
- Pending Unlocked Gold
- 0.00 CELO
- Tokens
-
Fetching tokens...
- Transactions
- 4 Transactions
- Transfers
- 0 Transfers
- Gas Used
- 145,858
- Last Balance Update
- 19485159
This contract has been verified via Sourcify.
View contract in Sourcify repository
- Contract name:
- UserMintStations
- Optimization enabled
- true
- Compiler version
- v0.8.17+commit.8df45f5f
- Optimization runs
- 10
- EVM Version
- london
- Verified at
- 2023-07-19T18:45:14.908793Z
contracts/UserMintStations.sol
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import {UserClaimable} from "./UserClaimable.sol"; import {Ratelimited} from "./Ratelimited.sol"; interface StationsInterface { function mintAmount(address _to, uint256 _tokenId, uint256 amount) external; } contract UserMintStations is UserClaimable, Ratelimited { bytes public constant OP_MINT = "whl-stations.mint"; bytes public constant OP_CANCEL = "whl-stations.cancel"; uint256 public constant INITIAL_RATELIMIT = 100; // can mint this many NFTs uint256 public constant INITIAL_RATELIMIT_PERIOD = 3600; // every these many seconds StationsInterface public stations; // Given admin will be able to manage both the signer addresses and rate limits. constructor( address _admin, address _stations ) UserClaimable(_admin) Ratelimited(_admin, INITIAL_RATELIMIT_PERIOD, INITIAL_RATELIMIT) { stations = StationsInterface(_stations); } // See UserClaimable to undestand the implementation. function mintStations( address beneficiary, uint256 nonce, uint256 deadline, bytes memory tokensAndAmounts, uint8 v, bytes32 r, bytes32 s ) external { bytes32 h = keccak256(abi.encodePacked(tokensAndAmounts)); _checkSignature(OP_MINT, beneficiary, nonce, deadline, h, v, r, s); require(tokensAndAmounts.length > 0, "nothing to mint"); require(tokensAndAmounts.length % 8 == 0, "malformed arg"); for (uint256 i = 0; i < tokensAndAmounts.length; i += 8) { uint256 tokenId = unpack32(tokensAndAmounts, i); uint256 amount = unpack32(tokensAndAmounts, i + 4); // verify we are within the rate limits _checkRatelimits(amount); // proceed with the mint stations.mintAmount(beneficiary, tokenId, amount); } } // Cancels a lingering mintStations() if called with the same nonce. function cancelMintStations( address beneficiary, uint256 nonce, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external { _checkSignature(OP_CANCEL, beneficiary, nonce, deadline, bytes32(0), v, r, s); } // This function is kept public because it helps verify that the parameters of // mintStations are correctly crafted off-chain. function unpack32(bytes memory array, uint256 position) public pure returns (uint256) { return 0 + (uint256(uint8(array[position + 0])) << 24) + (uint256(uint8(array[position + 1])) << 16) + (uint256(uint8(array[position + 2])) << 8) + (uint256(uint8(array[position + 3]))); } }
/_openzeppelin/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControl.sol"; import "../utils/Context.sol"; import "../utils/Strings.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", Strings.toHexString(account), " is missing role ", Strings.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleGranted} event. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. * * May emit a {RoleRevoked} event. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. * * May emit a {RoleRevoked} event. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * May emit a {RoleGranted} event. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. * * May emit a {RoleGranted} event. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. * * May emit a {RoleRevoked} event. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
/_openzeppelin/contracts/access/IAccessControl.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
/_openzeppelin/contracts/utils/Context.sol
// 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; } }
/_openzeppelin/contracts/utils/Strings.sol
// 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); } }
/_openzeppelin/contracts/utils/cryptography/ECDSA.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)); } }
/_openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
/_openzeppelin/contracts/utils/introspection/IERC165.sol
// 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); }
/_openzeppelin/contracts/utils/math/Math.sol
// 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); } } }
/contracts/Ratelimited.sol
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; // Implementation heavily inspired by // https://consensys.github.io/smart-contract-best-practices/development-recommendations/precautions/rate-limiting/ // The implementation's security is weakened compared to the above's // by working with timestamps rather than block numbers. // This is not problematic for wheelcoin as of today, therefore it seems an acceptable // tradeoff to not have to take a blockchain's block times in consideration. // contract Ratelimited is AccessControl { bytes32 public constant RATELIMIT_ADMIN = keccak256("RATELIMIT_ADMIN_ROLE"); uint256 public periodSeconds; // how many seconds before limit resets uint256 public limit; // max amount to process per period uint256 public currentPeriodEnd; // time at which the current period ends at uint256 public currentPeriodAmount; // amount already processed this period constructor(address _admin, uint256 _periodSeconds, uint256 _limit) { _grantRole(RATELIMIT_ADMIN, _admin); _grantRole(DEFAULT_ADMIN_ROLE, _admin); periodSeconds = _periodSeconds; limit = _limit; } function setRatelimits(uint256 _periodSeconds, uint256 _limit) public onlyRole(RATELIMIT_ADMIN) { periodSeconds = _periodSeconds; limit = _limit; } function _checkRatelimits(uint256 amount) internal { if (currentPeriodEnd < block.timestamp) { currentPeriodEnd = block.timestamp + periodSeconds; currentPeriodAmount = 0; } require(currentPeriodAmount + amount < limit, "ratelimited"); currentPeriodAmount += amount; } }
/contracts/UserClaimable.sol
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol"; import {ECDSA} from "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; contract UserClaimable is AccessControl { bytes32 public constant CLAIMABLE_ADMIN = keccak256("CLAIMABLE_ADMIN_ROLE"); bytes32 public constant SIGNER = keccak256("SIGNER_ROLE"); mapping(uint256 => bool) public spentNonces; event OperationExecuted( address indexed who, bytes operation, address indexed beneficiary, uint256 indexed nonce, address signer, bytes32 paramsHash ); constructor(address _admin) { _setRoleAdmin(SIGNER, CLAIMABLE_ADMIN); _grantRole(CLAIMABLE_ADMIN, _admin); } // Allows anyone to submit a transaction entitling the user to claim // some benefit, usually in the form of an asset mint. // // This is an internal function, intended to be called by a child contract // that proceeds to grant the benefits after calling this function. // // For the operation to succeed, an authorized signer must have produced // a signature granting the beneficiary (usually, msg.sender, but not // necessarily) the ability to claim the benefits. In other words, the // signature verifies the beneficiary, but the data itself can be submitted // by any account willing to pay for the transaction cost. // // The signature is created with a deadline, because we do not want // lingering transactions. // // The nonce exists for replay protection. If the same data is submitted // more than once, it will only work once. // // Note the signature includes the beneficiary, nonce, deadline, and any // parameters of the claim, so an attacker cannot meddle with the parameters. // // Note the operation should be unique across instances of this contract. // This is so that it's not possible to replay signatures across several // instances of this contract. // // Note it's possible for different signers to emit their signatures // entitling a beneficiary to claim the assets. This is safe as long as the // nonce is kept equal, because a nonce can be spent only exactly once. // function _checkSignature( bytes memory operation, address beneficiary, uint256 nonce, uint256 deadline, bytes32 paramsHash, uint8 v, bytes32 r, bytes32 s ) internal { // Verify we are within the deadline. require(deadline < block.timestamp, "too late"); // Spend the nonce, if not spent already. require(!spentNonces[nonce], "nonce was spent"); spentNonces[nonce] = true; // Verify the signature matches an authorized signer. bytes32 h = hashOperation(operation, beneficiary, nonce, deadline, paramsHash); address signer = recoverSigner(h, v, r, s); require(hasRole(SIGNER, signer), "bad signer"); emit OperationExecuted(msg.sender, operation, beneficiary, nonce, signer, paramsHash); } // This functionality is isolated here because it helps signers produce // the right signature off-chain. // // solhint-disable-next-line ordering function hashOperation( bytes memory operation, address beneficiary, uint256 nonce, uint256 deadline, bytes32 paramsHash ) public pure returns (bytes32) { return keccak256(abi.encodePacked(operation, beneficiary, nonce, deadline, paramsHash)); } // This functionality is isolated here because it helps test signers produce // the right signature off-chain. // function recoverSigner(bytes32 argsHash, uint8 v, bytes32 r, bytes32 s) public pure returns (address) { return ECDSA.recover(ECDSA.toEthSignedMessageHash(argsHash), v, r, s); } }
Compiler Settings
{"remappings":[],"optimizer":{"runs":10,"enabled":true},"metadata":{"useLiteralContent":true,"bytecodeHash":"ipfs"},"libraries":{},"evmVersion":"london","compilationTarget":{"contracts/UserMintStations.sol":"UserMintStations"}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_admin","internalType":"address"},{"type":"address","name":"_stations","internalType":"address"}]},{"type":"event","name":"OperationExecuted","inputs":[{"type":"address","name":"who","internalType":"address","indexed":true},{"type":"bytes","name":"operation","internalType":"bytes","indexed":false},{"type":"address","name":"beneficiary","internalType":"address","indexed":true},{"type":"uint256","name":"nonce","internalType":"uint256","indexed":true},{"type":"address","name":"signer","internalType":"address","indexed":false},{"type":"bytes32","name":"paramsHash","internalType":"bytes32","indexed":false}],"anonymous":false},{"type":"event","name":"RoleAdminChanged","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"previousAdminRole","internalType":"bytes32","indexed":true},{"type":"bytes32","name":"newAdminRole","internalType":"bytes32","indexed":true}],"anonymous":false},{"type":"event","name":"RoleGranted","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoleRevoked","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32","indexed":true},{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"address","name":"sender","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"CLAIMABLE_ADMIN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"DEFAULT_ADMIN_ROLE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"INITIAL_RATELIMIT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"INITIAL_RATELIMIT_PERIOD","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"OP_CANCEL","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"OP_MINT","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"RATELIMIT_ADMIN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"SIGNER","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"cancelMintStations","inputs":[{"type":"address","name":"beneficiary","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentPeriodAmount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"currentPeriodEnd","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getRoleAdmin","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"grantRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"hasRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"hashOperation","inputs":[{"type":"bytes","name":"operation","internalType":"bytes"},{"type":"address","name":"beneficiary","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"bytes32","name":"paramsHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"limit","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mintStations","inputs":[{"type":"address","name":"beneficiary","internalType":"address"},{"type":"uint256","name":"nonce","internalType":"uint256"},{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"bytes","name":"tokensAndAmounts","internalType":"bytes"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"periodSeconds","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"recoverSigner","inputs":[{"type":"bytes32","name":"argsHash","internalType":"bytes32"},{"type":"uint8","name":"v","internalType":"uint8"},{"type":"bytes32","name":"r","internalType":"bytes32"},{"type":"bytes32","name":"s","internalType":"bytes32"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"revokeRole","inputs":[{"type":"bytes32","name":"role","internalType":"bytes32"},{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRatelimits","inputs":[{"type":"uint256","name":"_periodSeconds","internalType":"uint256"},{"type":"uint256","name":"_limit","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"spentNonces","inputs":[{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract StationsInterface"}],"name":"stations","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"unpack32","inputs":[{"type":"bytes","name":"array","internalType":"bytes"},{"type":"uint256","name":"position","internalType":"uint256"}]}]
Contract Creation Code
0x60806040523480156200001157600080fd5b506040516200178a3803806200178a833981016040819052620000349162000205565b81610e10606482620000767fe2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f706000805160206200176a833981519152620000fc565b620000916000805160206200176a8339815191528262000147565b50620000be7f375a720dab3fb5f30de255b583af2e6f4b7a2089cae37b622093b7f1c13e8d908462000147565b620000cb60008462000147565b60029190915560035550600680546001600160a01b0319166001600160a01b0392909216919091179055506200023d565b600082815260208190526040808220600101805490849055905190918391839186917fbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff9190a4505050565b6000828152602081815260408083206001600160a01b038516845290915290205460ff16620001e4576000828152602081815260408083206001600160a01b03851684529091529020805460ff19166001179055620001a33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b80516001600160a01b03811681146200020057600080fd5b919050565b600080604083850312156200021957600080fd5b6200022483620001e8565b91506200023460208401620001e8565b90509250929050565b61151d806200024d6000396000f3fe608060405234801561001057600080fd5b506004361061013e5760003560e01c806301ffc9a714610143578063202418f81461016b57806321a5605314610181578063248a9ca3146101965780632c4fada6146101a95780632f2ff15d146101cc57806336568abe146101e1578063548149a7146101f4578063582abd1214610207578063587944561461021c5780635b19eb6b146102255780635e1371c1146102505780637bb007421461028d578063903eba20146102a057806391d14854146102b3578063a217fddf146102c6578063a4d66daf146102ce578063abe3e6aa146102d7578063c4a362a0146102ea578063cd81f6901461031c578063d45167d014610343578063d547741f14610356578063e347e9c014610369578063e465eb9e14610372578063f3a610fb1461037b578063f4514fa31461038e575b600080fd5b610156610151366004610f7d565b610397565b60405190151581526020015b60405180910390f35b610173606481565b604051908152602001610162565b6101736000805160206114a883398151915281565b6101736101a4366004610fa7565b6103ce565b6101566101b7366004610fa7565b60016020526000908152604090205460ff1681565b6101df6101da366004610fdc565b6103e3565b005b6101df6101ef366004610fdc565b610404565b6101736102023660046110aa565b610487565b6101736000805160206114c883398151915281565b61017360045481565b600654610238906001600160a01b031681565b6040516001600160a01b039091168152602001610162565b610280604051806040016040528060118152602001701dda1b0b5cdd185d1a5bdb9ccb9b5a5b9d607a1b81525081565b604051610162919061113e565b6101df61029b366004611162565b610558565b6101df6102ae3660046111e6565b61070e565b6101566102c1366004610fdc565b610751565b610173600081565b61017360035481565b6101736102e536600461123e565b61077a565b610280604051806040016040528060138152602001721dda1b0b5cdd185d1a5bdb9ccb98d85b98d95b606a1b81525081565b6101737f1ec98e70bacc56c6015e16a6a318370da33f3e9d22b7ffe27ff4ec0691fd25bb81565b6102386103513660046112a5565b6107b6565b6101df610364366004610fdc565b610822565b610173610e1081565b61017360055481565b6101df6103893660046112e0565b61083e565b61017360025481565b60006001600160e01b03198216637965db0b60e01b14806103c857506301ffc9a760e01b6001600160e01b03198316145b92915050565b60009081526020819052604090206001015490565b6103ec826103ce565b6103f581610862565b6103ff838361086f565b505050565b6001600160a01b03811633146104795760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61048382826108f3565b5050565b600082610495836003611318565b815181106104a5576104a561132b565b016020015160f81c6008846104bb856002611318565b815181106104cb576104cb61132b565b016020015160f81c901b6010856104e3866001611318565b815181106104f3576104f361132b565b016020015160f81c901b60188661050b876000611318565b8151811061051b5761051b61132b565b01602001516105339160f89190911c901b6000611318565b61053d9190611318565b6105479190611318565b6105519190611318565b9392505050565b60008460405160200161056b9190611341565b6040516020818303038152906040528051906020012090506105bc604051806040016040528060118152602001701dda1b0b5cdd185d1a5bdb9ccb9b5a5b9d607a1b81525089898985898989610958565b60008551116105ff5760405162461bcd60e51b815260206004820152600f60248201526e1b9bdd1a1a5b99c81d1bc81b5a5b9d608a1b6044820152606401610470565b6008855161060d919061135d565b1561064a5760405162461bcd60e51b815260206004820152600d60248201526c6d616c666f726d65642061726760981b6044820152606401610470565b60005b85518110156107035760006106628783610487565b9050600061067588610202856004611318565b905061068081610aca565b600654604051632952bac760e21b81526001600160a01b038d8116600483015260248201859052604482018490529091169063a54aeb1c90606401600060405180830381600087803b1580156106d557600080fd5b505af11580156106e9573d6000803e3d6000fd5b5050505050506008816106fc9190611318565b905061064d565b505050505050505050565b6040805180820190915260138152721dda1b0b5cdd185d1a5bdb9ccb98d85b98d95b606a1b6020820152610749908787876000888888610958565b505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000858585858560405160200161079595949392919061137f565b60405160208183030381529060405280519060200120905095945050505050565b6000610819610811866040517b0ca2ba3432b932bab69029b4b3b732b21026b2b9b9b0b3b29d05199960211b6020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b858585610b50565b95945050505050565b61082b826103ce565b61083481610862565b6103ff83836108f3565b6000805160206114a883398151915261085681610862565b50600291909155600355565b61086c8133610b78565b50565b6108798282610751565b610483576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556108af3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6108fd8282610751565b15610483576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b4285106109925760405162461bcd60e51b8152602060048201526008602482015267746f6f206c61746560c01b6044820152606401610470565b60008681526001602052604090205460ff16156109e35760405162461bcd60e51b815260206004820152600f60248201526e1b9bdb98d9481dd85cc81cdc195b9d608a1b6044820152606401610470565b60008681526001602081905260408220805460ff19169091179055610a0b898989898961077a565b90506000610a1b828686866107b6565b9050610a356000805160206114c883398151915282610751565b610a6e5760405162461bcd60e51b815260206004820152600a6024820152693130b21039b4b3b732b960b11b6044820152606401610470565b87896001600160a01b0316336001600160a01b03167f06084c584196f91d8519dbc9e2161894bd98f2e6efd8664d689fa55d3e71e0768d858b604051610ab6939291906113c6565b60405180910390a450505050505050505050565b426004541015610aea57600254610ae19042611318565b60045560006005555b60035481600554610afb9190611318565b10610b365760405162461bcd60e51b815260206004820152600b60248201526a1c985d195b1a5b5a5d195960aa1b6044820152606401610470565b8060056000828254610b489190611318565b909155505050565b6000806000610b6187878787610bd1565b91509150610b6e81610c8b565b5095945050505050565b610b828282610751565b61048357610b8f81610dd0565b610b9a836020610de2565b604051602001610bab9291906113f4565b60408051601f198184030181529082905262461bcd60e51b82526104709160040161113e565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115610bfe5750600090506003610c82565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610c52573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610c7b57600060019250925050610c82565b9150600090505b94509492505050565b6000816004811115610c9f57610c9f611463565b03610ca75750565b6001816004811115610cbb57610cbb611463565b03610d035760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610470565b6002816004811115610d1757610d17611463565b03610d645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610470565b6003816004811115610d7857610d78611463565b0361086c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610470565b60606103c86001600160a01b03831660145b60606000610df1836002611479565b610dfc906002611318565b6001600160401b03811115610e1357610e13611008565b6040519080825280601f01601f191660200182016040528015610e3d576020820181803683370190505b509050600360fc1b81600081518110610e5857610e5861132b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610e8757610e8761132b565b60200101906001600160f81b031916908160001a9053506000610eab846002611479565b610eb6906001611318565b90505b6001811115610f2e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610eea57610eea61132b565b1a60f81b828281518110610f0057610f0061132b565b60200101906001600160f81b031916908160001a90535060049490941c93610f2781611490565b9050610eb9565b5083156105515760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610470565b600060208284031215610f8f57600080fd5b81356001600160e01b03198116811461055157600080fd5b600060208284031215610fb957600080fd5b5035919050565b80356001600160a01b0381168114610fd757600080fd5b919050565b60008060408385031215610fef57600080fd5b82359150610fff60208401610fc0565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261102f57600080fd5b81356001600160401b038082111561104957611049611008565b604051601f8301601f19908116603f0116810190828211818310171561107157611071611008565b8160405283815286602085880101111561108a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080604083850312156110bd57600080fd5b82356001600160401b038111156110d357600080fd5b6110df8582860161101e565b95602094909401359450505050565b60005b838110156111095781810151838201526020016110f1565b50506000910152565b6000815180845261112a8160208601602086016110ee565b601f01601f19169290920160200192915050565b6020815260006105516020830184611112565b803560ff81168114610fd757600080fd5b600080600080600080600060e0888a03121561117d57600080fd5b61118688610fc0565b9650602088013595506040880135945060608801356001600160401b038111156111af57600080fd5b6111bb8a828b0161101e565b9450506111ca60808901611151565b925060a0880135915060c0880135905092959891949750929550565b60008060008060008060c087890312156111ff57600080fd5b61120887610fc0565b9550602087013594506040870135935061122460608801611151565b92506080870135915060a087013590509295509295509295565b600080600080600060a0868803121561125657600080fd5b85356001600160401b0381111561126c57600080fd5b6112788882890161101e565b95505061128760208701610fc0565b94979496505050506040830135926060810135926080909101359150565b600080600080608085870312156112bb57600080fd5b843593506112cb60208601611151565b93969395505050506040820135916060013590565b600080604083850312156112f357600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b808201808211156103c8576103c8611302565b634e487b7160e01b600052603260045260246000fd5b600082516113538184602087016110ee565b9190910192915050565b60008261137a57634e487b7160e01b600052601260045260246000fd5b500690565b60008651611391818460208b016110ee565b60609690961b6001600160601b0319169190950190815260148101939093526034830191909152605482015260740192915050565b6060815260006113d96060830186611112565b6001600160a01b039490941660208301525060400152919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516114268160178501602088016110ee565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516114578160288401602088016110ee565b01602801949350505050565b634e487b7160e01b600052602160045260246000fd5b80820281158282048414176103c8576103c8611302565b60008161149f5761149f611302565b50600019019056fe375a720dab3fb5f30de255b583af2e6f4b7a2089cae37b622093b7f1c13e8d90e2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f70a264697066735822122006e25cc37b3bd2ecc8fffceb88b0a18f23c418871f27bdd5c6b42c3326364bcf64736f6c634300081100331ec98e70bacc56c6015e16a6a318370da33f3e9d22b7ffe27ff4ec0691fd25bb0000000000000000000000005db7b29d0e74df97c9b347e1714b6c160657d2c70000000000000000000000003def938148743097213e419e5b5c284058a0a9ce
Deployed ByteCode
0x608060405234801561001057600080fd5b506004361061013e5760003560e01c806301ffc9a714610143578063202418f81461016b57806321a5605314610181578063248a9ca3146101965780632c4fada6146101a95780632f2ff15d146101cc57806336568abe146101e1578063548149a7146101f4578063582abd1214610207578063587944561461021c5780635b19eb6b146102255780635e1371c1146102505780637bb007421461028d578063903eba20146102a057806391d14854146102b3578063a217fddf146102c6578063a4d66daf146102ce578063abe3e6aa146102d7578063c4a362a0146102ea578063cd81f6901461031c578063d45167d014610343578063d547741f14610356578063e347e9c014610369578063e465eb9e14610372578063f3a610fb1461037b578063f4514fa31461038e575b600080fd5b610156610151366004610f7d565b610397565b60405190151581526020015b60405180910390f35b610173606481565b604051908152602001610162565b6101736000805160206114a883398151915281565b6101736101a4366004610fa7565b6103ce565b6101566101b7366004610fa7565b60016020526000908152604090205460ff1681565b6101df6101da366004610fdc565b6103e3565b005b6101df6101ef366004610fdc565b610404565b6101736102023660046110aa565b610487565b6101736000805160206114c883398151915281565b61017360045481565b600654610238906001600160a01b031681565b6040516001600160a01b039091168152602001610162565b610280604051806040016040528060118152602001701dda1b0b5cdd185d1a5bdb9ccb9b5a5b9d607a1b81525081565b604051610162919061113e565b6101df61029b366004611162565b610558565b6101df6102ae3660046111e6565b61070e565b6101566102c1366004610fdc565b610751565b610173600081565b61017360035481565b6101736102e536600461123e565b61077a565b610280604051806040016040528060138152602001721dda1b0b5cdd185d1a5bdb9ccb98d85b98d95b606a1b81525081565b6101737f1ec98e70bacc56c6015e16a6a318370da33f3e9d22b7ffe27ff4ec0691fd25bb81565b6102386103513660046112a5565b6107b6565b6101df610364366004610fdc565b610822565b610173610e1081565b61017360055481565b6101df6103893660046112e0565b61083e565b61017360025481565b60006001600160e01b03198216637965db0b60e01b14806103c857506301ffc9a760e01b6001600160e01b03198316145b92915050565b60009081526020819052604090206001015490565b6103ec826103ce565b6103f581610862565b6103ff838361086f565b505050565b6001600160a01b03811633146104795760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b61048382826108f3565b5050565b600082610495836003611318565b815181106104a5576104a561132b565b016020015160f81c6008846104bb856002611318565b815181106104cb576104cb61132b565b016020015160f81c901b6010856104e3866001611318565b815181106104f3576104f361132b565b016020015160f81c901b60188661050b876000611318565b8151811061051b5761051b61132b565b01602001516105339160f89190911c901b6000611318565b61053d9190611318565b6105479190611318565b6105519190611318565b9392505050565b60008460405160200161056b9190611341565b6040516020818303038152906040528051906020012090506105bc604051806040016040528060118152602001701dda1b0b5cdd185d1a5bdb9ccb9b5a5b9d607a1b81525089898985898989610958565b60008551116105ff5760405162461bcd60e51b815260206004820152600f60248201526e1b9bdd1a1a5b99c81d1bc81b5a5b9d608a1b6044820152606401610470565b6008855161060d919061135d565b1561064a5760405162461bcd60e51b815260206004820152600d60248201526c6d616c666f726d65642061726760981b6044820152606401610470565b60005b85518110156107035760006106628783610487565b9050600061067588610202856004611318565b905061068081610aca565b600654604051632952bac760e21b81526001600160a01b038d8116600483015260248201859052604482018490529091169063a54aeb1c90606401600060405180830381600087803b1580156106d557600080fd5b505af11580156106e9573d6000803e3d6000fd5b5050505050506008816106fc9190611318565b905061064d565b505050505050505050565b6040805180820190915260138152721dda1b0b5cdd185d1a5bdb9ccb98d85b98d95b606a1b6020820152610749908787876000888888610958565b505050505050565b6000918252602082815260408084206001600160a01b0393909316845291905290205460ff1690565b6000858585858560405160200161079595949392919061137f565b60405160208183030381529060405280519060200120905095945050505050565b6000610819610811866040517b0ca2ba3432b932bab69029b4b3b732b21026b2b9b9b0b3b29d05199960211b6020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b858585610b50565b95945050505050565b61082b826103ce565b61083481610862565b6103ff83836108f3565b6000805160206114a883398151915261085681610862565b50600291909155600355565b61086c8133610b78565b50565b6108798282610751565b610483576000828152602081815260408083206001600160a01b03851684529091529020805460ff191660011790556108af3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6108fd8282610751565b15610483576000828152602081815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b4285106109925760405162461bcd60e51b8152602060048201526008602482015267746f6f206c61746560c01b6044820152606401610470565b60008681526001602052604090205460ff16156109e35760405162461bcd60e51b815260206004820152600f60248201526e1b9bdb98d9481dd85cc81cdc195b9d608a1b6044820152606401610470565b60008681526001602081905260408220805460ff19169091179055610a0b898989898961077a565b90506000610a1b828686866107b6565b9050610a356000805160206114c883398151915282610751565b610a6e5760405162461bcd60e51b815260206004820152600a6024820152693130b21039b4b3b732b960b11b6044820152606401610470565b87896001600160a01b0316336001600160a01b03167f06084c584196f91d8519dbc9e2161894bd98f2e6efd8664d689fa55d3e71e0768d858b604051610ab6939291906113c6565b60405180910390a450505050505050505050565b426004541015610aea57600254610ae19042611318565b60045560006005555b60035481600554610afb9190611318565b10610b365760405162461bcd60e51b815260206004820152600b60248201526a1c985d195b1a5b5a5d195960aa1b6044820152606401610470565b8060056000828254610b489190611318565b909155505050565b6000806000610b6187878787610bd1565b91509150610b6e81610c8b565b5095945050505050565b610b828282610751565b61048357610b8f81610dd0565b610b9a836020610de2565b604051602001610bab9291906113f4565b60408051601f198184030181529082905262461bcd60e51b82526104709160040161113e565b6000806fa2a8918ca85bafe22016d0b997e4df60600160ff1b03831115610bfe5750600090506003610c82565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015610c52573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610c7b57600060019250925050610c82565b9150600090505b94509492505050565b6000816004811115610c9f57610c9f611463565b03610ca75750565b6001816004811115610cbb57610cbb611463565b03610d035760405162461bcd60e51b815260206004820152601860248201527745434453413a20696e76616c6964207369676e617475726560401b6044820152606401610470565b6002816004811115610d1757610d17611463565b03610d645760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610470565b6003816004811115610d7857610d78611463565b0361086c5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610470565b60606103c86001600160a01b03831660145b60606000610df1836002611479565b610dfc906002611318565b6001600160401b03811115610e1357610e13611008565b6040519080825280601f01601f191660200182016040528015610e3d576020820181803683370190505b509050600360fc1b81600081518110610e5857610e5861132b565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110610e8757610e8761132b565b60200101906001600160f81b031916908160001a9053506000610eab846002611479565b610eb6906001611318565b90505b6001811115610f2e576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110610eea57610eea61132b565b1a60f81b828281518110610f0057610f0061132b565b60200101906001600160f81b031916908160001a90535060049490941c93610f2781611490565b9050610eb9565b5083156105515760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610470565b600060208284031215610f8f57600080fd5b81356001600160e01b03198116811461055157600080fd5b600060208284031215610fb957600080fd5b5035919050565b80356001600160a01b0381168114610fd757600080fd5b919050565b60008060408385031215610fef57600080fd5b82359150610fff60208401610fc0565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b600082601f83011261102f57600080fd5b81356001600160401b038082111561104957611049611008565b604051601f8301601f19908116603f0116810190828211818310171561107157611071611008565b8160405283815286602085880101111561108a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080604083850312156110bd57600080fd5b82356001600160401b038111156110d357600080fd5b6110df8582860161101e565b95602094909401359450505050565b60005b838110156111095781810151838201526020016110f1565b50506000910152565b6000815180845261112a8160208601602086016110ee565b601f01601f19169290920160200192915050565b6020815260006105516020830184611112565b803560ff81168114610fd757600080fd5b600080600080600080600060e0888a03121561117d57600080fd5b61118688610fc0565b9650602088013595506040880135945060608801356001600160401b038111156111af57600080fd5b6111bb8a828b0161101e565b9450506111ca60808901611151565b925060a0880135915060c0880135905092959891949750929550565b60008060008060008060c087890312156111ff57600080fd5b61120887610fc0565b9550602087013594506040870135935061122460608801611151565b92506080870135915060a087013590509295509295509295565b600080600080600060a0868803121561125657600080fd5b85356001600160401b0381111561126c57600080fd5b6112788882890161101e565b95505061128760208701610fc0565b94979496505050506040830135926060810135926080909101359150565b600080600080608085870312156112bb57600080fd5b843593506112cb60208601611151565b93969395505050506040820135916060013590565b600080604083850312156112f357600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b808201808211156103c8576103c8611302565b634e487b7160e01b600052603260045260246000fd5b600082516113538184602087016110ee565b9190910192915050565b60008261137a57634e487b7160e01b600052601260045260246000fd5b500690565b60008651611391818460208b016110ee565b60609690961b6001600160601b0319169190950190815260148101939093526034830191909152605482015260740192915050565b6060815260006113d96060830186611112565b6001600160a01b039490941660208301525060400152919050565b76020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b8152600083516114268160178501602088016110ee565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516114578160288401602088016110ee565b01602801949350505050565b634e487b7160e01b600052602160045260246000fd5b80820281158282048414176103c8576103c8611302565b60008161149f5761149f611302565b50600019019056fe375a720dab3fb5f30de255b583af2e6f4b7a2089cae37b622093b7f1c13e8d90e2f4eaae4a9751e85a3e4a7b9587827a877f29914755229b07a7b2da98285f70a264697066735822122006e25cc37b3bd2ecc8fffceb88b0a18f23c418871f27bdd5c6b42c3326364bcf64736f6c63430008110033