Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

gnomic_airdrop source realm

Claim-based airdrop realm with Merkle proofs.

Overview

Claim-based airdrop realm with Merkle proofs.

Why Merkle rather than an on-chain list:

  • the beneficiary list can run to tens of thousands of rows; writing it on-chain costs gas and storage deposit in proportion;
  • here only 32 bytes go on-chain (the root), plus one record per ACTUAL claim. Whoever never claims costs nothing.

Operating flow:

  1. deploy this realm;
  2. fund it by transferring GRC20 tokens to it (its address is returned by RealmAddress());
  3. the admin publishes root, leaf count and deadline block with SetCampaign;
  4. each beneficiary calls Claim with their own proof;
  5. after the deadline the admin recovers the residue with Sweep.

The Merkle leaf is the string "<address>|<amount in base units>", UTF-8 encoded. The tree is Tendermint's "simple tree" (gno's crypto/merkle): leaf = SHA256(0x00||data), node = SHA256(0x01||left||right), split at the largest power of two below n. The generator in tools/merkle produces compatible proofs.

Constants 1

Variables 1

var Ownable

1var Ownable *ownable.Ownable
source

Ownable holds the administrative authority over the campaign.

Functions 44

func Balance

Action
1func Balance() int64
source

Balance is the token balance the realm currently holds.

func BurnedOf

Action
1func BurnedOf(addr address) int64
source

BurnedOf returns how much of addr's grant was destroyed.

func Claim

crossing Action
1func Claim(cur realm, amount int64, index int, auntsHex string)
source

Claim pays amount tokens to the caller, if the Merkle proof (index, auntsHex) shows that "<caller>|<amount>" is a leaf of the published tree.

auntsHex is the hex concatenation of the sibling hashes, 32 bytes each, just as produced by tools/merkle.

func ClaimInstant

crossing Action
1func ClaimInstant(cur realm, amount int64, index int, auntsHex string)
source

ClaimInstant is the first of the two alternatives to Claim: the instant share (instantBps, 30%) is paid at once and the rest (70%) is given up the same way a forfeit is — half burned, half to the ecosystem fund — whenever it is chosen, even after the whole grant would have vested. The share is larger than Claim's immediate 10% on purpose: it makes the shortcut a real choice rather than a punishment. It cannot be undone and suits someone who prefers a certain fraction today to the whole a year from now. The residue is destroyed, to every holder's benefit.

Only the person concerned can choose it: there is no "on behalf of" form.

func ClaimWindowEnd

Action
1func ClaimWindowEnd() int64
source

ClaimWindowEnd is the moment (unix) claims stop being accepted for the current campaign; SettleUnclaimed becomes callable from then on.

func Forfeit

crossing Action
1func Forfeit(cur realm, amount int64, index int, auntsHex string)
source

Forfeit is the second alternative to Claim: the beneficiary gives the grant up without taking anything. Half is burned, half goes to the ecosystem fund — the same split SettleUnclaimed applies to whoever never acted at all.

The proof is still required and the grant is still recorded: without that, the same address could forfeit and then claim. The record makes it final. Only the person concerned can choose it: there is no "on behalf of" form.

func FundOf

Action
1func FundOf(addr address) int64
source

FundOf returns how much of addr's grant went to the ecosystem fund.

func GrantEpoch

Action
1func GrantEpoch(addr address) int
source

GrantEpoch returns the campaign in which addr obtained its grant.

func HasClaimed

Action
1func HasClaimed(addr address) bool
source

HasClaimed reports whether addr has already claimed in the current campaign.

func HasGrant

Action
1func HasGrant(addr address) bool
source

HasGrant reports whether addr holds a grant, from this campaign or an earlier one.

func ImmediateBps

Action
1func ImmediateBps() int
source

ImmediateBps is the share unlocked at once, in hundredths of a percent.

func InstantBps

Action
1func InstantBps() int
source

InstantBps is the share ClaimInstant pays at once, in hundredths of a percent.

