Skip to content Search Apps Documentation Source Content 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.

meters state

Back to all declarations

Denom

untyped string

Denom is the only asset this realm accepts.

Value

"ugnot"

MaxFeeBps

int64

MaxFeeBps is the hard protocol-fee cap: 1000 bps = 10%.

Value

1000

MeterActive

untyped string

Meter status values.

Value

"active"

MeterRetired

untyped string

Meter status values.

Value

"retired"

EnrollActive

untyped string

Enrollment status values. Exited is terminal.

Value

"active"

EnrollExited

untyped string

Enrollment status values. Exited is terminal.

Value

"exited"

MaxTitleLen

untyped bigint

Input bounds.

Value

(80 <untyped> bigint)

MaxUnitLen

untyped bigint

Input bounds.

Value

(24 <untyped> bigint)

MinUnitPrice

int64

Input bounds.

Value

1

MaxUnitPrice

int64

// 1000 GNOT per unit

Value

1000000000

MinPeriodBlocks

int64

Input bounds.

Value

10

MaxPeriodBlocks

int64

Input bounds.

Value

7500000

MaxMetersPerProvider

untyped bigint

Input bounds.

Value

(20 <untyped> bigint)

MaxEnrollmentsPerConsumer

untyped bigint

Input bounds.

Value

(100 <untyped> bigint)

RenderLimit

untyped bigint

Input bounds.

Value

(20 <untyped> bigint)

meter

type

Value

meters.meter

enrollment

type

Value

meters.enrollment

admin

.uverse.address

// may set fee, fee recipient, stage successor

Value

<gnolang.StringValue>

pendingAdmin

.uverse.address

// staged by TransferAdmin, completes via AcceptAdmin

Value

<zero>

feeRecipient

.uverse.address

// may withdraw fees and sweep surplus

Value

<gnolang.StringValue>

feeBps

int64

// fee snapshotted into NEW meters

Value

0

self

.uverse.address

// this realm's address, captured at deploy

Value

<gnolang.StringValue>

nextMeter

int64

Value

2

nextEnr

int64

Value

4

enrollments

*v0.Tree

// padID(id) -> \*enrollment

Open
OID
040f01…bfaa:14
enrollments details

Inspect pointer

activeByKey

*v0.Tree

// padID(meterID)|consumer -> int64 enroll id, while Active

Open
OID
040f01…bfaa:17
activeByKey details

Inspect pointer

providerNum

*v0.Tree

// address -> \*int64, live meters per provider

Open
OID
040f01…bfaa:20
providerNum details

Inspect pointer

consumerNum

*v0.Tree

// address -> \*int64, Active enrollments per consumer

Open
OID
040f01…bfaa:23
consumerNum details

Inspect pointer

CreateMeter

func(title string, unit string, unitPrice int64, periodBlocks int64, edges string, rates string, maxFeeBps int64) int64

CreateMeter publishes a meter and returns its id. No coins are accepted; the storage deposit the caller pays is the anti-spam. edges and rates are comma-separated int64 lists building the tiers.Schedule over the ugnot BASE (units × unitPrice): len(rates) == len(edges)+1, each rate in \[0, 10000] ten-thousandths of list price. "" edges with rates "10000" is a flat meter. The current protocol fee is snapshotted in and must not exceed maxFeeBps, the ceiling the provider signed for — pass MaxFeeBps to accept any legal fee. Meters are immutable once created: price, period or schedule changes are a new meter, so nothing a consumer agreed to can move underneath them.

Open
OID
040f01…bfaa:32
CreateMeter details

Inspect func

RetireMeter

func(meterID int64)

RetireMeter stops NEW enrollments and NEW usage on the caller's own meter. Existing enrollments keep their funds paths whole: pending usage still settles, deposits stay withdrawable, Exit still refunds. The provider's meter slot frees. Terminal.

Open
OID
040f01…bfaa:33
RetireMeter details

Inspect func

Record

func(enrollID int64, units int64)

