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

v0 source realm

Package grc20faucet issues two free GRC20 tokens, RED and BLUE, and gives them away on request.

Readme View source

gno.land/r/moul/x/grc20faucet/v0

Two free GRC20 tokens, RED and BLUE, so experiments have something to run on. Worthless by construction, unlimited, and shared.

maketx call -pkgpath gno.land/r/moul/x/grc20faucet/v0 -func Claim

100.0000 of each per claim (4 decimals), once every 100 blocks per account.

token symbol registry key
Red Token RED gno.land/r/moul/x/grc20faucet/v0.RED
Blue Token BLUE gno.land/r/moul/x/grc20faucet/v0.BLUE

Both are registered in r/nt/grc20reg, which is the point: another realm can find and move them by key without importing this one. Everything else here is the ordinary GRC20 surface, with the symbol as the first argument:

-func Transfer     -args RED  -args <to>      -args 250000
-func Approve      -args BLUE -args <spender> -args 250000
-func TransferFrom -args RED  -args <from> -args <to> -args 250000

Approve is the interesting one. It is what lets a realm such as r/moul/x/grc20wrapdemo pull your tokens into escrow, and until you call it that realm has no authority over your balance at all.

Two tokens rather than one because the interesting patterns start at two: a meta-token over a pair needs a pair.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

Dependency graph:

gno.land/r/moul/x/grc20faucet/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

Overview

Package grc20faucet issues two free GRC20 tokens, RED and BLUE, and gives them away on request.

It exists so that anything needing a token to experiment on has one that is worthless, unlimited and shared. Both tokens are registered in gno.land/r/nt/grc20reg/v0, which is what lets another realm find and move them by key without importing this package: that indirection is the whole point, and it is what gno.land/r/moul/x/grc20wrapdemo/v0 wraps.

Two tokens rather than one, because the interesting patterns start at two: a meta-token over a pair needs a pair.

Constants 1

const decimals, ClaimAmount, ClaimEvery

 1const (
 2	decimals = 4
 3
 4	// ClaimAmount is minted of EACH token per claim: 100.0000 units.
 5	ClaimAmount = int64(1_000_000)
 6
 7	// ClaimEvery is the cooldown, in blocks, between two claims by the same
 8	// account. Free money with no cooldown is a spam vector, not a faucet.
 9	ClaimEvery = int64(100)
10)
source

Variables 1

var Red, Blue, redLedger, blueLedger, RedKey, BlueKey, lastClaim

 1var (
 2	Red  *grc20.Token
 3	Blue *grc20.Token
 4
 5	redLedger  *grc20.PrivateLedger
 6	blueLedger *grc20.PrivateLedger
 7
 8	// RedKey and BlueKey are the grc20reg lookup keys, the way a realm that
 9	// does NOT import this package refers to these tokens.
10	RedKey  string
11	BlueKey string
12
13	lastClaim = avl.NewTree() // address -> block height of its last claim
14)
source

Tokens are exported so an importing realm can read them directly; the ledgers stay private, since they carry unrestricted mint and burn.

Functions 9

func Allowance

Action
1func Allowance(symbol string, owner, spender address) int64
source

Allowance returns what `owner` let `spender` draw of `symbol`.

func Approve

crossing Action
1func Approve(cur realm, symbol string, spender address, amount int64)
source

Approve lets `spender` draw `amount` of `symbol` from the caller's balance.

This is the call that makes every wrapper in grc20wrapdemo work: the wrapper realm has no authority over anybody's tokens until its address is named here.

func BalanceOf

Action
1func BalanceOf(symbol string, owner address) int64
source

BalanceOf returns `owner`'s balance of `symbol`.

func Claim

crossing Action
1func Claim(cur realm)
source

Claim mints ClaimAmount of both RED and BLUE to the caller.

func NextClaim

Action
1func NextClaim(who address) (int64, bool)
source

NextClaim returns the block height at which `who` may claim again, and whether they have ever claimed at all.

func TotalSupply

Action
1func TotalSupply(symbol string) int64
source

TotalSupply returns how much of `symbol` has been claimed so far.

func Transfer

crossing Action
1func Transfer(cur realm, symbol string, to address, amount int64)
source

Transfer moves the caller's own units of `symbol`.

func TransferFrom

crossing Action
1func TransferFrom(cur realm, symbol string, from, to address, amount int64)
source

TransferFrom spends an allowance the caller was granted.

Imports 5

Source Files 4