Skip to main content

IPublicLockV4

The PublicLock Interface

Methods

address2Str

function address2Str(address _addr) external pure returns (string)

A utility function for erc721 metadata

Parameters

NameTypeDescription
_addraddressAn address to convert

Returns

NameTypeDescription
_0stringundefined

approve

function approve(address _approved, uint256 _tokenId) external payable

Set or reaffirm the approved address for an NFT

The zero address indicates there is no approved address.Throws unless msg.sender is the current NFT owner, or an authorized operator of the current owner.

Parameters

NameTypeDescription
_approvedaddressThe new approved NFT controller
_tokenIduint256The NFT to approve

balanceOf

function balanceOf(address _owner) external view returns (uint256)

In the specific case of a Lock, each owner can own only at most 1 key.

Throws if _owner = address(0)

Parameters

NameTypeDescription
_owneraddressThe address of the key owner

Returns

NameTypeDescription
_0uint256undefined

beneficiary

function beneficiary() external view returns (address)

=================================================================== Auto-generated getter functions from public state variables

Returns

NameTypeDescription
_0addressundefined

cancelAndRefund

function cancelAndRefund() external nonpayable

Destroys the msg.sender's key and sends a refund based on the amount of time remaining.

cancelAndRefundFor

function cancelAndRefundFor(address _keyOwner, bytes _signature) external nonpayable

Cancels a key owned by a different user and sends the funds to the msg.sender.

Parameters

NameTypeDescription
_keyOwneraddressthis user's key will be canceled
_signaturebytesgetCancelAndRefundApprovalHash signed by the _keyOwner

destroyLock

function destroyLock() external nonpayable

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

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.

expirationDuration

function expirationDuration() external view returns (uint256)

Returns

NameTypeDescription
_0uint256undefined

expireKeyFor

function expireKeyFor(address _owner) external nonpayable

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

NameTypeDescription
_owneraddressThe address of the key owner

getApproved

function getApproved(uint256 _tokenId) external view returns (address)

Will return the approved recipient for a key, if any.

Parameters

NameTypeDescription
_tokenIduint256The ID of the token we're inquiring about.

Returns

NameTypeDescription
_0addressundefined

getCancelAndRefundApprovalHash

function getCancelAndRefundApprovalHash(address _keyOwner, address _txSender) external view returns (bytes32 approvalHash)

returns the hash to sign in order to allow another user to cancel on your behalf.

Parameters

NameTypeDescription
_keyOwneraddressThe key owner's address
_txSenderaddressThe address cancelling the key on behalf of the key-owner

Returns

NameTypeDescription
approvalHashbytes32undefined

getCancelAndRefundValueFor

function getCancelAndRefundValueFor(address _owner) external view returns (uint256 refund)

Determines how much of a refund a key owner would receive if they issued

Parameters

NameTypeDescription
_owneraddressThe 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

NameTypeDescription
refunduint256undefined

getHasValidKey

function getHasValidKey(address _owner) external view returns (bool)

Checks if the user has a non-expired key.

Parameters

NameTypeDescription
_owneraddressThe address of the key owner

Returns

NameTypeDescription
_0boolundefined

getOwnersByPage

function getOwnersByPage(uint256 _page, uint256 _pageSize) external view returns (address[])

A function which returns a subset of the keys for this Lock as an array

Throws if there are no key owners yet

Parameters

NameTypeDescription
_pageuint256the page of key owners requested when faceted by page size
_pageSizeuint256the number of Key Owners requested per page

Returns

NameTypeDescription
_0address[]undefined

getTokenIdFor

function getTokenIdFor(address _account) external view returns (uint256)

Find the tokenId for a given user

Throws if key owner does not have a valid key

Parameters

NameTypeDescription
_accountaddressThe address of the key owner

Returns

NameTypeDescription
_0uint256undefined

getTransferFee

function getTransferFee(address _owner) external view returns (uint256)

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

NameTypeDescription
_owneraddressThe owner of the key check the transfer fee for.

Returns

NameTypeDescription
_0uint256undefined

grantKeys

function grantKeys(address[] _recipients, uint256[] _expirationTimestamps) external nonpayable

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

NameTypeDescription
_recipientsaddress[]An array of receiving addresses
_expirationTimestampsuint256[]An array of expiration Timestamps for the keys being granted

isAlive

function isAlive() external view returns (bool)

Returns

NameTypeDescription
_0boolundefined

isApprovedForAll

function isApprovedForAll(address _owner, address _operator) external view returns (bool)

Tells whether an operator is approved by a given owner

Parameters

NameTypeDescription
_owneraddressowner address which you want to query the approval of
_operatoraddressoperator address which you want to query the approval of

Returns

NameTypeDescription
_0boolundefined

isKeyOwner

function isKeyOwner(uint256 _tokenId, address _owner) external view returns (bool)

Checks if the given address owns the given tokenId.

Parameters

NameTypeDescription
_tokenIduint256The tokenId of the key to check
_owneraddressThe potential key owners address

Returns

