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

merkledrop package

Overview

Package merkledrop is an idiomatic gno.land port of the classic Solidity MerkleDistributor airdrop (Uniswap's contract, OpenZeppelin's MerkleProof).

A fixed merkleRoot commits to a set of (address, amount) allocations. A recipient proves membership by supplying the sibling hashes on the path from their leaf up to the root. Each address may claim exactly once.

Leaf and node hashing use crypto/sha256 (available in the gno stdlib), the same primitive Solidity distributors use via keccak — here sha256 keeps the off-chain tree builder trivially reproducible. Internal nodes hash the two children in sorted order (the OpenZeppelin "commutative" scheme), so proofs carry no left/right flags.

Example
1leaf   = sha256(addr.String() + "|" + amount)
2node   = sha256(min(a,b) || max(a,b))

Balances are pure accounting (uint64); no real coin moves — there is no msg.value on gno, so this models the allocation ledger only.

Functions

AmountClaimed

func AmountClaimed(claimer address) uint64

AmountClaimed returns how much the address has already claimed (0 if none).

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop.AmountClaimed()"

Result

Claim

func Claim(cur realm, amount uint64, proof string)

Claim proves the caller is entitled to `amount` via `proof` (comma-separated hex sibling hashes) and marks the allocation claimed. Panics on a bad proof or a double claim. Mirrors MerkleDistributor.claim (msg.sender is the caller).

Params

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/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop" -func "Claim" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "topaz-1" -remote "https://rpc.topaz.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.topaz.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop" -func "Claim" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "topaz-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.topaz.testnets.gno.land" call.tx
  

HasClaimed

func HasClaimed(claimer address) bool

HasClaimed reports whether the address already claimed.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop.HasClaimed()"

Result

Render

func Render(path string) string

Render shows the committed root, aggregate stats, and the list of claimers.

Param

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop.Render()"

Result

Verify

func Verify(claimer address, amount uint64, proof string) bool

Verify reports whether (claimer, amount, proof) resolves to merkleRoot. Pure and read-only — safe to call from tests and Render.

Params

Command

gnokey query vm/qeval -remote "https://rpc.topaz.testnets.gno.land" -data "gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/merkledrop.Verify(,,)"

Result