πŸ€™Claiming Onchain Rewards

This article shows how to claim rewards from your FuulProject contract.

1. Getting claimable amount

The more reliable and real time claimable rewards information will be on the subgraphs

To get the total unclaimed rewards for a specific user and Fuul project, use the availableToClaim parameter returned in the following query.

userBalances(
  where: { 
    owner_contains_nocase: "0x12345", 
    project_: {
      deployedAddress:"0x12345"
    }}
) {
  availableToClaim
  claimed
  currency
  project {
    id
    deployedAddress
  }
}

You can also filter out by currency like this:

Please visit the Subgraph section of the documentation to get the endpoints and know more about the schema

2. Building claim function argument

The claim function argument is an array of claimCheckstruct elements.

For example, to claim 10 ETH from a deployed FuulContract on Base, this will have to. be called:

Your claimChecks array can contain multiple elements, belonging to different projects and currencies.

3. Making the transaction

To perform a claim, the transaction must always be directed to the FuulManager contract.

The address is always 0xC38E3A10B5818601b29c83F195E8b5854AAE45aF on the networks we are deployed (Polygon, Arbitrum One, Optimism, Base).

So, the complete code, using ethers.js, would be the following:

Last updated