NameTypeDescription
_0boolundefined

isOwner

function isOwner() external view returns (bool)

Returns

NameTypeDescription
_0boolundefined

keyExpirationTimestampFor

function keyExpirationTimestampFor(address _owner) external view returns (uint256 timestamp)

Returns the key's ExpirationTimestamp field for a given owner.Throws if owner has never owned a key for this lock

Parameters

NameTypeDescription
_owneraddressaddress of the user for whom we search the key

Returns

NameTypeDescription
timestampuint256undefined

keyOwnerToNonce

function keyOwnerToNonce(address) external view returns (uint256)

Parameters

NameTypeDescription
_0addressundefined

Returns

NameTypeDescription
_0uint256undefined

keyPrice

function keyPrice() external view returns (uint256)

Returns

NameTypeDescription
_0uint256undefined

maxNumberOfKeys

function maxNumberOfKeys() external view returns (uint256)

Returns

NameTypeDescription
_0uint256undefined

name

function name() external view returns (string _name)

A descriptive name for a collection of NFTs in this contract

Returns

NameTypeDescription
_namestringundefined

numberOfOwners

function numberOfOwners() external view returns (uint256)

Public function which returns the total number of unique owners (both expired and valid). This may be larger than totalSupply.

Returns

NameTypeDescription
_0uint256undefined

owner

function owner() external view returns (address)

=================================================================== From Openzeppelin's Ownable.sol

Returns

NameTypeDescription
_0addressundefined

ownerOf

function ownerOf(uint256 _tokenId) external view returns (address)

Find the owner of an NFT

NFTs assigned to zero address are considered invalid, and queries about them do throw.

Parameters

NameTypeDescription
_tokenIduint256The identifier for an NFT

Returns

NameTypeDescription
_0addressundefined

owners

function owners(uint256) external view returns (address)

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0addressundefined

publicLockVersion

function publicLockVersion() external pure returns (uint16)

The version number of the current implementation on this network.

Returns

NameTypeDescription
_0uint16undefined

purchaseFor

function purchaseFor(address _recipient) external payable

Key Purchase functionThrows if lock is disabled.

Parameters

NameTypeDescription
_recipientaddressaddress of the recipient of the purchased key

purchaseForFrom

function purchaseForFrom(address _recipient, address _referrer) external payable

Purchase function, public version, with referrer.Throws if lock is disabled, or if referrer doesn't have a valid key.

Parameters

NameTypeDescription
_recipientaddressaddress of the recipient of the purchased key
_referreraddressaddress of the user making the referral

renounceOwnership

function renounceOwnership() external nonpayable

safeTransferFrom

function safeTransferFrom(address _from, address _to, uint256 _tokenId) external payable

Transfers the ownership of an NFT from one address to another address

This works identically to the other function with an extra data parameter, except this function just sets data to ''

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

safeTransferFrom

function safeTransferFrom(address _from, address _to, uint256 _tokenId, bytes data) external payable

Transfers the ownership of an NFT from one address to another address

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT. When transfer is complete, this function 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)')).

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer
databytesAdditional data with no specified format, sent in call to _to

setApprovalForAll

function setApprovalForAll(address _to, bool _approved) external nonpayable

Sets or unsets the approval of a given operator An operator is allowed to transfer all tokens of the sender on their behalfThrows if lock is disabled, or if _to == msg.sender.

Parameters

NameTypeDescription
_toaddressoperator address to set the approval
_approvedboolrepresenting the status of the approval to be set

setBaseTokenURI

function setBaseTokenURI(string _baseTokenURI) external nonpayable

Allows the Lock owner to update the baseTokenURI for this Lock.

Throws if called by other than the lock owner

Parameters

NameTypeDescription
_baseTokenURIstringString representing the base of the URI for this lock.

strConcat

function strConcat(string _a, string _b, string _c, string _d) external pure returns (string _concatenatedString)

notice A utility function for erc721 metadata

Parameters

NameTypeDescription
_astringString 1
_bstringString 2
_cstringString 3
_dstringString 4

Returns

NameTypeDescription
_concatenatedStringstringundefined

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool)

=================================================================== From ERC165.sol

Parameters

NameTypeDescription
interfaceIdbytes4undefined

Returns

NameTypeDescription
_0boolundefined

symbol

function symbol() external view returns (string)

Gets the token symbol

Returns

NameTypeDescription
_0stringundefined

tokenURI

function tokenURI(uint256 _tokenId) external view returns (string)

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

NameTypeDescription
_tokenIduint256The tokenID we're inquiring about

Returns

NameTypeDescription
_0stringundefined

totalSupply

function totalSupply() external view returns (uint256)

=================================================================== From IERC721Enumerable

Returns

NameTypeDescription
_0uint256undefined

transferFrom

function transferFrom(address _from, address _to, uint256 _tokenId) external payable

=================================================================== From Openzeppelin's IERC721.solTransfer ownership of an NFT -- THE CALLER IS RESPONSIBLE TO CONFIRM THAT _to IS CAPABLE OF RECEIVING NFTS OR ELSE THEY MAY BE PERMANENTLY LOST

