Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referral #5

Merged
merged 11 commits into from
Nov 30, 2023
Merged

Referral #5

merged 11 commits into from
Nov 30, 2023

Conversation

roaminro
Copy link
Contributor

@roaminro roaminro commented Jun 20, 2023

referral code generation:
a referral code is an object that is encoded in base64-url (for easy sharing), it has the following fields:

  • the chain id (to prevent replay attack)
  • the referral contract id (to prevent replay attack)
  • an issuer address
  • an issuance date
  • an expiration date (a timestamp in milliseconds, 0 means no expiration)
  • an optional field to only allow a contract to redeem the referral code
  • an optional field to only allow an account to redeem the referral code
  • an optional arbitrary data field
  • a signature generated by the issuer address

Referral codes are generated off-chain (since issuance date is part of the signed payload, generating a code every 1 ms would generate a unique referral code everytime)

Referral contract (this contract can be leveraged by other smart contracts too):
implement redeem function:

  • check expiration date
  • check allowed contract/account
  • calculate hash of the referral code object
  • signature is verified against calculated hash and issuer address provided
  • return true/false depending on the result of the verification
  • valid codes hashes are stored so that they cannot be reused

Name-service contract:

  • Updated authorizeMint, authorizeBurn and authorizeRenewal to allow for passing arbitrary bytes to the underlying domain contract
  • Updated ABI accordingly

Koin domain contract:

  • call referral contract to validate referral code
  • verify referral code issuer is a premium account
  • verify premium account can still issue referral codes (number of referrals and refresh period can be set via contract metadata)
  • if buying a premium account with referral code, apply discount (percentage to apply can be set via contract metadata)
  • if buying a free account with referral code, allow minting

@lukemwillis lukemwillis merged commit 1ee8ae3 into lukemwillis:main Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants