README.md
gno.land/r/moul/demo/grc20
Step 6 of the r/moul/demo walkthrough: the same ledger as
wikicoin, but on the standard p/nt/grc20 token instead of a
hand-rolled tree.
1var (
2 Token *tokens.Token // exported: anyone may read
3 privateLedger *tokens.PrivateLedger // unexported: mint, burn, transfer
4)
That split is the whole lesson. NewToken returns two handles onto one
token. The Token handle is read-only and safe to export, so other realms can
call Token.BalanceOf(...) or Token.GetName() across the realm boundary. The
PrivateLedger handle can move anyone's balance, so it stays unexported: gno's
export rules become the access control, with no permission check to get wrong.
Exporting the ledger by accident is a total loss of the token. Keep it lowercase and expose deliberate wrappers instead.
init creates "Foo Token" (FOO, 4 decimals) and mints 100000000 units to a
test address. MyBalance() shows a read scoped to the caller.
Previous: wikicoin. Next: vault locks tokens up.
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:

⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.