Throws unless msg.sender is the current owner, an authorized operator, or the approved address for this NFT. Throws if _from is not the current owner. Throws if _to is the zero address. Throws if _tokenId is not a valid NFT.

Parameters

NameTypeDescription
_fromaddressThe current owner of the NFT
_toaddressThe new owner
_tokenIduint256The NFT to transfer

transferOwnership

function transferOwnership(address newOwner) external nonpayable

Parameters

NameTypeDescription
newOwneraddressundefined

uint2Str

function uint2Str(uint256 _i) external pure returns (string _uintAsString)

A utility function for erc721 metadata

Parameters

NameTypeDescription
_iuint256A uint to convert

Returns

NameTypeDescription
_uintAsStringstringundefined

unlockProtocol

function unlockProtocol() external view returns (address)

Returns

NameTypeDescription
_0addressundefined

updateBeneficiary

function updateBeneficiary(address _beneficiary) external nonpayable

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

NameTypeDescription
_beneficiaryaddressThe new address to set as the beneficiary

updateKeyPrice

function updateKeyPrice(uint256 _keyPrice) external nonpayable

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 disabled

Parameters

NameTypeDescription
_keyPriceuint256The new price to set for keys

updateLockName

function updateLockName(string _lockName) external nonpayable

Allows the Lock owner to assign a descriptive name for this Lock.

Throws if called by other than the lock owner

Parameters

NameTypeDescription
_lockNamestringThe new name for the lock

updateLockSymbol

function updateLockSymbol(string _lockSymbol) external nonpayable

Allows the Lock owner to assign a Symbol for this Lock.

Throws if called by other than the lock owner

Parameters

NameTypeDescription
_lockSymbolstringThe new Symbol for the lock

updateRefundPenalty

function updateRefundPenalty(uint256 _refundPenaltyNumerator, uint256 _refundPenaltyDenominator) external nonpayable

Allow the owner to change the refund penalty.

Throws if called by other than owner

Parameters

NameTypeDescription
_refundPenaltyNumeratoruint256undefined
_refundPenaltyDenominatoruint256undefined

updateTransferFee

function updateTransferFee(uint256 _transferFeeNumerator, uint256 _transferFeeDenominator) external nonpayable

Allow the Lock owner to change the transfer fee.

Throws if called by other than lock-owner Ex: 200 bps = 2%

Parameters

NameTypeDescription
_transferFeeNumeratoruint256undefined
_transferFeeDenominatoruint256undefined

withdraw

function withdraw(uint256 _amount) external nonpayable

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

NameTypeDescription
_amountuint256specifies 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 use case.

Events

Approval

event Approval(address indexed _owner, address indexed _approved, uint256 indexed _tokenId)

Parameters

NameTypeDescription
_owner indexedaddressundefined
_approved indexedaddressundefined
_tokenId indexeduint256undefined

ApprovalForAll

event ApprovalForAll(address indexed _owner, address indexed _operator, bool _approved)

Parameters

NameTypeDescription
_owner indexedaddressundefined
_operator indexedaddressundefined
_approvedboolundefined

CancelKey

event CancelKey(uint256 indexed tokenId, address indexed owner, address indexed sendTo, uint256 refund)

Parameters

NameTypeDescription
tokenId indexeduint256undefined
owner indexedaddressundefined
sendTo indexedaddressundefined
refunduint256undefined

Destroy

event Destroy(uint256 balance, address indexed owner)

Parameters

NameTypeDescription
balanceuint256undefined
owner indexedaddressundefined

Disable

event Disable()

ExpireKey

event ExpireKey(uint256 indexed tokenId)

Parameters

NameTypeDescription
tokenId indexeduint256undefined

NewLockSymbol

event NewLockSymbol(string symbol)

Parameters

NameTypeDescription
symbolstringundefined

PriceChanged

event PriceChanged(uint256 oldKeyPrice, uint256 keyPrice)

Parameters

NameTypeDescription
oldKeyPriceuint256undefined
keyPriceuint256undefined

RefundPenaltyChanged

event RefundPenaltyChanged(uint256 _refundPenaltyNumerator, uint256 _refundPenaltyDenominator)

Parameters

NameTypeDescription
_refundPenaltyNumeratoruint256undefined
_refundPenaltyDenominatoruint256undefined

Transfer

event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId)

Parameters

NameTypeDescription
_from indexedaddressundefined
_to indexedaddressundefined
_tokenId indexeduint256undefined

TransferFeeChanged

event TransferFeeChanged(uint256 _transferFeeNumerator, uint256 _transferFeeDenominator)

Parameters

NameTypeDescription
_transferFeeNumeratoruint256undefined
_transferFeeDenominatoruint256undefined

Withdrawal

event Withdrawal(address indexed sender, address indexed beneficiary, uint256 amount)

Parameters

NameTypeDescription
sender indexedaddressundefined
beneficiary indexedaddressundefined
amountuint256undefined