Incentives #

Read more about the Incentive system in Hiro here.

Sender incentives #

Listing sender incentives #

You can list all sender incentives for the user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
let incentivesList = await hiroClient.incentivesSenderList(session);
incentivesList.forEach(incentive => {
    // Iterate over the key-value pairs in the Claims object
    Object.entries(incentive.Claims).forEach(([key, value]) => {
        console.log(`${key} claimed at ${value.ClaimTimeSec}.`);
    });

    // Iterate over the UnclaimedRecipients array
    incentive.UnclaimedRecipients.forEach(userId => {
        console.log(`${userId} has not yet claimed.`);
    });
});

Creating sender incentives #

You can create a sender incentive for the user.

1
2
3
4
5
let incentiveSenderCreateRequest : IncentiveSenderCreateRequest = {
    id: "coin-invite"
};
let result = await hiroClient.incentivesSenderCreate(session, incentiveSenderCreateRequest);
console.log(result.incentives[0].code); // <- code to send to another player!

Claiming sender incentives #

You can claim a sender incentive for the user.

1
2
3
4
let incentiveSenderCreateRequest : IncentiveSenderClaimRequest = {
    code
};
let result = await hiroClient.incentivesSenderClaim(session, incentiveSenderCreateRequest);

Deleting sender incentives #

You can delete a sender incentive for the user.

1
2
3
4
let incentiveSenderDeleteRequest : IncentiveSenderDeleteRequest = {
  code
};
let result = await hiroClient.incentivesSenderDelete(session, incentiveSenderDeleteRequest);

Recipient incentives #

Getting recipient incentives #

You can get a recipient incentive for the user.

1
2
3
4
let incentiveSenderCreateRequest : IncentivesRecipientGetRequest = {
    code
};
let result = await hiroClient.incentivesRecipientGet(session, incentiveSenderCreateRequest);

Claiming #

You can claim a reciever incentive for the user.

1
2
3
4
5
let incentivesRecipientClaimRequest : IncentiveRecipientClaimRequest = {
    code
};
let result = await hiroClient.incentivesRecipientClaim(session, incentivesRecipientClaimRequest);
console.log(result.reward);