View claim.ts on GitHub
Runnable script in the SDK repo.
1. Set up the config
Build a wagmi config with a private key account. (For browser/dApp usage, swap the private key for a connector likeinjected() from @wagmi/core.)
2. Fetch your periods
getPeriods resolves your leaves and proofs entirely client-side — it reads the YieldDistributor over your wagmi Config and pulls per-period merkle proofs from the public artifact endpoint. No API key needed.
Periods still in the operator’s replace window (~24h post-publish) and expired periods are filtered out automatically; everything returned with status: "unclaimed" is safe to submit immediately.
{ chainId, distributor, periodId, status, root, index, account, amount, proof } — everything the on-chain claim() needs. amount is raw 6-decimal C0 (use viem’s formatUnits for display).
The default artifact host is
https://api.caminotreasury.com. Override per-call with apiUrl to point at a self-hosted mirror or, once artifacts are mirrored to a static CDN, a fully decentralized source:3. Submit one claim per period
There’s no on-chain batch entrypoint, so a loop is the right shape.claim() returns the tx hash immediately; waitForTransactionReceipt blocks until the claim is mined.
msg.sender is unconstrained on the contract — the C0 is transferred to the account embedded in the leaf, not to whoever signs the transaction. This is what lets a relayer or sponsor pay gas while the holder still receives the funds.
What’s next
- Yield Distributor — full read/write/watch surface for the contract
- How to deposit USDC into C0 — mint C0 to start qualifying for future periods