The Flow
- Fetch the merkle proof for the user and campaign.
- Gate the button on
claimable > 0nand the correct wallet chain. - Simulate to catch reverts before asking for a signature.
- Submit and update your state from the receipt.
Fetch the Proof
publishedAt as unix seconds. The SDK parses both. Skip the SDK and you own that conversion. See Data Conventions.
Gate the Button
campaign.id.chainId), which is not necessarily where the position lives.
Simulate First
simulate runs an eth_call and asks for no signature, so it is safe to call on render or on hover. It costs one RPC round trip and turns an on-chain revert into a message you can act on. The revert reasons are listed in Contracts.
Submit With viem
tbi.claim returns as soon as the transaction is broadcast; it does not wait for confirmation. Omit proof and the SDK fetches it for you, but fetching first lets you check claimable before prompting a wallet.
After the Claim
Mark the campaign claimed client-side once you have a transaction receipt, and let the next natural refresh pick up the settled state. If you need the authoritative answer immediately, read it from the chain. See Reading claim state on-chain.Claim Several Campaigns at Once
A user with positions in several campaigns on the same reward chain can claim them in one transaction through Multicall3.chainId to let the SDK find every campaign with claimable rewards on that chain, or pass explicit ids when you want control over the set:
claimAll drops zero-claimable proofs and rejects batches spanning multiple reward chains. It is all or nothing: one failing subcall reverts the whole transaction. If you would rather have partial success, loop tbi.claim() per campaign.
Non-viem Stacks
encodeClaim returns plain calldata and touches no wallet.
encodeClaimAll({ proofs }) for the batch equivalent. You still install viem for its types, but you never construct a wallet client.
Sponsor Gas
The claim function pays itsuser argument, not msg.sender. That means you can submit claims through your own relayer and cover the gas without ever holding user rewards. Nothing in the SDK or the contract blocks it. Build the calldata with encodeClaim and send it from your own signer.
Gas Expectations
A claim with a five-node merkle proof measured 132,443 gas. Proof length grows with the number of participants, so treat that as a reference point rather than a fixed cost.Keep Exploring
How Claiming Works
Merkle roots, cumulative amounts, and cliff state.
Contracts
The claim signature and every revert selector.
Errors
Which errors to catch and which retry themselves.