func IsOpen

Action
1func IsOpen() bool
source

IsOpen reports whether claims are currently accepted.

func IsSealed

Action
1func IsSealed() bool
source

IsSealed reports whether the campaign has been sealed: if true, no new campaign can ever be opened.

func Leaf

Action
1func Leaf(addr address, amount int64) string
source

Leaf returns the canonical Merkle-leaf encoding for the (address, amount) pair. It must match byte for byte the one used by the off-chain generator.

func NextWithdrawAt

Action
1func NextWithdrawAt(addr address) int64
source

NextWithdrawAt returns the unix time from which addr may withdraw again (0 when there is no grant, the grant is closed, or no cooldown is running).

func Outstanding

Action
1func Outstanding() int64
source

Outstanding is the total granted and not yet withdrawn: the part of the realm's balance that Sweep cannot touch.

func Root

Action
1func Root() string
source

Root returns the current Merkle root in hex.

func SealCampaign

crossing Action
1func SealCampaign(cur realm)
source

SealCampaign closes off the possibility of opening new campaigns forever. Irreversible: no code path sets sealed back to false. Call it once the published root is the final one.

Until then the owner can fix a mistake by republishing the root; afterwards the airdrop is provably one-off and anyone can check with IsSealed().

func SetCampaign

crossing Action
1func SetCampaign(cur realm, rootHex string, total int, end int64)
source

SetCampaign publishes a new campaign: rootHex is the Merkle root in hex (32 bytes), total the number of leaves in the tree, end the deadline block (0 = no deadline).

Publishing a new campaign resets the claim history: whoever appears on both lists can claim again. That is deliberate — it allows recurring airdrops on the same realm without a redeploy.

func SettleUnclaimed

crossing Action
1func SettleUnclaimed(cur realm)
source

SettleUnclaimed disposes of whatever was never claimed, once the claim window has elapsed: half is burned, the other half goes to the team fund.

The rule is enforced here rather than promised: there is no Sweep and no BurnRemaining, so the owner cannot pocket the residue nor destroy all of it. Settlement waits for the window even if CloseCampaign stopped claims earlier, and grants already made stay untouchable — only the free part (balance minus outstanding) is settled. Anyone may call it: it is a public service, not a privilege.

func TotalBurned

Action
1func TotalBurned() int64
source

TotalBurned is the total destroyed: instant exits, renunciations and the settlement of the unclaimed residue.

func TotalToFund

Action
1func TotalToFund() int64
source

TotalToFund is what voluntary forfeits sent to the ecosystem fund.

func TransferOwnership

crossing Action
1func TransferOwnership(cur realm, newOwner address)
source

TransferOwnership hands administration of the campaign over.

func Vested

Action
1func Vested(addr address) int64
source

Vested returns how much of addr's grant has vested so far. A closed grant (instant exit or forfeit) will never vest anything more: it reports what was paid, not where the curve would be.

func VestingEnd

Action
1func VestingEnd() int64
source

VestingEnd is the moment (unix) at which everything granted in the current campaign counts as fully vested.

func VestingStart

Action
1func VestingStart() int64
source

VestingStart is the moment (unix) the CURRENT campaign's linear release runs from. Grants from earlier campaigns keep their own, readable with VestingStartOf.

func Withdraw

crossing Action
1func Withdraw(cur realm)
source

Withdraw transfers to the caller the vested, not-yet-withdrawn part.

func WithdrawFor

crossing Action
1func WithdrawFor(cur realm, beneficiary address)
source

WithdrawFor is like Withdraw but on another beneficiary's behalf: the tokens still go to beneficiary, whoever sends the transaction only pays the gas.

func Withdrawable

Action
1func Withdrawable(addr address) int64
source

Withdrawable returns how much addr can withdraw right now.

func Withdrawn

Action
1func Withdrawn(addr address) int64
source

Withdrawn returns how much addr has already withdrawn.

Imports 14

Source Files 3