Trigger XP in your application when a user completes a specific action, such as registering, completing a task, watching a video or posting a comment.

Before proceeding ensure you’ve instantiated the SDK and created a dApp.
See the Quickstart to get setup.

1

Get the XP Token Address

  • XP Address can be found in the dashboard in the keys section of the dApp page.
2

Reward XP

import { ActivityType, RewardType, toWei } from "@openformat/sdk";

const params = {
  // The address of the user who is receiving the XP tokens
  receiver: "0x03755352654D73DA06756077Dd7f040ADcE3Fd58",
  tokens: [
    {
      // A given ID for an action a user completes in your application
      id: "complete_activity",
      // The smart contract address of your XP TOKEN
      address: "INSERT_XP_ADDRESS",
      // The amount of XP tokens the receiver address will receive
      amount: toWei("10"),
      type: RewardType.XP_TOKEN,
      activityType: ActivityType.ACTION,
    },
  ],
};

await sdk.Reward.trigger(params);

Congratulations 🎉 You’ve just rewarded your first 10 XP.

The leaderboard API endpoint can now be used to quickly setup a leaderboard.