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

threads/v0 package

Overview

Package threads is a discussion block any realm can embed, keyed on the page it appears on rather than on the realm that stores it.

It is the text half of gno.land/r/moul/reactions: the same embed shape, the same page keys, two lines in the host realm.

Example
1import "gno.land/r/moul/x/social/threads/v0"
2
3func Render(path string) string {
4	return body + threads.RenderBlock()
5}

RenderBlock takes no argument because it does not need one: a plain read exported by a realm and called by another opens no realm frame, so unsafe.CurrentRealm() inside it reports the CALLER. The host realm's own path is the page key, and nothing has to be configured or registered. RenderBlockFor is the explicit form, for a realm that renders more than one page or already holds its path as a constant.

The token, and the three things it has to answer

THREAD exists because placement is the one thing a discussion has that people want and cannot all have at once.

Example
1mint   1 THREAD to a thread's author, the first time each distinct
2       address replies to it. People, not messages, and never yourself.
3sink   [Boost] burns PinCost THREAD to pin a thread to the top of its
4       page for PinBlocks blocks. That is the only thing that removes
5       supply, and the only thing the token does.
6buyer  anyone who wants placement and has not earned it. They have to
7       acquire THREAD from someone who did, with [Transfer], which is
8       what makes attention a market rather than a scoreboard.

It is farmable, and saying so is cheaper than pretending otherwise: two addresses replying to each other mint one THREAD each per thread. The fix is a gate on who counts as a replier, which belongs in a vouching realm and not here; until then the cost of farming is one transaction per point and the benefit is capped by what a pin is worth.

Functions

Allowance

func Allowance(owner, spender address) int64

Allowance is what owner let spender draw.

Params

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/social/threads/v0.Allowance(,)"

Result

Approve

func Approve(cur realm, spender address, amount int64)

Approve lets spender draw amount of the caller's THREAD.

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/social/threads/v0" -func "Approve" -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/social/threads/v0" -func "Approve" -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
  

BalanceOf

func BalanceOf(owner address) int64

BalanceOf is an address's THREAD balance.

Param

Command

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

Result

Boost

func Boost(cur realm, threadID int64)

Boost burns PinCost THREAD from the caller and pins the thread to the top of its page for PinBlocks blocks.

Anyone may boost anyone's thread. The pin is on the thread and not on the buyer, so the thing being sold is placement and not authorship.

Param

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/social/threads/v0" -func "Boost" -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/social/threads/v0" -func "Boost" -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
  

Count

func Count(page string) int

Count is how many threads a page holds.

Param

Command

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

Result

Pages

func Pages() int

Pages is how many pages have ever been posted on.

Command

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

Result

PinnedUntil

func PinnedUntil(threadID int64) int64

PinnedUntil is the height a thread stops being pinned at, or 0.

Param

Command

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

Result

Post

func Post(cur realm, page, body string) int64

Post opens a thread under page.

page is a package path, the full one: "gno.land/r/moul/home". It does not have to be a realm that embeds the block, and nothing checks that it exists. A page is just a name, which is what lets a realm key discussion on something finer than itself.

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/social/threads/v0" -func "Post" -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/social/threads/v0" -func "Post" -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 routes three views: the realm's own index, one page's threads, and one thread.

A page key contains slashes, so "page/<key>" is split on the prefix rather than by path element: realmpath gives the parts, and rejoining them would only be a way to get it wrong.

Param

Command

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

Result

RenderBlock

func RenderBlock() string

RenderBlock returns the block for the realm CALLING it, which is the form a host realm embeds.

It has no cur realm parameter on purpose. A plain read is borrowed: gno opens no realm frame for it, so unsafe.CurrentRealm() reports the caller's path and the block keys itself with no argument. Adding a cur realm here would silently reverse that and key every embed to this realm instead.

Command

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

Result

RenderBlockFor

func RenderBlockFor(page string) string

RenderBlockFor is RenderBlock for a named page. Use it from a crossing function, where there is no caller to read off the stack, or when one realm renders several pages.

Param

Command

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

Result

Repliers

func Repliers(threadID int64) int

Repliers is how many distinct addresses have replied to a thread, which is also how much its author has earned from it.

Param

Command

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

Result

Reply

func Reply(cur realm, threadID int64, body string)

Reply appends to a thread.

The first time each distinct address replies to a given thread, its author earns EarnPerReplier. Replying again earns nothing, and replying to your own thread never earns anything.

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/social/threads/v0" -func "Reply" -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/social/threads/v0" -func "Reply" -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
  

TokenKey

func TokenKey() string

TokenKey is the r/nt/grc20reg key for THREAD.

Command

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

Result

Total

func Total() int

Total is how many threads exist, across every page.

Command

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

Result

TotalSupply

func TotalSupply() int64

TotalSupply is the THREAD in existence: everything earned, less everything burned by Boost.

Command

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

Result

Transfer

func Transfer(cur realm, to address, amount int64)

Transfer moves the caller's own THREAD. It is what makes the sink a market: somebody who wants a pin and has written nothing has to buy from an author.

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/social/threads/v0" -func "Transfer" -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/social/threads/v0" -func "Transfer" -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
  

TransferFrom

func TransferFrom(cur realm, from, to address, amount int64)

TransferFrom spends an allowance the caller was granted.

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/social/threads/v0" -func "TransferFrom" -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/social/threads/v0" -func "TransferFrom" -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