Live#…
Reading the chain…
Network now · GullyChain Testnet
Block
—
Txs · 30 blocks
—
Gas, gwei
—
Launches
—

Referral distributor

On this page

Live

Live on Gully Chain Testnet since 2026-11-11 (block 6703, source verified). Claims open once the Gully Safe funds it and the first epoch root is posted; until then earnings are paid manually from the Gully Safe.

GullyReferralDistributor is the contract that pays referral and share earnings on Gully Chain. A sharer earns 20% of the platform cut for 90 days on what the people they brought in spend; the social service keeps that ledger off chain and, once per epoch, commits everyone's total to one Merkle root on chain. Anyone then claims what they are owed with one proof, whenever they like.

Contract GullyReferralDistributor v1.0.0, source verified on Sourcify
Address 0x54600a745227da4a912b49BF7EB03763Ede312Ad
Network Gully Chain Testnet, chain id 485590
Token USDC.e 0x65Ba03c6FA90Ed549f465D4c8f2e784D6eEB7E76 (opens in a new tab), 6 decimals
Owner and treasury Gully Safe 0xC5526E28B5cDe3C5962A224896804a499d5bb240 (opens in a new tab)
Guardian Gully Labs 0x92cFC047652d6aEf7eb0fa2744B912d9f627fA41 (opens in a new tab) (cancel a pending root, pause new roots)
Root delay 24 hours

#Leaves are cumulative

The tree is an OpenZeppelin StandardMerkleTree with leaf types ['address', 'uint256'] (leaves sorted, sorted-pair hashing):

Solidity
leaf = keccak256(bytes.concat(keccak256(abi.encode(account, cumulativeAmount))))

cumulativeAmount is the account's all-time allocation in USDC.e base units, not one epoch's. Every new root carries every account's running total, and a claim pays cumulativeAmount - claimed[account]. So an account that skips weeks collects everything with the latest proof, and nothing can be claimed twice. leaf(address, uint256) on the contract returns the same hash.

Test vector (also pinned in the contract tests): accounts 0x…01, 0x…02, 0x…03 with 1000000, 2500000 and 42 give the root 0xa24db175a4be6ed32a165094761cc6e93643724f06cdf37433915bb8766fb785 (total 3500042).

#Claiming

Function Who What
claim(account, cumulativeAmount, proof) anyone pays account (never the caller) what is left; reverts NothingToClaim, InvalidProof, or Closed after a sweep
claimMany(accounts[], cumulativeAmounts[], proofs[][]) anyone (keeper) batch; accounts with nothing left are skipped, a bad proof reverts the batch
claimable(account, cumulativeAmount, proof) view what claim would pay now; 0 on a bad proof, never reverts

Claims never pause. kre8.fun shows the button; a keeper may also batch claims for everyone, since the money always goes to the account itself.

#Proof API

Code
GET https://social.kre8.fun/v1/earnings/referrals/proof?address=0x…
JSON
{
  "address": "0x…", "chainId": 485590, "distributor": "0x54600a745227da4a912b49BF7EB03763Ede312Ad",
  "token": "0x65Ba03c6FA90Ed549f465D4c8f2e784D6eEB7E76", "decimals": 6,
  "entries": [
    { "epoch": 12, "root": "0x…", "cumulativeAmount": "1250000", "proof": ["0x…"], "activatesAt": 1793900000, "status": "active" }
  ]
}

status is active (claim with it now) or pending (claimable from activatesAt). 404 means nothing is allocated to that address yet.

#Roots and the delay

  • The social ledger job posts one root per epoch (weekly) with postRoot(epoch, root, total, uri, dataHash) from its poster key. total is the sum of all leaves; uri and dataHash point at the published tree.
  • A root is accepted only when it is fully funded: total - totalClaimed <= USDC.e balance. The contract can never owe more than it holds.
  • Epochs increase, totals never decrease, and only one root is pending at a time. A root becomes claimable 24 hours after it is posted (activatePending() by anyone, or automatically on the next claim).
  • During those 24 hours the Safe or the guardian can cancelPending(reason) a wrong root. The epoch can then be posted again.

#Funding

The Gully Safe funds the contract in one Safe batch: USDC.e.approve(distributor, amount) + fund(amount). Plain USDC.e transfers count too: everything is balance based. owed() is what posted roots still need, surplus() is the rest.

#What the admin can and cannot do

  • No admin path to user funds. withdrawSurplus(amount) moves only surplus() and only to the treasury (the Safe, immutable). rescueToken can never touch USDC.e and also pays only the treasury.
  • pause() (Safe or guardian) blocks new roots only; unpause() is Safe-only.
  • The Safe sets the poster, the guardian (0x0 = none) and the root delay (1 hour to 7 days). Ownership moves in two steps; it cannot be renounced.

#Nothing stays stuck

If no root is posted for 365 days, the Safe may announceSweep(). That starts a 60-day notice: claims keep working and any new root cancels it. After the notice anyone can call sweep(): the whole USDC.e balance goes to the Safe, and the contract closes (claims and roots revert Closed; anything sent later can be swept to the Safe too).

#Monitoring

Gully's monitoring reads the balance, owed(), surplus(), the pending root's age and lastRootAt every 10 minutes and alerts when the balance is below what is owed (never expected), when no root came for 14 days while earnings are owed, when a sweep is announced, when it is paused or has no poster.

#Events

RootPosted(epoch, root, total, activatesAt, uri, dataHash), RootActivated, RootCancelled, Claimed(account, amount, cumulativeAmount, caller), Funded, SurplusWithdrawn, TokenRescued, PosterUpdated, GuardianUpdated, RootDelayUpdated, SweepAnnounced(sweepAt, balance), SweepCancelled, Swept(amount), plus OpenZeppelin's Paused / Unpaused and ownership events.