The RewardManager API is used to interact to manage reward program. Those intending to offer or receive rewards have to register using this sdk.

Hierarchy

  • RewardManagerClass

Constructors

Properties

rewardManager: undefined | Contract
rewardSafeDelegate: undefined | Contract
layer2Web3: default
layer2Signer?: Signer

Methods

  • The RegisterRewardProgram API is used to register a reward program using a prepaid card. The call can specify an EOA admin account -- it defaults to the owner of the prepaid card itself. The reward program admin will then be able to manage the reward program using other api functions likelockRewardProgram, addRewardRule, updateRewardProgramAdmin. A fee of 500 spend is charged when registering a reward program. Currently, tally only gives rewards to a single reward program (sokol: "0x4767D0D74356433d54880Fcd7f083751d64388aF").

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.registerRewardProgram(prepaidCard, admin)

    Parameters

    • txnHash: string

    Returns Promise<{
        rewardProgramId: string;
        txReceipt: SuccessfulTransactionReceipt;
    }>

  • Parameters

    • prepaidCardAddress: string
    • admin: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<{
        rewardProgramId: string;
        txReceipt: SuccessfulTransactionReceipt;
    }>

  • The RegisterRewardee API is used to register a rewardee for a reward program using a prepaid card. The purpose of registering is not to "be considered to receive rewards" rather to "be able to claim rewards that have been given". By registering, the owner of the prepaid card is given ownership of a reward safe that will be used to retrieve rewards from the reward pool. A rewardee/eoa is eligible to only have one reward safe for each reward program; any attempts to re-register will result in a revert error. There is no fee in registering a reward safe, the prepaid card will pay the gas fees to execute the transaction.

    Example

    let rewardManagerAPI = await getSDK(RewardManager, web3);
    await rewardManagerAPI.registerRewardee(prepaidCard , rewardProgramId)

    Parameters

    • txnHash: string

    Returns Promise<{
        rewardSafe: string;
        txReceipt: SuccessfulTransactionReceipt;
    }>

  • Parameters

    • prepaidCardAddress: string
    • rewardProgramId: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<{
        rewardSafe: string;
        txReceipt: SuccessfulTransactionReceipt;
    }>

  • The registerRewardeeGasEstimate returns a gas estimate for the prepaid card send transaction when registering a rewardee.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.registerRewardeeGasEstimate(prepaidCard, rewardProgramId)

    Parameters

    • prepaidCardAddress: string
    • rewardProgramId: string

    Returns Promise<GasEstimate>

  • The UpdateRewardProgramAdmin API is used to update the reward program admin of a reward program using a prepaid card. The prepaid card will pay for the gas fees to execute the transaction. Only the reward program admin can call this function.

    Example

    let rewardManagerAPI = await getSDK(RewardManager, web3);
    await rewardManagerAPI.updateRewardProgramAdmin(prepaidCard , rewardProgramId, newAdmin)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • prepaidCardAddress: string
    • rewardProgramId: string
    • newAdmin: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The AddRewardRule API is used to add a reward rule for a reward program using a prepaid card. The reward rule is specified as a blob of bytes which tally will parse to understand how to compute rewards for the reward program. Each reward program will only ever have a single reward rule -- a single blob. The prepaid card will pay for the gas fees to execute the transaction. Only the reward program admin can call this function.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.addRewardRule(prepaidCard, rewardProgramId, blob)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • prepaidCardAddress: string
    • rewardProgramId: string
    • blob: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The Withdraw API is used to withdraw ERC677 tokens earned in a reward safe to any other destination address -- it is simlar to a transfer function. The gas fees in the withdrawal will be paid out of the balance of the safe -- similar to Safe.sendTokens.

    amount is an optional param. When amount is included, one must ensure that there is sufficient balance leftover to pay for gas of the transaction, .i.e safeBalance < amount - estimatedGasCost. The scenario which this occurs is when the user specifies amount that is close to safeBalance. The client should make this check. When amount is excluded, the whole balance of the safe is withdrawn which is automatically taxed for gas, .i.e the gas deduction occurs internally within the sdk function. It is recommended when the client expects to withdraw the "max" balance that it doesn't specify amount.

    Example

    let rewardManagerAPI = await getSDK(RewardManager, web3);
    await rewardManagerAPI.withdraw(rewardSafe , to, token, amount)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • safeAddress: string
    • to: string
    • tokenAddress: string
    • Optional amount: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

  • The withdrawGasEstimate returns a gas estimate for withdrawing a reward.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.withdrawGasEstimate(rewardSafeAddress, to, tokenAddress, amount)

    Parameters

    • rewardSafeAddress: string
    • to: string
    • tokenAddress: string
    • amount: string

    Returns Promise<GasEstimate>

  • The getRuleJson returns the rule structure of a particular reward program. The rule json will include on-chaain "explanation" block which is the lookup map for explanation of each reward. A client can use this map alongside explanationId and explanationData returned by the reward api.

    Example

    let rewardManagerAPI = await getSDK('RewardManager', web3);
    await rewardManagerAPI.getRuleJson(rewardProgramId)

    Parameters

    • rewardProgramId: string

    Returns Promise<RuleJson>

Cardpay

  • The LockRewardProgram API is used to to lock a reward program using a prepaid card. When a reward program is locked, tally will choose to stop calculating rewards for reward reward program from that point forward. This doesn't stop the unclaimed rewards from being claimed, i.e. unused proofs. The prepaid card will pay for the gas fees to execute the transaction. Only the reward program admin can call this function. Executing this function again will unlock the reward program, which will allow tally to restart calculating rewards.

    Example

    let rewardManagerAPI = await getSDK(RewardManager, web3);
    await rewardManagerAPI.lockRewardProgram(prepaidCard , rewardProgramId)

    Parameters

    • txnHash: string

    Returns Promise<SuccessfulTransactionReceipt>

  • Parameters

    • prepaidCardAddress: string
    • rewardProgramId: string
    • Optional txnOptions: TransactionOptions
    • Optional contractOptions: ContractOptions

    Returns Promise<SuccessfulTransactionReceipt>

Generated using TypeDoc