🎯XP Protocol
Last updated
Last updated
XP Protocol gives marketplaces, social networks, and even creators an easy way to track and incentivize on-chain & off-chain behaviors.
All you have to do is create a project, specify which actions you would like to track, and provide a point amount per action. Then you can call our API or smart contract and let us know each time a user completes an action (very similar to analytics services).
All user scores are stored on-chain and accessible through our API, subgraph, or directly through smart contract calls.
You can then incentivize users based on their score by giving airdrops, gating features, or providing special tiered access to other products. Or you can allow users to redeem XP points directly for crypto, as we do in our mobile app, creating a crypto-native loyalty program!
NFT Marketplace: As a marketplace, you can create your own 🎉Reputation protocol that could encourages users to take specific actions that you wish to incentivize. Simply by giving your collectors a point system they can compete to be included on leaderboards or unlock new features hidden from others on the platform. Also because this data is on-chain (on Polygon, other chains coming soon) you can also set up token allocation, airdrops, and cash-out systems.
Creator: As a creator you may be minting on many different chains and platforms. It can be very difficult to systematically reward your top collectors and curators. You can now spin up your very own 🪙Reward protocol and send points to collectors of your work that anyone can tap into, including any marketplaces or social networks. Rewarding your audience is an essential part of social economics.
Startup/Developer: The XP protocol is a fabric to build other protocols on top of. We have seen many reputation systems fail simply because they were not flexible enough to work for most use cases outside their intended design. We aim to solve this with our simple and flexible XP protocol. This protocol fabric sends data cross-chain as well as off-chain via REST services making it the most versatile and flexible protocol fabric available for future reputation systems. Are you a startup looking to build an XP system for web3 gaming? or thinking about creating a reputation system for social networks? a loyalty program for your web3-enabled store? - XP protocol is the fastest way to do that, instantiate & create your protocol in minutes not months.
Our XP Protocol is located on Polygon mainnet:
Address: 0xf1b5AF2bd94dDfB696B54DaBb06118A79C7460bc
Polygonscan: https://polygonscan.com/address/0xf1b5af2bd94ddfb696b54dabb06118a79c7460bc
Network ID: 137
(Polygon mainnet)
The essential steps for using the XP protocol are:
Create a project.
Update user scores.
Query user scores.
Steps 1 & 2 can be done in three different ways: directly on PolygonScan, through the Rest API, or through smart contract function calls.
We will go through all the steps using PolygonScan below. We also provide the necessary function calls for our Rest API or smart contract. In all three examples, the process and inputs for each function are the same.
Using PolygonScan:
Before you begin, head to https://polygonscan.com/address/0x658b1975E6C26d435A7e0F27fF7bdF883f694B23#writeContract and connect your web3 wallet.
Find the createProject function:
You will need to input a project ID as a bytes32. If you do not know how to generate a hash, you can use this simple tool: https://emn178.github.io/online-tools/sha256.html. Make sure to add a "0x" in front of the hash.
Next, you will input the name of the project.
Then add one or more actions to the project. Each action consists of a name, how many points the user receives (or loses) for this action and the direction (0 means that points increment, 1 means that points decrement). Here is an example input for the actions:
[{name: "Bought", points: 10, direction 0}, {name: "Sold", points: 15, direction 0}, {name: "Liked", points: 1, direction 0}]
Finally, add an array of project owners and an array of project updaters. Project owners can call any administrative function for the project (including updateScore). Project updaters can only call updateScore. Make sure to include your own Polygon address in the owners array.
2. Find the updateScore function:
This function will increase or decrease a user's score based on the action selected. You will input the name of the action (must be identical to the name you inputted when creating the action).
You must specify the project ID as created in the previous step, and also create a unique update ID for each action update (also a bytes32). The update ID is used to ensure that each score update is only counted once.
The score type is a string that describes the category that this score falls into. You can create as many score types as you like, or only have one. You will be able to query user scores by individual score type or by total use score.
The target wallet should be the address of the user who has completed the action.
3. That's it! You can now track and reward your users based on their actions. Explore the page on the subgraph to see how you can query and check user scores: https://app.gitbook.com/o/pdTICoPjmrytuetswpm6/s/WPXLCvkhAvAfu3pqC6Kx/products/xp-protocol/xp-subgraph
Find the documentation on Rest API here: Rest API
createProject:
Inputs: bytes32 _projectId, string _name, Action[] _inputActions, address[] _owners, address[] _updaters
In order to begin keeping track of user scores you must first create a project. The project will contain all of the users and their scoreboards. Only you will be able to update it, in addition to any other owners and updaters whose addresses you input.
You can specify the actions that are tracked by inputing them here or in the below addActions function. An action is an object that contains the inputs of: name, points and direction
.
Here is an example action object:
{ name: 'boughtAction', points: 250, direction: 0 }
A direction of 0
means incremental and a direction of 1
means decremental.
addActions:
Inputs: bytes32 _projectId, Action[] _inputActions
Allows you to add from 1-20 new actions as an array of action objects.
An example of an action object:
{ name: 'flippedAction', points: 30, direction: 1 }
The 'flippedAction' will reduce a user's score by 30 points each time it it submitted.
updateScore:
Inputs: bytes32 _updateId, bytes32 _projectId, string _actionName, string _scoreType, address _targetWallet
Allows you to submit a user action in order to update their score.
Actions are called with a string containing their name.
Must specify a string for scoreType
which is a category or persona that the score falls under, for example "collector"
or "creator"
.
Must also provide the targetWallet
address of user whose score is being updated.
Discord: https://discord.gg/B4xdPJKB5U
Email: contact@xp-protocol.io