Claiming Rewards from Contract
This page details the process of claiming rewards from contract only if needed.
Rewards are published on a weekly basis. They are distributed as signed payloads that must be submitted to our rewards contract to be claimed. This document will outline retrieving and submitting that payload.
When the payloads are signed they are uploaded to IPFS. This process gives us a "folder hash" for those payloads where they can be downloaded. We track those hashes in our Rewards Hash contract. The values in this payload are your cumulative total reward across the life of the protocol, so you always want to be sure to grab the latest one.
To find the latest hash, first grab the latest cycle index that the Rewards Hash contract knows about:

Then, submit that index to the
cycleHashes(uint256)
function. This should give you two strings
back but the one you care about is latestClaimable
.
Now that you have the hash, you can download the payload. Payloads are published in a predictable pattern so we'll just need to construct the URL. URL structure:
https://cloudflare-ipfs.com/ipfs/{latestClaimableHash}/{walletAddress}.json
Notes about each segment:
- Domain - This is not necessarily a recommendation to use CloudFlare's IPFS gateway, but it should be a reliable path. That said, since CloudFlare does not pin files, the loading time to retrieve the payload from here can be very large and require multiple tries. If you have an IPFS instance you can pin files on, it may be worth pining the hash first and downloading from there. Tokemak currently pins the files on our gateway at
[ipfs.tokemaklabs.xyz](<http://ipfs.tokemaklabs.xyz>)
, but that is subject to change. - {latestClaimableHash} - Should be replaced with the value queried from the
cycleHashes()
function. This value is case sensitive. - {walletAddress} - This should be the wallet that has staked either reactor assets or TOKE. This value should be all lowercase.
Final example URL:

Notes:
- The signature section will only be populated with values when that cycle is a claimable one. While we are on daily cycles, claimable payloads are only published once a week. This may change in the future
All of the information needed to call the
claim()
function on the Rewards contract is contained in the JSON pulled from IPFS. The claim function takes 4 parameters:- recipient - ipfsJson.payload
- v - ipfsJson.signature.v
- r - ipfsJson.signature.r
- s - ipfsJson.signature.s
If you want to know how much your current payload entitles you to, you can call
getClaimableAmount(tuple)
on the Rewards contract, passing it the ipfsJson.payload.A couple notes about claiming:
- Submitting the same payload twice will result in a revert on the second submission. It's a good idea to check your claimable amount before calling
- The claim() must be performed by the recipient of the reward. That is,
msg.sender
==staker
==ipfsJson.payload.wallet
- If it is a contract that will be staking, make sure to have a function that can perform the claim.
- Rewards:
0x79dD22579112d8a5F7347c5ED7E609e60da713C5
- Rewards Hash:
0x5ec3EC6A8aC774c7d53665ebc5DDf89145d02fB6