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

nativereg/v0 package

Overview

Package nativereg is the metadata a native coin does not have.

A realm-issued coin is a string and a balance. `/gno.land/r/moul/x/moultest/v0:moultest` is the entire object: no name, no symbol, no decimals, no icon, no link to whoever issues it. The bank knows the number and nothing else, so a wallet or an explorer showing you a balance has only that path to print.

This realm is where a denom says what it is. It is the mirror image of `r/nt/grc20reg`, and the two solve opposite problems: a GRC20 is an object that carries its own name and is hard to FIND, so the registry maps a key to the object; a native denom is trivial to find and carries no name, so the registry maps the denom to what it means.

Registration is proved, not claimed

A denom embeds the package path of the realm allowed to issue it, verbatim: `"/" + pkgPath + ":" + baseName` (`chain.CoinDenom`). So the issuer is readable from the denom, and Register simply requires the caller to be it. A realm registers its own coins and nobody else's, with no allowlist, no owner and no signature scheme.

A user account cannot register anything, not even a denom it holds all of: there is no package path in a user call to compare against. That is the intended shape, since the thing being described is the issuance, not the holding.

What is a hint and what is a fact

`Denom` and `Issuer` are facts: the chain enforces the relation between them. Everything else is whatever the issuing realm chose to say, and `Decimals` in particular is a DISPLAY hint with nothing behind it. The bank has no notion of divisibility; a coin wrapped out of a 6-decimal GRC20 is still counted in whole units by every balance query. Rendering 1000000 as 1.000000 is a convention between this realm and whoever reads it.

So trusting an entry means trusting the realm that wrote it, exactly as much as holding its coin already means trusting it not to call `RemoveCoin` on you.

Functions

Count

func Count() int

Count returns how many denoms are registered.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.Count()"

Result

IsRegistered

func IsRegistered(denom string) bool

IsRegistered reports whether a denom has said anything about itself.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.IsRegistered()"

Result

IssuerOf

func IssuerOf(denom string) string

IssuerOf returns the package path embedded in a denom, without consulting the registry: the relation is in the string itself. It aborts on anything that is not a realm denom, which includes `ugnot`.

It is exported because it is useful to anybody handling a denom, registered or not: given a balance, this is how you find the code that can take it away.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.IssuerOf()"

Result

Register

func Register(cur realm, denom, name, symbol string, decimals int, doc string)

Register records or rewrites what a denom means. The caller must be the realm the denom names, which is the entire authorization.

Calling it again overwrites the entry and bumps [Entry.Revisions]. An issuer can always re-describe its own coin, and can never describe anybody else's.

Params

Command

# WARNING: This command is running in an INSECURE mode.
# It is strongly recommended to use a hardware device for signing
# and avoid trusting any computer connected to the internet,
# as your private keys could be exposed.

gnokey maketx call -pkgpath "gno.land/r/moul/x/nativereg/v0" -func "Register" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "gnoland-1" -remote "https://rpc.gno.land" ADDRESSgnokey query -remote "https://rpc.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/moul/x/nativereg/v0" -func "Register" -args $'' -args $'' -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "gnoland-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.gno.land" call.tx
  

Render

func Render(path string) string

Render lists the registry. `?<denom>` shows one entry, `?<pkgpath>` shows everything one realm issues.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.Render()"

Result

ByIssuer

func ByIssuer(pkgPath string) []Entry

ByIssuer returns every entry issued by one realm, in registration order.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.ByIssuer()"

Result

Get

func Get(denom string) (Entry, bool)

Get returns the entry for a denom, and whether it has one.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.Get()"

Result

List

func List() []Entry

List returns every entry, in registration order.

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.List()"

Result

MustGet

func MustGet(denom string) Entry

MustGet is Get for a caller that treats an unregistered denom as a bug.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/nativereg/v0.MustGet()"

Result