Optional
layer2Signer: SignerPrivate
rewardPrivate
rewardPrivate
layer2Private
Optional
layer2The 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").
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.registerRewardProgram(prepaidCard, admin)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThe 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.
let rewardManagerAPI = await getSDK(RewardManager, web3);
await rewardManagerAPI.registerRewardee(prepaidCard , rewardProgramId)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThe registerRewardeeGasEstimate
returns a gas estimate for the prepaid card send transaction when registering a rewardee.
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.registerRewardeeGasEstimate(prepaidCard, rewardProgramId)
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.
let rewardManagerAPI = await getSDK(RewardManager, web3);
await rewardManagerAPI.updateRewardProgramAdmin(prepaidCard , rewardProgramId, newAdmin)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThe 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.
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.addRewardRule(prepaidCard, rewardProgramId, blob)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThe 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
.
let rewardManagerAPI = await getSDK(RewardManager, web3);
await rewardManagerAPI.withdraw(rewardSafe , to, token, amount)
Optional
amount: stringOptional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsThe withdrawGasEstimate
returns a gas estimate for withdrawing a reward.
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.withdrawGasEstimate(rewardSafeAddress, to, tokenAddress, amount)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsPrivate
getPrivate
getPrivate
getPrivate
getPrivate
getPrivate
getPrivate
executePrivate
executePrivate
executePrivate
executePrivate
executeThe getRewardProgramsInfo
is a catch-all query that enlist all information about reward programs that have been registered.
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.getRewardProgramsInfo()
Private
getThe 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.
let rewardManagerAPI = await getSDK('RewardManager', web3);
await rewardManagerAPI.getRuleJson(rewardProgramId)
Private
getPrivate
getPrivate
rewardeeThe 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.
let rewardManagerAPI = await getSDK(RewardManager, web3);
await rewardManagerAPI.lockRewardProgram(prepaidCard , rewardProgramId)
Optional
txnOptions: TransactionOptionsOptional
contractOptions: ContractOptionsGenerated using TypeDoc
The
RewardManager
API is used to interact to manage reward program. Those intending to offer or receive rewards have to register using this sdk.