Comment on page

Genie API

Get Reward Information

Returns the reward information of a user in a particular campaign, including the encrypted message payload required to claim from the campaign contract.

Request Path Parameters

  • :address: the address of the claimer or user
  • :contract: the contract address of the campaign

Responses

Success (200 OK)

Returns a JSON with the following fields:
  • contractPayload: the payload that the user should pass to the campaign contract when executing the claim tx
  • rewardAssetType: can be either token or lootbox and determines the return type of the reward field
  • reward: an object containing the following fields:
    • assetId: the contract address or denom of the reward asset
    • symbol: the symbol/ticker of the reward asset
    • decimals: the number of decimals of the reward asset
    • totalReward [only present if rewardAssetType is token]: an array where each number represents the unclaimed rewards for each mission
    • lootboxInfo [only present if rewardsAssetType is lootbox]: an array where each number represents the total number of lootboxes earned for each mission

Error (401 Unauthorized)

Such a response can be expected if:
  • This API is called outside of the campaign's claim period
  • The claimer is not eligible for the campaign
  • The claimer does not have any pending rewards to claim

Error (401 Unauthorized)

Such a response can be expected if:
  • The given contract address does not correspond to a valid Genie campaign

Examples

We will now show an example flow using the following example values:
  • Claimer address: the_claimer
  • Campaign contract address: the_contract

Claiming Tokens

Firstly, make a GET request to the endpoint: https://api.seer.coinhall.org/api/genie/v2/claimers/the_claimer/claims/the_contract. If successful, you will receive the following example response:
{
"contractPayload": "eyJjbGFSJ9", // shortened for brevity
"rewardAssetType": "token",
"reward": {
"assetId": "uosmo",
"symbol": "OSMO",
"decimals": 6,
"totalReward": [0, 123, 456, 0]
}
}
Using the contractPayload field above, you can then form the wasm execute message that should be sent to the campaign contract:
{
"claim": {
"payload": "eyJjbGFSJ9"
}
}

Claiming Lootboxes

Firstly, make a GET request to the endpoint: https://api.seer.coinhall.org/api/genie/v2/claimers/the_claimer/claims/the_contract. If successful, you will receive the following example response:
{
"contractPayload": "eyJjbGFSJ9", // shortened for brevity
"rewardAssetType": "token",
"reward": {
"assetId": "uosmo",
"symbol": "OSMO",
"decimals": 6,
"lootboxInfo": [3, 1]
}
}
Using the contractPayload field above, you can then form the wasm execute message that should be sent to the campaign contract:
{
"claim": {
"payload": "eyJjbGFSJ9"
}
}

FAQs

Since the API returns the total number of lootboxes that the user has earned, how do I get the number of unopened lootboxes that the user currently has?

The number of opened lootboxes is stored on the campaign contract. You will need to query the contract with the following message:
{
"user_lootbox_info": {
"address": "REPLACE_CLAIMER_ADDRESS_HERE"
}
}
This will return the following message, describing the number of lootboxes that the user has opened/claimed:
{
"claimed_lootbox": [1, 0]
}
Subtract the total number of lootboxes from the API with the result we just queried from the contract to get the number of pending lootboxes that the user can claim. For example, if the reward.lootboxInfo from the API is [3, 1], then the result will be [3, 1] - [1, 0] = [2, 1], where there is two unopened lootboxes for mission 1 and one unopened lootbox for mission 2.