Record asserts that the enrollment's consumer used units more units of the meter's service in the CURRENT period. Provider only. Fail-closed on the deposit bound: if charging the period's new total at the enrollment's schedule would exceed the deposited balance, the whole posting is refused — never clipped, because a clipped assertion is a wrong assertion with the same signature as a right one. Any elapsed period settles first, so the bound is always measured against the balance that will actually back this period.

Open
OID
040f01…bfaa:34
Record details

Inspect func

Enroll

func(meterID int64) int64

Enroll opens an enrollment on a meter for the caller, with any attached coins credited as the initial deposit. One active enrollment per (meter, consumer); Exit frees the slot. Terms (price, schedule, period, fee) are copied in at this moment and never re-read.

Open
OID
040f01…bfaa:35
Enroll details

Inspect func

Deposit

func(enrollID int64)

Deposit adds the attached coins to the caller's own enrollment deposit. Elapsed usage settles first, so a top-up lands on a current balance.

Open
OID
040f01…bfaa:36
Deposit details

Inspect func

WithdrawDeposit

func(enrollID int64, amount int64)

WithdrawDeposit returns amount of the caller's own enrollment deposit. The current period's pending charge stays covered: withdrawable is balance − Charge(current usage), so a provider's already-recorded usage can never be defunded. Elapsed usage settles first.

Open
OID
040f01…bfaa:37
WithdrawDeposit details

Inspect func

Exit

func(enrollID int64)

Exit closes the caller's own enrollment: elapsed periods settle, the CURRENT period's recorded usage settles immediately (the provider served it; exiting is not an escape from it), the remaining deposit refunds in full, and the slot frees. Terminal.

Open
OID
040f01…bfaa:38
Exit details

Inspect func

Settle

func(enrollID int64)

Settle settles any fully-elapsed period of an enrollment. Permissionless by design — like the sibling realms' valves, no settlement's liveness may depend on either party showing up. No coins may ride on it, and calling it on an enrollment with nothing elapsed is a refused no-op so the event stream never carries empty settlements.

Open
OID
040f01…bfaa:39
Settle details

Inspect func

Claim

func(amount int64)

Claim sends amount ugnot of the caller's claimable balance back to the caller. Providers earn into this balance at every settlement.

Open
OID
040f01…bfaa:40
Claim details

Inspect func

ClaimAll

func()

ClaimAll sends the caller's entire claimable balance back to the caller. Fails if there is nothing to claim.

Open
OID
040f01…bfaa:41
ClaimAll details

Inspect func

WithdrawFees

func()

WithdrawFees sends the accrued fee pot to the fee recipient. Only the fee recipient may call it, and only the pot moves.

Open
OID
040f01…bfaa:42
WithdrawFees details

Inspect func

SweepDenom

func(denom string)

SweepDenom recovers out-of-band coins (sent by raw bank transfer, outside any entrypoint) to the fee recipient. For the ledger denom the reserve is Liabilities() — user balances and the fee pot are structurally unreachable. Fee recipient only.

Open
OID
040f01…bfaa:43
SweepDenom details

Inspect func

SetFeeBps

func(bps int64)

SetFeeBps sets the protocol fee snapshotted into NEW meters. Admin only. No existing meter or enrollment moves.

Open
OID
040f01…bfaa:44
SetFeeBps details

Inspect func

SetFeeRecipient

func(recipient .uverse.address)

SetFeeRecipient points fee withdrawal and sweeps at recipient. Admin only.

Open
OID
040f01…bfaa:45
SetFeeRecipient details

Inspect func

TransferAdmin

func(successor .uverse.address)

TransferAdmin stages successor as the next admin; AcceptAdmin completes it. Two-step with consent — a one-step transfer bricked resources in two prior audits (service\_registry Y4, permission\_registry Y4).

Open
OID
040f01…bfaa:46
TransferAdmin details

Inspect func

AcceptAdmin

func()

AcceptAdmin completes a staged admin transfer. Pending admin only.

