Gift Cards Maintenance

Getting balance and redemption

Getting Gift Card Actual Balance

To retrieve a gift-card balance use the following method

async giftCardBalance(giftCard: GiftCardProperties): Promise<bigint>
See Also

Parameters

giftCard - gift card object which contained all information needed to operate

You can get gift card object from the source URL by invoking method gitfCardFromCode

Returns

Promise returns gift card balance in pool dimension

Example

const code = 'QvHXyAF2ykRCSTCwiLJbGGJVjJX7M8Xp5vfNNLaiEvwV8BQfYBeR6ivtY7svMpPyCsL6huTHpB';
try {
    const gk = await zkClient.giftCardFromCode(code);
    const balance = await zkClient.giftCardBalance(gk);
    console.log(`Actual gift card balance ${balance} BOB`)
} catch (err) {
    console.log(`An error was occured while parsing the gift-card: ${err.message}`);
}
// output: Actual gift card balance 100000000000 BOB

Gift Card Redemption

You can send money from the gift-card to the your account with the following method

async redeemGiftCard(
    giftCard: GiftCardProperties,
    preferredProvingMode?: ProverMode
): Promise<string>
See Also

Parameters

giftCard - gift card object which contained all information needed to operate

You can get gift card object from the source URL by invoking method gitfCardFromCode

preferredProvingMode - you can optionally set other ProverMode for redemption process. E.g. you can use delegated prover to redemption process speed up (if configured) while your account using local prover only

Returns

Promise returns job ID associated with redemption transaction

Example

const code = 'QvHXyAF2ykRCSTCwiLJbGGJVjJX7M8Xp5vfNNLaiEvwV8BQfYBeR6ivtY7svMpPyCsL6huTHpB';
try {
    const gk = await zkClient.giftCardFromCode(code);
    const jobId = await zkClient.giftCardBalance(gk);
    console.log(`The gift card was redeemed (job #${jobId})`)
} catch (err) {
    console.log(`An error was occured while redeeming the gift-card: ${err.message}`);
}
// output: The gift card was redeemed (job #843)

Last updated