After a successful referral, Spindl will automatically credit wallets with rewards in an on-chain smart contract. The smart contract provides methods to directly to check the status of rewards for a particular wallet and facilitate a withdrawal transaction on-chain.
The Smart Contract address and Campaign ID to use in the methods below are specific to your running campaigns, and available within the Spindl Dashboard.
Campaign ID: This is the campaign id associated with the campaign you are running. If you are running multiple campaigns, you can check for rewards for each one individually.
(Note: The status will almost always be NONE or ACTIVE. The PAUSED status is a special flag that only you can trigger, for suspicious referrers)
Examples
Wallet Has Pending Rewards
Recipient 0x0000000000000000000000000000000000000021 has been credited some rewards. The return value is:
[1,1200000000,0]
The status is ACTIVE (1), which means the recipient is eligible to withdraw funds. They have earned 1200000000 wei, and withdrawn 0 wei, so they are eligible to withdraw 1200000000 - 0 = 1200000000
Wallet Has No Rewards
Recipient 0x0000000000000000000000000000000000000000 has never been rewarded. The return value is:
[0, 0, 0]
The status is NONE (0), which means the recipient address has never been credited. The earned and withdrawn values are 0 (since there is nothing owed to them).
Wallet Has Withdrawn All Rewards
Recipient 0xD4ed4369ae2c27924ee59bd49459C642C20395B2 has withdrawn all rewards. In this case, the return value is:
[0,1200000000,1200000000]
The status is ACTIVE (1), which means the recipient is eligible to withdraw funds. They have earned 1200000000 wei, and withdrawn 1200000000 wei, so there are no remaining funds left to withdraw.
Withdraw Rewards
Transaction Call
withdrawRecipientEarnings(uint32 _campaignId, uint256 _amount, address _to) public virtual
Campaign ID: This is the campaign id associated with the campaign you are running.
Amount: The amount to withdraw. This is usually the total withdrawal amount, but can be a smaller amount as well. This will be in the currency for the campaign.
To: The recipient of the funds. This is usually the address of the wallet calling this function, but you can set it to another address specific by the user
Returns
This is a transaction, so there will be no return type. The transaction should be successful if the caller is owed at least that amount in the campaign.
Campaign Details
RPC Call
campaigns(_campaignId) public view returns (totalBudget uint256, status uint8, paymentType address, totalEarned uint256)