Open
OID
040f01…bfaa:47
AcceptAdmin details

Inspect func

PriceOf

func(meterID int64, units int64) int64

PriceOf prices units of meter meterID at its schedule: the charge a period closing at exactly that usage would settle. The quote every consumer can take before enrolling and every provider can show beside an invoice.

Open
OID
040f01…bfaa:48
PriceOf details

Inspect func

PendingChargeOf

func(enrollID int64) int64

PendingChargeOf is the charge the enrollment's current recorded usage would settle at — what WithdrawDeposit holds back.

Open
OID
040f01…bfaa:49
PendingChargeOf details

Inspect func

BalanceOf

func(enrollID int64) int64

BalanceOf is an enrollment's deposited balance as the LEDGER holds it — including a not-yet-settled elapsed period's charge; net view: subtract PendingChargeOf.

Open
OID
040f01…bfaa:50
BalanceOf details

Inspect func

ChargeHeadroomOf

func(enrollID int64) int64

ChargeHeadroomOf is how much MORE charge the current period could absorb before Record's deposit bound refuses: balance − pending charge.

Open
OID
040f01…bfaa:51
ChargeHeadroomOf details

Inspect func

MeterInfo

func(meterID int64) (provider .uverse.address, title string, unit string, unitPrice int64, periodBlocks int64, meterFeeBps int64, status string, lifetimeEnrollments int64)
Open
OID
040f01…bfaa:52
MeterInfo details

Inspect func

ScheduleOf

func(meterID int64) (edges []int64, rates []int64)

ScheduleOf returns a meter's schedule as its edge and rate slices.

Open
OID
040f01…bfaa:53
ScheduleOf details

Inspect func

EnrollInfo

func(enrollID int64) (meterID int64, consumer .uverse.address, provider .uverse.address, status string, startHeight int64, usage int64, usagePeriod int64, settledPeriods int64)
Open
OID
040f01…bfaa:54
EnrollInfo details

Inspect func

ActiveEnrollID

func(meterID int64, consumer .uverse.address) (int64, bool)

ActiveEnrollID resolves the caller-free (meter, consumer) index.

Open
OID
040f01…bfaa:55
ActiveEnrollID details

Inspect func

CurrentPeriodOf

func(enrollID int64) int64

CurrentPeriodOf is the period index now open for an enrollment.

Open
OID
040f01…bfaa:56
CurrentPeriodOf details

Inspect func

PendingAdmin

func() .uverse.address
Open
OID
040f01…bfaa:58
PendingAdmin details

Inspect func

FeeRecipient

func() .uverse.address
Open
OID
040f01…bfaa:59
FeeRecipient details

Inspect func

NumEnrollments

func() int64
Open
OID
040f01…bfaa:62
NumEnrollments details

Inspect func

ClaimableOf

func(a .uverse.address) int64
Open
OID
040f01…bfaa:66
ClaimableOf details

Inspect func

currentPeriod

func(e *meters.enrollment) int64

currentPeriod is the index of the period open at the chain head.

Open
OID
040f01…bfaa:70
currentPeriod details

Inspect func

chargeFor

func(e *meters.enrollment, usage int64) int64

chargeFor prices usage units at the enrollment's copied terms.

Open
OID
040f01…bfaa:71
chargeFor details

Inspect func

settleElapsed

func(e *meters.enrollment)

settleElapsed settles the usage accumulator if its period has closed, then re-anchors the accumulator on the current period. Exact because usage can only ever belong to one period: periods between usagePeriod and now had no recorded usage and so owe zero.

Open
OID
040f01…bfaa:72
settleElapsed details

Inspect func

settleUsage

func(e *meters.enrollment)

settleUsage charges the accumulator where it stands and moves the funds: enrollment deposit -> provider claimable, protocol fee split at the enrollment's snapshotted bps. Record's deposit bound is what guarantees the withdrawal cannot fail; if that invariant were ever broken the ledger's own refusal aborts the whole transaction rather than under-settling.

