Email Subscription Paymaster on ZKSync Era
- Crypto / Web3
Encourage Email Subscription by Sponsoring Gas Fees when Email is in Subscription
We modified the Paymaster contract so that it will pay for the user's gas fees if 1) they own the NFT contract (same logic as the tutorial), and 2) the email hash + email signature match the public address of the server using ZK Sync Era's SDK for Signature Checker.
See our demo for video presentation: https://www.loom.com/share/a04751732c904c3e9ff1f00dc310223e?sid=e5667eb6-b6ca-412f-8b20-4bc6e6f63809
We have a back-end server that has email addresses and hashes with the private key to produce a signature. The solidity contract then compares the email address, the signature and the public key to return a boolean true or false.
The contract addresses we deployed on ZKSync Era's testnet are: Greeter Contract = "0x91aC94801A0f3ab7dedD68d1563f1F1c42f78B98"; NFT Contract ="0x28dFBfC56EB41168D6FAa0836dca2bf48CAd537e"; Paymaster Contract = "0x1Edd0259abb6A821a14cC939e0C3f48A3f7A7C82";
In particular, the Paymaster Contract was modified to include a verifyServerSignature function. The verifyServerSignature function takes in the emailHash (hashed email), serverSignature (hashed email and private key), and serverAddress to return a true or false. The serverAddress is compared to the expected serverAddress from the emailHash and the serverSignature.
The true or false is then used to decide whether or not the Paymaster will pay for the gas fees for the transaction.
In our demo, someone with their email in the email subscription will get be able to change the greeting without using fees.
Purpose: Email for e-commerce merchants is often a large driver of order conversion. Emails sent out by merchants often get orders from customers that capitalize on new deals or reminder of the great products that the merchant offers. This allows e-commerce merchants to offer potential customers another reason to sign-up to the email newsletter and obtain customized web3 experiences. The emails are not stored on-chain. The emails are stored in an off-chain email server but use the cryptography to provide gas-less experiences to users that are on the email list.
We are all recent graduates of the 3 month intensive Software Engineering bootcamp in Toronto hosted by Brainstation.
We are excited about exploring web3 applications further!