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

patron/v0 package

Overview

Package patron is recurring support for a builder, on chain.

A creator opens a plan with a price per period and a period measured in blocks. A supporter attaches ugnot to Subscribe and buys whole periods of it. Anybody can ask at any height whether a given address is still active, which is the one question a tip cannot answer.

There is no cron on chain, so a renewal is a pull and not a push

Nothing in this realm can charge anybody. A renewal happens because the supporter sends another payment, never because a timer fired: there is no scheduler here, and there is no way to write one, since a native coin cannot be pulled at all. A reader arriving from web2 expects a standing mandate on a card and there is nothing of the kind, anywhere on this chain.

What this adds over the tip jar

gno.land/r/moul/x/daily/tipjar is the one-shot version and is already live: one payment, a leaderboard, and then nothing. The recurrence is the whole difference. A plan has a price and a period, a payment buys whole periods of it, renewing early never discards time already paid for, and the realm answers "is this address active right now" at any height. It is the one app in the x/social family that produces a recurring write rather than a one-off.

Earnings are credited at payment time, not streamed

The creator can withdraw the full price the instant it is paid. A supporter who stops being active is NOT refunded, and no part of a paid period ever comes back. That is a deliberate v0 limitation: escrowed streaming, where the creator claims only what has elapsed and the supporter cancels and reclaims the rest, needs a claim schedule and a refund path, and that is a larger realm than this one rather than a flag on it.

Money leaves by pull

Both halves of what this realm owes, a creator's earnings and a supporter's change, land in one credit ledger and leave through Withdraw. The credit is zeroed before any coin moves, and the realm never loops over payees: one unpayable address would otherwise fail the whole batch and hand a griefer a cheap denial of service.

v0 ships no token

Deliberately, and the README says why: a creator coin minted per period paid is easy, and the sink is not, because what it would be redeemed for is a promise made off chain.

Functions

Close

func Close(cur realm, planID int64)

Close stops a plan taking new subscriptions. Creator only.

Everything already paid for runs to its own paid-through height. Closing a plan is not a way to take a period back.

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/patron/v0" -func "Close" -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/patron/v0" -func "Close" -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() int

Count is how many plans exist.

Command

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

Result

CreditOf

func CreditOf(addr address) int64

CreditOf is what addr can withdraw right now.

Param

Command

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

Result

EarnedBy

func EarnedBy(creator address) int64

EarnedBy is the lifetime ugnot credited to creator across every plan, whether or not it has been withdrawn.

Param

Command

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

Result

IsActive

func IsActive(planID int64, who address) bool

IsActive reports whether who is paid up on this plan at the current height.

Active means now < paidThrough, strictly: an address paid through height h is active at h-1 and not at h.

Params

Command

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

Result

Open

func Open(cur realm, title, description string, pricePerPeriod, periodBlocks int64) int64

Open creates a plan and returns its id. Anyone may open one, and opening one costs nothing beyond gas and the storage deposit.

pricePerPeriod is in ugnot and must be at least one: a free plan is a tip jar, not a subscription. periodBlocks is a period in BLOCKS, bounded both ways by the engine, because height is the clock consensus agrees on and a block timestamp is not something to build a billing cliff out of.

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/patron/v0" -func "Open" -args $'' -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/patron/v0" -func "Open" -args $'' -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
  

PaidThrough

func PaidThrough(planID int64, who address) int64

PaidThrough is the height who stops being active at on this plan, or zero if they never paid.

Params

Command

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

Result

Render

func Render(path string) string

Render routes two views: the index and one plan.

Param

Command

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

Result

Reopen

func Reopen(cur realm, planID int64)

Reopen lets a closed plan take subscriptions again. Creator only.

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/patron/v0" -func "Reopen" -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/patron/v0" -func "Reopen" -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
  

Subscribe

func Subscribe(cur realm, planID int64) int64

Subscribe buys whole periods on a plan with the ugnot attached to the call, and returns the caller's new paid-through height.

Attach the coins with -send: a payment short of one period is refused, and the remainder under one period is credited back to the caller rather than kept, so an overpayment is change and never a silent fee. Take it back with Withdraw.

It has to be called directly by a user, and that is not a style choice

The envelope is what the SIGNER attached to the transaction. A realm the user called has already received those coins itself, and could then call in here as many times as it liked against one payment, so the caller is checked before the envelope is read. The same property means a realm cannot forward an envelope it was handed (`NewBanker` requires the previous frame to be a user call), and that `maketx run` cannot reach this function at all, because a run script is itself a code realm. Use `maketx call -send`.

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/patron/v0" -func "Subscribe" -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/patron/v0" -func "Subscribe" -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
  

SupporterCount

func SupporterCount(planID int64) int

SupporterCount is how many distinct addresses have ever paid this plan, active or not.

Param

Command

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

Result

TotalOwed

func TotalOwed() int64

TotalOwed is everything this realm owes, which is what it must keep in reserve at its own address.

Command

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

Result

Withdraw

func Withdraw(cur realm) int64

Withdraw pays the caller everything this realm owes them and returns the amount: a creator's earnings, a supporter's change, or both at once.

The credit is zeroed by the engine before a coin moves, so a recipient that calls straight back in finds nothing left 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/patron/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/patron/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