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

v0 source realm

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

Readme View source

gno.land/r/moul/x/social/patron/v0

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; anyone can ask at any height whether a given address is still active.

Open(title, description, pricePerPeriod, periodBlocks) -> planID
Subscribe(planID)            payable, returns the new paid-through height
Close(planID) / Reopen(planID)   creator only
Withdraw()                   earnings and change leave the same way
IsActive(planID, who)        the one question a tip jar cannot answer

There is no cron on chain, so a renewal is a pull and not a push. Nothing here can charge anybody: a renewal happens because the supporter sends another payment, never because a timer fired, and a native coin cannot be pulled at all. A reader arriving from web2 expects a standing mandate on a card; there is nothing of the kind anywhere on this chain, and that is the single most important sentence on this page.

r/moul/x/daily/tipjar is the one-shot version and is already live. The recurrence is the whole difference, and it makes this the one app in the x/social family that produces a recurring write rather than a one-off.

Renewing early never discards time already paid for: an extension runs from whichever is later, now or the current paid-through. Renewing after lapsing runs from now. A payment short of one period is refused rather than partially credited, and the remainder under a whole period is credited back to the supporter, because keeping it would be a silent fee and a subscription realm is exactly where a silent fee must not be.

Earnings are credited at payment time, not streamed. The creator can withdraw the full price the instant it is paid, and a supporter who stops being active is not refunded. That is a deliberate v0 limitation: escrowed streaming, where the creator claims only what has elapsed and the supporter reclaims the rest, needs a claim schedule and a refund path, which is a larger realm rather than a flag on this one.

Both halves of what the realm owes, a creator's earnings and a supporter's change, land in one credit ledger and leave through Withdraw, which zeroes the credit before any coin moves. EarnedBy and CreditOf are deliberately different numbers: lifetime credited against withdrawable now.

Subscribe is payable and therefore has to be called directly by a user. A realm called by another realm cannot forward the envelope and maketx run cannot reach a payable function at all, so there is no path where another contract subscribes on somebody's behalf.

The token question

v0 ships none, and the condition for yes is written down in the engine's README: a creator coin is easy to mint and has no sink, because what a supporter would redeem it for is a promise made off chain. What would change the answer is a redeem the chain can enforce. The slot it would drop into is p/moul/x/social/coin, a GRC20 that refuses to exist until its mint rule, its sink and its buyer are declared.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

On mainnet: deployment status transactions unique callers deployed revision

Dependency graph:

gno.land/r/moul/x/social/patron/v0 dependency graph

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.

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 13

func Close

crossing Action
1func Close(cur realm, planID int64)
source

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.

func CreditOf

Action
1func CreditOf(addr address) int64
source

CreditOf is what addr can withdraw right now.

func EarnedBy

Action
1func EarnedBy(creator address) int64
source

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

func IsActive

Action
1func IsActive(planID int64, who address) bool
source

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.

func Open

crossing Action
1func Open(cur realm, title, description string, pricePerPeriod, periodBlocks int64) int64
source

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.

func PaidThrough

Action
1func PaidThrough(planID int64, who address) int64
source

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

func Render

1func Render(path string) string
source

Render routes two views: the index and one plan.

func Reopen

crossing Action
1func Reopen(cur realm, planID int64)
source

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

func Subscribe

crossing Action
1func Subscribe(cur realm, planID int64) int64
source

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`.

func SupporterCount

Action
1func SupporterCount(planID int64) int
source

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

func TotalOwed

Action
1func TotalOwed() int64
source

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

func Withdraw

crossing Action
1func Withdraw(cur realm) int64
source

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.

Imports 13

Source Files 5