Contract Overview
Balance:
0 MATIC
MATIC Value:
$0.00
My Name Tag:
Not Available, login to update
Txn Hash |
Method
|
Block
|
From
|
To
|
Value | [Txn Fee] | |||
---|---|---|---|---|---|---|---|---|---|
0xec607a154f65792139ae392117cbd6dccf09f38626eb9c27668fcfec0fbd3699 | 0x60806040 | 21986692 | 475 days 10 hrs ago | 0xe5cd62ac8d2ca2a62a04958f07dd239c1ffe1a9e | IN | Contract Creation | 0 MATIC | 0.15270582 |
[ Download CSV Export ]
Similar Match Source Code
Note: This contract matches the deployed ByteCode of the Source Code for Contract 0x8ffbca1775af6e79480271b2c651eec94ac414fc
Contract Name:
PublicLock
Compiler Version
v0.5.17+commit.d19bba13
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
pragma solidity 0.5.17; import './interfaces/IPublicLock.sol'; import '@openzeppelin/upgrades/contracts/Initializable.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/introspection/ERC165.sol'; import './mixins/MixinDisable.sol'; import './mixins/MixinERC721Enumerable.sol'; import './mixins/MixinFunds.sol'; import './mixins/MixinGrantKeys.sol'; import './mixins/MixinKeys.sol'; import './mixins/MixinLockCore.sol'; import './mixins/MixinLockMetadata.sol'; import './mixins/MixinPurchase.sol'; import './mixins/MixinRefunds.sol'; import './mixins/MixinTransfer.sol'; import './mixins/MixinSignatures.sol'; import './mixins/MixinLockManagerRole.sol'; import './mixins/MixinKeyGranterRole.sol'; /** * @title The Lock contract * @author Julien Genestoux (unlock-protocol.com) * @dev ERC165 allows our contract to be queried to determine whether it implements a given interface. * Every ERC-721 compliant contract must implement the ERC165 interface. * https://eips.ethereum.org/EIPS/eip-721 */ contract PublicLock is IPublicLock, Initializable, ERC165, MixinLockManagerRole, MixinKeyGranterRole, MixinSignatures, MixinFunds, MixinDisable, MixinLockCore, MixinKeys, MixinLockMetadata, MixinERC721Enumerable, MixinGrantKeys, MixinPurchase, MixinTransfer, MixinRefunds { function initialize( address _lockCreator, uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string memory _lockName ) public initializer() { MixinFunds._initializeMixinFunds(_tokenAddress); MixinDisable._initializeMixinDisable(); MixinLockCore._initializeMixinLockCore(_lockCreator, _expirationDuration, _keyPrice, _maxNumberOfKeys); MixinLockMetadata._initializeMixinLockMetadata(_lockName); MixinERC721Enumerable._initializeMixinERC721Enumerable(); MixinRefunds._initializeMixinRefunds(); MixinLockManagerRole._initializeMixinLockManagerRole(_lockCreator); MixinKeyGranterRole._initializeMixinKeyGranterRole(_lockCreator); // registering the interface for erc721 with ERC165.sol using // the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721 _registerInterface(0x80ac58cd); } /** * @notice Allow the contract to accept tips in ETH sent directly to the contract. * @dev This is okay to use even if the lock is priced in ERC-20 tokens */ function() external payable {} }
pragma solidity 0.5.17; /** * @title The PublicLock Interface * @author Nick Furfaro (unlock-protocol.com) */ contract IPublicLock { // See indentationissue description here: // https://github.com/duaraghav8/Ethlint/issues/268 // solium-disable indentation /// Functions function initialize( address _lockCreator, uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName ) external; /** * @notice Allow the contract to accept tips in ETH sent directly to the contract. * @dev This is okay to use even if the lock is priced in ERC-20 tokens */ function() external payable; /** * @dev Never used directly */ function initialize() external; /** * @notice The version number of the current implementation on this network. * @return The current version number. */ function publicLockVersion() public pure returns (uint); /** * @notice Gets the current balance of the account provided. * @param _tokenAddress The token type to retrieve the balance of. * @param _account The account to get the balance of. * @return The number of tokens of the given type for the given address, possibly 0. */ function getBalance( address _tokenAddress, address _account ) external view returns (uint); /** * @notice Used to disable lock before migrating keys and/or destroying contract. * @dev Throws if called by other than a lock manager. * @dev Throws if lock contract has already been disabled. */ function disableLock() external; /** * @dev Called by a lock manager or beneficiary to withdraw all funds from the lock and send them to the `beneficiary`. * @dev Throws if called by other than a lock manager or beneficiary * @param _tokenAddress specifies the token address to withdraw or 0 for ETH. This is usually * the same as `tokenAddress` in MixinFunds. * @param _amount specifies the max amount to withdraw, which may be reduced when * considering the available balance. Set to 0 or MAX_UINT to withdraw everything. * -- however be wary of draining funds as it breaks the `cancelAndRefund` and `expireAndRefundFor` * use cases. */ function withdraw( address _tokenAddress, uint _amount ) external; /** * @notice An ERC-20 style approval, allowing the spender to transfer funds directly from this lock. */ function approveBeneficiary( address _spender, uint _amount ) external returns (bool); /** * A function which lets a Lock manager of the lock to change the price for future purchases. * @dev Throws if called by other than a Lock manager * @dev Throws if lock has been disabled * @dev Throws if _tokenAddress is not a valid token * @param _keyPrice The new price to set for keys * @param _tokenAddress The address of the erc20 token to use for pricing the keys, * or 0 to use ETH */ function updateKeyPricing( uint _keyPrice, address _tokenAddress ) external; /** * A function which lets a Lock manager update the beneficiary account, * which receives funds on withdrawal. * @dev Throws if called by other than a Lock manager or beneficiary * @dev Throws if _beneficiary is address(0) * @param _beneficiary The new address to set as the beneficiary */ function updateBeneficiary( address _beneficiary ) external; /** * Checks if the user has a non-expired key. * @param _user The address of the key owner */ function getHasValidKey( address _user ) external view returns (bool); /** * @notice Find the tokenId for a given user * @return The tokenId of the NFT, else returns 0 * @param _account The address of the key owner */ function getTokenIdFor( address _account ) external view returns (uint); /** * A function which returns a subset of the keys for this Lock as an array * @param _page the page of key owners requested when faceted by page size * @param _pageSize the number of Key Owners requested per page * @dev Throws if there are no key owners yet */ function getOwnersByPage( uint _page, uint _pageSize ) external view returns (address[] memory); /** * Checks if the given address owns the given tokenId. * @param _tokenId The tokenId of the key to check * @param _keyOwner The potential key owners address */ function isKeyOwner( uint _tokenId, address _keyOwner ) external view returns (bool); /** * @dev Returns the key's ExpirationTimestamp field for a given owner. * @param _keyOwner address of the user for whom we search the key * @dev Returns 0 if the owner has never owned a key for this lock */ function keyExpirationTimestampFor( address _keyOwner ) external view returns (uint timestamp); /** * Public function which returns the total number of unique owners (both expired * and valid). This may be larger than totalSupply. */ function numberOfOwners() external view returns (uint); /** * Allows a Lock manager to assign a descriptive name for this Lock. * @param _lockName The new name for the lock * @dev Throws if called by other than a Lock manager */ function updateLockName( string calldata _lockName ) external; /** * Allows a Lock manager to assign a Symbol for this Lock. * @param _lockSymbol The new Symbol for the lock * @dev Throws if called by other than a Lock manager */ function updateLockSymbol( string calldata _lockSymbol ) external; /** * @dev Gets the token symbol * @return string representing the token symbol */ function symbol() external view returns(string memory); /** * Allows a Lock manager to update the baseTokenURI for this Lock. * @dev Throws if called by other than a Lock manager * @param _baseTokenURI String representing the base of the URI for this lock. */ function setBaseTokenURI( string calldata _baseTokenURI ) external; /** @notice A distinct Uniform Resource Identifier (URI) for a given asset. * @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC * 3986. The URI may point to a JSON file that conforms to the "ERC721 * Metadata JSON Schema". * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md * @param _tokenId The tokenID we're inquiring about * @return String representing the URI for the requested token */ function tokenURI( uint256 _tokenId ) external view returns(string memory); /** * @notice Allows a Lock manager to add or remove an event hook */ function setEventHooks( address _onKeyPurchaseHook, address _onKeyCancelHook ) external; /** * Allows a Lock manager to give a collection of users a key with no charge. * Each key may be assigned a different expiration date. * @dev Throws if called by other than a Lock manager * @param _recipients An array of receiving addresses * @param _expirationTimestamps An array of expiration Timestamps for the keys being granted */ function grantKeys( address[] calldata _recipients, uint[] calldata _expirationTimestamps, address[] calldata _keyManagers ) external; /** * @dev Purchase function * @param _value the number of tokens to pay for this purchase >= the current keyPrice - any applicable discount * (_value is ignored when using ETH) * @param _recipient address of the recipient of the purchased key * @param _referrer address of the user making the referral * @param _data arbitrary data populated by the front-end which initiated the sale * @dev Throws if lock is disabled. Throws if lock is sold-out. Throws if _recipient == address(0). * @dev Setting _value to keyPrice exactly doubles as a security feature. That way if a Lock manager increases the * price while my transaction is pending I can't be charged more than I expected (only applicable to ERC-20 when more * than keyPrice is approved for spending). */ function purchase( uint256 _value, address _recipient, address _referrer, bytes calldata _data ) external payable; /** * @notice returns the minimum price paid for a purchase with these params. * @dev this considers any discount from Unlock or the OnKeyPurchase hook. */ function purchasePriceFor( address _recipient, address _referrer, bytes calldata _data ) external view returns (uint); /** * Allow a Lock manager to change the transfer fee. * @dev Throws if called by other than a Lock manager * @param _transferFeeBasisPoints The new transfer fee in basis-points(bps). * Ex: 200 bps = 2% */ function updateTransferFee( uint _transferFeeBasisPoints ) external; /** * Determines how much of a fee a key owner would need to pay in order to * transfer the key to another account. This is pro-rated so the fee goes down * overtime. * @dev Throws if _keyOwner does not have a valid key * @param _keyOwner The owner of the key check the transfer fee for. * @param _time The amount of time to calculate the fee for. * @return The transfer fee in seconds. */ function getTransferFee( address _keyOwner, uint _time ) external view returns (uint); /** * @dev Invoked by a Lock manager to expire the user's key and perform a refund and cancellation of the key * @param _keyOwner The key owner to whom we wish to send a refund to * @param amount The amount to refund the key-owner * @dev Throws if called by other than a Lock manager * @dev Throws if _keyOwner does not have a valid key */ function expireAndRefundFor( address _keyOwner, uint amount ) external; /** * @dev allows the key manager to expire a given tokenId * and send a refund to the keyOwner based on the amount of time remaining. * @param _tokenId The id of the key to cancel. */ function cancelAndRefund(uint _tokenId) external; /** * @dev Cancels a key managed by a different user and sends the funds to the keyOwner. * @param _keyManager the key managed by this user will be canceled * @param _v _r _s getCancelAndRefundApprovalHash signed by the _keyManager * @param _tokenId The key to cancel */ function cancelAndRefundFor( address _keyManager, uint8 _v, bytes32 _r, bytes32 _s, uint _tokenId ) external; /** * @notice Sets the minimum nonce for a valid off-chain approval message from the * senders account. * @dev This can be used to invalidate a previously signed message. */ function invalidateOffchainApproval( uint _nextAvailableNonce ) external; /** * Allow a Lock manager to change the refund penalty. * @dev Throws if called by other than a Lock manager * @param _freeTrialLength The new duration of free trials for this lock * @param _refundPenaltyBasisPoints The new refund penaly in basis-points(bps) */ function updateRefundPenalty( uint _freeTrialLength, uint _refundPenaltyBasisPoints ) external; /** * @dev Determines how much of a refund a key owner would receive if they issued * @param _keyOwner The key owner to get the refund value for. * a cancelAndRefund block.timestamp. * Note that due to the time required to mine a tx, the actual refund amount will be lower * than what the user reads from this call. */ function getCancelAndRefundValueFor( address _keyOwner ) external view returns (uint refund); function keyManagerToNonce(address ) external view returns (uint256 ); /** * @notice returns the hash to sign in order to allow another user to cancel on your behalf. * @dev this can be computed in JS instead of read from the contract. * @param _keyManager The key manager's address (also the message signer) * @param _txSender The address cancelling cancel on behalf of the keyOwner * @return approvalHash The hash to sign */ function getCancelAndRefundApprovalHash( address _keyManager, address _txSender ) external view returns (bytes32 approvalHash); function addKeyGranter(address account) external; function addLockManager(address account) external; function isKeyGranter(address account) external view returns (bool); function isLockManager(address account) external view returns (bool); function onKeyPurchaseHook() external view returns(address); function onKeyCancelHook() external view returns(address); function revokeKeyGranter(address _granter) external; function renounceLockManager() external; ///=================================================================== /// Auto-generated getter functions from public state variables function beneficiary() external view returns (address ); function expirationDuration() external view returns (uint256 ); function freeTrialLength() external view returns (uint256 ); function isAlive() external view returns (bool ); function keyPrice() external view returns (uint256 ); function maxNumberOfKeys() external view returns (uint256 ); function owners(uint256 ) external view returns (address ); function refundPenaltyBasisPoints() external view returns (uint256 ); function tokenAddress() external view returns (address ); function transferFeeBasisPoints() external view returns (uint256 ); function unlockProtocol() external view returns (address ); function keyManagerOf(uint) external view returns (address ); ///=================================================================== /** * @notice Allows the key owner to safely share their key (parent key) by * transferring a portion of the remaining time to a new key (child key). * @dev Throws if key is not valid. * @dev Throws if `_to` is the zero address * @param _to The recipient of the shared key * @param _tokenId the key to share * @param _timeShared The amount of time shared * checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256('onERC721Received(address,address,uint,bytes)'))`. * @dev Emit Transfer event */ function shareKey( address _to, uint _tokenId, uint _timeShared ) external; /** * @notice Update transfer and cancel rights for a given key * @param _tokenId The id of the key to assign rights for * @param _keyManager The address to assign the rights to for the given key */ function setKeyManagerOf( uint _tokenId, address _keyManager ) external; /// @notice A descriptive name for a collection of NFTs in this contract function name() external view returns (string memory _name); ///=================================================================== /// From ERC165.sol function supportsInterface(bytes4 interfaceId) external view returns (bool ); ///=================================================================== /// From ERC-721 /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address _owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address _owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; /** * @notice Get the approved address for a single NFT * @dev Throws if `_tokenId` is not a valid NFT. * @param _tokenId The NFT to find the approved address for * @return The approved address for this NFT, or the zero address if there is none */ function getApproved(uint256 _tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address _owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex(address _owner, uint256 index) public view returns (uint256 tokenId); function tokenByIndex(uint256 index) public view returns (uint256); /** * @notice An ERC-20 style transfer. * @param _value sends a token with _value * expirationDuration (the amount of time remaining on a standard purchase). * @dev The typical use case would be to call this with _value 1, which is on par with calling `transferFrom`. If the user * has more than `expirationDuration` time remaining this may use the `shareKey` function to send some but not all of the token. */ function transfer( address _to, uint _value ) external returns (bool success); }
pragma solidity >=0.4.24 <0.7.0; /** * @title Initializable * * @dev Helper contract to support initializer functions. To use it, replace * the constructor with a function that has the `initializer` modifier. * WARNING: Unlike constructors, initializer functions must be manually * invoked. This applies both to deploying an Initializable contract, as well * as extending an Initializable contract via inheritance. * WARNING: When used with inheritance, manual care must be taken to not invoke * a parent initializer twice, or ensure that all initializers are idempotent, * because this is not dealt with automatically as with constructors. */ contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private initializing; /** * @dev Modifier to use in the initializer function of a contract. */ modifier initializer() { require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); bool isTopLevelCall = !initializing; if (isTopLevelCall) { initializing = true; initialized = true; } _; if (isTopLevelCall) { initializing = false; } } /// @dev Returns true if and only if the function is running in the constructor function isConstructor() private view returns (bool) { // extcodesize checks the size of the code stored in an address, and // address returns the current address. Since the code is still not // deployed when running a constructor, any checks on its code size will // yield zero, making it an effective way to detect if a contract is // under construction or not. address self = address(this); uint256 cs; assembly { cs := extcodesize(self) } return cs == 0; } // Reserved storage space to allow for layout changes in the future. uint256[50] private ______gap; }
pragma solidity ^0.5.0; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ contract ERC165 is Initializable, IERC165 { /* * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 */ bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; function initialize() public initializer { // Derived contracts need only register support for their own interfaces, // we register support for ERC165 itself here _registerInterface(_INTERFACE_ID_ERC165); } /** * @dev See {IERC165-supportsInterface}. * * Time complexity O(1), guaranteed to always use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) public view returns (bool) { return _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } uint256[50] private ______gap; }
pragma solidity 0.5.17; import './MixinFunds.sol'; import './MixinLockManagerRole.sol'; /** * @title Mixin allowing the Lock owner to disable a Lock (preventing new purchases) * and then destroy it. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinDisable is MixinLockManagerRole, MixinFunds { // Used to disable payable functions when deprecating an old lock bool public isAlive; event Disable(); function _initializeMixinDisable( ) internal { isAlive = true; } // Only allow usage when contract is Alive modifier onlyIfAlive() { require(isAlive, 'LOCK_DEPRECATED'); _; } /** * @dev Used to disable lock before migrating keys and/or destroying contract */ function disableLock() external onlyLockManager onlyIfAlive { emit Disable(); isAlive = false; } }
pragma solidity 0.5.17; import './MixinKeys.sol'; import './MixinLockCore.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721Enumerable.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/introspection/ERC165.sol'; /** * @title Implements the ERC-721 Enumerable extension. */ contract MixinERC721Enumerable is IERC721Enumerable, ERC165, MixinLockCore, // Implements totalSupply MixinKeys { function _initializeMixinERC721Enumerable() internal { /** * register the supported interface to conform to ERC721Enumerable via ERC165 * 0x780e9d63 === * bytes4(keccak256('totalSupply()')) ^ * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^ * bytes4(keccak256('tokenByIndex(uint256)')) */ _registerInterface(0x780e9d63); } /// @notice Enumerate valid NFTs /// @dev Throws if `_index` >= `totalSupply()`. /// @param _index A counter less than `totalSupply()` /// @return The token identifier for the `_index`th NFT, /// (sort order not specified) function tokenByIndex( uint256 _index ) public view returns (uint256) { require(_index < _totalSupply, 'OUT_OF_RANGE'); return _index; } /// @notice Enumerate NFTs assigned to an owner /// @dev Throws if `_index` >= `balanceOf(_keyOwner)` or if /// `_keyOwner` is the zero address, representing invalid NFTs. /// @param _keyOwner An address where we are interested in NFTs owned by them /// @param _index A counter less than `balanceOf(_keyOwner)` /// @return The token identifier for the `_index`th NFT assigned to `_keyOwner`, /// (sort order not specified) function tokenOfOwnerByIndex( address _keyOwner, uint256 _index ) public view returns (uint256) { require(_index == 0, 'ONLY_ONE_KEY_PER_OWNER'); return getTokenIdFor(_keyOwner); } }
pragma solidity 0.5.17; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol'; /** * @title An implementation of the money related functions. * @author HardlyDifficult (unlock-protocol.com) */ contract MixinFunds { using Address for address payable; using SafeERC20 for IERC20; /** * The token-type that this Lock is priced in. If 0, then use ETH, else this is * a ERC20 token address. */ address public tokenAddress; function _initializeMixinFunds( address _tokenAddress ) internal { tokenAddress = _tokenAddress; require( _tokenAddress == address(0) || IERC20(_tokenAddress).totalSupply() > 0, 'INVALID_TOKEN' ); } /** * Gets the current balance of the account provided. */ function getBalance( address _tokenAddress, address _account ) public view returns (uint) { if(_tokenAddress == address(0)) { return _account.balance; } else { return IERC20(_tokenAddress).balanceOf(_account); } } /** * Transfers funds from the contract to the account provided. * * Security: be wary of re-entrancy when calling this function. */ function _transfer( address _tokenAddress, address _to, uint _amount ) internal { if(_amount > 0) { if(_tokenAddress == address(0)) { // https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/ address(uint160(_to)).sendValue(_amount); } else { IERC20 token = IERC20(_tokenAddress); token.safeTransfer(_to, _amount); } } } }
pragma solidity 0.5.17; import './MixinKeys.sol'; import './MixinKeyGranterRole.sol'; /** * @title Mixin allowing the Lock owner to grant / gift keys to users. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinGrantKeys is MixinKeyGranterRole, MixinKeys { /** * Allows the Lock owner to give a collection of users a key with no charge. * Each key may be assigned a different expiration date. */ function grantKeys( address[] calldata _recipients, uint[] calldata _expirationTimestamps, address[] calldata _keyManagers ) external onlyKeyGranterOrManager { for(uint i = 0; i < _recipients.length; i++) { address recipient = _recipients[i]; uint expirationTimestamp = _expirationTimestamps[i]; address keyManager = _keyManagers[i]; require(recipient != address(0), 'INVALID_ADDRESS'); Key storage toKey = keyByOwner[recipient]; require(expirationTimestamp > toKey.expirationTimestamp, 'ALREADY_OWNS_KEY'); uint idTo = toKey.tokenId; if(idTo == 0) { _assignNewTokenId(toKey); idTo = toKey.tokenId; _recordOwner(recipient, idTo); } // Set the key Manager _setKeyManagerOf(idTo, keyManager); emit KeyManagerChanged(idTo, keyManager); toKey.expirationTimestamp = expirationTimestamp; // trigger event emit Transfer( address(0), // This is a creation. recipient, idTo ); } } }
pragma solidity 0.5.17; import './MixinLockCore.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol'; /** * @title Mixin for managing `Key` data, as well as the * Approval related functions needed to meet the ERC721 * standard. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinKeys is MixinLockCore { using SafeMath for uint; // The struct for a key struct Key { uint tokenId; uint expirationTimestamp; } // Emitted when the Lock owner expires a user's Key event ExpireKey(uint indexed tokenId); // Emitted when the expiration of a key is modified event ExpirationChanged( uint indexed _tokenId, uint _amount, bool _timeAdded ); event KeyManagerChanged(uint indexed _tokenId, address indexed _newManager); // Keys // Each owner can have at most exactly one key // TODO: could we use public here? (this could be confusing though because it getter will // return 0 values when missing a key) mapping (address => Key) internal keyByOwner; // Each tokenId can have at most exactly one owner at a time. // Returns 0 if the token does not exist // TODO: once we decouple tokenId from owner address (incl in js), then we can consider // merging this with totalSupply into an array instead. mapping (uint => address) internal _ownerOf; // Addresses of owners are also stored in an array. // Addresses are never removed by design to avoid abuses around referals address[] public owners; // A given key has both an owner and a manager. // If keyManager == address(0) then the key owner is also the manager // Each key can have at most 1 keyManager. mapping (uint => address) public keyManagerOf; // Keeping track of approved transfers // This is a mapping of addresses which have approved // the transfer of a key to another address where their key can be transferred // Note: the approver may actually NOT have a key... and there can only // be a single approved address mapping (uint => address) private approved; // Keeping track of approved operators for a given Key manager. // This approves a given operator for all keys managed by the calling "keyManager" // The caller may not currently be the keyManager for ANY keys. // These approvals are never reset/revoked automatically, unlike "approved", // which is reset on transfer. mapping (address => mapping (address => bool)) private managerToOperatorApproved; // Ensure that the caller is the keyManager of the key // or that the caller has been approved // for ownership of that key modifier onlyKeyManagerOrApproved( uint _tokenId ) { require( _isKeyManager(_tokenId, msg.sender) || _isApproved(_tokenId, msg.sender) || isApprovedForAll(_ownerOf[_tokenId], msg.sender), 'ONLY_KEY_MANAGER_OR_APPROVED' ); _; } // Ensures that an owner owns or has owned a key in the past modifier ownsOrHasOwnedKey( address _keyOwner ) { require( keyByOwner[_keyOwner].expirationTimestamp > 0, 'HAS_NEVER_OWNED_KEY' ); _; } // Ensures that an owner has a valid key modifier hasValidKey( address _user ) { require( getHasValidKey(_user), 'KEY_NOT_VALID' ); _; } // Ensures that a key has an owner modifier isKey( uint _tokenId ) { require( _ownerOf[_tokenId] != address(0), 'NO_SUCH_KEY' ); _; } // Ensure that the caller owns the key modifier onlyKeyOwner( uint _tokenId ) { require( isKeyOwner(_tokenId, msg.sender), 'ONLY_KEY_OWNER' ); _; } /** * In the specific case of a Lock, each owner can own only at most 1 key. * @return The number of NFTs owned by `_keyOwner`, either 0 or 1. */ function balanceOf( address _keyOwner ) public view returns (uint) { require(_keyOwner != address(0), 'INVALID_ADDRESS'); return getHasValidKey(_keyOwner) ? 1 : 0; } /** * Checks if the user has a non-expired key. */ function getHasValidKey( address _keyOwner ) public view returns (bool) { return keyByOwner[_keyOwner].expirationTimestamp > block.timestamp; } /** * @notice Find the tokenId for a given user * @return The tokenId of the NFT, else returns 0 */ function getTokenIdFor( address _account ) public view returns (uint) { return keyByOwner[_account].tokenId; } /** * A function which returns a subset of the keys for this Lock as an array * @param _page the page of key owners requested when faceted by page size * @param _pageSize the number of Key Owners requested per page */ function getOwnersByPage(uint _page, uint _pageSize) public view returns (address[] memory) { uint pageSize = _pageSize; uint _startIndex = _page * pageSize; uint endOfPageIndex; if (_startIndex + pageSize > owners.length) { endOfPageIndex = owners.length; pageSize = owners.length - _startIndex; } else { endOfPageIndex = (_startIndex + pageSize); } // new temp in-memory array to hold pageSize number of requested owners: address[] memory ownersByPage = new address[](pageSize); uint pageIndex = 0; // Build the requested set of owners into a new temporary array: for (uint i = _startIndex; i < endOfPageIndex; i++) { ownersByPage[pageIndex] = owners[i]; pageIndex++; } return ownersByPage; } /** * Checks if the given address owns the given tokenId. */ function isKeyOwner( uint _tokenId, address _keyOwner ) public view returns (bool) { return _ownerOf[_tokenId] == _keyOwner; } /** * @dev Returns the key's ExpirationTimestamp field for a given owner. * @param _keyOwner address of the user for whom we search the key * @dev Returns 0 if the owner has never owned a key for this lock */ function keyExpirationTimestampFor( address _keyOwner ) public view returns (uint) { return keyByOwner[_keyOwner].expirationTimestamp; } /** * Public function which returns the total number of unique owners (both expired * and valid). This may be larger than totalSupply. */ function numberOfOwners() public view returns (uint) { return owners.length; } // Returns the owner of a given tokenId function ownerOf( uint _tokenId ) public view returns(address) { return _ownerOf[_tokenId]; } /** * @notice Public function for updating transfer and cancel rights for a given key * @param _tokenId The id of the key to assign rights for * @param _keyManager The address with the manager's rights for the given key. * Setting _keyManager to address(0) means the keyOwner is also the keyManager */ function setKeyManagerOf( uint _tokenId, address _keyManager ) public isKey(_tokenId) { require( _isKeyManager(_tokenId, msg.sender) || isLockManager(msg.sender), 'UNAUTHORIZED_KEY_MANAGER_UPDATE' ); _setKeyManagerOf(_tokenId, _keyManager); } function _setKeyManagerOf( uint _tokenId, address _keyManager ) internal { if(keyManagerOf[_tokenId] != _keyManager) { keyManagerOf[_tokenId] = _keyManager; _clearApproval(_tokenId); emit KeyManagerChanged(_tokenId, address(0)); } } /** * This approves _approved to get ownership of _tokenId. * Note: that since this is used for both purchase and transfer approvals * the approved token may not exist. */ function approve( address _approved, uint _tokenId ) public onlyIfAlive onlyKeyManagerOrApproved(_tokenId) { require(msg.sender != _approved, 'APPROVE_SELF'); approved[_tokenId] = _approved; emit Approval(_ownerOf[_tokenId], _approved, _tokenId); } /** * @notice Get the approved address for a single NFT * @dev Throws if `_tokenId` is not a valid NFT. * @param _tokenId The NFT to find the approved address for * @return The approved address for this NFT, or the zero address if there is none */ function getApproved( uint _tokenId ) public view isKey(_tokenId) returns (address) { address approvedRecipient = approved[_tokenId]; return approvedRecipient; } /** * @dev Tells whether an operator is approved by a given keyManager * @param _owner owner address which you want to query the approval of * @param _operator operator address which you want to query the approval of * @return bool whether the given operator is approved by the given owner */ function isApprovedForAll( address _owner, address _operator ) public view returns (bool) { uint tokenId = keyByOwner[_owner].tokenId; address keyManager = keyManagerOf[tokenId]; if(keyManager == address(0)) { return managerToOperatorApproved[_owner][_operator]; } else { return managerToOperatorApproved[keyManager][_operator]; } } /** * Returns true if _keyManager is the manager of the key * identified by _tokenId */ function _isKeyManager( uint _tokenId, address _keyManager ) internal view returns (bool) { if(keyManagerOf[_tokenId] == _keyManager || (keyManagerOf[_tokenId] == address(0) && isKeyOwner(_tokenId, _keyManager))) { return true; } else { return false; } } /** * Assigns the key a new tokenId (from totalSupply) if it does not already have * one assigned. */ function _assignNewTokenId( Key storage _key ) internal { if (_key.tokenId == 0) { // This is a brand new owner // We increment the tokenId counter _totalSupply++; // we assign the incremented `_totalSupply` as the tokenId for the new key _key.tokenId = _totalSupply; } } /** * Records the owner of a given tokenId */ function _recordOwner( address _keyOwner, uint _tokenId ) internal { if (_ownerOf[_tokenId] != _keyOwner) { // TODO: this may include duplicate entries owners.push(_keyOwner); // We register the owner of the tokenID _ownerOf[_tokenId] = _keyOwner; } } /** * @notice Modify the expirationTimestamp of a key * by a given amount. * @param _tokenId The ID of the key to modify. * @param _deltaT The amount of time in seconds by which * to modify the keys expirationTimestamp * @param _addTime Choose whether to increase or decrease * expirationTimestamp (false == decrease, true == increase) * @dev Throws if owner does not have a valid key. */ function _timeMachine( uint _tokenId, uint256 _deltaT, bool _addTime ) internal { address tokenOwner = _ownerOf[_tokenId]; require(tokenOwner != address(0), 'NON_EXISTENT_KEY'); Key storage key = keyByOwner[tokenOwner]; uint formerTimestamp = key.expirationTimestamp; bool validKey = getHasValidKey(tokenOwner); if(_addTime) { if(validKey) { key.expirationTimestamp = formerTimestamp.add(_deltaT); } else { key.expirationTimestamp = block.timestamp.add(_deltaT); } } else { key.expirationTimestamp = formerTimestamp.sub(_deltaT); } emit ExpirationChanged(_tokenId, _deltaT, _addTime); } /** * @dev Sets or unsets the approval of a given operator * An operator is allowed to transfer all tokens of the sender on their behalf * @param _to operator address to set the approval * @param _approved representing the status of the approval to be set */ function setApprovalForAll( address _to, bool _approved ) public onlyIfAlive { require(_to != msg.sender, 'APPROVE_SELF'); managerToOperatorApproved[msg.sender][_to] = _approved; emit ApprovalForAll(msg.sender, _to, _approved); } /** * @dev Checks if the given user is approved to transfer the tokenId. */ function _isApproved( uint _tokenId, address _user ) internal view returns (bool) { return approved[_tokenId] == _user; } /** * @dev Function to clear current approval of a given token ID * @param _tokenId uint256 ID of the token to be transferred */ function _clearApproval( uint256 _tokenId ) internal { if (approved[_tokenId] != address(0)) { approved[_tokenId] = address(0); } } }
pragma solidity 0.5.17; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721Enumerable.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol'; import './MixinDisable.sol'; import './MixinLockManagerRole.sol'; import '../interfaces/IUnlock.sol'; import './MixinFunds.sol'; import '../interfaces/hooks/ILockKeyCancelHook.sol'; import '../interfaces/hooks/ILockKeyPurchaseHook.sol'; /** * @title Mixin for core lock data and functions. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinLockCore is IERC721Enumerable, MixinLockManagerRole, MixinFunds, MixinDisable { using Address for address; event Withdrawal( address indexed sender, address indexed tokenAddress, address indexed beneficiary, uint amount ); event PricingChanged( uint oldKeyPrice, uint keyPrice, address oldTokenAddress, address tokenAddress ); // Unlock Protocol address // TODO: should we make that private/internal? IUnlock public unlockProtocol; // Duration in seconds for which the keys are valid, after creation // should we take a smaller type use less gas? // TODO: add support for a timestamp instead of duration uint public expirationDuration; // price in wei of the next key // TODO: allow support for a keyPriceCalculator which could set prices dynamically uint public keyPrice; // Max number of keys sold if the keyReleaseMechanism is public uint public maxNumberOfKeys; // A count of how many new key purchases there have been uint internal _totalSupply; // The account which will receive funds on withdrawal address public beneficiary; // The denominator component for values specified in basis points. uint internal constant BASIS_POINTS_DEN = 10000; ILockKeyPurchaseHook public onKeyPurchaseHook; ILockKeyCancelHook public onKeyCancelHook; // Ensure that the Lock has not sold all of its keys. modifier notSoldOut() { require(maxNumberOfKeys > _totalSupply, 'LOCK_SOLD_OUT'); _; } modifier onlyLockManagerOrBeneficiary() { require( isLockManager(msg.sender) || msg.sender == beneficiary, 'ONLY_LOCK_MANAGER_OR_BENEFICIARY' ); _; } function _initializeMixinLockCore( address _beneficiary, uint _expirationDuration, uint _keyPrice, uint _maxNumberOfKeys ) internal { require(_expirationDuration <= 100 * 365 * 24 * 60 * 60, 'MAX_EXPIRATION_100_YEARS'); unlockProtocol = IUnlock(msg.sender); // Make sure we link back to Unlock's smart contract. beneficiary = _beneficiary; expirationDuration = _expirationDuration; keyPrice = _keyPrice; maxNumberOfKeys = _maxNumberOfKeys; } // The version number of the current implementation on this network function publicLockVersion( ) public pure returns (uint) { return 8; } /** * @dev Called by owner to withdraw all funds from the lock and send them to the `beneficiary`. * @param _tokenAddress specifies the token address to withdraw or 0 for ETH. This is usually * the same as `tokenAddress` in MixinFunds. * @param _amount specifies the max amount to withdraw, which may be reduced when * considering the available balance. Set to 0 or MAX_UINT to withdraw everything. * * TODO: consider allowing anybody to trigger this as long as it goes to owner anyway? * -- however be wary of draining funds as it breaks the `cancelAndRefund` and `expireAndRefundFor` * use cases. */ function withdraw( address _tokenAddress, uint _amount ) external onlyLockManagerOrBeneficiary { uint balance = getBalance(_tokenAddress, address(this)); uint amount; if(_amount == 0 || _amount > balance) { require(balance > 0, 'NOT_ENOUGH_FUNDS'); amount = balance; } else { amount = _amount; } emit Withdrawal(msg.sender, _tokenAddress, beneficiary, amount); // Security: re-entrancy not a risk as this is the last line of an external function _transfer(_tokenAddress, beneficiary, amount); } /** * A function which lets the owner of the lock change the pricing for future purchases. * This consists of 2 parts: The token address and the price in the given token. * In order to set the token to ETH, use 0 for the token Address. */ function updateKeyPricing( uint _keyPrice, address _tokenAddress ) external onlyLockManager onlyIfAlive { uint oldKeyPrice = keyPrice; address oldTokenAddress = tokenAddress; require( _tokenAddress == address(0) || IERC20(_tokenAddress).totalSupply() > 0, 'INVALID_TOKEN' ); keyPrice = _keyPrice; tokenAddress = _tokenAddress; emit PricingChanged(oldKeyPrice, keyPrice, oldTokenAddress, tokenAddress); } /** * A function which lets the owner of the lock update the beneficiary account, * which receives funds on withdrawal. */ function updateBeneficiary( address _beneficiary ) external { require(msg.sender == beneficiary || isLockManager(msg.sender), 'ONLY_BENEFICIARY_OR_LOCKMANAGER'); require(_beneficiary != address(0), 'INVALID_ADDRESS'); beneficiary = _beneficiary; } /** * @notice Allows a lock manager to add or remove an event hook */ function setEventHooks( address _onKeyPurchaseHook, address _onKeyCancelHook ) external onlyLockManager() { require(_onKeyPurchaseHook == address(0) || _onKeyPurchaseHook.isContract(), 'INVALID_ON_KEY_SOLD_HOOK'); require(_onKeyCancelHook == address(0) || _onKeyCancelHook.isContract(), 'INVALID_ON_KEY_CANCEL_HOOK'); onKeyPurchaseHook = ILockKeyPurchaseHook(_onKeyPurchaseHook); onKeyCancelHook = ILockKeyCancelHook(_onKeyCancelHook); } function totalSupply() public view returns(uint256) { return _totalSupply; } /** * @notice An ERC-20 style approval, allowing the spender to transfer funds directly from this lock. */ function approveBeneficiary( address _spender, uint _amount ) public onlyLockManagerOrBeneficiary returns (bool) { return IERC20(tokenAddress).approve(_spender, _amount); } }
pragma solidity 0.5.17; import '@openzeppelin/contracts-ethereum-package/contracts/introspection/ERC165.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721Enumerable.sol'; import '../UnlockUtils.sol'; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinLockManagerRole.sol'; /** * @title Mixin for metadata about the Lock. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinLockMetadata is IERC721Enumerable, ERC165, MixinLockManagerRole, MixinLockCore, MixinKeys { using UnlockUtils for uint; using UnlockUtils for address; using UnlockUtils for string; /// A descriptive name for a collection of NFTs in this contract.Defaults to "Unlock-Protocol" but is settable by lock owner string public name; /// An abbreviated name for NFTs in this contract. Defaults to "KEY" but is settable by lock owner string private lockSymbol; // the base Token URI for this Lock. If not set by lock owner, the global URI stored in Unlock is used. string private baseTokenURI; event NewLockSymbol( string symbol ); function _initializeMixinLockMetadata( string memory _lockName ) internal { ERC165.initialize(); name = _lockName; // registering the optional erc721 metadata interface with ERC165.sol using // the ID specified in the standard: https://eips.ethereum.org/EIPS/eip-721 _registerInterface(0x5b5e139f); } /** * Allows the Lock owner to assign a descriptive name for this Lock. */ function updateLockName( string calldata _lockName ) external onlyLockManager { name = _lockName; } /** * Allows the Lock owner to assign a Symbol for this Lock. */ function updateLockSymbol( string calldata _lockSymbol ) external onlyLockManager { lockSymbol = _lockSymbol; emit NewLockSymbol(_lockSymbol); } /** * @dev Gets the token symbol * @return string representing the token name */ function symbol() external view returns(string memory) { if(bytes(lockSymbol).length == 0) { return unlockProtocol.globalTokenSymbol(); } else { return lockSymbol; } } /** * Allows the Lock owner to update the baseTokenURI for this Lock. */ function setBaseTokenURI( string calldata _baseTokenURI ) external onlyLockManager { baseTokenURI = _baseTokenURI; } /** @notice A distinct Uniform Resource Identifier (URI) for a given asset. * @param _tokenId The iD of the token for which we want to retrieve the URI. * If 0 is passed here, we just return the appropriate baseTokenURI. * If a custom URI has been set we don't return the lock address. * It may be included in the custom baseTokenURI if needed. * @dev URIs are defined in RFC 3986. The URI may point to a JSON file * that conforms to the "ERC721 Metadata JSON Schema". * https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md */ function tokenURI( uint256 _tokenId ) external view returns(string memory) { string memory URI; string memory tokenId; string memory lockAddress = address(this).address2Str(); string memory seperator; if(_tokenId != 0) { tokenId = _tokenId.uint2Str(); } else { tokenId = ''; } if(bytes(baseTokenURI).length == 0) { URI = unlockProtocol.globalBaseTokenURI(); seperator = '/'; } else { URI = baseTokenURI; seperator = ''; lockAddress = ''; } return URI.strConcat( lockAddress, seperator, tokenId ); } }
pragma solidity 0.5.17; import './MixinDisable.sol'; import './MixinKeys.sol'; import './MixinLockCore.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol'; import './MixinFunds.sol'; /** * @title Mixin for the purchase-related functions. * @author HardlyDifficult * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinPurchase is MixinFunds, MixinDisable, MixinLockCore, MixinKeys { using SafeMath for uint; event RenewKeyPurchase(address indexed owner, uint newExpiration); /** * @dev Purchase function * @param _value the number of tokens to pay for this purchase >= the current keyPrice - any applicable discount * (_value is ignored when using ETH) * @param _recipient address of the recipient of the purchased key * @param _referrer address of the user making the referral * @param _data arbitrary data populated by the front-end which initiated the sale * @dev Setting _value to keyPrice exactly doubles as a security feature. That way if the lock owner increases the * price while my transaction is pending I can't be charged more than I expected (only applicable to ERC-20 when more * than keyPrice is approved for spending). */ function purchase( uint256 _value, address _recipient, address _referrer, bytes calldata _data ) external payable onlyIfAlive notSoldOut { require(_recipient != address(0), 'INVALID_ADDRESS'); // Assign the key Key storage toKey = keyByOwner[_recipient]; uint idTo = toKey.tokenId; uint newTimeStamp; if (idTo == 0) { // Assign a new tokenId (if a new owner or previously transferred) _assignNewTokenId(toKey); // refresh the cached value idTo = toKey.tokenId; _recordOwner(_recipient, idTo); newTimeStamp = block.timestamp + expirationDuration; toKey.expirationTimestamp = newTimeStamp; // trigger event emit Transfer( address(0), // This is a creation. _recipient, idTo ); } else if (toKey.expirationTimestamp > block.timestamp) { // This is an existing owner trying to extend their key newTimeStamp = toKey.expirationTimestamp.add(expirationDuration); toKey.expirationTimestamp = newTimeStamp; emit RenewKeyPurchase(_recipient, newTimeStamp); } else { // This is an existing owner trying to renew their expired key // SafeAdd is not required here since expirationDuration is capped to a tiny value // (relative to the size of a uint) newTimeStamp = block.timestamp + expirationDuration; toKey.expirationTimestamp = newTimeStamp; // reset the key Manager to 0x00 _setKeyManagerOf(idTo, address(0)); emit RenewKeyPurchase(_recipient, newTimeStamp); } (uint inMemoryKeyPrice, uint discount, uint tokens) = _purchasePriceFor(_recipient, _referrer, _data); if (discount > 0) { unlockProtocol.recordConsumedDiscount(discount, tokens); } // Record price without any tips unlockProtocol.recordKeyPurchase(inMemoryKeyPrice, _referrer); // We explicitly allow for greater amounts of ETH or tokens to allow 'donations' uint pricePaid; if(tokenAddress != address(0)) { pricePaid = _value; IERC20 token = IERC20(tokenAddress); token.safeTransferFrom(msg.sender, address(this), _value); } else { pricePaid = msg.value; } require(pricePaid >= inMemoryKeyPrice, 'INSUFFICIENT_VALUE'); if(address(onKeyPurchaseHook) != address(0)) { onKeyPurchaseHook.onKeyPurchase(msg.sender, _recipient, _referrer, _data, inMemoryKeyPrice, pricePaid); } } /** * @notice returns the minimum price paid for a purchase with these params. * @dev minKeyPrice considers any discount from Unlock or the OnKeyPurchase hook */ function purchasePriceFor( address _recipient, address _referrer, bytes calldata _data ) external view returns (uint minKeyPrice) { (minKeyPrice, , ) = _purchasePriceFor(_recipient, _referrer, _data); } /** * @notice returns the minimum price paid for a purchase with these params. * @dev minKeyPrice considers any discount from Unlock or the OnKeyPurchase hook * unlockDiscount and unlockTokens are the values returned from `computeAvailableDiscountFor` */ function _purchasePriceFor( address _recipient, address _referrer, bytes memory _data ) internal view returns (uint minKeyPrice, uint unlockDiscount, uint unlockTokens) { if(address(onKeyPurchaseHook) != address(0)) { minKeyPrice = onKeyPurchaseHook.keyPurchasePrice(msg.sender, _recipient, _referrer, _data); } else { minKeyPrice = keyPrice; } if(minKeyPrice > 0) { (unlockDiscount, unlockTokens) = unlockProtocol.computeAvailableDiscountFor(_recipient, minKeyPrice); require(unlockDiscount <= minKeyPrice, 'INVALID_DISCOUNT_FROM_UNLOCK'); minKeyPrice -= unlockDiscount; } } }
pragma solidity 0.5.17; import '@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol'; import './MixinSignatures.sol'; import './MixinKeys.sol'; import './MixinLockCore.sol'; import './MixinLockManagerRole.sol'; import './MixinFunds.sol'; contract MixinRefunds is MixinLockManagerRole, MixinSignatures, MixinFunds, MixinLockCore, MixinKeys { using SafeMath for uint; // CancelAndRefund will return funds based on time remaining minus this penalty. // This is calculated as `proRatedRefund * refundPenaltyBasisPoints / BASIS_POINTS_DEN`. uint public refundPenaltyBasisPoints; uint public freeTrialLength; /// @notice The typehash per the EIP-712 standard /// @dev This can be computed in JS instead of read from the contract bytes32 private constant CANCEL_TYPEHASH = keccak256('cancelAndRefundFor(address _keyOwner)'); event CancelKey( uint indexed tokenId, address indexed owner, address indexed sendTo, uint refund ); event RefundPenaltyChanged( uint freeTrialLength, uint refundPenaltyBasisPoints ); function _initializeMixinRefunds() internal { // default to 10% refundPenaltyBasisPoints = 1000; } /** * @dev Invoked by the lock owner to destroy the user's ket and perform a refund and cancellation * of the key */ function expireAndRefundFor( address _keyOwner, uint amount ) external onlyLockManager hasValidKey(_keyOwner) { _cancelAndRefund(_keyOwner, amount); } /** * @dev Destroys the key and sends a refund based on the amount of time remaining. * @param _tokenId The id of the key to cancel. */ function cancelAndRefund(uint _tokenId) external onlyKeyManagerOrApproved(_tokenId) { address keyOwner = ownerOf(_tokenId); uint refund = _getCancelAndRefundValue(keyOwner); _cancelAndRefund(keyOwner, refund); } /** * @dev Cancels a key managed by a different user and sends the funds to the msg.sender. * @param _keyManager the key managed by this user will be canceled * @param _v _r _s getCancelAndRefundApprovalHash signed by the _keyOwner * @param _tokenId The key to cancel */ function cancelAndRefundFor( address _keyManager, uint8 _v, bytes32 _r, bytes32 _s, uint _tokenId ) external consumeOffchainApproval( getCancelAndRefundApprovalHash(_keyManager, msg.sender), _keyManager, _v, _r, _s ) { address keyOwner = ownerOf(_tokenId); uint refund = _getCancelAndRefundValue(keyOwner); _cancelAndRefund(keyOwner, refund); } /** * Allow the owner to change the refund penalty. */ function updateRefundPenalty( uint _freeTrialLength, uint _refundPenaltyBasisPoints ) external onlyLockManager { emit RefundPenaltyChanged( _freeTrialLength, _refundPenaltyBasisPoints ); freeTrialLength = _freeTrialLength; refundPenaltyBasisPoints = _refundPenaltyBasisPoints; } /** * @dev Determines how much of a refund a key owner would receive if they issued * a cancelAndRefund block.timestamp. * Note that due to the time required to mine a tx, the actual refund amount will be lower * than what the user reads from this call. */ function getCancelAndRefundValueFor( address _keyOwner ) external view returns (uint refund) { return _getCancelAndRefundValue(_keyOwner); } /** * @notice returns the hash to sign in order to allow another user to cancel on your behalf. * @dev this can be computed in JS instead of read from the contract. * @param _keyManager The key manager's address (also the message signer) * @param _txSender The address cancelling cancel on behalf of the keyOwner * @return approvalHash The hash to sign */ function getCancelAndRefundApprovalHash( address _keyManager, address _txSender ) public view returns (bytes32 approvalHash) { return keccak256( abi.encodePacked( // Approval is specific to this Lock address(this), // The specific function the signer is approving CANCEL_TYPEHASH, // Approval enables only one cancel call keyManagerToNonce[_keyManager], // Approval allows only one account to broadcast the tx _txSender ) ); } /** * @dev cancels the key for the given keyOwner and sends the refund to the msg.sender. */ function _cancelAndRefund( address _keyOwner, uint refund ) internal { Key storage key = keyByOwner[_keyOwner]; emit CancelKey(key.tokenId, _keyOwner, msg.sender, refund); // expirationTimestamp is a proxy for hasKey, setting this to `block.timestamp` instead // of 0 so that we can still differentiate hasKey from hasValidKey. key.expirationTimestamp = block.timestamp; if (refund > 0) { // Security: doing this last to avoid re-entrancy concerns _transfer(tokenAddress, _keyOwner, refund); } // inform the hook if there is one registered if(address(onKeyCancelHook) != address(0)) { onKeyCancelHook.onKeyCancel(msg.sender, _keyOwner, refund); } } /** * @dev Determines how much of a refund a key owner would receive if they issued * a cancelAndRefund now. * @param _keyOwner The owner of the key check the refund value for. */ function _getCancelAndRefundValue( address _keyOwner ) private view hasValidKey(_keyOwner) returns (uint refund) { Key storage key = keyByOwner[_keyOwner]; // Math: safeSub is not required since `hasValidKey` confirms timeRemaining is positive uint timeRemaining = key.expirationTimestamp - block.timestamp; if(timeRemaining + freeTrialLength >= expirationDuration) { refund = keyPrice; } else { // Math: using safeMul in case keyPrice or timeRemaining is very large refund = keyPrice.mul(timeRemaining) / expirationDuration; } // Apply the penalty if this is not a free trial if(freeTrialLength == 0 || timeRemaining + freeTrialLength < expirationDuration) { uint penalty = keyPrice.mul(refundPenaltyBasisPoints) / BASIS_POINTS_DEN; if (refund > penalty) { // Math: safeSub is not required since the if confirms this won't underflow refund -= penalty; } else { refund = 0; } } } }
pragma solidity 0.5.17; import './MixinLockManagerRole.sol'; import './MixinDisable.sol'; import './MixinKeys.sol'; import './MixinFunds.sol'; import './MixinLockCore.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/IERC721Receiver.sol'; import '@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol'; /** * @title Mixin for the transfer-related functions needed to meet the ERC721 * standard. * @author Nick Furfaro * @dev `Mixins` are a design pattern seen in the 0x contracts. It simply * separates logically groupings of code to ease readability. */ contract MixinTransfer is MixinLockManagerRole, MixinFunds, MixinLockCore, MixinKeys { using SafeMath for uint; using Address for address; event TransferFeeChanged( uint transferFeeBasisPoints ); // 0x150b7a02 == bytes4(keccak256('onERC721Received(address,address,uint256,bytes)')) bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; // The fee relative to keyPrice to charge when transfering a Key to another account // (potentially on a 0x marketplace). // This is calculated as `keyPrice * transferFeeBasisPoints / BASIS_POINTS_DEN`. uint public transferFeeBasisPoints; /** * @notice Allows the key owner to safely share their key (parent key) by * transferring a portion of the remaining time to a new key (child key). * @param _to The recipient of the shared key * @param _tokenId the key to share * @param _timeShared The amount of time shared */ function shareKey( address _to, uint _tokenId, uint _timeShared ) public onlyIfAlive onlyKeyManagerOrApproved(_tokenId) { require(transferFeeBasisPoints < BASIS_POINTS_DEN, 'KEY_TRANSFERS_DISABLED'); require(_to != address(0), 'INVALID_ADDRESS'); address keyOwner = _ownerOf[_tokenId]; require(getHasValidKey(keyOwner), 'KEY_NOT_VALID'); Key storage fromKey = keyByOwner[keyOwner]; Key storage toKey = keyByOwner[_to]; uint idTo = toKey.tokenId; uint time; // get the remaining time for the origin key uint timeRemaining = fromKey.expirationTimestamp - block.timestamp; // get the transfer fee based on amount of time wanted share uint fee = getTransferFee(keyOwner, _timeShared); uint timePlusFee = _timeShared.add(fee); // ensure that we don't try to share too much if(timePlusFee < timeRemaining) { // now we can safely set the time time = _timeShared; // deduct time from parent key, including transfer fee _timeMachine(_tokenId, timePlusFee, false); } else { // we have to recalculate the fee here fee = getTransferFee(keyOwner, timeRemaining); time = timeRemaining - fee; fromKey.expirationTimestamp = block.timestamp; // Effectively expiring the key emit ExpireKey(_tokenId); } if (idTo == 0) { _assignNewTokenId(toKey); idTo = toKey.tokenId; _recordOwner(_to, idTo); emit Transfer( address(0), // This is a creation or time-sharing _to, idTo ); } else if (toKey.expirationTimestamp <= block.timestamp) { // reset the key Manager for expired keys _setKeyManagerOf(idTo, address(0)); } // add time to new key _timeMachine(idTo, time, true); // trigger event emit Transfer( keyOwner, _to, idTo ); require(_checkOnERC721Received(keyOwner, _to, _tokenId, ''), 'NON_COMPLIANT_ERC721_RECEIVER'); } function transferFrom( address _from, address _recipient, uint _tokenId ) public onlyIfAlive hasValidKey(_from) onlyKeyManagerOrApproved(_tokenId) { require(isKeyOwner(_tokenId, _from), 'TRANSFER_FROM: NOT_KEY_OWNER'); require(transferFeeBasisPoints < BASIS_POINTS_DEN, 'KEY_TRANSFERS_DISABLED'); require(_recipient != address(0), 'INVALID_ADDRESS'); uint fee = getTransferFee(_from, 0); Key storage fromKey = keyByOwner[_from]; Key storage toKey = keyByOwner[_recipient]; uint previousExpiration = toKey.expirationTimestamp; // subtract the fee from the senders key before the transfer _timeMachine(_tokenId, fee, false); if (toKey.tokenId == 0) { toKey.tokenId = _tokenId; _recordOwner(_recipient, _tokenId); // Clear any previous approvals _clearApproval(_tokenId); } if (previousExpiration <= block.timestamp) { // The recipient did not have a key, or had a key but it expired. The new expiration is the sender's key expiration // An expired key is no longer a valid key, so the new tokenID is the sender's tokenID toKey.expirationTimestamp = fromKey.expirationTimestamp; toKey.tokenId = _tokenId; // Reset the key Manager to the key owner _setKeyManagerOf(_tokenId, address(0)); _recordOwner(_recipient, _tokenId); } else { // The recipient has a non expired key. We just add them the corresponding remaining time // SafeSub is not required since the if confirms `previousExpiration - block.timestamp` cannot underflow toKey.expirationTimestamp = fromKey .expirationTimestamp.add(previousExpiration - block.timestamp); } // Effectively expiring the key for the previous owner fromKey.expirationTimestamp = block.timestamp; // Set the tokenID to 0 for the previous owner to avoid duplicates fromKey.tokenId = 0; // trigger event emit Transfer( _from, _recipient, _tokenId ); } /** * @notice An ERC-20 style transfer. * @param _value sends a token with _value * expirationDuration (the amount of time remaining on a standard purchase). * @dev The typical use case would be to call this with _value 1, which is on par with calling `transferFrom`. If the user * has more than `expirationDuration` time remaining this may use the `shareKey` function to send some but not all of the token. */ function transfer( address _to, uint _value ) public returns (bool success) { uint maxTimeToSend = _value * expirationDuration; Key storage fromKey = keyByOwner[msg.sender]; uint timeRemaining = fromKey.expirationTimestamp.sub(block.timestamp); if(maxTimeToSend < timeRemaining) { shareKey(_to, fromKey.tokenId, maxTimeToSend); } else { transferFrom(msg.sender, _to, fromKey.tokenId); } // Errors will cause a revert return true; } /** * @notice Transfers the ownership of an NFT from one address to another address * @dev This works identically to the other function with an extra data parameter, * except this function just sets data to '' * @param _from The current owner of the NFT * @param _to The new owner * @param _tokenId The NFT to transfer */ function safeTransferFrom( address _from, address _to, uint _tokenId ) public { safeTransferFrom(_from, _to, _tokenId, ''); } /** * @notice Transfers the ownership of an NFT from one address to another address. * When transfer is complete, this functions * checks if `_to` is a smart contract (code size > 0). If so, it calls * `onERC721Received` on `_to` and throws if the return value is not * `bytes4(keccak256('onERC721Received(address,address,uint,bytes)'))`. * @param _from The current owner of the NFT * @param _to The new owner * @param _tokenId The NFT to transfer * @param _data Additional data with no specified format, sent in call to `_to` */ function safeTransferFrom( address _from, address _to, uint _tokenId, bytes memory _data ) public { transferFrom(_from, _to, _tokenId); require(_checkOnERC721Received(_from, _to, _tokenId, _data), 'NON_COMPLIANT_ERC721_RECEIVER'); } /** * Allow the Lock owner to change the transfer fee. */ function updateTransferFee( uint _transferFeeBasisPoints ) external onlyLockManager { emit TransferFeeChanged( _transferFeeBasisPoints ); transferFeeBasisPoints = _transferFeeBasisPoints; } /** * Determines how much of a fee a key owner would need to pay in order to * transfer the key to another account. This is pro-rated so the fee goes down * overtime. * @param _keyOwner The owner of the key check the transfer fee for. */ function getTransferFee( address _keyOwner, uint _time ) public view returns (uint) { if(! getHasValidKey(_keyOwner)) { return 0; } else { Key storage key = keyByOwner[_keyOwner]; uint timeToTransfer; uint fee; // Math: safeSub is not required since `hasValidKey` confirms timeToTransfer is positive // this is for standard key transfers if(_time == 0) { timeToTransfer = key.expirationTimestamp - block.timestamp; } else { timeToTransfer = _time; } fee = timeToTransfer.mul(transferFeeBasisPoints) / BASIS_POINTS_DEN; return fee; } } /** * @dev Internal function to invoke `onERC721Received` on a target address * The call is not executed if the target address is not a contract * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) internal returns (bool) { if (!to.isContract()) { return true; } bytes4 retval = IERC721Receiver(to).onERC721Received( msg.sender, from, tokenId, _data); return (retval == _ERC721_RECEIVED); } }
pragma solidity 0.5.17; import '@openzeppelin/contracts-ethereum-package/contracts/cryptography/ECDSA.sol'; contract MixinSignatures { /// @notice emits anytime the nonce used for off-chain approvals changes. event NonceChanged( address indexed keyManager, uint nextAvailableNonce ); // Stores a nonce per user to use for signed messages mapping(address => uint) public keyManagerToNonce; /// @notice Validates an off-chain approval signature. /// @dev If valid the nonce is consumed, else revert. modifier consumeOffchainApproval( bytes32 _hash, address _keyManager, uint8 _v, bytes32 _r, bytes32 _s ) { require( ecrecover( ECDSA.toEthSignedMessageHash(_hash), _v, _r, _s ) == _keyManager, 'INVALID_SIGNATURE' ); keyManagerToNonce[_keyManager]++; emit NonceChanged(_keyManager, keyManagerToNonce[_keyManager]); _; } /** * @notice Sets the minimum nonce for a valid off-chain approval message from the * senders account. * @dev This can be used to invalidate a previously signed message. */ function invalidateOffchainApproval( uint _nextAvailableNonce ) external { require(_nextAvailableNonce > keyManagerToNonce[msg.sender], 'NONCE_ALREADY_USED'); keyManagerToNonce[msg.sender] = _nextAvailableNonce; emit NonceChanged(msg.sender, _nextAvailableNonce); } }
pragma solidity 0.5.17; // This contract mostly follows the pattern established by openzeppelin in // openzeppelin/contracts-ethereum-package/contracts/access/roles import '@openzeppelin/contracts-ethereum-package/contracts/access/Roles.sol'; contract MixinLockManagerRole { using Roles for Roles.Role; event LockManagerAdded(address indexed account); event LockManagerRemoved(address indexed account); Roles.Role private lockManagers; function _initializeMixinLockManagerRole(address sender) internal { if (!isLockManager(sender)) { lockManagers.add(sender); } } modifier onlyLockManager() { require(isLockManager(msg.sender), 'MixinLockManager: caller does not have the LockManager role'); _; } function isLockManager(address account) public view returns (bool) { return lockManagers.has(account); } function addLockManager(address account) public onlyLockManager { lockManagers.add(account); emit LockManagerAdded(account); } function renounceLockManager() public { lockManagers.remove(msg.sender); emit LockManagerRemoved(msg.sender); } }
pragma solidity 0.5.17; // This contract mostly follows the pattern established by openzeppelin in // openzeppelin/contracts-ethereum-package/contracts/access/roles import '@openzeppelin/contracts-ethereum-package/contracts/access/Roles.sol'; import './MixinLockManagerRole.sol'; contract MixinKeyGranterRole is MixinLockManagerRole { using Roles for Roles.Role; event KeyGranterAdded(address indexed account); event KeyGranterRemoved(address indexed account); Roles.Role private keyGranters; function _initializeMixinKeyGranterRole(address sender) internal { if (!isKeyGranter(sender)) { keyGranters.add(sender); } } modifier onlyKeyGranterOrManager() { require(isKeyGranter(msg.sender) || isLockManager(msg.sender), 'MixinKeyGranter: caller does not have the KeyGranter or LockManager role'); _; } function isKeyGranter(address account) public view returns (bool) { return keyGranters.has(account); } function addKeyGranter(address account) public onlyLockManager { keyGranters.add(account); emit KeyGranterAdded(account); } function revokeKeyGranter(address _granter) public onlyLockManager { keyGranters.remove(_granter); emit KeyGranterRemoved(_granter); } }
pragma solidity ^0.5.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); }
pragma solidity ^0.5.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. Does not include * the optional functions; to access them see {ERC20Detailed}. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
pragma solidity ^0.5.5; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Converts an `address` into `address payable`. Note that this is * simply a type cast: the actual underlying value is not changed. * * _Available since v2.4.0._ */ function toPayable(address account) internal pure returns (address payable) { return address(uint160(account)); } /** * @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]. * * _Available since v2.4.0._ */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-call-value (bool success, ) = recipient.call.value(amount)(""); require(success, "Address: unable to send value, recipient may have reverted"); } }
pragma solidity ^0.5.0; import "./IERC20.sol"; import "../../math/SafeMath.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 ERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using SafeMath for uint256; 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)); } 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' // solhint-disable-next-line max-line-length 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).add(value); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } /** * @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. // A Solidity high level call has three parts: // 1. The target address is checked to verify it contains contract code // 2. The call itself is made, and success asserted // 3. The return value is decoded, which in turn checks the size of the returned data. // solhint-disable-next-line max-line-length require(address(token).isContract(), "SafeERC20: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = address(token).call(data); require(success, "SafeERC20: low-level call failed"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
pragma solidity ^0.5.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * - Subtraction cannot overflow. * * _Available since v2.4.0._ */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { // Solidity only automatically asserts when dividing by 0 require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * - The divisor cannot be zero. * * _Available since v2.4.0._ */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
pragma solidity ^0.5.0; /** * @title Roles * @dev Library for managing addresses assigned to a Role. */ library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
pragma solidity ^0.5.0; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "./IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ contract IERC721Enumerable is Initializable, IERC721 { function totalSupply() public view returns (uint256); function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256 tokenId); function tokenByIndex(uint256 index) public view returns (uint256); }
pragma solidity 0.5.17; /** * @title The Unlock Interface * @author Nick Furfaro (unlock-protocol.com) **/ interface IUnlock { // Use initialize instead of a constructor to support proxies(for upgradeability via zos). function initialize(address _unlockOwner) external; /** * @dev Create lock * This deploys a lock for a creator. It also keeps track of the deployed lock. * @param _tokenAddress set to the ERC20 token address, or 0 for ETH. * @param _salt an identifier for the Lock, which is unique for the user. * This may be implemented as a sequence ID or with RNG. It's used with `create2` * to know the lock's address before the transaction is mined. */ function createLock( uint _expirationDuration, address _tokenAddress, uint _keyPrice, uint _maxNumberOfKeys, string calldata _lockName, bytes12 _salt ) external returns(address); /** * This function keeps track of the added GDP, as well as grants of discount tokens * to the referrer, if applicable. * The number of discount tokens granted is based on the value of the referal, * the current growth rate and the lock's discount token distribution rate * This function is invoked by a previously deployed lock only. */ function recordKeyPurchase( uint _value, address _referrer // solhint-disable-line no-unused-vars ) external; /** * This function will keep track of consumed discounts by a given user. * It will also grant discount tokens to the creator who is granting the discount based on the * amount of discount and compensation rate. * This function is invoked by a previously deployed lock only. */ function recordConsumedDiscount( uint _discount, uint _tokens // solhint-disable-line no-unused-vars ) external; /** * This function returns the discount available for a user, when purchasing a * a key from a lock. * This does not modify the state. It returns both the discount and the number of tokens * consumed to grant that discount. */ function computeAvailableDiscountFor( address _purchaser, // solhint-disable-line no-unused-vars uint _keyPrice // solhint-disable-line no-unused-vars ) external view returns(uint discount, uint tokens); // Function to read the globalTokenURI field. function globalBaseTokenURI() external view returns(string memory); /** * @dev Redundant with globalBaseTokenURI() for backwards compatibility with v3 & v4 locks. */ function getGlobalBaseTokenURI() external view returns (string memory); // Function to read the globalTokenSymbol field. function globalTokenSymbol() external view returns(string memory); // Function to read the chainId field. function chainId() external view returns(uint); /** * @dev Redundant with globalTokenSymbol() for backwards compatibility with v3 & v4 locks. */ function getGlobalTokenSymbol() external view returns (string memory); /** * @notice Allows the owner to update configuration variables */ function configUnlock( address _udt, address _weth, uint _estimatedGasForPurchase, string calldata _symbol, string calldata _URI, uint _chainId ) external; /** * @notice Upgrade the PublicLock template used for future calls to `createLock`. * @dev This will initialize the template and revokeOwnership. */ function setLockTemplate( address payable _publicLockAddress ) external; // Allows the owner to change the value tracking variables as needed. function resetTrackedValue( uint _grossNetworkProduct, uint _totalDiscountGranted ) external; function grossNetworkProduct() external view returns(uint); function totalDiscountGranted() external view returns(uint); function locks(address) external view returns(bool deployed, uint totalSales, uint yieldedDiscountTokens); // The address of the public lock template, used when `createLock` is called function publicLockAddress() external view returns(address); // Map token address to exchange contract address if the token is supported // Used for GDP calculations function uniswapOracles(address) external view returns(address); // The WETH token address, used for value calculations function weth() external view returns(address); // The UDT token address, used to mint tokens on referral function udt() external view returns(address); // The approx amount of gas required to purchase a key function estimatedGasForPurchase() external view returns(uint); // The version number of the current Unlock implementation on this network function unlockVersion() external pure returns(uint16); /** * @notice allows the owner to set the oracle address to use for value conversions * setting the _oracleAddress to address(0) removes support for the token * @dev This will also call update to ensure at least one datapoint has been recorded. */ function setOracle( address _tokenAddress, address _oracleAddress ) external; /** * @dev Returns true if the caller is the current owner. */ function isOwner() external view returns(bool); /** * @dev Returns the address of the current owner. */ function owner() external view returns(address); /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() external; /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) external; }
pragma solidity 0.5.17; /** * @notice Functions to be implemented by a keyCancelHook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockKeyCancelHook { /** * @notice If the lock owner has registered an implementer * then this hook is called with every key cancel. * @param operator the msg.sender issuing the cancel * @param to the account which had the key canceled * @param refund the amount sent to the `to` account (ETH or a ERC-20 token) */ function onKeyCancel( address operator, address to, uint256 refund ) external; }
pragma solidity 0.5.17; /** * @notice Functions to be implemented by a keyPurchaseHook. * @dev Lock hooks are configured by calling `setEventHooks` on the lock. */ interface ILockKeyPurchaseHook { /** * @notice Used to determine the purchase price before issueing a transaction. * This allows the hook to offer a discount on purchases. * This may revert to prevent a purchase. * @param from the msg.sender making the purchase * @param recipient the account which will be granted a key * @param referrer the account which referred this key sale * @param data arbitrary data populated by the front-end which initiated the sale * @return the minimum value/price required to purchase a key with these settings * @dev the lock's address is the `msg.sender` when this function is called via * the lock's `purchasePriceFor` function */ function keyPurchasePrice( address from, address recipient, address referrer, bytes calldata data ) external view returns (uint minKeyPrice); /** * @notice If the lock owner has registered an implementer then this hook * is called with every key sold. * @param from the msg.sender making the purchase * @param recipient the account which will be granted a key * @param referrer the account which referred this key sale * @param data arbitrary data populated by the front-end which initiated the sale * @param minKeyPrice the price including any discount granted from calling this * hook's `keyPurchasePrice` function * @param pricePaid the value/pricePaid included with the purchase transaction * @dev the lock's address is the `msg.sender` when this function is called */ function onKeyPurchase( address from, address recipient, address referrer, bytes calldata data, uint minKeyPrice, uint pricePaid ) external; }
pragma solidity ^0.5.0; import "@openzeppelin/upgrades/contracts/Initializable.sol"; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ contract IERC721 is Initializable, IERC165 { event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of NFTs in `owner`'s account. */ function balanceOf(address owner) public view returns (uint256 balance); /** * @dev Returns the owner of the NFT specified by `tokenId`. */ function ownerOf(uint256 tokenId) public view returns (address owner); /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * * * Requirements: * - `from`, `to` cannot be zero. * - `tokenId` must be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this * NFT by either {approve} or {setApprovalForAll}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public; /** * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to * another (`to`). * * Requirements: * - If the caller is not `from`, it must be approved to move this NFT by * either {approve} or {setApprovalForAll}. */ function transferFrom(address from, address to, uint256 tokenId) public; function approve(address to, uint256 tokenId) public; function getApproved(uint256 tokenId) public view returns (address operator); function setApprovalForAll(address operator, bool _approved) public; function isApprovedForAll(address owner, address operator) public view returns (bool); function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; }
pragma solidity 0.5.17; // This contract provides some utility methods for use with the unlock protocol smart contracts. // Borrowed from: // https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L943 library UnlockUtils { function strConcat( string memory _a, string memory _b, string memory _c, string memory _d ) internal pure returns (string memory _concatenatedString) { return string(abi.encodePacked(_a, _b, _c, _d)); } function uint2Str( uint _i ) internal pure returns (string memory _uintAsString) { // make a copy of the param to avoid security/no-assign-params error uint c = _i; if (_i == 0) { return '0'; } uint j = _i; uint len; while (j != 0) { len++; j /= 10; } bytes memory bstr = new bytes(len); uint k = len - 1; while (c != 0) { bstr[k--] = byte(uint8(48 + c % 10)); c /= 10; } return string(bstr); } function address2Str( address _addr ) internal pure returns(string memory) { bytes32 value = bytes32(uint256(_addr)); bytes memory alphabet = '0123456789abcdef'; bytes memory str = new bytes(42); str[0] = '0'; str[1] = 'x'; for (uint i = 0; i < 20; i++) { str[2+i*2] = alphabet[uint8(value[i + 12] >> 4)]; str[3+i*2] = alphabet[uint8(value[i + 12] & 0x0f)]; } return string(str); } }
pragma solidity ^0.5.0; /** * @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 { /** * @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. * * NOTE: This call _does not revert_ if the signature is invalid, or * if the signer is otherwise unable to be retrieved. In those scenarios, * the zero address is returned. * * 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) { // Check the signature length if (signature.length != 65) { return (address(0)); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } // 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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); } if (v != 27 && v != 28) { return address(0); } // If the signature is valid (and not malleable), return the signer address return ecrecover(hash, v, r, s); } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * 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)); } }
pragma solidity ^0.5.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ contract IERC721Receiver { /** * @notice Handle the receipt of an NFT * @dev The ERC721 smart contract calls this function on the recipient * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, * otherwise the caller will revert the transaction. The selector to be * returned can be obtained as `this.onERC721Received.selector`. This * function MAY throw to revert and reject the transfer. * Note: the ERC721 contract address is always the message sender. * @param operator The address which called `safeTransferFrom` function * @param from The address which previously owned the token * @param tokenId The NFT identifier which is being transferred * @param data Additional data with no specified format * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` */ function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) public returns (bytes4); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"sendTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"refund","type":"uint256"}],"name":"CancelKey","type":"event"},{"anonymous":false,"inputs":[],"name":"Disable","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_timeAdded","type":"bool"}],"name":"ExpirationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ExpireKey","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"KeyGranterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_newManager","type":"address"}],"name":"KeyManagerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"LockManagerRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"string","name":"symbol","type":"string"}],"name":"NewLockSymbol","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"keyManager","type":"address"},{"indexed":false,"internalType":"uint256","name":"nextAvailableNonce","type":"uint256"}],"name":"NonceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldKeyPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"keyPrice","type":"uint256"},{"indexed":false,"internalType":"address","name":"oldTokenAddress","type":"address"},{"indexed":false,"internalType":"address","name":"tokenAddress","type":"address"}],"name":"PricingChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"freeTrialLength","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"refundPenaltyBasisPoints","type":"uint256"}],"name":"RefundPenaltyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"newExpiration","type":"uint256"}],"name":"RenewKeyPurchase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"transferFeeBasisPoints","type":"uint256"}],"name":"TransferFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":true,"internalType":"address","name":"tokenAddress","type":"address"},{"indexed":true,"internalType":"address","name":"beneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawal","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addKeyGranter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addLockManager","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_approved","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"approveBeneficiary","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAndRefund","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_keyManager","type":"address"},{"internalType":"uint8","name":"_v","type":"uint8"},{"internalType":"bytes32","name":"_r","type":"bytes32"},{"internalType":"bytes32","name":"_s","type":"bytes32"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAndRefundFor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"disableLock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"expirationDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"expireAndRefundFor","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"freeTrialLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address","name":"_account","type":"address"}],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyManager","type":"address"},{"internalType":"address","name":"_txSender","type":"address"}],"name":"getCancelAndRefundApprovalHash","outputs":[{"internalType":"bytes32","name":"approvalHash","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"getCancelAndRefundValueFor","outputs":[{"internalType":"uint256","name":"refund","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"getHasValidKey","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_page","type":"uint256"},{"internalType":"uint256","name":"_pageSize","type":"uint256"}],"name":"getOwnersByPage","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"getTokenIdFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"},{"internalType":"uint256","name":"_time","type":"uint256"}],"name":"getTransferFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"_recipients","type":"address[]"},{"internalType":"uint256[]","name":"_expirationTimestamps","type":"uint256[]"},{"internalType":"address[]","name":"_keyManagers","type":"address[]"}],"name":"grantKeys","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_lockCreator","type":"address"},{"internalType":"uint256","name":"_expirationDuration","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"uint256","name":"_maxNumberOfKeys","type":"uint256"},{"internalType":"string","name":"_lockName","type":"string"}],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_nextAvailableNonce","type":"uint256"}],"name":"invalidateOffchainApproval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isAlive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isKeyGranter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"isKeyOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isLockManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"}],"name":"keyExpirationTimestampFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"keyManagerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"keyManagerToNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"keyPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxNumberOfKeys","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"numberOfOwners","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"onKeyCancelHook","outputs":[{"internalType":"contract ILockKeyCancelHook","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"onKeyPurchaseHook","outputs":[{"internalType":"contract ILockKeyPurchaseHook","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"owners","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"publicLockVersion","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"purchase","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"address","name":"_referrer","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"purchasePriceFor","outputs":[{"internalType":"uint256","name":"minKeyPrice","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"refundPenaltyBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceLockManager","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_granter","type":"address"}],"name":"revokeKeyGranter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"bool","name":"_approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_baseTokenURI","type":"string"}],"name":"setBaseTokenURI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_onKeyPurchaseHook","type":"address"},{"internalType":"address","name":"_onKeyCancelHook","type":"address"}],"name":"setEventHooks","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_keyManager","type":"address"}],"name":"setKeyManagerOf","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_timeShared","type":"uint256"}],"name":"shareKey","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_keyOwner","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"transferFeeBasisPoints","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_recipient","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"unlockProtocol","outputs":[{"internalType":"contract IUnlock","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"updateBeneficiary","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_keyPrice","type":"uint256"},{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"updateKeyPricing","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_lockName","type":"string"}],"name":"updateLockName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_lockSymbol","type":"string"}],"name":"updateLockSymbol","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_freeTrialLength","type":"uint256"},{"internalType":"uint256","name":"_refundPenaltyBasisPoints","type":"uint256"}],"name":"updateRefundPenalty","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_transferFeeBasisPoints","type":"uint256"}],"name":"updateTransferFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50615b1a80620000216000396000f3fe6080604052600436106104105760003560e01c806370a082311161021e578063abdf82ce11610123578063d2503485116100ab578063f0ba60401161007a578063f0ba604014611405578063f12c6b6e1461141a578063f3fef3a314611459578063fc42b58f14611492578063fe72e4c1146114cb57610410565b8063d250348514611332578063d32bfb6c14611365578063d4fac45d1461138f578063e985e9c5146113ca57610410565b8063b585a6d5116100f2578063b585a6d5146111d4578063b88d4fde1461120d578063c1c98d03146112de578063c87b56dd146112f3578063d1bbd49c1461131d57610410565b8063abdf82ce146110df578063ad0e0a4d14611112578063b11d7ec11461114d578063b2e0f6e71461118657610410565b8063970aaeb7116101a6578063a22cb46511610175578063a22cb46514610fea578063a2e4cd2e14611025578063a375cb051461105e578063a9059cbb14611073578063aae4b8f7146110ac57610410565b8063970aaeb714610f3057806397aa390a14610f63578063994a8a7114610f9c5780639d76ea5814610fd557610410565b806381a3c943116101ed57806381a3c94314610d865780638577a6d514610ea15780638d0361fc14610ecb57806393fd184414610f0657806395d89b4114610f1b57610410565b806370a0823114610cae57806374b6c10614610ce1578063782a4ade14610cf65780638129fc1c14610d7157610410565b80632f745c59116103245780634f6ccce7116102ac578063564aa99d1161027b578063564aa99d14610b2d57806356e0d51f14610b605780636352211e14610b755780636d8ea5b414610b9f5780636eadde4314610bd257610410565b80634f6ccce714610a2257806352b0f63814610a4c57806352d6a8e414610a7f578063550ef3a814610ab257610410565b806339f46986116102f357806339f46986146108e25780633f33133a146109125780634136aa35146109a057806342842e0e146109b55780634d025fed146109f857610410565b80632f745c59146107ef57806330176e131461082857806335576ad0146108a357806338af3eed146108cd57610410565b806310803b72116103a7578063183767da11610376578063183767da1461073a578063217751bc1461074f57806323b872dd146107645780632af9162a146107a75780632d33dd5b146107da57610410565b806310803b721461067b57806310e56973146106fb57806311a4c03a1461071057806318160ddd1461072557610410565b8063095ea7b3116103e3578063095ea7b314610554578063097ba3331461058d5780630aaffd2a146106335780630f15023b1461066657610410565b806301ffc9a714610412578063025e7c271461045a57806306fdde03146104a0578063081812fc1461052a575b005b34801561041e57600080fd5b506104466004803603602081101561043557600080fd5b50356001600160e01b0319166114fe565b604080519115158252519081900360200190f35b34801561046657600080fd5b506104846004803603602081101561047d57600080fd5b5035611521565b604080516001600160a01b039092168252519081900360200190f35b3480156104ac57600080fd5b506104b5611548565b6040805160208082528351818301528351919283929083019185019080838360005b838110156104ef5781810151838201526020016104d7565b50505050905090810190601f16801561051c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561053657600080fd5b506104846004803603602081101561054d57600080fd5b50356115d6565b34801561056057600080fd5b506104106004803603604081101561057757600080fd5b506001600160a01b03813516906020013561164c565b34801561059957600080fd5b50610621600480360360608110156105b057600080fd5b6001600160a01b038235811692602081013590911691810190606081016040820135600160201b8111156105e357600080fd5b8201836020820111156105f557600080fd5b803590602001918460018302840111600160201b8311171561061657600080fd5b5090925090506117d3565b60408051918252519081900360200190f35b34801561063f57600080fd5b506104106004803603602081101561065657600080fd5b50356001600160a01b0316611822565b34801561067257600080fd5b506104846118ff565b34801561068757600080fd5b506106ab6004803603604081101561069e57600080fd5b508035906020013561190e565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156106e75781810151838201526020016106cf565b505050509050019250505060405180910390f35b34801561070757600080fd5b506106216119de565b34801561071c57600080fd5b506106216119e4565b34801561073157600080fd5b506106216119ea565b34801561074657600080fd5b506106216119f1565b34801561075b57600080fd5b506104846119f7565b34801561077057600080fd5b506104106004803603606081101561078757600080fd5b506001600160a01b03813581169160208101359091169060400135611a06565b3480156107b357600080fd5b50610410600480360360208110156107ca57600080fd5b50356001600160a01b0316611d05565b3480156107e657600080fd5b50610484611d91565b3480156107fb57600080fd5b506106216004803603604081101561081257600080fd5b506001600160a01b038135169060200135611da0565b34801561083457600080fd5b506104106004803603602081101561084b57600080fd5b810190602081018135600160201b81111561086557600080fd5b82018360208201111561087757600080fd5b803590602001918460018302840111600160201b8311171561089857600080fd5b509092509050611dfe565b3480156108af57600080fd5b50610410600480360360208110156108c657600080fd5b5035611e53565b3480156108d957600080fd5b50610484611ef5565b3480156108ee57600080fd5b506104106004803603604081101561090557600080fd5b5080359060200135611f04565b6104106004803603608081101561092857600080fd5b8135916001600160a01b03602082013581169260408301359091169190810190608081016060820135600160201b81111561096257600080fd5b82018360208201111561097457600080fd5b803590602001918460018302840111600160201b8311171561099557600080fd5b509092509050611f8e565b3480156109ac57600080fd5b5061044661247e565b3480156109c157600080fd5b50610410600480360360608110156109d857600080fd5b506001600160a01b0381358116916020810135909116906040013561248e565b348015610a0457600080fd5b5061048460048036036020811015610a1b57600080fd5b50356124a9565b348015610a2e57600080fd5b5061062160048036036020811015610a4557600080fd5b50356124c4565b348015610a5857600080fd5b5061044660048036036020811015610a6f57600080fd5b50356001600160a01b031661250f565b348015610a8b57600080fd5b5061062160048036036020811015610aa257600080fd5b50356001600160a01b0316612522565b348015610abe57600080fd5b5061041060048036036020811015610ad557600080fd5b810190602081018135600160201b811115610aef57600080fd5b820183602082011115610b0157600080fd5b803590602001918460018302840111600160201b83111715610b2257600080fd5b50909250905061252d565b348015610b3957600080fd5b5061041060048036036020811015610b5057600080fd5b50356001600160a01b031661257d565b348015610b6c57600080fd5b50610621612609565b348015610b8157600080fd5b5061048460048036036020811015610b9857600080fd5b503561260f565b348015610bab57600080fd5b5061044660048036036020811015610bc257600080fd5b50356001600160a01b031661262a565b348015610bde57600080fd5b50610410600480360360c0811015610bf557600080fd5b6001600160a01b03823581169260208101359260408201359092169160608201359160808101359181019060c0810160a0820135600160201b811115610c3a57600080fd5b820183602082011115610c4c57600080fd5b803590602001918460018302840111600160201b83111715610c6d57600080fd5b91908080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525092955061264a945050505050565b348015610cba57600080fd5b5061062160048036036020811015610cd157600080fd5b50356001600160a01b031661274a565b348015610ced57600080fd5b506106216127b9565b348015610d0257600080fd5b5061041060048036036020811015610d1957600080fd5b810190602081018135600160201b811115610d3357600080fd5b820183602082011115610d4557600080fd5b803590602001918460018302840111600160201b83111715610d6657600080fd5b5090925090506127bf565b348015610d7d57600080fd5b50610410612874565b348015610d9257600080fd5b5061041060048036036060811015610da957600080fd5b810190602081018135600160201b811115610dc357600080fd5b820183602082011115610dd557600080fd5b803590602001918460208302840111600160201b83111715610df657600080fd5b919390929091602081019035600160201b811115610e1357600080fd5b820183602082011115610e2557600080fd5b803590602001918460208302840111600160201b83111715610e4657600080fd5b919390929091602081019035600160201b811115610e6357600080fd5b820183602082011115610e7557600080fd5b803590602001918460208302840111600160201b83111715610e9657600080fd5b509092509050612926565b348015610ead57600080fd5b5061041060048036036020811015610ec457600080fd5b5035612b33565b348015610ed757600080fd5b5061062160048036036040811015610eee57600080fd5b506001600160a01b0381358116916020013516612baf565b348015610f1257600080fd5b50610621612c3a565b348015610f2757600080fd5b506104b5612c40565b348015610f3c57600080fd5b5061062160048036036020811015610f5357600080fd5b50356001600160a01b0316612e2f565b348015610f6f57600080fd5b5061041060048036036040811015610f8657600080fd5b506001600160a01b038135169060200135612e4a565b348015610fa857600080fd5b5061044660048036036040811015610fbf57600080fd5b50803590602001356001600160a01b0316612ee3565b348015610fe157600080fd5b50610484612f04565b348015610ff657600080fd5b506104106004803603604081101561100d57600080fd5b506001600160a01b0381351690602001351515612f13565b34801561103157600080fd5b506104106004803603604081101561104857600080fd5b50803590602001356001600160a01b031661301e565b34801561106a57600080fd5b506106216131ed565b34801561107f57600080fd5b506104466004803603604081101561109657600080fd5b506001600160a01b0381351690602001356131f3565b3480156110b857600080fd5b50610446600480360360208110156110cf57600080fd5b50356001600160a01b031661325a565b3480156110eb57600080fd5b506106216004803603602081101561110257600080fd5b50356001600160a01b031661326d565b34801561111e57600080fd5b506104106004803603604081101561113557600080fd5b506001600160a01b038135811691602001351661328b565b34801561115957600080fd5b506104106004803603604081101561117057600080fd5b50803590602001356001600160a01b03166133e5565b34801561119257600080fd5b50610410600480360360a08110156111a957600080fd5b506001600160a01b038135169060ff60208201351690604081013590606081013590608001356134b2565b3480156111e057600080fd5b50610446600480360360408110156111f757600080fd5b506001600160a01b038135169060200135613602565b34801561121957600080fd5b506104106004803603608081101561123057600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b81111561126a57600080fd5b82018360208201111561127c57600080fd5b803590602001918460018302840111600160201b8311171561129d57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295506136fc945050505050565b3480156112ea57600080fd5b5061041061376a565b3480156112ff57600080fd5b506104b56004803603602081101561131657600080fd5b5035613836565b34801561132957600080fd5b50610621613ab0565b34801561133e57600080fd5b506104106004803603602081101561135557600080fd5b50356001600160a01b0316613ab5565b34801561137157600080fd5b506104106004803603602081101561138857600080fd5b5035613b41565b34801561139b57600080fd5b50610621600480360360408110156113b257600080fd5b506001600160a01b0381358116916020013516613be7565b3480156113d657600080fd5b50610446600480360360408110156113ed57600080fd5b506001600160a01b0381358116916020013516613c91565b34801561141157600080fd5b50610410613d26565b34801561142657600080fd5b506104106004803603606081101561143d57600080fd5b506001600160a01b038135169060208101359060400135613d64565b34801561146557600080fd5b506104106004803603604081101561147c57600080fd5b506001600160a01b0381351690602001356140ea565b34801561149e57600080fd5b50610621600480360360408110156114b557600080fd5b506001600160a01b03813516906020013561422b565b3480156114d757600080fd5b50610621600480360360208110156114ee57600080fd5b50356001600160a01b031661429e565b6001600160e01b0319811660009081526033602052604090205460ff165b919050565b6074818154811061152e57fe5b6000918252602090912001546001600160a01b0316905081565b6078805460408051602060026001851615610100026000190190941693909304601f810184900484028201840190925281815292918301828280156115ce5780601f106115a3576101008083540402835291602001916115ce565b820191906000526020600020905b8154815290600101906020018083116115b157829003601f168201915b505050505081565b60008181526073602052604081205482906001600160a01b031661162f576040805162461bcd60e51b815260206004820152600b60248201526a4e4f5f535543485f4b455960a81b604482015290519081900360640190fd5b50506000908152607660205260409020546001600160a01b031690565b606954600160a01b900460ff1661169c576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b806116a781336142b0565b806116b757506116b78133614312565b806116df57506000818152607360205260409020546116df906001600160a01b031633613c91565b61171e576040805162461bcd60e51b815260206004820152601c60248201526000805160206159a2833981519152604482015290519081900360640190fd5b336001600160a01b038416141561176b576040805162461bcd60e51b815260206004820152600c60248201526b20a8282927ab22afa9a2a62360a11b604482015290519081900360640190fd5b600082815260766020908152604080832080546001600160a01b0319166001600160a01b038881169182179092556073909352818420549151869492909116917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000611816858585858080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061433392505050565b50909695505050505050565b606f546001600160a01b031633148061183f575061183f3361325a565b611890576040805162461bcd60e51b815260206004820152601f60248201527f4f4e4c595f42454e45464943494152595f4f525f4c4f434b4d414e4147455200604482015290519081900360640190fd5b6001600160a01b0381166118dd576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b606f80546001600160a01b0319166001600160a01b0392909216919091179055565b606a546001600160a01b031681565b607454606090829084820290600090828401111561193457506074548181039250611939565b508082015b606083604051908082528060200260200182016040528015611965578160200160208202803883390190505b5090506000835b838110156119cf576074818154811061198157fe5b9060005260206000200160009054906101000a90046001600160a01b03168383815181106119ab57fe5b6001600160a01b03909216602092830291909101909101526001918201910161196c565b50909450505050505b92915050565b606c5481565b606b5481565b606e545b90565b607b5481565b6071546001600160a01b031681565b606954600160a01b900460ff16611a56576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b82611a608161262a565b611aa1576040805162461bcd60e51b815260206004820152600d60248201526c12d15657d393d517d590531251609a1b604482015290519081900360640190fd5b81611aac81336142b0565b80611abc5750611abc8133614312565b80611ae45750600081815260736020526040902054611ae4906001600160a01b031633613c91565b611b23576040805162461bcd60e51b815260206004820152601c60248201526000805160206159a2833981519152604482015290519081900360640190fd5b611b2d8386612ee3565b611b7e576040805162461bcd60e51b815260206004820152601c60248201527f5452414e534645525f46524f4d3a204e4f545f4b45595f4f574e455200000000604482015290519081900360640190fd5b612710607b5410611bcf576040805162461bcd60e51b815260206004820152601660248201527512d15657d514905394d1915494d7d11254d05093115160521b604482015290519081900360640190fd5b6001600160a01b038416611c1c576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6000611c2986600061422b565b6001600160a01b03808816600090815260726020526040808220928916825281206001810154939450919290611c62908890869061453f565b8154611c7e57868255611c758888614661565b611c7e876146e9565b428111611cac5760018084015490830155868255611c9d876000614724565b611ca78888614661565b611cc9565b6001830154611cc39042830363ffffffff6147a616565b60018301555b426001840155600080845560405188916001600160a01b03808c1692908d1691600080516020615a9c83398151915291a4505050505050505050565b611d0e3361325a565b611d495760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b611d5a60678263ffffffff61480016565b6040516001600160a01b038216907f766f6199fea59554b9ff688e413302b9200f85d74811c053c12d945ac6d8dd7a90600090a250565b6070546001600160a01b031681565b60008115611dee576040805162461bcd60e51b815260206004820152601660248201527527a7262cafa7a722afa5a2acafa822a92fa7aba722a960511b604482015290519081900360640190fd5b611df783612e2f565b9392505050565b611e073361325a565b611e425760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b611e4e607a8383615805565b505050565b336000908152606860205260409020548111611eab576040805162461bcd60e51b81526020600482015260126024820152711393d390d157d053149150511657d554d15160721b604482015290519081900360640190fd5b33600081815260686020908152604091829020849055815184815291517ff5d035b703f1ad8d403dd02e821d04257acafc5f6c5d70a3907bd8abf33a2e0f9281900390910190a250565b606f546001600160a01b031681565b611f0d3361325a565b611f485760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b604080518381526020810183905281517fd6867bc538320e67d7bdc35860c27c08486eb490b4fd9b820fff18fb28381d3c929181900390910190a1607d91909155607c55565b606954600160a01b900460ff16611fde576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b606e54606d5411612026576040805162461bcd60e51b815260206004820152600d60248201526c1313d0d2d7d4d3d31117d3d555609a1b604482015290519081900360640190fd5b6001600160a01b038416612073576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6001600160a01b038416600090815260726020526040812080549091816120e35761209d83614867565b825491506120ab8783614661565b50606b5442016001830181905560405182906001600160a01b03891690600090600080516020615a9c833981519152908290a46121ab565b428360010154111561215357606b5460018401546121069163ffffffff6147a616565b600184018190556040805182815290519192506001600160a01b038916917f872bd7c99ad5e7b6ed7f0a890f348839cb8e225c9deaa3909afedae54c93d17d9181900360200190a26121ab565b50606b5442016001830181905561216b826000614724565b6040805182815290516001600160a01b038916917f872bd7c99ad5e7b6ed7f0a890f348839cb8e225c9deaa3909afedae54c93d17d919081900360200190a25b60008060006121f18a8a8a8a8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525061433392505050565b91945092509050811561226b57606a5460408051633652466360e01b8152600481018590526024810184905290516001600160a01b039092169163365246639160448082019260009290919082900301818387803b15801561225257600080fd5b505af1158015612266573d6000803e3d6000fd5b505050505b606a546040805163939d9f1f60e01b8152600481018690526001600160a01b038c811660248301529151919092169163939d9f1f91604480830192600092919082900301818387803b1580156122c057600080fd5b505af11580156122d4573d6000803e3d6000fd5b5050606954600092506001600160a01b031615905061231457506069548b906001600160a01b031661230e8133308563ffffffff61487c16565b50612317565b50345b83811015612361576040805162461bcd60e51b8152602060048201526012602482015271494e53554646494349454e545f56414c554560701b604482015290519081900360640190fd5b6070546001600160a01b03161561247057607060009054906101000a90046001600160a01b03166001600160a01b03166398499657338d8d8d8d8a886040518863ffffffff1660e01b815260040180886001600160a01b03166001600160a01b03168152602001876001600160a01b03166001600160a01b03168152602001866001600160a01b03166001600160a01b03168152602001806020018481526020018381526020018281038252868682818152602001925080828437600081840152601f19601f82011690508083019250505098505050505050505050600060405180830381600087803b15801561245757600080fd5b505af115801561246b573d6000803e3d6000fd5b505050505b505050505050505050505050565b606954600160a01b900460ff1681565b611e4e838383604051806020016040528060008152506136fc565b6075602052600090815260409020546001600160a01b031681565b6000606e54821061250b576040805162461bcd60e51b815260206004820152600c60248201526b4f55545f4f465f52414e474560a01b604482015290519081900360640190fd5b5090565b60006119d860678363ffffffff6148d616565b60006119d88261493d565b6125363361325a565b6125715760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b611e4e60788383615805565b6125863361325a565b6125c15760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b6125d260678263ffffffff614a4416565b6040516001600160a01b038216907f684f8a71407db0c334454ebe9c9b288549317893a20b10dc779ec5c118dcd12190600090a250565b607c5481565b6000908152607360205260409020546001600160a01b031690565b6001600160a01b0316600090815260726020526040902060010154421090565b600054610100900460ff16806126635750612663614ac5565b80612671575060005460ff16155b6126ac5760405162461bcd60e51b815260040180806020018281038252602e815260200180615a6e602e913960400191505060405180910390fd5b600054610100900460ff161580156126d7576000805460ff1961ff0019909116610100171660011790555b6126e085614acb565b6126e8614b9a565b6126f487878686614baf565b6126fd82614c45565b612705614c71565b61270d614c83565b61271687614c8b565b61271f87614ca9565b61272f6380ac58cd60e01b614cc7565b8015612741576000805461ff00191690555b50505050505050565b60006001600160a01b038216612799576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6127a28261262a565b6127ad5760006127b0565b60015b60ff1692915050565b606d5481565b6127c83361325a565b6128035760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b61280f60798383615805565b507f8868e22e84ebf32da89b2ebcb0ac642816304ea3863b257f240df9098719cb97828260405180806020018281038252848482818152602001925080828437600083820152604051601f909101601f19169092018290039550909350505050a15050565b600054610100900460ff168061288d575061288d614ac5565b8061289b575060005460ff16155b6128d65760405162461bcd60e51b815260040180806020018281038252602e815260200180615a6e602e913960400191505060405180910390fd5b600054610100900460ff16158015612901576000805460ff1961ff0019909116610100171660011790555b6129116301ffc9a760e01b614cc7565b8015612923576000805461ff00191690555b50565b61292f3361250f565b8061293e575061293e3361325a565b6129795760405162461bcd60e51b81526004018080602001828103825260488152602001806159c26048913960600191505060405180910390fd5b60005b8581101561274157600087878381811061299257fe5b905060200201356001600160a01b0316905060008686848181106129b257fe5b90506020020135905060008585858181106129c957fe5b905060200201356001600160a01b0316905060006001600160a01b0316836001600160a01b03161415612a35576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6001600160a01b038316600090815260726020526040902060018101548311612a98576040805162461bcd60e51b815260206004820152601060248201526f414c52454144595f4f574e535f4b455960801b604482015290519081900360640190fd5b805480612ab557612aa882614867565b508054612ab58582614661565b612abf8184614724565b6040516001600160a01b0384169082907f9d2895c45a420624de863a2f437b022d879f457bf7a829044055a10c5a6fd5e390600090a36001820184905560405181906001600160a01b03871690600090600080516020615a9c833981519152908290a450506001909301925061297c915050565b612b3c3361325a565b612b775760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b6040805182815290517f0496ed1e61eb69727f9659a8e859288db4758ffb1f744d1c1424634f90a257f49181900360200190a1607b55565b600030604051808061590860259139604080519182900360250182206001600160a01b03881660009081526068602081815291849020546bffffffffffffffffffffffff19606098891b811684880152603487019490945260548601529588901b90911660748401528151808403909501855260889092019052825192019190912091505092915050565b60745490565b60795460609060026000196101006001841615020190911604612d9d57606a60009054906101000a90046001600160a01b03166001600160a01b031663cec410526040518163ffffffff1660e01b815260040160006040518083038186803b158015612cab57600080fd5b505afa158015612cbf573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015612ce857600080fd5b8101908080516040519392919084600160201b821115612d0757600080fd5b908301906020820185811115612d1c57600080fd5b8251600160201b811182820188101715612d3557600080fd5b82525081516020918201929091019080838360005b83811015612d62578181015183820152602001612d4a565b50505050905090810190601f168015612d8f5780820380516001836020036101000a031916815260200191505b5060405250505090506119ee565b6079805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015612e235780601f10612df857610100808354040283529160200191612e23565b820191906000526020600020905b815481529060010190602001808311612e0657829003601f168201915b505050505090506119ee565b6001600160a01b031660009081526072602052604090205490565b612e533361325a565b612e8e5760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b81612e988161262a565b612ed9576040805162461bcd60e51b815260206004820152600d60248201526c12d15657d393d517d590531251609a1b604482015290519081900360640190fd5b611e4e8383614d4b565b600091825260736020526040909120546001600160a01b0391821691161490565b6069546001600160a01b031681565b606954600160a01b900460ff16612f63576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b6001600160a01b038216331415612fb0576040805162461bcd60e51b815260206004820152600c60248201526b20a8282927ab22afa9a2a62360a11b604482015290519081900360640190fd5b3360008181526077602090815260408083206001600160a01b03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b6130273361325a565b6130625760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b606954600160a01b900460ff166130b2576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b606c546069546001600160a01b03908116908316158061313657506000836001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561310857600080fd5b505afa15801561311c573d6000803e3d6000fd5b505050506040513d602081101561313257600080fd5b5051115b613177576040805162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22faa27a5a2a760991b604482015290519081900360640190fd5b606c849055606980546001600160a01b0319166001600160a01b038581169190911791829055604080518581526020810188905284831681830152929091166060830152517f3615065ccf48367ac483ac86701248e2e5ff55bdd9be845007d34a3b68d719d4916080908290030190a150505050565b607d5481565b606b54336000908152607260205260408120600181015491928402918390613221904263ffffffff614e4616565b90508083101561323f5761323a86836000015485613d64565b61324e565b61324e33878460000154611a06565b50600195945050505050565b60006119d860668363ffffffff6148d616565b6001600160a01b031660009081526072602052604090206001015490565b6132943361325a565b6132cf5760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b6001600160a01b03821615806132f257506132f2826001600160a01b0316614e88565b613343576040805162461bcd60e51b815260206004820152601860248201527f494e56414c49445f4f4e5f4b45595f534f4c445f484f4f4b0000000000000000604482015290519081900360640190fd5b6001600160a01b03811615806133665750613366816001600160a01b0316614e88565b6133b7576040805162461bcd60e51b815260206004820152601a60248201527f494e56414c49445f4f4e5f4b45595f43414e43454c5f484f4f4b000000000000604482015290519081900360640190fd5b607080546001600160a01b039384166001600160a01b03199182161790915560718054929093169116179055565b60008281526073602052604090205482906001600160a01b031661343e576040805162461bcd60e51b815260206004820152600b60248201526a4e4f5f535543485f4b455960a81b604482015290519081900360640190fd5b61344883336142b0565b8061345757506134573361325a565b6134a8576040805162461bcd60e51b815260206004820152601f60248201527f554e415554484f52495a45445f4b45595f4d414e414745525f55504441544500604482015290519081900360640190fd5b611e4e8383614724565b6134bc8533612baf565b85858585836001600160a01b031660016134d587614ec4565b85858560405160008152602001604052604051808581526020018460ff1660ff1681526020018381526020018281526020019450505050506020604051602081039080840390855afa15801561352f573d6000803e3d6000fd5b505050602060405103516001600160a01b031614613588576040805162461bcd60e51b8152602060048201526011602482015270494e56414c49445f5349474e415455524560781b604482015290519081900360640190fd5b6001600160a01b038416600081815260686020908152604091829020805460010190819055825190815291517ff5d035b703f1ad8d403dd02e821d04257acafc5f6c5d70a3907bd8abf33a2e0f9281900390910190a260006135e98761260f565b905060006135f68261493d565b90506124708282614d4b565b600061360d3361325a565b806136225750606f546001600160a01b031633145b613673576040805162461bcd60e51b815260206004820181905260248201527f4f4e4c595f4c4f434b5f4d414e414745525f4f525f42454e4546494349415259604482015290519081900360640190fd5b6069546040805163095ea7b360e01b81526001600160a01b038681166004830152602482018690529151919092169163095ea7b39160448083019260209291908290030181600087803b1580156136c957600080fd5b505af11580156136dd573d6000803e3d6000fd5b505050506040513d60208110156136f357600080fd5b50519392505050565b613707848484611a06565b61371384848484614f15565b613764576040805162461bcd60e51b815260206004820152601d60248201527f4e4f4e5f434f4d504c49414e545f4552433732315f5245434549564552000000604482015290519081900360640190fd5b50505050565b6137733361325a565b6137ae5760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b606954600160a01b900460ff166137fe576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b6040517f25a311358326fb18c62efc24bc28d3126acee8d2a67fd8b2145b757dc8bd1bc190600090a16069805460ff60a01b19169055565b606080808061384430615048565b90506060851561385e57613857866151c4565b9250613871565b6040518060200160405280600081525092505b607a54600260001961010060018416150201909116046139e257606a60009054906101000a90046001600160a01b03166001600160a01b031663a998e9fb6040518163ffffffff1660e01b815260040160006040518083038186803b1580156138d957600080fd5b505afa1580156138ed573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561391657600080fd5b8101908080516040519392919084600160201b82111561393557600080fd5b90830190602082018581111561394a57600080fd5b8251600160201b81118282018810171561396357600080fd5b82525081516020918201929091019080838360005b83811015613990578181015183820152602001613978565b50505050905090810190601f1680156139bd5780820380516001836020036101000a031916815260200191505b506040818101905260018152602f60f81b6020820152939750929350613a9492505050565b607a805460408051602060026001851615610100026000190190941693909304601f81018490048402820184019092528181529291830182828015613a685780601f10613a3d57610100808354040283529160200191613a68565b820191906000526020600020905b815481529060010190602001808311613a4b57829003601f168201915b505050505093506040518060200160405280600081525090506040518060200160405280600081525091505b613aa68483838663ffffffff61528816565b9695505050505050565b600890565b613abe3361325a565b613af95760405162461bcd60e51b815260040180806020018281038252603b81526020018061592d603b913960400191505060405180910390fd5b613b0a60668263ffffffff614a4416565b6040516001600160a01b038216907f91d5c045d5bd98bf59a379b259ebca05b93bf79af1845fdf87e3172385d4c7f790600090a250565b80613b4c81336142b0565b80613b5c5750613b5c8133614312565b80613b845750600081815260736020526040902054613b84906001600160a01b031633613c91565b613bc3576040805162461bcd60e51b815260206004820152601c60248201526000805160206159a2833981519152604482015290519081900360640190fd5b6000613bce8361260f565b90506000613bdb8261493d565b90506137648282614d4b565b60006001600160a01b038316613c0857506001600160a01b038116316119d8565b826001600160a01b03166370a08231836040518263ffffffff1660e01b815260040180826001600160a01b03166001600160a01b0316815260200191505060206040518083038186803b158015613c5e57600080fd5b505afa158015613c72573d6000803e3d6000fd5b505050506040513d6020811015613c8857600080fd5b505190506119d8565b6001600160a01b038083166000908152607260209081526040808320548084526075909252822054919290911680613cf4575050506001600160a01b0380831660009081526077602090815260408083209385168352929052205460ff166119d8565b6001600160a01b0390811660009081526077602090815260408083209387168352929052205460ff1691506119d89050565b613d3760663363ffffffff61480016565b60405133907f42885193b8178d25fca25a38e6fcc93918501e91be06d85e0c8afb3bad95238090600090a2565b606954600160a01b900460ff16613db4576040805162461bcd60e51b815260206004820152600f60248201526e1313d0d2d7d11154149150d0551151608a1b604482015290519081900360640190fd5b81613dbf81336142b0565b80613dcf5750613dcf8133614312565b80613df75750600081815260736020526040902054613df7906001600160a01b031633613c91565b613e36576040805162461bcd60e51b815260206004820152601c60248201526000805160206159a2833981519152604482015290519081900360640190fd5b612710607b5410613e87576040805162461bcd60e51b815260206004820152601660248201527512d15657d514905394d1915494d7d11254d05093115160521b604482015290519081900360640190fd5b6001600160a01b038416613ed4576040805162461bcd60e51b815260206004820152600f60248201526e494e56414c49445f4144445245535360881b604482015290519081900360640190fd5b6000838152607360205260409020546001600160a01b0316613ef58161262a565b613f36576040805162461bcd60e51b815260206004820152600d60248201526c12d15657d393d517d590531251609a1b604482015290519081900360640190fd5b6001600160a01b0380821660009081526072602052604080822092881682528120805460018401549192909142900381613f70878a61422b565b90506000613f848a8363ffffffff6147a616565b905082811015613fa257899350613f9d8b82600061453f565b613fe6565b613fac888461422b565b42600189015560405181850395509092508b907f59f2fe866dd27a1c2d34115520888c3150365cbc931aab97fa88c4b9ab40b79590600090a25b8461402d57613ff486614867565b855494506140028c86614661565b60405185906001600160a01b038e1690600090600080516020615a9c833981519152908290a4614043565b4286600101541161404357614043856000614724565b61404f8585600161453f565b848c6001600160a01b0316896001600160a01b0316600080516020615a9c83398151915260405160405180910390a4614099888d8d60405180602001604052806000815250614f15565b612470576040805162461bcd60e51b815260206004820152601d60248201527f4e4f4e5f434f4d504c49414e545f4552433732315f5245434549564552000000604482015290519081900360640190fd5b6140f33361325a565b806141085750606f546001600160a01b031633145b614159576040805162461bcd60e51b815260206004820181905260248201527f4f4e4c595f4c4f434b5f4d414e414745525f4f525f42454e4546494349415259604482015290519081900360640190fd5b60006141658330613be7565b9050600082158061417557508183115b156141c957600082116141c2576040805162461bcd60e51b815260206004820152601060248201526f4e4f545f454e4f5547485f46554e445360801b604482015290519081900360640190fd5b50806141cc565b50815b606f546040805183815290516001600160a01b039283169287169133917f342e7ff505a8a0364cd0dc2ff195c315e43bce86b204846ecd36913e117b109e9181900360200190a4606f546137649085906001600160a01b0316836153d9565b60006142368361262a565b614242575060006119d8565b6001600160a01b038316600090815260726020526040812090808461426f57428360010154039150614273565b8491505b61271061428b607b548461542690919063ffffffff16565b8161429257fe5b0493506119d892505050565b60686020526000908152604090205481565b6000828152607560205260408120546001600160a01b03838116911614806142fd57506000838152607560205260409020546001600160a01b03161580156142fd57506142fd8383612ee3565b1561430a575060016119d8565b5060006119d8565b600091825260766020526040909120546001600160a01b0391821691161490565b607054600090819081906001600160a01b0316156144475760705460405163221c1fd160e01b815233600482018181526001600160a01b038a811660248501528981166044850152608060648501908152895160848601528951919095169463221c1fd1948c938c938c93919260a40190602085019080838360005b838110156143c75781810151838201526020016143af565b50505050905090810190601f1680156143f45780820380516001836020036101000a031916815260200191505b509550505050505060206040518083038186803b15801561441457600080fd5b505afa158015614428573d6000803e3d6000fd5b505050506040513d602081101561443e57600080fd5b5051925061444d565b606c5492505b821561453657606a5460408051630cb175e360e01b81526001600160a01b038981166004830152602482018790528251931692630cb175e392604480840193919291829003018186803b1580156144a357600080fd5b505afa1580156144b7573d6000803e3d6000fd5b505050506040513d60408110156144cd57600080fd5b508051602090910151909250905082821115614530576040805162461bcd60e51b815260206004820152601c60248201527f494e56414c49445f444953434f554e545f46524f4d5f554e4c4f434b00000000604482015290519081900360640190fd5b81830392505b93509350939050565b6000838152607360205260409020546001600160a01b03168061459c576040805162461bcd60e51b815260206004820152601060248201526f4e4f4e5f4558495354454e545f4b455960801b604482015290519081900360640190fd5b6001600160a01b0381166000908152607260205260408120600181015490916145c48461262a565b905084156146075780156145ec576145e2828763ffffffff6147a616565b6001840155614602565b6145fc428763ffffffff6147a616565b60018401555b61461d565b614617828763ffffffff614e4616565b60018401555b604080518781528615156020820152815189927fe9408df99703ae33a9d01185bcad328ea8683fb1f920da9c30959c192f21b5b3928290030190a250505050505050565b6000818152607360205260409020546001600160a01b038381169116146146e55760748054600181019091557f19a0b39aa25ac793b5f6e9a0534364cc0b3fd1ea9b651e79c7f50a59d48ef8130180546001600160a01b0384166001600160a01b031991821681179092556000838152607360205260409020805490911690911790555b5050565b6000818152607660205260409020546001600160a01b03161561292357600090815260766020526040902080546001600160a01b0319169055565b6000828152607560205260409020546001600160a01b038281169116146146e557600082815260756020526040902080546001600160a01b0319166001600160a01b038316179055614775826146e9565b60405160009083907f9d2895c45a420624de863a2f437b022d879f457bf7a829044055a10c5a6fd5e3908390a35050565b600082820183811015611df7576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b61480a82826148d6565b6148455760405162461bcd60e51b8152600401808060200182810382526021815260200180615a0a6021913960400191505060405180910390fd5b6001600160a01b0316600090815260209190915260409020805460ff19169055565b805461292357606e8054600101908190559055565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b17905261376490859061547f565b60006001600160a01b03821661491d5760405162461bcd60e51b8152600401808060200182810382526022815260200180615a4c6022913960400191505060405180910390fd5b506001600160a01b03166000908152602091909152604090205460ff1690565b6000816149498161262a565b61498a576040805162461bcd60e51b815260206004820152600d60248201526c12d15657d393d517d590531251609a1b604482015290519081900360640190fd5b6001600160a01b03831660009081526072602052604090206001810154606b54607d5442909203918201106149c357606c5493506149e4565b606b54606c546149d9908363ffffffff61542616565b816149e057fe5b0493505b607d5415806149f85750606b54607d548201105b15614a3c576000612710614a19607c54606c5461542690919063ffffffff16565b81614a2057fe5b04905080851115614a35578085039450614a3a565b600094505b505b505050919050565b614a4e82826148d6565b15614aa0576040805162461bcd60e51b815260206004820152601f60248201527f526f6c65733a206163636f756e7420616c72656164792068617320726f6c6500604482015290519081900360640190fd5b6001600160a01b0316600090815260209190915260409020805460ff19166001179055565b303b1590565b606980546001600160a01b0319166001600160a01b0383169081179091551580614b5957506000816001600160a01b03166318160ddd6040518163ffffffff1660e01b815260040160206040518083038186803b158015614b2b57600080fd5b505afa158015614b3f573d6000803e3d6000fd5b505050506040513d6020811015614b5557600080fd5b5051115b612923576040805162461bcd60e51b815260206004820152600d60248201526c24a72b20a624a22faa27a5a2a760991b604482015290519081900360640190fd5b6069805460ff60a01b1916600160a01b179055565b63bbf81e00831115614c08576040805162461bcd60e51b815260206004820152601860248201527f4d41585f45585049524154494f4e5f3130305f59454152530000000000000000604482015290519081900360640190fd5b606a8054336001600160a01b031991821617909155606f80549091166001600160a01b039590951694909417909355606b91909155606c55606d55565b614c4d612874565b8051614c6090607890602084019061587f565b50612923635b5e139f60e01b614cc7565b614c8163780e9d6360e01b614cc7565b565b6103e8607c55565b614c948161325a565b6129235761292360668263ffffffff614a4416565b614cb28161250f565b6129235761292360678263ffffffff614a4416565b6001600160e01b03198082161415614d26576040805162461bcd60e51b815260206004820152601c60248201527f4552433136353a20696e76616c696420696e7465726661636520696400000000604482015290519081900360640190fd5b6001600160e01b0319166000908152603360205260409020805460ff19166001179055565b6001600160a01b03821660008181526072602090815260409182902080548351868152935191943394909391927f0a7068a9989857441c039a14a42b67ed71dd1fcfe5a9b17cc87b252e47bce528929181900390910190a44260018201558115614dc657606954614dc6906001600160a01b031684846153d9565b6071546001600160a01b031615611e4e576071546040805163b499b6c560e01b81523360048201526001600160a01b038681166024830152604482018690529151919092169163b499b6c591606480830192600092919082900301818387803b158015614e3257600080fd5b505af1158015612741573d6000803e3d6000fd5b6000611df783836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250615637565b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590614ebc57508115155b949350505050565b604080517f19457468657265756d205369676e6564204d6573736167653a0a333200000000602080830191909152603c8083019490945282518083039094018452605c909101909152815191012090565b6000614f29846001600160a01b0316614e88565b614f3557506001614ebc565b604051630a85bd0160e11b815233600482018181526001600160a01b03888116602485015260448401879052608060648501908152865160848601528651600095928a169463150b7a029490938c938b938b939260a4019060208501908083838e5b83811015614faf578181015183820152602001614f97565b50505050905090810190601f168015614fdc5780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b158015614ffe57600080fd5b505af1158015615012573d6000803e3d6000fd5b505050506040513d602081101561502857600080fd5b50516001600160e01b031916630a85bd0160e11b14915050949350505050565b604080518082018252601081526f181899199a1a9b1b9c1cb0b131b232b360811b60208201528151602a80825260608281019094526001600160a01b03851692918491602082018180388339019050509050600360fc1b816000815181106150ac57fe5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106150d557fe5b60200101906001600160f81b031916908160001a90535060005b60148110156151bb578260048583600c016020811061510a57fe5b1a60f81b6001600160f81b031916901c60f81c60ff168151811061512a57fe5b602001015160f81c60f81b82826002026002018151811061514757fe5b60200101906001600160f81b031916908160001a905350828482600c016020811061516e57fe5b825191901a600f1690811061517f57fe5b602001015160f81c60f81b82826002026003018151811061519c57fe5b60200101906001600160f81b031916908160001a9053506001016150ef565b50949350505050565b606081806151eb5750506040805180820190915260018152600360fc1b602082015261151c565b8260005b811561520357600101600a820491506151ef565b6060816040519080825280601f01601f191660200182016040528015615230576020820181803883390190505b50905060001982015b841561527e57600a850660300160f81b8282806001900393508151811061525c57fe5b60200101906001600160f81b031916908160001a905350600a85049450615239565b5095945050505050565b6060848484846040516020018085805190602001908083835b602083106152c05780518252601f1990920191602091820191016152a1565b51815160209384036101000a600019018019909216911617905287519190930192870191508083835b602083106153085780518252601f1990920191602091820191016152e9565b51815160209384036101000a600019018019909216911617905286519190930192860191508083835b602083106153505780518252601f199092019160209182019101615331565b51815160209384036101000a600019018019909216911617905285519190930192850191508083835b602083106153985780518252601f199092019160209182019101615379565b6001836020036101000a0380198251168184511680821785525050505050509050019450505050506040516020818303038152906040529050949350505050565b8015611e4e576001600160a01b03831661540b576154066001600160a01b0383168263ffffffff6156ce16565b611e4e565b826137646001600160a01b038216848463ffffffff6157b316565b600082615435575060006119d8565b8282028284828161544257fe5b0414611df75760405162461bcd60e51b8152600401808060200182810382526021815260200180615a2b6021913960400191505060405180910390fd5b615491826001600160a01b0316614e88565b6154e2576040805162461bcd60e51b815260206004820152601f60248201527f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e747261637400604482015290519081900360640190fd5b60006060836001600160a01b0316836040518082805190602001908083835b602083106155205780518252601f199092019160209182019101615501565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114615582576040519150601f19603f3d011682016040523d82523d6000602084013e615587565b606091505b5091509150816155de576040805162461bcd60e51b815260206004820181905260248201527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564604482015290519081900360640190fd5b805115613764578080602001905160208110156155fa57600080fd5b50516137645760405162461bcd60e51b815260040180806020018281038252602a815260200180615abc602a913960400191505060405180910390fd5b600081848411156156c65760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561568b578181015183820152602001615673565b50505050905090810190601f1680156156b85780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b80471015615723576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e6365000000604482015290519081900360640190fd5b6040516000906001600160a01b0384169083908381818185875af1925050503d806000811461576e576040519150601f19603f3d011682016040523d82523d6000602084013e615773565b606091505b5050905080611e4e5760405162461bcd60e51b815260040180806020018281038252603a815260200180615968603a913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052611e4e90849061547f565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106158465782800160ff19823516178555615873565b82800160010185558215615873579182015b82811115615873578235825591602001919060010190615858565b5061250b9291506158ed565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106158c057805160ff1916838001178555615873565b82800160010185558215615873579182015b828111156158735782518255916020019190600101906158d2565b6119ee91905b8082111561250b57600081556001016158f356fe63616e63656c416e64526566756e64466f722861646472657373205f6b65794f776e6572294d6978696e4c6f636b4d616e616765723a2063616c6c657220646f6573206e6f74206861766520746865204c6f636b4d616e6167657220726f6c65416464726573733a20756e61626c6520746f2073656e642076616c75652c20726563697069656e74206d617920686176652072657665727465644f4e4c595f4b45595f4d414e414745525f4f525f415050524f564544000000004d6978696e4b65794772616e7465723a2063616c6c657220646f6573206e6f74206861766520746865204b65794772616e746572206f72204c6f636b4d616e6167657220726f6c65526f6c65733a206163636f756e7420646f6573206e6f74206861766520726f6c65536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77526f6c65733a206163636f756e7420697320746865207a65726f2061646472657373436f6e747261637420696e7374616e63652068617320616c7265616479206265656e20696e697469616c697a6564ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a72315820940f859c6035b092454c135aaf9c8d7da5c76fd4fc4c3ffe9777968819daf7ab64736f6c63430005110032
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.