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.

mandate package

Overview

Package mandate is capped, revocable direct debit on native GNOT, built on Gno session keys.

A payee publishes a plan ("1 GNOT every 7 days"). A payer subscribes with two things signed by the payer's own key:

  1. a session on chain for the payee's collector key, scoped to this realm only, with a spend limit of the plan's amount plus a small fee allowance per period, and an expiry;
  2. Subscribe here, which records the terms for that session.

The payee's collector then calls Pull once per period, signed with the session key on behalf of the payer and sending exactly the plan's amount. The realm is the rulebook: it checks who, how much and when, then forwards the coins to the payee in the same transaction. It never keeps funds.

Honest limits, also shown on the home page:

  • It is direct debit, not escrow. A payer can revoke the session, cancel, or empty the account at any time; the payee is then not paid.
  • The chain caps what the payer can lose per period at the session's spend limit: amount plus fee allowance. A hostile payee can burn the allowance as gas fees (it goes to the network, not to the payee).
  • The chain allows at most 16 sessions per account, so a wallet can have at most 16 mandates at a time.
  • A realm cannot see an on-chain session revoke. A service deciding whether someone has paid reads PaidThrough, which moves only when a payment succeeds; HasMandate is only the realm's view (recorded, not cancelled, not expired), and the chain's own view of the session is the free query auth/accounts/<payer>/session/<session address>.
  • A session scoped to vm/exec:<this realm> also allows every realm under this path (the chain's scope match is prefix-based). Nothing must ever be deployed under a sub-path of this realm. Pull also refuses any session whose allow list is not exactly this realm, but that cannot protect a payer from a sub-realm called directly.

There is no admin, owner, pause, upgrade or sweep.

Functions

Cancel

func Cancel(cur realm, payer address, sessionAddr address)
Ask AI Claude ChatGPT

Cancel ends a mandate in the realm. The payer or the payee may cancel, each with their own key (never a session). A payer should also revoke the session on chain (the payer page shows the command); cancelling alone already makes every later Pull fail.

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/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Cancel" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Cancel" -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

CollectorPlans

func CollectorPlans(payee address, page int) string
Ask AI Claude ChatGPT

CollectorPlans lists a payee's plans for a collector script, one per line:

Example
1<plan id> <amount ugnot> <period seconds> <mandates>

PageSize per page; the last line is "more" or "end".

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.CollectorPlans(,)"

Result

CollectorScan

func CollectorScan(planID uint64, sessionAddr address, from int) string
Ask AI Claude ChatGPT

CollectorScan walks at most ScanLimit entries of a plan's supporter list, from index `from` (0 = oldest), and returns the active mandates whose session key is sessionAddr, one per line:

Example
1<index> <mandate id> <payer> <amount ugnot> <next pull unix> <due|wait> <pulls> <paid>

<paid> is 1 when the payer has paid for this plan (this mandate pulled, or it started with paid time carried over from an earlier one), 0 when it never has. The last line is "next <index>" when more entries follow, "end" otherwise. Cancelled and expired mandates, and mandates for other keys, are skipped here, so a collector never needs to read them. Anyone can record a mandate without a session, so a collector should check on chain that the session exists, at least before the first pull of a mandate whose payer never paid.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.CollectorScan(,,)"

Result

HasMandate

func HasMandate(payer address, planID uint64) bool
Ask AI Claude ChatGPT

HasMandate reports whether payer has a mandate for the plan that is neither cancelled nor expired in the realm. It says nothing about payment (a mandate costs only a storage deposit to record) and cannot see a session revoked on chain: do not grant anything on it; use PaidThrough.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.HasMandate(,)"

Result

IsPaidUp

func IsPaidUp(payer address, planID uint64) bool
Ask AI Claude ChatGPT

IsPaidUp reports whether payer's latest payment for the plan still covers now (now < PaidThrough). See PaidThrough.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.IsPaidUp(,)"

Result

NextPullAt

func NextPullAt(payer address, planID uint64) int64
Ask AI Claude ChatGPT

NextPullAt returns when the next pull of payer's active mandate for the plan is allowed (unix seconds), or 0 if there is no active mandate.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.NextPullAt(,)"

Result

Offer

func Offer(cur realm, title string, amountUgnot, periodSeconds int64) uint64
Ask AI Claude ChatGPT

Offer publishes a plan: amountUgnot every periodSeconds, paid to the caller. Signed with the payee's own key; no session, no coins.

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/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Offer" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Offer" -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 "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

PaidThrough

func PaidThrough(payer address, planID uint64) int64
Ask AI Claude ChatGPT

PaidThrough is the read for services that deliver something to paying supporters. It returns the unix time until which the payer's payments for the plan cover them: the latest payment's time plus one period. Paid time stays the payer's when a mandate is cancelled (by either side) or expires, and a new mandate for the same plan starts when it ends, so it is not charged twice. The one exception: a payer who already holds 16 kept periods (MaxCreditsPerPayer). 0 when they never paid for the plan. Deliver while now < PaidThrough.

It turns false at the due time and moves on only when the payee's collector pulls the next payment: allow a grace equal to how often the collector runs (an hour, say) before treating a supporter as lapsed.

A payment is proof; a mandate is not: anyone can record a mandate without creating a session and without paying. A realm also cannot see a session revoked on chain: a revoked supporter simply stops paying, so PaidThrough stops moving and runs out within one period.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.PaidThrough(,)"

Result

PlanCounts

func PlanCounts(planID uint64) (paidThisPeriod, paidLastPeriod, unpaid int, unpaidExact bool)
Ask AI Claude ChatGPT

PlanCounts returns the numbers the gnoweb plan page shows: how many supporters paid in the plan's current period window and in the one before (as in GetPlan), and how many active mandates have never paid, among the latest ScanLimit entries (unpaidExact is false when there were more entries than that).

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.PlanCounts()"

Result

Pull

func Pull(cur realm)
Ask AI Claude ChatGPT

Pull collects one period's payment. It must be signed with the mandate's session key on behalf of the payer (gnokey ... -master <payer> <session key>), as a direct call, sending exactly the plan's amount. The realm forwards the coins to the plan's payee in the same transaction. At most one pull per period; the next one is due one period after this one, the same rule the chain applies to the session's spend period.

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/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Pull" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Pull" -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

Render

func Render(path string) string
Ask AI Claude ChatGPT

Render returns the gnoweb page for path, with the footer.

Param

Command

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

Result

SetCollectorKey

func SetCollectorKey(cur realm, pubKey string)
Ask AI Claude ChatGPT

SetCollectorKey publishes the public key (bech32, gpub1...) of the key the payee's collector signs pulls with. Plan pages show it in the copy-ready commands, so payers create their session for the right key. Signed with the payee's own key. It does not change existing mandates.

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/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "SetCollectorKey" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "SetCollectorKey" -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -broadcast=false ADDRESS > call.tx
gnokey sign -tx-path call.tx -chainid "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

Subscribe

func Subscribe(cur realm, planID uint64, sessionAddr address, expiresAtUnix int64) uint64
Ask AI Claude ChatGPT

Subscribe records the terms for one session: the payer allows the holder of sessionAddr to pull the plan's amount once per period until expiresAtUnix, through this realm only. Signed with the payer's own key (never a session), no coins. Create the session on chain in the same transaction or just before (see the plan page for the exact command).

The first payment is collected by the first Pull, which is due at once (billing in advance: each period is paid at its start).

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/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Subscribe" -args $'' -args $'' -args $'' -gas-fee 1000000ugnot -gas-wanted 1_000_000_000 -send "" -chainid "onyx-1" -remote "https://rpc.onyx.testnets.gno.land" ADDRESSgnokey query -remote "https://rpc.onyx.testnets.gno.land" auth/accounts/ADDRESS
gnokey maketx call -pkgpath "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate" -func "Subscribe" -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 "onyx-1" -account-number ACCOUNTNUMBER -account-sequence SEQUENCENUMBER ADDRESS
gnokey broadcast -remote "https://rpc.onyx.testnets.gno.land" call.tx
  

Totals

func Totals() (plansCount, mandatesCount int, pulls, paid int64)
Ask AI Claude ChatGPT

Totals returns the number of plans and mandates, and all pulls so far.

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.Totals()"

Result

MandateOf

func MandateOf(payer, sessionAddr address) (MandateInfo, bool)
Ask AI Claude ChatGPT

MandateOf returns the latest mandate of payer for this session address.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.MandateOf(,)"

Result

MandatesOf

func MandatesOf(payer address, page int) []MandateInfo
Ask AI Claude ChatGPT

MandatesOf lists a payer's mandates (all states), newest first.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.MandatesOf(,)"

Result

PayingSupporters

func PayingSupporters(planID uint64, from int) ([]MandateInfo, int)
Ask AI Claude ChatGPT

PayingSupporters lists a plan's supporters the way its gnoweb page does: mandates that have paid at least once and are active now, newest first, at most PageSize per call. Pass from = -1 for the newest; the second result is where to continue. A client must stop when it is -1 (the list is exhausted): -1 passed back in starts again from the newest, so a client that feeds the cursor back unchecked loops for ever. Each call walks at most WalkLimit entries and looks up at most ScanLimit of them, so a call may return fewer than PageSize (even none) and still a cursor.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.PayingSupporters(,)"

Result

SupportersOf

func SupportersOf(planID uint64, page int) []MandateInfo
Ask AI Claude ChatGPT

SupportersOf lists a plan's active mandates (not cancelled, replaced or expired), oldest first. Page n covers entries (n-1)*PageSize to n*PageSize-1 of the plan's list, so a page may hold fewer rows than PageSize; inactive ones are on the payers' own pages.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.SupportersOf(,)"

Result

GetPayee

func GetPayee(payee address) (PayeeInfo, bool)
Ask AI Claude ChatGPT

GetPayee returns a payee's totals and collector key.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.GetPayee()"

Result

GetPlan

func GetPlan(id uint64) (PlanInfo, bool)
Ask AI Claude ChatGPT

GetPlan returns the plan with this id.

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.GetPlan()"

Result

Plans

func Plans(page int) []PlanInfo
Ask AI Claude ChatGPT

Plans lists all plans, newest first, PageSize per page (page 1 first).

Param

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.Plans()"

Result

PlansOf

func PlansOf(payee address, page int) []PlanInfo
Ask AI Claude ChatGPT

PlansOf lists a payee's plans, oldest first.

Params

Command

gnokey query vm/qeval -remote "https://rpc.onyx.testnets.gno.land" -data "gno.land/r/g1llc3lq3zmjtjdk29dk52munrzxt5ne746cl7r8/mandate.PlansOf(,)"

Result

Gno Expression Evaluator

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