Fuul
  • INTRO
    • ⚑What is Fuul?
    • πŸ’ͺWhy use Fuul?
    • πŸ€”Use Cases
    • βš™οΈIntegration
    • πŸ”—Main Links
  • HOW IT WORKS
    • πŸ’ΈTypes of Rewards
    • βœ…Conversion Events
      • 1️⃣CLAMM LPs (e.g. Uniswap V3)
      • 2️⃣Constant LPs (e.g., Uniswap V2)
      • 3️⃣Lending & Borrowing
      • 4️⃣Staking
      • 5️⃣Token Holders
      • 6️⃣Custom Onchain Events
      • 7️⃣Custom Offchain Events
  • πŸ€‘Incentive Payouts
    • πŸ—ΏFixed Rewards
    • 🌊Variable Rewards
    • πŸ’°Pool Distribution
  • πŸ§‘β€πŸ€β€πŸ§‘Referrals
  • ♾️Attribution Methods
  • πŸ’²Budgets
  • ⚑Fuul Incentives Manager
  • πŸŽ–οΈLeaderboards
  • πŸ’»Incentives Hub
    • πŸ‘¨β€πŸ’»White-Label Implementation
    • πŸ‘No-Code
  • FOR DEVS
    • ⭐Getting started with Fuul Web SDK
    • βš™οΈSending Custom Events through the API
    • πŸ“„Tracking referrals in your app
    • πŸ‘¨β€πŸ’»API Key Management
    • πŸ› οΈBuilding your incentives hub in your app (white-label)
      • ℹ️Getting all incentives information
      • πŸ”—Creating affiliate links or codes
      • πŸ’―Getting Leaderboard Data
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ™‹Getting Individual Rewards
        • πŸͺ™Tokens
        • 🌟Points
      • πŸ€™Claiming Onchain Rewards
    • πŸ”§Building widgets
    • πŸ“’Managing Audiences and Segments
      • πŸ‘€Getting User Audiences using Fuul SDK
      • πŸ‘₯Updating Audience Segments using Fuul API
    • ✈️Migration from older SDK versions
    • πŸ†˜Troubleshooting
  • PROTOCOL
    • ⛓️Smart Contracts
    • 🧡Subgraphs
  • Guides
    • ✏️Getting Started
      • Creating Your First Incentive Program
      • How to Add a Budget in Fuul
  • 🏁Creating Triggers & Conversions
    • Understanding Triggers Types
    • Creating an Event with CSV file
  • 🎨Program Incentive Page
    • Building no code landing pages
  • πŸ“ŠAnalytics
    • Understanding Sybil Detection
Powered by GitBook
On this page
  • 1. Getting claimable amount
  • 2. Building claim function argument
  • 3. Making the transaction
  1. FOR DEVS
  2. Building your incentives hub in your app (white-label)

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:

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

2. Building claim function argument

The claim function argument is an array of claimCheckstruct elements.

// Solidity interface

struct ClaimCheck {
    address projectAddress;
    address currency;
    uint256 amount;
    uint256[] tokenIds; // used for NFTs
    uint256[] amounts; // used for NFTs
}

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

const claimChecks = [
  {
    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.

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:

// Build claimChecks

const claimChecks = [
  {
    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 contract

const address = "0xC38E3A10B5818601b29c83F195E8b5854AAE45aF";

const abi = [
  "function claim(ClaimCheck[] calldata claimChecks) external"
];

const [user1] = await ethers.getSigners();

const fuulManager = new ethers.Contract(address, abi, user1);

// Make the transaction

const tx = await fuulManager.claim(claimChecks);
PreviousPointsNextBuilding widgets

Last updated 29 days ago

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

πŸ› οΈ
πŸ€™
Subgraph