Claims

XP Claims

The score-updating process requires a trusted party to initiate a score update for a specific user. This can be done manually through the dashboard, or by any number of integration operators.

On the other hand, if we have score updates that we want users themselves to execute for participating in certain events/IRL attendance, we have XP Claims.

XP Claims are user-serviceable score updates. This means that a claim can be executed by a user directly without the need for backend verification.

XP Claims can be executed by linking to a claim via the Discover website endpoint below

https://discover.xp-protocol.io/xpclaim/<CLAIM ID HERE>

Creating a Claim

A claim can be created via the XP Dashboard or directly from our REST API.

  1. https://dashboard.xp-protocol.io

  2. Below is an example of a call directly to the REST API

 
   import Web3 from 'web3';
      
      let expireDateUnix = Math.floor(date.getTime() / 1000);

      const signature = await web3.eth.personal.sign(
        timestamp,/// in seconds
         <xp owner wallet address> //This wallet must be an owner of the XP Instance
      );

      let claimData = {
        claimData: {
          xpProjectId: <projectId>,
          description: <claimDescription>,
          name: <claimName>,
          points: <points>,
          updateIdFormat: "singleUse",//only supports singleUse on v1
          xpAction: <action-name>,//name the action that will be fired when triggered.
          xpExpire: expireDateUnix.toString(),//unix time in seconds of expiration
          xpScoreType: <score type>, //what scoretype to attribute points to
          discoverable: <boolean>, // allow people to be able to discover this via discover app,
        },
        verification: {
          signature,
          message: timestamp,//timestamp must match signature
          address: <xp owner wallet address>,
        },
      };

      let createClaimResponse = await fetch(
        "https://api.xp-protocol.io/create-claim",
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify(claimData),
        }
      );

If the call is successful it should response with the following unique identifier.



{ status: "created", claimId: "fe269616-e113-4d6b-8711-e816bfcabfa3" }

Querying Claims By Project ID

Claims can be queried by project id to be used for display purposes.

Only "Discoverable" claims will be returned in this query.

Below is an example of a query.

 let getClaims = await fetch(
        "https://api.xp-protocol.io/get-claims",
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({xpProjectId:<xp project id here>}),
        }
      );

Query A Single Claim

let getClaim = await fetch(
        "https://api.xp-protocol.io/get-claim",
        {
          method: "POST",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({claimId: <claim id here>}),
        }
      );

Last updated