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 package

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.

Function

SealCampaign

func SealCampaign(cur realm)

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().

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/nym-thegnomic001/gnomic_airdrop" -func "SealCampaign" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "http://127.0.0.1:26657" ADDRESSgnokey query -remote "http://127.0.0.1:26657" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/nym-thegnomic001/gnomic_airdrop" -func "SealCampaign" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "http://127.0.0.1:26657" call.tx