func Call
Call returns a URL for the specified function with optional key-value arguments, for the current realm.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
gno.land/p/moul/txlinkBuild a clickable "call this function" link for a realm's Render output, so a
page can offer a transaction instead of telling the reader what to type.
1// current realm, one arg
2txlink.Call("AddTodo", "todo", "buy milk")
3// -> /r/moul/home$help&func=AddTodo&todo=buy+milk
4
5// builder, with a send amount
6txlink.NewLink("Donate").
7 AddArgs("message", "thanks").
8 SetSend("1000000ugnot").
9 URL()
The output is the gnoweb $help&func= form: following it opens the help page
with the function selected and the arguments pre-filled. The user still signs.
Nothing here broadcasts, and nothing here can.
Realm.prefix() decides what the link is relative to:
Realm value |
link |
|---|---|
"" (the default) |
the current realm, read from CurrentRealm().PkgPath() |
| a path on this chain | /r/..., chain domain trimmed |
| a path on another chain | https://<that domain>/r/... |
So txlink.Call(...) in a realm links to itself, and
txlink.Realm("gno.land/r/other/x").Call(...) links to a neighbour, without
either caller hardcoding a domain. Do not build the string yourself: a
hardcoded self-link is wrong the moment the realm moves, which
r/moul/demo/render still demonstrates by
accident.
AddArgs takes
them flat ("k1", "v1", "k2", "v2").. panics. .send is reserved; use SetSend.NewLink("") returns nil and every method on a
nil builder returns nil, so a chain never panics halfway; URL() on it
returns "".func= is kept first in the query string on purpose, ahead of the
url-encoded rest, so the links stay readable.Related: p/moul/helplink is the fuller version of the same
idea; txlink is the streamlined one. For parsing the path on the way in,
see p/moul/realmpath.
Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
⚠️ Disclaimer: provided as-is, without warranty; not security-audited. Full disclaimer: DISCLAIMER.
Realm represents a specific realm for generating tx links.
TxBuilder provides a fluent interface for building transaction URLs
AddArgs adds multiple key-value pairs at once. Arguments should be provided as pairs: AddArgs("key1", "value1", "key2", "value2").
SetSend adds a send amount. (Only one send amount can be specified.)
URL generates the final URL using the standard $help&func=name format.