πŸ€™Claiming Onchain Rewards on Fuul

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

1. Getting claim checks

Claim checks are vouchers that allow users to claim their rewards.

Using the SDK you can get the claimable claim checks for a user with the getClaimableChecks method.

import { Fuul, UserIdentifierType } from '@fuul/sdk';

const claimableChecks = await Fuul.getClaimableChecks({
  user_identifier: '0xe06099DbbF626892397f9A74C7f42F16748292Db',
  user_identifier_type: UserIdentifierType.EvmAddress
});

You can also get the unclaimed claim checks using the claim check endpointarrow-up-right on the Fuul API.

circle-info

The getClaimableChecks method was introduced in version 7.8.0. If you're using an earlier version, please upgrade to access this functionality

2. Building claim function argument

The claim function argument is an array of claimCheckstruct elements. You will receive all the parameters from the endpoint.

// Solidity interface

struct ClaimCheck {
    address projectAddress;
    address to;
    address currency;
    IFuulProject.TokenType currencyType;
    uint256 amount;
    ClaimReason reason;
    uint256 tokenId;
    uint256 deadline;
    bytes32 proof;
    bytes[] signatures;
}

enum ClaimReason {
    AFFILIATE_PAYOUT,
    END_USER_PAYOUT
}

enum TokenType {
    NATIVE,
    ERC20,
    ERC721,
    ERC1155
}

The 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.

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

Last updated