Search
K

Endpoints

XP

post
https://
api.xp-protocol.io/create-project
This endpoint sends a create project request to the XP contract
post
https:
//api.xp-protocol.io/update-score
Update score of a wallet address
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 modified 8mo ago