The PublicLock Interface
Methods​ BASIS_POINTS_DEN​ function BASIS_POINTS_DEN ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
CANCEL_TYPEHASH​ function CANCEL_TYPEHASH ( ) external view returns ( bytes32 )
Copy The typehash per the EIP-712 standard
This can be computed in JS instead of read from the contract
Returns​ Name Type Description _0 bytes32 undefined
approve​ function approve ( address to , uint256 tokenId ) external nonpayable
Copy Parameters​ Name Type Description to address undefined tokenId uint256 undefined
balanceOf​ function balanceOf ( address owner ) external view returns ( uint256 balance )
Copy Returns the number of NFTs in owner
's account.
Parameters​ Name Type Description owner address undefined
Returns​ Name Type Description balance uint256 undefined
beneficiary​ function beneficiary ( ) external view returns ( address )
Copy =================================================================== Auto-generated getter functions from public state variables
Returns​ Name Type Description _0 address undefined
cancelAndRefund​ function cancelAndRefund ( ) external nonpayable
Copy Destroys the msg.sender's key and sends a refund based on the amount of time remaining.
cancelAndRefundFor​ function cancelAndRefundFor ( address _keyOwner , uint8 _v , bytes32 _r , bytes32 _s ) external nonpayable
Copy Cancels a key owned by a different user and sends the funds to the msg.sender.
Parameters​ Name Type Description _keyOwner address this user's key will be canceled _v uint8 _r _s getCancelAndRefundApprovalHash signed by the _keyOwner _r bytes32 undefined _s bytes32 undefined
destroyLock​ function destroyLock ( ) external nonpayable
Copy Used to clean up old lock contracts from the blockchain. TODO: add a check to ensure all keys are INVALID!
Throws if called by other than owner.Throws if lock has not yet been disabled.
disableLock​ function disableLock ( ) external nonpayable
Copy Used to disable lock before migrating keys and/or destroying contract.
Throws if called by other than the owner.Throws if lock contract has already been disabled.
erc1820​ function erc1820 ( ) external view returns ( address )
Copy Returns​ Name Type Description _0 address undefined
expirationDuration​ function expirationDuration ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
expireKeyFor​ function expireKeyFor ( address _owner ) external nonpayable
Copy A function which lets the owner of the lock expire a users' key.
Throws if called by other than lock ownerThrows if key owner does not have a valid key
Parameters​ Name Type Description _owner address The address of the key owner
freeTrialLength​ function freeTrialLength ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
fullRefund​ function fullRefund ( address _keyOwner , uint256 amount ) external nonpayable
Copy Invoked by the lock owner to destroy the user's key and perform a refund and cancellation of the keyThrows if called by other than ownerThrows if _keyOwner does not have a valid key
Parameters​ Name Type Description _keyOwner address The key owner to whom we wish to send a refund to amount uint256 The amount to refund the key-owner
getApproved​ function getApproved ( uint256 tokenId ) external view returns ( address operator )
Copy Parameters​ Name Type Description tokenId uint256 undefined
Returns​ Name Type Description operator address undefined
getBalance​ function getBalance ( address _tokenAddress , address _account ) external view returns ( uint256 )
Copy Gets the current balance of the account provided.
Parameters​ Name Type Description _tokenAddress address The token type to retrieve the balance of. _account address The account to get the balance of.
Returns​ Name Type Description _0 uint256 undefined
getCancelAndRefundApprovalHash​ function getCancelAndRefundApprovalHash ( address _keyOwner , address _txSender ) external view returns ( bytes32 approvalHash )
Copy returns the hash to sign in order to allow another user to cancel on your behalf.
this can be computed in JS instead of read from the contract.
Parameters​ Name Type Description _keyOwner address The key owner's address (also the message signer) _txSender address The address cancelling cancel on behalf of the keyOwner
Returns​ Name Type Description approvalHash bytes32 undefined
getCancelAndRefundValueFor​ function getCancelAndRefundValueFor ( address _owner ) external view returns ( uint256 refund )
Copy Determines how much of a refund a key owner would receive if they issued
Parameters​ Name Type Description _owner address 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.
Returns​ Name Type Description refund uint256 undefined
getHasValidKey​ function getHasValidKey ( address _owner ) external view returns ( bool )
Copy Checks if the user has a non-expired key.
Parameters​ Name Type Description _owner address The address of the key owner
Returns​ Name Type Description _0 bool undefined
getOwnersByPage​ function getOwnersByPage ( uint256 _page , uint256 _pageSize ) external view returns ( address [ ] )
Copy A function which returns a subset of the keys for this Lock as an array
Throws if there are no key owners yet
Parameters​ Name Type Description _page uint256 the page of key owners requested when faceted by page size _pageSize uint256 the number of Key Owners requested per page
Returns​ Name Type Description _0 address[] undefined
getTokenIdFor​ function getTokenIdFor ( address _account ) external view returns ( uint256 )
Copy Find the tokenId for a given user
Throws if key owner does not have a valid key
Parameters​ Name Type Description _account address The address of the key owner
Returns​ Name Type Description _0 uint256 undefined
getTransferFee​ function getTransferFee ( address _owner , uint256 _time ) external view returns ( uint256 )
Copy 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.
Throws if _owner does not have a valid key
Parameters​ Name Type Description _owner address The owner of the key check the transfer fee for. _time uint256 The amount of time to calculate the fee for.
Returns​ Name Type Description _0 uint256 undefined
grantKeys​ function grantKeys ( address [ ] _recipients , uint256 [ ] _expirationTimestamps ) external nonpayable
Copy Allows the Lock owner to give a collection of users a key with no charge. Each key may be assigned a different expiration date.
Throws if called by other than the lock-owner
Parameters​ Name Type Description _recipients address[] An array of receiving addresses _expirationTimestamps uint256[] An array of expiration Timestamps for the keys being granted
initialize​ function initialize ( address _owner , uint256 _expirationDuration , address _tokenAddress , uint256 _keyPrice , uint256 _maxNumberOfKeys , string _lockName ) external nonpayable
Copy =================================================================== Functions
Parameters​ Name Type Description _owner address undefined _expirationDuration uint256 undefined _tokenAddress address undefined _keyPrice uint256 undefined _maxNumberOfKeys uint256 undefined _lockName string undefined
invalidateOffchainApproval​ function invalidateOffchainApproval ( uint256 _nextAvailableNonce ) external nonpayable
Copy Sets the minimum nonce for a valid off-chain approval message from the senders account.
This can be used to invalidate a previously signed message.
Parameters​ Name Type Description _nextAvailableNonce uint256 undefined
isAlive​ function isAlive ( ) external view returns ( bool )
Copy Returns​ Name Type Description _0 bool undefined
isApprovedForAll​ function isApprovedForAll ( address owner , address operator ) external view returns ( bool )
Copy Parameters​ Name Type Description owner address undefined operator address undefined
Returns​ Name Type Description _0 bool undefined
isKeyOwner​ function isKeyOwner ( uint256 _tokenId , address _owner ) external view returns ( bool )
Copy Checks if the given address owns the given tokenId.
Parameters​ Name Type Description _tokenId uint256 The tokenId of the key to check _owner address The potential key owners address
Returns​ Name Type Description _0 bool undefined
isOwner​ function isOwner ( ) external view returns ( bool )
Copy Returns​ Name Type Description _0 bool undefined
keyCancelInterfaceId​ function keyCancelInterfaceId ( ) external view returns ( bytes32 )
Copy Returns​ Name Type Description _0 bytes32 undefined
keyExpirationTimestampFor​ function keyExpirationTimestampFor ( address _owner ) external view returns ( uint256 timestamp )
Copy Returns the key's ExpirationTimestamp field for a given owner.Throws if owner has never owned a key for this lock
Parameters​ Name Type Description _owner address address of the user for whom we search the key
Returns​ Name Type Description timestamp uint256 undefined
keyOwnerToNonce​ function keyOwnerToNonce ( address ) external view returns ( uint256 )
Copy Parameters​ Name Type Description _0 address undefined
Returns​ Name Type Description _0 uint256 undefined
keyPrice​ function keyPrice ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
keySoldInterfaceId​ function keySoldInterfaceId ( ) external view returns ( bytes32 )
Copy Returns​ Name Type Description _0 bytes32 undefined
maxNumberOfKeys​ function maxNumberOfKeys ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
function name ( ) external view returns ( string _name )
Copy A descriptive name for a collection of NFTs in this contract
Returns​ Name Type Description _name string undefined
numberOfOwners​ function numberOfOwners ( ) external view returns ( uint256 )
Copy Public function which returns the total number of unique owners (both expired and valid). This may be larger than totalSupply.
Returns​ Name Type Description _0 uint256 undefined
function owner ( ) external view returns ( address )
Copy =================================================================== From Openzeppelin's Ownable.sol
Returns​ Name Type Description _0 address undefined
ownerOf​ function ownerOf ( uint256 tokenId ) external view returns ( address owner )
Copy Returns the owner of the NFT specified by tokenId
.
Parameters​ Name Type Description tokenId uint256 undefined
Returns​ Name Type Description owner address undefined
function owners ( uint256 ) external view returns ( address )
Copy Parameters​ Name Type Description _0 uint256 undefined
Returns​ Name Type Description _0 address undefined
publicLockVersion​ function publicLockVersion ( ) external pure returns ( uint256 )
Copy The version number of the current implementation on this network.
Returns​ Name Type Description _0 uint256 undefined
purchase​ function purchase ( uint256 _value , address _recipient , address _referrer , bytes _data ) external payable
Copy Purchase functionThrows if lock is disabled. Throws if lock is sold-out. Throws if _recipient == address(0).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).
Parameters​ Name Type Description _value uint256 the number of tokens to pay for this purchase >= the current keyPrice - any applicable discount (_value is ignored when using ETH) _recipient address address of the recipient of the purchased key _referrer address address of the user making the referral _data bytes arbitrary data populated by the front-end which initiated the sale
refundPenaltyBasisPoints​ function refundPenaltyBasisPoints ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
renounceOwnership​ function renounceOwnership ( ) external nonpayable
Copy safeTransferFrom​ function safeTransferFrom ( address from , address to , uint256 tokenId ) external nonpayable
Copy 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}.
Parameters​ Name Type Description from address undefined to address undefined tokenId uint256 undefined
safeTransferFrom​ function safeTransferFrom ( address from , address to , uint256 tokenId , bytes data ) external nonpayable
Copy Parameters​ Name Type Description from address undefined to address undefined tokenId uint256 undefined data bytes undefined
setApprovalForAll​ function setApprovalForAll ( address operator , bool _approved ) external nonpayable
Copy Parameters​ Name Type Description operator address undefined _approved bool undefined
setBaseTokenURI​ function setBaseTokenURI ( string _baseTokenURI ) external nonpayable
Copy Allows the Lock owner to update the baseTokenURI for this Lock.
Throws if called by other than the lock owner
Parameters​ Name Type Description _baseTokenURI string String representing the base of the URI for this lock.
shareKey​ function shareKey ( address _to , uint256 _tokenId , uint256 _timeShared ) external nonpayable
Copy 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).
Throws if key is not valid.Throws if _to
is the zero addressEmit Transfer event
Parameters​ Name Type Description _to address The recipient of the shared key _tokenId uint256 the key to share _timeShared uint256 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)'))
.
supportsInterface​ function supportsInterface ( bytes4 interfaceId ) external view returns ( bool )
Copy =================================================================== From ERC165.sol
Parameters​ Name Type Description interfaceId bytes4 undefined
Returns​ Name Type Description _0 bool undefined
function symbol ( ) external view returns ( string )
Copy Gets the token symbol
Returns​ Name Type Description _0 string undefined
tokenAddress​ function tokenAddress ( ) external view returns ( address )
Copy Returns​ Name Type Description _0 address undefined
tokenByIndex​ function tokenByIndex ( uint256 index ) external view returns ( uint256 )
Copy Parameters​ Name Type Description index uint256 undefined
Returns​ Name Type Description _0 uint256 undefined
tokenOfOwnerByIndex​ function tokenOfOwnerByIndex ( address owner , uint256 index ) external view returns ( uint256 tokenId )
Copy Parameters​ Name Type Description owner address undefined index uint256 undefined
Returns​ Name Type Description tokenId uint256 undefined
tokenURI​ function tokenURI ( uint256 _tokenId ) external view returns ( string )
Copy A distinct Uniform Resource Identifier (URI) for a given asset.
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
Parameters​ Name Type Description _tokenId uint256 The tokenID we're inquiring about
Returns​ Name Type Description _0 string undefined
totalSupply​ function totalSupply ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
transferFeeBasisPoints​ function transferFeeBasisPoints ( ) external view returns ( uint256 )
Copy Returns​ Name Type Description _0 uint256 undefined
transferFrom​ function transferFrom ( address from , address to , uint256 tokenId ) external nonpayable
Copy 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}.*
Parameters​ Name Type Description from address undefined to address undefined tokenId uint256 undefined
transferOwnership​ function transferOwnership ( address newOwner ) external nonpayable
Copy Parameters​ Name Type Description newOwner address undefined
unlockProtocol​ function unlockProtocol ( ) external view returns ( address )
Copy Returns​ Name Type Description _0 address undefined
updateBeneficiary​ function updateBeneficiary ( address _beneficiary ) external nonpayable
Copy A function which lets the owner of the lock update the beneficiary account, which receives funds on withdrawal.
Throws if called by other than owner of beneficiaryThrows if _beneficiary is address(0)
Parameters​ Name Type Description _beneficiary address The new address to set as the beneficiary
updateKeyPricing​ function updateKeyPricing ( uint256 _keyPrice , address _tokenAddress ) external nonpayable
Copy A function which lets the owner of the lock to change the price for future purchases.
Throws if called by other than ownerThrows if lock has been disabledThrows if _tokenAddress is not a valid token
Parameters​ Name Type Description _keyPrice uint256 The new price to set for keys _tokenAddress address The address of the erc20 token to use for pricing the keys, or 0 to use ETH
updateLockName​ function updateLockName ( string _lockName ) external nonpayable
Copy Allows the Lock owner to assign a descriptive name for this Lock.
Throws if called by other than the lock owner
Parameters​ Name Type Description _lockName string The new name for the lock
updateLockSymbol​ function updateLockSymbol ( string _lockSymbol ) external nonpayable
Copy Allows the Lock owner to assign a Symbol for this Lock.
Throws if called by other than the lock owner
Parameters​ Name Type Description _lockSymbol string The new Symbol for the lock
updateRefundPenalty​ function updateRefundPenalty ( uint256 _freeTrialLength , uint256 _refundPenaltyBasisPoints ) external nonpayable
Copy Allow the owner to change the refund penalty.
Throws if called by other than owner
Parameters​ Name Type Description _freeTrialLength uint256 The new duration of free trials for this lock _refundPenaltyBasisPoints uint256 The new refund penaly in basis-points(bps)
updateTransferFee​ function updateTransferFee ( uint256 _transferFeeBasisPoints ) external nonpayable
Copy Allow the Lock owner to change the transfer fee.
Throws if called by other than lock-owner
Parameters​ Name Type Description _transferFeeBasisPoints uint256 The new transfer fee in basis-points(bps). Ex: 200 bps = 2%
withdraw​ function withdraw ( address _tokenAddress , uint256 _amount ) external nonpayable
Copy Called by owner to withdraw all funds from the lock and send them to the beneficiary
.Throws if called by other than the owner or beneficiary
Parameters​ Name Type Description _tokenAddress address specifies the token address to withdraw or 0 for ETH. This is usually the same as tokenAddress
in MixinFunds. _amount uint256 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 fullRefund
use cases.
Approval​ event Approval ( address indexed owner , address indexed approved , uint256 indexed tokenId )
Copy Parameters​ Name Type Description owner indexed
address undefined approved indexed
address undefined tokenId indexed
uint256 undefined
ApprovalForAll​ event ApprovalForAll ( address indexed owner , address indexed operator , bool approved )
Copy Parameters​ Name Type Description owner indexed
address undefined operator indexed
address undefined approved bool undefined
CancelKey​ event CancelKey ( uint256 indexed tokenId , address indexed owner , address indexed sendTo , uint256 refund )
Copy Parameters​ Name Type Description tokenId indexed
uint256 undefined owner indexed
address undefined sendTo indexed
address undefined refund uint256 undefined
Destroy​ event Destroy ( uint256 balance , address indexed owner )
Copy Parameters​ Name Type Description balance uint256 undefined owner indexed
address undefined
Disable​ ExpireKey​ event ExpireKey ( uint256 indexed tokenId )
Copy Parameters​ Name Type Description tokenId indexed
uint256 undefined
NewLockSymbol​ event NewLockSymbol ( string symbol )
Copy Parameters​ Name Type Description symbol string undefined
NonceChanged​ event NonceChanged ( address indexed keyOwner , uint256 nextAvailableNonce )
Copy Parameters​ Name Type Description keyOwner indexed
address undefined nextAvailableNonce uint256 undefined
PricingChanged​ event PricingChanged ( uint256 oldKeyPrice , uint256 keyPrice , address oldTokenAddress , address tokenAddress )
Copy Parameters​ Name Type Description oldKeyPrice uint256 undefined keyPrice uint256 undefined oldTokenAddress address undefined tokenAddress address undefined
RefundPenaltyChanged​ event RefundPenaltyChanged ( uint256 freeTrialLength , uint256 refundPenaltyBasisPoints )
Copy Parameters​ Name Type Description freeTrialLength uint256 undefined refundPenaltyBasisPoints uint256 undefined
Transfer​ event Transfer ( address indexed from , address indexed to , uint256 indexed tokenId )
Copy Parameters​ Name Type Description from indexed
address undefined to indexed
address undefined tokenId indexed
uint256 undefined
TransferFeeChanged​ event TransferFeeChanged ( uint256 transferFeeBasisPoints )
Copy Parameters​ Name Type Description transferFeeBasisPoints uint256 undefined
Withdrawal​ event Withdrawal ( address indexed sender , address indexed tokenAddress , address indexed beneficiary , uint256 amount )
Copy Parameters​ Name Type Description sender indexed
address undefined tokenAddress indexed
address undefined beneficiary indexed
address undefined amount uint256 undefined