Skip to main content

ILockKeyPurchaseHook

Functions to be implemented by a keyPurchaseHook.

Lock hooks are configured by calling setEventHooks on the lock.

Methods​

keyPurchasePrice​

function keyPurchasePrice(address from, address recipient, address referrer, bytes data) external view returns (uint256 minKeyPrice)

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.

the lock's address is the msg.sender when this function is called via the lock's purchasePriceFor function

Parameters​

NameTypeDescription
fromaddressthe msg.sender making the purchase
recipientaddressthe account which will be granted a key
referreraddressthe account which referred this key sale
databytesarbitrary data populated by the front-end which initiated the sale

Returns​

NameTypeDescription
minKeyPriceuint256the minimum value/price required to purchase a key with these settings

onKeyPurchase​

function onKeyPurchase(address from, address recipient, address referrer, bytes data, uint256 minKeyPrice, uint256 pricePaid) external nonpayable

If the lock owner has registered an implementer then this hook is called with every key sold.

the lock's address is the msg.sender when this function is called

Parameters​

NameTypeDescription
fromaddressthe msg.sender making the purchase
recipientaddressthe account which will be granted a key
referreraddressthe account which referred this key sale
databytesarbitrary data populated by the front-end which initiated the sale
minKeyPriceuint256the price including any discount granted from calling this hook's keyPurchasePrice function
pricePaiduint256the value/pricePaid included with the purchase transaction