Open
OID
040f01…bfaa:73
settleUsage details

Inspect func

mustGetMeter

func(id int64) *meters.meter
Open
OID
040f01…bfaa:74
mustGetMeter details

Inspect func

mustGetEnrollment

func(id int64) *meters.enrollment
Open
OID
040f01…bfaa:75
mustGetEnrollment details

Inspect func

enrollKey

func(id int64) string

enrollKey is the ledger account an enrollment's deposit lives under. It cannot collide with a provider's claimable account: addresses never start with '#'.

Open
OID
040f01…bfaa:76
enrollKey details

Inspect func

assertNoSend

func()

assertNoSend refuses coins on every non-payable entrypoint. Reads the ORIGIN envelope, so a transaction that attached coins anywhere is refused even if an intermediary consumed them.

Open
OID
040f01…bfaa:77
assertNoSend details

Inspect func

counter

func(tree *v0.Tree, a .uverse.address) *int64

counter returns the live-count cell for a, creating it at zero.

Open
OID
040f01…bfaa:78
counter details

Inspect func

decCounter

func(tree *v0.Tree, a .uverse.address)

decCounter decrements a's live count and removes the cell at zero — the index must not accumulate dead keys (service\_registry's lesson).

Open
OID
040f01…bfaa:79
decCounter details

Inspect func

parseInt64List

func(s string, max int, what string) []int64

