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

README.md

2.68 Kb · 49 lines

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 constructor becomes init(), which runs once at deploy. The deployer is recorded as minter.
  • mapping(address => uint) becomes an avl.Tree keyed 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 explicit panic("restricted"). A panic aborts the transaction and reverts every write, the same way a revert does.
  • Solidity's msg.sender is unsafe.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 what AssertOriginCall guards 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.

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

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

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