joe roganfor 50% off.
codeAccountand we can store the
codeAddress) publicly without exposing the secret itself on-chain.
keyOwneris the address of the account that's purchasing a key.
bytes _datafield. The lock forwards this information to the discount code contract for confirmation. If the signature is missing or incorrect then the user is charged full price.
keyPurchaseHook. The lock manager needs to configure the lock's hook to point to the discount code contract. By default there are none set in order to remain flexible so lock managers can choose which features they would like to add to their lock.
0x0000000000000000000000000000000000000000if you don't have a use case for that. Additional you can de-register the hook anytime by setting both params to 0.
codeAddress. This step is required so that we don't publish the code directly as all information on Ethereum is public and we don't want users to simply look at the transaction history in order to discover a discount that anyone could use.
codeAddressthe following steps are recommended. This process is not yet integrated onto our dashboard so they will need to be performed manually.
codeAccountwhich is what we will store on-chain:
addCodeson the discount code contract from the lock manager's account. You can use Etherscan's Write Contract page to make the call. There are 3 parameters:
_codeAddressesis an array of addresses. If you are only adding a single discount code then it can be populated like so:
_discountBasisPointsis also an array. The discounts are represented in basis points which means 100 represents 1%. This allows you to be more precise on discounts, e.g. if you wanted to offer 12.42% off. The order should align with the
_codeAddressesso that if the first discount code is 15% off and the second is 50% off you can enter the following:
addCodesagain and set the discount for that
codeAccountusing the same approach that we used when adding the discount code originally (steps 1-3).
"\x19Ethereum Signed Message:\n32" + messageToSign.
purchasecall to use the
purchasePricecalculated above and include the signature if the user has entered a discount code. For example:
keyPricewill be used.
joe roganexample we have been working with, it would not be difficult for someone to guess and check to find that discount.
keyOwneris included in the signature to ensure that another account cannot simply replay the same transaction
_datafield to purchase with a discount for themselves.
codeAccountitself is generated is flexible, for example including the lock's address in the private key prevents users from discovering that a discount code can also be used on another lock.