You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-8Lines changed: 8 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# Discount Hook for Locks
2
2
3
-
This project implements an Unlock [PublicLock Hook](https://docs.unlock-protocol.com/core-protocol/public-lock/hooks) that can be used on Locks smart contracts to support "Discount Code".
3
+
This project implements an Unlock [PublicLock Hook](https://docs.unlock-protocol.com/core-protocol/public-lock/hooks) that can be used on Locks smart contracts to support a discount code or coupon.
4
4
5
5
This process is _secured_ and cannot be bypassed by calling the contract directly as the discount code is used to submit the transaction on-chain.
6
6
7
7
When the user enters a discount code on the frontend application, it is used to generate a private key that is then used to sign the recipient's address. That signature is passed as the data argument on the `purchase` call.
8
8
9
-
A lock manager can add any number of discount code to their lock by calling the function `setDiscountCodeForLock`.
9
+
A lock manager can add any number of discount code to their lock by calling the function `setDiscountCodeForLock` multiple times.
10
10
11
11
The Unlock Protocol team has deployed and verified a version of this hook on the following networks:
12
12
@@ -21,31 +21,31 @@ Test networks:
21
21
22
22
## Example
23
23
24
-
[This lock](https://goerli.etherscan.io/address/0x2490f447fdb7b259bc454871806b6b794de65944) deployed is deployed on Goerli and uses this discount hook with 2 different discounts:
24
+
[This example lock](https://goerli.etherscan.io/address/0x2490f447fdb7b259bc454871806b6b794de65944) is deployed on Goerli and uses this discount hook with 2 different discounts:
25
25
26
26
-`FRIENDS` for a 50% discount
27
27
-`FAMILY` for a 100% discount
28
28
29
-
This means you can only purchase a key if you go[through this checkout URL](https://app.unlock-protocol.com/checkout?paywallConfig=%7B%22locks%22%3A%7B%220x2490f447fdb7b259bc454871806b6b794de65944%22%3A%7B%22network%22%3A5%2C%22name%22%3A%22%22%2C%22captcha%22%3Afalse%2C%22password%22%3Afalse%2C%22promo%22%3Atrue%2C%22emailRequired%22%3Afalse%2C%22maxRecipients%22%3Anull%2C%22dataBuilder%22%3A%22%22%2C%22skipRecipient%22%3Afalse%7D%7D%2C%22pessimistic%22%3Atrue%2C%22skipRecipient%22%3Atrue%2C%22title%22%3A%22Try+Discounts%21%22%2C%22icon%22%3A%22%22%7D) and enter any of the 2 discount codes you will see a discounted price on the final confirmation screen!
29
+
This means if you purchase a key [through this checkout URL](https://app.unlock-protocol.com/checkout?paywallConfig=%7B%22locks%22%3A%7B%220x2490f447fdb7b259bc454871806b6b794de65944%22%3A%7B%22network%22%3A5%2C%22name%22%3A%22%22%2C%22captcha%22%3Afalse%2C%22password%22%3Afalse%2C%22promo%22%3Atrue%2C%22emailRequired%22%3Afalse%2C%22maxRecipients%22%3Anull%2C%22dataBuilder%22%3A%22%22%2C%22skipRecipient%22%3Afalse%7D%7D%2C%22pessimistic%22%3Atrue%2C%22skipRecipient%22%3Atrue%2C%22title%22%3A%22Try+Discounts%21%22%2C%22icon%22%3A%22%22%7D) and enter any of the 2 discount codes you will see a discounted price on the final confirmation screen!
30
30
31
31
If you don't enter a discount code, you will pay the full price of 0.01 Eth.
32
32
33
33
## Using the hook for your own lock
34
34
35
-
1. First, you need to generate promo codes, then [go to this page to generate the corresponding Ethereum address](https://unlock-protocol.github.io/discount-hook/). You can also generate this locally if needed by checking out the repo and switching to the `gh-page` branch.
35
+
1. First, you need to generate promo codes, then [go to this page to generate the corresponding signer address](https://unlock-protocol.github.io/discount-hook/). You can also generate this locally if needed by checking out the repo and switching to the `gh-page` branch.
36
36
37
37
<imgwidth="1044"alt="Screen Shot 2023-01-09 at 12 55 04 PM"src="https://user-images.githubusercontent.com/17735/211374963-b9fc6999-50ce-4e91-8ae4-4a5a55db91e8.png">
38
38
39
39
40
-
2. Then, click on which network your lock has been deployed on (list above) and head to `Contract` > `Write Contract`. Connect your wallet (you need to be connected as a lock's manager) and click on `setDiscountForLock`. There, enter the lock address, and then the signer address generated in the previous step and the discount to be applied. Since the EVM does not support floating numbers, you have to enter the value in "basis points". For example for a 100% discount, you would enter `10000`. For a 3% discount, you would enter `300`.
40
+
2. Then, click on the network your lock has been deployed on (list above) and head to `Contract` > `Write Contract`. Connect your wallet (you need to be connected as one of the lock's manager) and click on `setDiscountForLock`. There, enter the lock address, and then the signer address generated in the previous step and the discount amount to be applied. Since the EVM does not support floating numbers, you have to enter the discount percentage in [basis points](https://en.wikipedia.org/wiki/Basis_point). For example for a 100% discount, you would enter `10000`. For a 3% discount, you would enter `300`.
41
41
42
42
<imgwidth="696"alt="Screen Shot 2023-01-09 at 12 56 45 PM"src="https://user-images.githubusercontent.com/17735/211375263-029bfd0a-a421-4188-b329-b664819bf5e4.png">
43
43
44
-
3. After that, you need to point your lock to the hook. You can do that by going to your lock's settings page on the Unlock Dashboard. Then check the Advanced tab and the Hooks section.
44
+
3. After that, you need to point your lock to the hook. You can do that by going to your lock's settings page on the Unlock Dashboard. Then check the Advanced tab and the Hooks section. Add the address of the key purchase hook for the network your lock is deployed on. You can find a list of all the key purchase hook addresses listed above (and please get in touch with us if you need it to be deployed on more networks).
45
45
46
46
<imgwidth="1266"alt="Screen Shot 2023-01-09 at 12 57 19 PM"src="https://user-images.githubusercontent.com/17735/211375358-c00fecba-d4e5-46d9-a8cb-2ab00aec9731.png">
47
47
48
-
4. Finally, [build a Checkout URL](https://docs.unlock-protocol.com/tools/checkout/configuration) and make sure you tick `Promo Codes` option for the lock to which you are applying a discount!
48
+
4. Finally, [build a Checkout URL](https://unlock-protocol.com/blog/checkout-builder-release) and make sure you tick `Promo Codes` option for the lock to which you are applying a discount!
49
49
50
50
<imgwidth="751"alt="Screen Shot 2023-01-09 at 12 57 52 PM"src="https://user-images.githubusercontent.com/17735/211375444-f59089c9-c320-4c3f-8db0-c85a15836466.png">
0 commit comments