parseInt64List parses a comma-separated int64 list, bounding the element count BEFORE materialising values so a thousand-element string dies on count, not memory (r/receivables' bounding argument). "" is the empty list.

Open
OID
040f01…bfaa:80
parseInt64List details

Inspect func

trimSpaces

func(s string) string
Open
OID
040f01…bfaa:81
trimSpaces details

Inspect func

addChecked

func(a int64, b int64) (int64, bool)

addChecked / mulChecked are int64 overflow-checked arithmetic. Written here rather than imported because they are two lines each and the house keeps its payment arithmetic visible at the call site.

Open
OID
040f01…bfaa:82
addChecked details

Inspect func

mulChecked

func(a int64, b int64) (int64, bool)
Open
OID
040f01…bfaa:83
mulChecked details

Inspect func

Render

func(path string) string

Render shows the catalog at "", a meter at "meter/\<id>", an enrollment at "enroll/\<id>". Every user string is sanitized; every list is bounded by RenderLimit with the bound stated.

Open
OID
040f01…bfaa:86
Render details

Inspect func

renderMeter

func(idStr string) string
Open
OID
040f01…bfaa:88
renderMeter details

Inspect func

renderEnrollment

func(idStr string) string
Open
OID
040f01…bfaa:89
renderEnrollment details

Inspect func

hasPrefix

func(s string, p string) bool
Open
OID
040f01…bfaa:90
hasPrefix details

Inspect func
Denom : untyped string ="ugnot"
MaxFeeBps : int64 =1000
MeterActive : untyped string ="active"
MeterRetired : untyped string ="retired"
EnrollActive : untyped string ="active"
EnrollExited : untyped string ="exited"
MaxTitleLen : untyped bigint =(80 <untyped> bigint)
MaxUnitLen : untyped bigint =(24 <untyped> bigint)
MinUnitPrice : int64 =1
MaxUnitPrice : int64 =1000000000
MinPeriodBlocks : int64 =10
MaxPeriodBlocks : int64 =7500000
MaxMetersPerProvider : untyped bigint =(20 <untyped> bigint)
MaxEnrollmentsPerConsumer : untyped bigint =(100 <untyped> bigint)
RenderLimit : untyped bigint =(20 <untyped> bigint)
meter : type =meters.meter
enrollment : type =meters.enrollment
admin : .uverse.address =<gnolang.StringValue>
pendingAdmin : .uverse.address =<zero>
feeRecipient : .uverse.address =<gnolang.StringValue>
feeBps : int64 =0
self : .uverse.address =<gnolang.StringValue>
nextMeter : int64 =2
nextEnr : int64 =4
metersT : *v0.Tree Inspect
enrollments : *v0.Tree Inspect
activeByKey : *v0.Tree Inspect
providerNum : *v0.Tree Inspect
consumerNum : *v0.Tree Inspect
ledger : *feeledger.Ledger Inspect
init.30 : func() Inspect
CreateMeter : func(title string, unit string, unitPrice int64, periodBlocks int64, edges string, rates string, maxFeeBps int64) int64 Inspect
RetireMeter : func(meterID int64) Inspect
Record : func(enrollID int64, units int64) Inspect
Enroll : func(meterID int64) int64 Inspect
Deposit : func(enrollID int64) Inspect
WithdrawDeposit : func(enrollID int64, amount int64) Inspect
Exit : func(enrollID int64) Inspect
Settle : func(enrollID int64) Inspect
Claim : func(amount int64) Inspect
ClaimAll : func() Inspect
WithdrawFees : func() Inspect
SweepDenom : func(denom string) Inspect
SetFeeBps : func(bps int64) Inspect
SetFeeRecipient : func(recipient .uverse.address) Inspect
TransferAdmin : func(successor .uverse.address) Inspect
AcceptAdmin : func() Inspect
PriceOf : func(meterID int64, units int64) int64 Inspect
PendingChargeOf : func(enrollID int64) int64 Inspect
BalanceOf : func(enrollID int64) int64 Inspect
ChargeHeadroomOf : func(enrollID int64) int64 Inspect
MeterInfo : func(meterID int64) (provider .uverse.address, title string, unit string, unitPrice int64, periodBlocks int64, meterFeeBps int64, status string, lifetimeEnrollments int64) Inspect
ScheduleOf : func(meterID int64) (edges []int64, rates []int64) Inspect
EnrollInfo : func(enrollID int64) (meterID int64, consumer .uverse.address, provider .uverse.address, status string, startHeight int64, usage int64, usagePeriod int64, settledPeriods int64) Inspect
ActiveEnrollID : func(meterID int64, consumer .uverse.address) (int64, bool) Inspect
CurrentPeriodOf : func(enrollID int64) int64 Inspect
Admin : func() .uverse.address Inspect
PendingAdmin : func() .uverse.address Inspect
FeeRecipient : func() .uverse.address Inspect
FeeBps : func() int64 Inspect
NumMeters : func() int64 Inspect
NumEnrollments : func() int64 Inspect
UsersTotal : func() int64 Inspect
FeesAccrued : func() int64 Inspect
Liabilities : func() int64 Inspect
ClaimableOf : func(a .uverse.address) int64 Inspect
Held : func() int64 Inspect
Address : func() .uverse.address Inspect
Height : func() int64 Inspect
currentPeriod : func(e *meters.enrollment) int64 Inspect
chargeFor : func(e *meters.enrollment, usage int64) int64 Inspect
settleElapsed : func(e *meters.enrollment) Inspect
settleUsage : func(e *meters.enrollment) Inspect
mustGetMeter : func(id int64) *meters.meter Inspect
mustGetEnrollment : func(id int64) *meters.enrollment Inspect
enrollKey : func(id int64) string Inspect
assertNoSend : func() Inspect
counter : func(tree *v0.Tree, a .uverse.address) *int64 Inspect
decCounter : func(tree *v0.Tree, a .uverse.address) Inspect
parseInt64List : func(s string, max int, what string) []int64 Inspect
trimSpaces : func(s string) string Inspect
addChecked : func(a int64, b int64) (int64, bool) Inspect
mulChecked : func(a int64, b int64) (int64, bool) Inspect
padID : func(id int64) string Inspect
itoa : func(n int64) string Inspect
Render : func(path string) string Inspect
renderHome : func() string Inspect
renderMeter : func(idStr string) string Inspect
renderEnrollment : func(idStr string) string Inspect
hasPrefix : func(s string, p string) bool Inspect