đŸ› ī¸
Okapi docs
  • 👋Welcome to Okapi
  • 🧰Our products
  • Fundamentals
    • đŸ› ī¸Quickstart
      • đŸ–ŧī¸Mint new NFT
      • đŸĒ™Mint new tokens
      • 🔑Get API key
      • đŸŽ¯Create an Objective
      • 🎁Create a Reward
      • 🔐Create a token gate
      • đŸ—„ī¸Update your organization profile
      • 🔁Manage subscriptions
      • đŸ”ĸCompute units
      • đŸ’ŗPricing
      • đŸ•šī¸Demo
  • đŸ’ģJS SDK
    • đŸ“ĻInstall Okapi
    • 👀Wallet
    • đŸŽ¯Objective
    • 🎁Reward
    • 🔐Token gating
  • Use case
    • 💡Use case
      • 🎮Gaming
      • 🍔Restaurants
      • đŸ›ī¸Retailers
      • âœˆī¸Travel
      • 🏨Hospitality
      • đŸĻFinancial services
Powered by GitBook
On this page
  1. JS SDK

Reward

Reward transaction for FIXED amount

PreviousObjectiveNextToken gating

Last updated 2 years ago

You can think of the Reward endpoint as the when you want to reward a user in exchange or Tokens or NFTs. This is determined by the Reward created on your .

In this example, we want to give our users 5$ OFF their order in exchange for 500 Okapi coins . To do so, we need to use the reward endpoint.

To see how to create a reward on Okapi, see the Create an reward section.

This endpoint takes an id (reward ID) and a user (unique identifier).

const data = await okApiClient.reward({ id: "REWARD_ID", user: "john@doe.com" })
{
    "txSignature": "UEiSQsYjbhDun2NRtQXQNdfmqqPz8sAxdLGDMvheMjC9UcbjmLF3eR4F6X213ZX679Wjy7NW8hKL7dcZ8b6qrQU",
    "succcess": true
}
{
    "txSignature": null,
    "success": false,
    "error": "Insufficient funds"
}
{
    "message": "Forbidden"
}

If the reward ID exists and the transaction is successful, your user (john@doe.com) will be debited 500 Okapi coin from it's wallet. You will get a success boolean and a txSignature .

Cost: 10 compute units

Note: The documentation for Reward transaction for DYNAMIC amount is coming soon.

You can take a look at the transaction from the response here to see that the user has been debited 500 Okapi coins . Note that you can see that your account received the 500 Okapi coins debited from your user account.

đŸ’ģ
🎁
https://explorer.solana.com/tx/UEiSQsYjbhDun2NRtQXQNdfmqqPz8sAxdLGDMvheMjC9UcbjmLF3eR4F6X213ZX679Wjy7NW8hKL7dcZ8b6qrQU
Okapi dashboard