Cosmic Bull

coinio

gno.land/p/g1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39/coinio on gno.land mainnet
gno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/coinio on onyx-1 testnet

pure packageprimitivevalue-handlinglive on mainnetlive on onyx-1

Receive, pay out and sweep coins without rewriting the checks each time.

Every realm that holds funds needs the same payment guards, so they are written once here and audited once.

In detail curated

Native-coin I/O for realms: the Receive receipt-guard trio (caller shape, envelope, denomination), Payout via RealmSend, reserve-protected Sweep, and HeldAt.

Use it

A pure package has no state and no transactions: you use it by importing it.

Import it

on gno.land mainnet

import "gno.land/p/g1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39/coinio"

on onyx-1 testnet

import "gno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/coinio"

The path is the address: there is no package manager, nothing to add to a manifest and no version to pin, so the package you compile against is the one the chain runs. It differs per chain because the namespace in it is the deploying account's.

Called from real code

Not an example written for this page. These lines are quoted from auction, a deployed package in this portfolio that imports this one as coinio, out of the committed file whose sha256 onyx-1 testnet attested. They compile because they are compiled.

bidder, amount := coinio.Receive(0, cur, Denom)
onyx/r/auction/auction.gno line 238, onyx-1 testnet
coinio.Payout(0, cur, caller, Denom, amount)
onyx/r/auction/auction.gno line 337, onyx-1 testnet
coinio.Payout(0, cur, feeRecipient, Denom, amount)
onyx/r/auction/auction.gno line 391, onyx-1 testnet

Deployments

Deployed on 2 chains from the same source. The bytes are identical — one digest, ea9d467d380ff297…, on both — so the API below is the API on either. Everything that is not the bytes differs per chain and is stated per chain: the import path, the namespace, the transaction, the height, the cost, and which files the chain holds.

gno.land mainnet gnoland-1

RenderedSourceCall builder

chain-attested
Import pathgno.land/p/g1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39/coinio
Namespaceg1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39
Deployed at height323,266
Deploy transaction7c1b494f65b77e9acc9a3f049c150bd112bd4d1825e88503e16a9bd1ca3605f0 look it up on the RPC
Deployerg1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39
Gas used9,793,648
Storagenot attested per package on this chain — see the limitations below
Files on chaincoinio.gno gnomod.toml
Deployed bytescoinio.gno — 5,685 bytes
sha256ea9d467d380ff2971695d452f96fe64ea46d847d094023f755edf5f79995b09d
Realm addressnone — A /p/ package is not a realm: it holds no state, custodies no coins and is never a transaction sender. The pkgPath derivation would still produce a value; recording one would name nothing.
Used byr/budgets, r/crowdfund, r/revshare, r/service_market, r/subscriptions, r/upkeep, r/vesting

Do not take the hash above on trust. $download returns the bytes gnoland-1 is actually running; this command fetches them and prints their digest, which should equal the one in the table:

curl -sS 'https://gno.land/p/g1qp5pt8cdq2f6kfdamn3yuxwg6quqnfpyewzz39/coinio$download&file=coinio.gno' | shasum -a 256

Expected: ea9d467d380ff2971695d452f96fe64ea46d847d094023f755edf5f79995b09d — 5,685 bytes. Use curl: the gno.land edges answer Python's default user-agent with HTTP 403.

onyx-1 testnet onyx-1

RenderedSourceCall builder

chain-attested
Import pathgno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/coinio
Namespaceg1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3
Deployed at height96,543
Deploy transaction6ad482fed77da2f6ab5ac882fdf17248e2af29e29c865bd3ddc1a7702e786c53 look it up on the RPC
Deployerg1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3
Gas used9,792,027
Storagenot attested per package on this chain — see the limitations below
Files on chaincoinio.gno gnomod.toml
Deployed bytescoinio.gno — 5,685 bytes
sha256ea9d467d380ff2971695d452f96fe64ea46d847d094023f755edf5f79995b09d
Realm addressnone — A /p/ package is not a realm: it holds no state, custodies no coins and is never a transaction sender. The pkgPath derivation would still produce a value; recording one would name nothing.
Used byr/auction, r/budgets, r/crowdfund, r/deposits, r/invoices, r/loans, r/meters, r/netting, r/payroll, r/reimbursements, r/sealedbid, r/subscriptions

Do not take the hash above on trust. $download returns the bytes onyx-1 is actually running; this command fetches them and prints their digest, which should equal the one in the table:

curl -sS 'https://onyx.testnets.gno.land/p/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/coinio$download&file=coinio.gno' | shasum -a 256

