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

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/demo/grc20/v0

Directory · 4 Files
README.md Open

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.

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

gno.land/r/moul/demo/grc20/v0 dependency graph

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