Rewards and wallet

Daily, weekly or one-time rewards decided by the server and credited to a per-player wallet.

On this page

Define rewards#

Create rewards on the Rewards page:

FieldMeaning
Reward keyIdentifier used in code, e.g. daily_coins.
Amount and currencyHow much is credited, and to which currency (e.g. coins).
Cooldowndaily, weekly or once.
ActiveInactive rewards are hidden and cannot be claimed.

List rewards#

With a signed-in player each reward includes claimable and next_claim_at:

C#
var available = await Majacloud.Rewards.ListAsync();
foreach (var reward in available.Value)
    Debug.Log(reward.RewardKey + " claimable: " + reward.Claimable + " next: " + reward.NextClaimAt);

Claim#

The server decides whether the claim is allowed and credits the wallet atomically. A second claim in the same period fails with conflict and details.next_claim_at.

C#
var claim = await Majacloud.Rewards.ClaimAsync("daily_coins");
if (claim.Ok)
{
    Debug.Log($"+{claim.Value.Amount} {claim.Value.Currency}, balance {claim.Value.Balance}");
}
else if (claim.Error.Code == MajacloudErrorCode.Conflict)
{
    DateTime? next = claim.Error.GetDetailDateTime("next_claim_at"); // UTC
}

Wallet#

Read the player's balances per currency:

C#
var wallet = await Majacloud.Rewards.GetWalletAsync();
Debug.Log("Coins: " + wallet.Value.Coins + ", gems: " + wallet.Value.Get("gems"));

When rewards reset#

Daily rewards can be claimed again from 00:00 UTC, weekly rewards from Monday 00:00 UTC, and one-time rewards never again.

Search page titles, headings and text.

↑↓ to navigate ↵ to open Esc to close