Endpoints

XP

This endpoint sends a create project request to the XP contract

POST https://api.xp-protocol.io/create-project

This should be the first step into the XP ecoysystem

Headers

Request Body

Update score of a wallet address

POST https://api.xp-protocol.io/update-score

In the XP ecosystem this function should be called any time you want to trigger a score change.

Request Body

{
    // Response
}

More endpoints coming soon...

Example Request

The below request demonstrates how to perform a POST call to the /update-score endpoint with an X-API-KEY & Signature provided by either an "updater" or an "owner" of the project.

let myHeaders = new Headers();
let message = Date.now().toString();
let signatureObject = await web3.eth.accounts.sign(message, <PRIVATE_KEY>); //Private key of a wallet that is either an Updater or an Owner of the current project.
let signature = signatureObject.signature;

//Headers
myHeaders.append("X-API-KEY","<key>");
myHeaders.append("Content-Type", "application/json");
  
  //UpdateId, should be unique, duplicate updateIds are ignored and do will not update the target address's score.
  ///think of an updateId as a unique transaction.
 let updateId = targetAddress.toString()':'+ Date.now().toString()
 let id = '0x' + sha256(updateId).toString(); // 0x to signify its a bytes32
  //Send to API
    const body = JSON.stringify({
        "updateId": <updateId>,
        "projectId": <PROJECT_ID>,
        "actionName": <action-name>,
        "scoreType": <scoreType>,
        "targetWallet": <targetAddress>,
        "signature": signature,
        "message": message
    })
    const requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: body,
        redirect: 'follow'
    };
    
    let response = await fetch('https://api.xp-protocol.io/update-score, requestOptions).then(async (response) => ({ status: response.status, value: await response.text() }));
c

Last updated