/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/demo/wikicoin/v0
Directory · 4 Files
gno.land/r/moul/demo/wikicoin
Step 5 of the r/moul/demo walkthrough: the token from
Wikipedia's Solidity article,
translated to gno line by line.
1func Mint(cur realm, receiver address, amount uint) // minter only
2func Send(cur realm, receiver address, amount uint)
3func BalanceOf(addr address) uint
What the translation shows:
- Solidity's
constructorbecomesinit(), which runs once at deploy. The deployer is recorded asminter. mapping(address => uint)becomes anavl.Treekeyed by the address string. Gno has maps, but an avl tree is the storage-friendly choice for a ledger that grows.require(msg.sender == minter)becomes an explicitpanic("restricted"). A panic aborts the transaction and reverts every write, the same way a revert does.- Solidity's
msg.senderisunsafe.OriginCaller()here, which is the transaction signer, not the immediate caller. That distinction does not matter in a demo and matters a great deal in production: it is whatAssertOriginCallguards exist for.
This is teaching material, not a token to use. For a real one, use
p/nt/grc20,
which grc20 demonstrates next.
Previous: render. Next: grc20.
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.