Expected: ea9d467d380ff2971695d452f96fe64ea46d847d094023f755edf5f79995b09d — 5,685 bytes. Use curl: the gno.land edges answer Python's default user-agent with HTTP 403.

API

chain-derived 3 exported functions.

Read from vm/qdoc on gnoland-1. It describes the onyx-1 testnet deployment as well: the deployed bytes are identical on every chain here — one digest, ea9d467d380ff297… — and this site refuses to build a shared page for a package whose bytes differ across chains, so the same API is the API on each. The API is the only thing that carries across; every provenance fact above is per-chain.

This is a /p/ package: you import it, you do not call it in a transaction. gnoweb's $help shows only exported top-level functions, so the types and methods below do not appear there at all — which is why this reference exists.

Overview

Package coinio is the chain-facing coin plumbing that every value-holding realm on gno.land repeats: verified payment receipt, disciplined payout, and reserve-protected surplus sweeping. It was extracted from two audited, pearl-1-validated realms (vault and bounties) whose implementations of these mechanics were line-identical.

The package is PURE and STATELESS: it holds no balances, no roles, and no configuration; all state stays in the consuming realm (and its accounting package, e.g. feeledger). It emits no events — consumers emit their own. Every function either succeeds or panics, aborting the transaction: these are payment guards, and no failure here has a meaningful recovery path.

CAPABILITY CONTRACT: pure packages cannot declare crossing functions (a first `realm` parameter), so every coin-moving function here uses the canonical secondary-parameter shape `(_ int, rlm realm, ...)` — the same pattern as chain treasury packages. Pass 0 and your crossing entrypoint's own live `cur` (forwarded through non-crossing calls keeps it current). Each function asserts rlm.IsCurrent() before acting, so a stale, stored, or Previous() realm value fails closed (the designation-forgery guard secondary realm parameters require). Coins can only move FROM rlm.Address() — the calling realm itself — so no consumer can spend another realm's funds through this package.

AUTHORIZATION is the consumer's responsibility: coinio decides HOW coins move, never WHO may move them. Gate your entrypoints before calling in.

ORDERING CONTRACT (the one invariant coinio cannot enforce): debit your own accounting BEFORE calling Payout or Sweep (checks-effects-interactions). A panic inside coinio aborts the whole transaction, reverting your debit with it — that is what makes the debit-first order safe.

Imports

Functions

HeldAt

func HeldAt(addr address, denom string) int64

HeldAt returns the amount of denom held at addr. Read-only; usable from views and Render without a realm capability.

Payout

func Payout(_ int, rlm realm, to address, denom string, amount int64)

Payout sends amount of denom from the calling realm's own address to `to`. DEBIT YOUR ACCOUNTING FIRST — a panic here (or anywhere later in the transaction) reverts the debit together with the send.

Sweep

func Sweep(_ int, rlm realm, to address, denom string, reserve int64) int64

Sweep sends the surplus of a single denomination — everything the calling realm holds above `reserve` — to `to`, and returns the swept amount. Pass your total liabilities as the reserve for the denom your accounting tracks, and 0 for foreign denominations. Panics if there is no positive surplus, so reserved funds are untouchable by construction. One denomination per call keeps the operation gas- bounded regardless of how many junk denoms third parties force-send.


Doc text is reproduced as vm/qdoc returns it. The node markdown-escapes doc comments, so a bracket or angle bracket may carry a backslash the committed source does not have. The source itself is at source and in this repository.

Dependencies

A first-party dependency is imported from the SAME chain's namespace, so each deployment above depends on that chain's copy — the paths differ even where the code does not.

chain-attested
Importschain, chain/banker, chain/runtime/unsafe
First-party dependenciesnone

Known limitations

Recorded by the people who built and deployed it. This list is deliberately not empty where honesty costs something.

curated

gno.land mainnet

onyx-1 testnet

The manifest records no limitation for this package on onyx-1. That is an absence of a recorded caveat, not a proof that none exists — the deployment record for that chain carries its own "what was NOT verified live" section.

Source

Source file (gnoland-1)mainnet/p/coinio/coinio.gno at commit c2e10d17ffbf in the project repository (not public — the digest command above is the check that needs no repository)
Matches the deployed bytes (gnoland-1)yes — byte-identical
Source file (onyx-1)onyx/p/coinio/coinio.gno at commit c2e10d17ffbf in the project repository (not public — the digest command above is the check that needs no repository)
Matches the deployed bytes (onyx-1)yes — byte-identical