This article shows how to claim rewards from your FuulProject contract.
Building claim function argument
The claim function argument is an array of claimCheckstruct elements.
// Solidity interfacestructClaimCheck {address projectAddress;address currency;uint256 amount;uint256[] tokenIds; // used for NFTsuint256[] amounts; // used for NFTs}
For example, to claim 10 ETH from a deployed FuulContract on Base, this will have to. be called:
constclaimChecks= [ { projectAddress:'FuulProject contract address',// On the Handy Links section on the app currency:'0x0000000000000000000000000000000000000000', amount:ethers.utils.formatEther(10), tokenIds: [],// Empty because it's an ERC20 amounts: [],// Empty because it's an ERC20 },];
Your claimChecks array can contain multiple elements, belonging to different projects and currencies.
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:
// Build claimChecksconstclaimChecks= [ { projectAddress:'FuulProject contract address',// On the Handy Links section on the app currency:'0x0000000000000000000000000000000000000000', amount:ethers.utils.formatEther(10), tokenIds: [],// Empty because it's an ERC20 amounts: [],// Empty because it's an ERC20 },];// Get FuulManager contractconstaddress="0xC38E3A10B5818601b29c83F195E8b5854AAE45aF";constabi= ["function claim(ClaimCheck[] calldata claimChecks) external"];const [user1] =awaitethers.getSigners();constfuulManager=newethers.Contract(address, abi, user1);// Make the transactionconsttx=awaitfuulManager.claim(claimChecks);