🧑🤝🧑Referral Design Pattern
A design pattern build for rewarding user attribution
Intro
Referrals
One way to use XP Protocol is as an on-chain Referral System. This design encourages your users to refer new users to your platform/protocol.
A referral is said to be "attributed" to the person who brought the new user in.
The key to setting this up correctly while ensuring it does not get gamed is to tap into the unique identifier of a updateScore() transaction.
updateId: Is a unique identifier that must be sent with each updateScore() transaction. This transaction is Deduped on-chain to prevent attacks.
Notice this particular line below:
This line sets the updateId to a concatenation of the two user addresses involved in this score update.
The simplicity in this line is that as a developer you do not need to worry about checking to see if a user has already gotten a reward for referring that particular user. This means there is no state management or querying that needs to happen before you fire off a score update.
The deduping will happen on-chain, each score update is Idempotent.
Idempotence is a key differentiator with XP Protocol which allows developers to bypass complexity in storying and tracking referrals.
That's it!
Last updated