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

vouch/v0 package

Overview

Package vouch is a web of trust other realms can gate on: one address vouches for another, in writing, optionally with GNOT locked behind it.

The one call that matters is a plain read:

Example
1import "gno.land/r/moul/x/social/vouch/v0"
2
3func Claim(cur realm) {
4	if !vouch.IsTrusted(cur.Previous().Address(), 2) {
5		panic("get two people to vouch for you first")
6	}
7	…
8}

IsTrusted takes no cur realm on purpose. A read with no realm token is borrowed: gno opens no realm frame for it, so it costs the caller nothing beyond the read and cannot be tricked into acting as anybody. Nothing here branches on who is asking, and no read in this realm ever will: the answer to "is this address trusted" must not depend on who wants to know.

What it does, and what it refuses to do

Vouch is payable. Any coins sent with it are locked as a bond on that vouch, which is the voucher putting their own money where their claim is. A bond is optional and zero is the ordinary case. Revoke takes the vouch back and credits the bond to the voucher, who collects it with Withdraw.

There is no slashing in v0 and that is the interesting half. Slashing needs an arbiter, somebody who decides a vouch was a lie, and every candidate is a design question rather than a feature: a DAO vote is a popularity contest, a challenge market pays whoever is loudest, an oracle is one key that can confiscate anybody's money. The bond is still worth having without it, because an illiquid deposit is a cost a hundred throwaway addresses cannot all pay at once.

No token

This realm issues none, deliberately. A transferable vouch is a bought reputation, and the moment a vouch can be sold the score stops measuring what it says it measures. The bond is GNOT: value at risk, without being a market in trust itself. The README says what would change the answer.

Functions

Badge

func Badge(addr address) string

Badge is the one-line trust mark for addr, for a host realm that wants to show what its gate just read. Like IsTrusted it is a borrowed read and takes no realm token.

Param

Command

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

Result

BondFrom

func BondFrom(from, target address) int64

BondFrom is what from locked on target, or zero.

Params

Command

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

Result

BondedFor

func BondedFor(addr address) int64

BondedFor is the total ugnot locked on addr by everyone vouching for them.

Param

Command

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

Result

Count

func Count() int

Count is how many vouches exist.

Command

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

Result

IsTrusted

func IsTrusted(addr address, min int) bool

IsTrusted reports whether addr is vouched for by at least min distinct addresses. This is the gate, and it is one line at the call site.

A min below one is read as one: a gate that lets everybody through is a bug in the caller rather than an answer this realm will agree to.

It cannot tell you that the vouchers are distinct people. Two addresses vouching for each other both reach a score of one, which Mutual exposes and which is the reason to ask for more than one.

Params

Command

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

Result

Mutual

func Mutual(a, b address) bool

Mutual reports whether a and b vouch for each other, which is the cheapest sybil shape and therefore worth discounting.

Params

Command

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

Result

Owed

func Owed(addr address) int64

Owed is what addr can collect with Withdraw.

Param

Command

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

Result

People

func People() int

People is how many addresses have at least one vouch for them.

Command

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

Result

ReasonFrom

func ReasonFrom(from, target address) string

ReasonFrom is what from wrote about target, or the empty string. It is raw caller text: escape it before rendering it anywhere.

Params

Command

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

Result

Render

func Render(path string) string

Render routes two views: the realm's own index, and one address's page.

An address carries no slash, so the per-address route is a path element and not a prefix strip.

Param

Command

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

Result

Revoke

func Revoke(cur realm, target address) int64

Revoke withdraws the caller's vouch for target and credits any bond back to them. The coins do not move here: call Withdraw to collect them.

Splitting it in two is the pull-payment pattern. A realm that sent on revoke would be handing control to the recipient in the middle of its own state change, and a recipient that refuses the coins could make revoking impossible.

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/vouch/v0" -func "Revoke" -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/vouch/v0" -func "Revoke" -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
  

ScoreOf

func ScoreOf(addr address) int

ScoreOf is how many distinct addresses vouch for addr.

Param

Command

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

Result

TotalBonded

func TotalBonded() int64

TotalBonded is everything locked on vouches that still stand.

Command

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

Result

TotalOwed

func TotalOwed() int64

TotalOwed is every revoked bond nobody has collected yet. This realm holds TotalBonded plus TotalOwed on behalf of other people.

Command

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

Result

Vouch

func Vouch(cur realm, target address, reason string)

Vouch records that the caller stands behind target, for the stated reason.

It is payable: coins sent with the call are locked as a bond on this vouch and are returned by Revoke, never by anything else. Sending nothing is fine and is the ordinary case.

Vouching again for the same address UPDATES the reason and ADDS to the bond. It does not count twice: the score this realm exists to publish is a count of people, so a second transaction from the same address buys precisely nothing. Vouching for yourself is refused.

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/vouch/v0" -func "Vouch" -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/vouch/v0" -func "Vouch" -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
  

Withdraw

func Withdraw(cur realm) int64

Withdraw pays the caller every bond their revoked vouches freed, and returns the amount sent.

The credit is zeroed before the coins leave, so a recipient that calls straight back in finds nothing to take.

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/vouch/v0" -func "Withdraw" -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/vouch/v0" -func "Withdraw" -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