Skip to content Search Apps Documentation Source Content Run Reset Eval Playground 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.

usernames package

Overview

Package usernames is the toolbox tool for gno.land identities: it turns a username into an address, an address into a username, and tells you which of the two you are actually holding.

It is the page form of

Example
1gnokey query vm/qeval --data 'gno.land/r/sys/users.ResolveName("akkadia")' -remote https://rpc.gno.land

with the three things that query does not tell you: whether the name you asked about is the user's CURRENT name or an alias they renamed away from, what canonical key it collapses to, and whether a lookalike of it is already taken.

Why not r/sys/users.ResolveAny

`ResolveAny` returns `(*UserData, bool)` and the bool does not mean "found". For an input that parses as an address it returns `(ResolveAddress(addr), true)` whatever the lookup produced, so an unregistered address comes back as `(nil, true)`. Every caller that reads the bool and dereferences the pointer panics on the first address nobody claimed. [lookup] branches on the input itself and checks the pointer instead.

Part of r/moul/toolbox(/r/moul/toolbox).

Functions

AddressOf

func AddressOf(input string) string
Ask AI Claude ChatGPT

AddressOf returns the address behind a username or an address, or "" when nobody holds it.

It is the call another realm would want, and the one it cannot have: this realm is `private = true`, so nothing can import it. Over `vm/qeval` it is the whole point.

Example
1gnokey query vm/qeval -data 'gno.land/r/moul/toolbox/usernames.AddressOf("moul")'

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.AddressOf()"

Result

Canonical

func Canonical(name string) string
Ask AI Claude ChatGPT

Canonical returns the canonical key a name collapses to. Two names with the same canonical form cannot both be registered, which is how `r/sys/users` refuses a lookalike of an existing account.

Example
1gnokey query vm/qeval -data 'gno.land/r/moul/toolbox/usernames.Canonical("M0ul")'

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.Canonical()"

Result

CanonicalOwner

func CanonicalOwner(name string) string
Ask AI Claude ChatGPT

CanonicalOwner returns the name that already holds this name's canonical key, or "" when the key is free. A non-empty answer that is not the name itself is a lookalike collision.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.CanonicalOwner()"

Result

CurrentName

func CurrentName(input string) string
Ask AI Claude ChatGPT

CurrentName reports the user's current name when input is an alias they renamed away from, and "" otherwise.

`r/sys/users` keeps old names resolving on purpose, so an address looked up by a name that is no longer current is not an error and nothing in the resolve result says so. This is the one call that does.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.CurrentName()"

Result

Display

func Display(input string) string
Ask AI Claude ChatGPT

Display returns what a page should print for an input: "@name" when there is a username, and the input unchanged when there is not.

So it is total over every input a page actually has, and a caller never has to branch on "not found" the way NameOf makes it. The one input it has nothing to say about is "", which it returns unchanged: an empty answer to an empty question, rather than a placeholder a page would then have to special case anyway.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.Display()"

Result

NameOf

func NameOf(input string) string
Ask AI Claude ChatGPT

NameOf returns the current username behind a username or an address, or "" when nobody holds it.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.NameOf()"

Result

Render

func Render(path string) string
Ask AI Claude ChatGPT

Render routes gnoweb paths:

Example
1/                the form, and what the tool answers
2/lookup?q=moul   the result, which is where the form submits
3/moul            the same result, addressable directly
4/g1manfred...    the same, by address

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.Render()"

Result

Resolve

func Resolve(input string) (name string, addr string, found bool)
Ask AI Claude ChatGPT

Resolve returns the current username and the address behind any input, a username or a `g1` address.

found is false when nobody holds it, which is also the answer for a deleted user: `r/sys/users` keeps the tombstone and resolves it to nothing.

Example
1gnokey query vm/qeval -data 'gno.land/r/moul/toolbox/usernames.Resolve("moul")'

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.Resolve()"

Result

Taken

func Taken(name string) bool
Ask AI Claude ChatGPT

Taken reports whether the exact name is registered, including names that were deleted or renamed away from: it answers "would registering this fail", not "is somebody using this".

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames.Taken()"

Result

Gno Expression Evaluator

Evaluate any read-only Gno expression against gno.land/r/g1magld5ptgzaktqcexxq0pgq5lmdf0kz6re8hlv/toolbox/usernames, for example a function call with arguments.