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

permbook_demo package

Overview

Package permbook_demo is the reference consumer for the permbook permission primitive. It exists to make permbook's central claim falsifiable on a live chain.

That claim is: a permission revoked in transaction N is refused in transaction N+1. A pure package cannot demonstrate this — a vm/qeval is a single ephemeral evaluation and nothing it writes survives it. Only a realm, called across several transactions, can show a grant taking effect and then a revoke taking it away. So this realm is not a decoration on the primitive; it is the experiment.

What it does

Two permission-gated actions, deliberately trivial so that the only interesting thing about them is the gate:

  • bump — increments a counter and records who did it
  • notice — replaces a short public notice

Neither action is reachable without the corresponding permission. The deployer is the book's admin and is the only account that may grant or revoke. Holding "bump" confers no authority over the book itself: a holder cannot grant, cannot revoke, and cannot nominate. That separation is the property being demonstrated.

How it wires permbook correctly

This realm is also the worked example of permbook's consumer contract:

  • every permbook mutator is called from a CROSSING entrypoint, passing that entrypoint's own cur, so the principal permbook resolves is this realm's immediate caller (contract 1);
  • the *Book is an unexported package-level var and is never returned across a realm boundary (contract 2);
  • Has is asked about an address this realm derived itself from cur.Previous().Address(), never about a parameter (contract 3);
  • the limits are chosen once, at init, and documented below (contract 4).

This realm holds no coins and imports no banker. Every crossing entrypoint rejects attached coins; the read views are non-crossing, which MsgCall will not dispatch to, so no transaction can attach coins to one.

Function

PermissionCount

func PermissionCount() int

PermissionCount returns how many distinct permissions currently exist.

Command

gnokey query vm/qeval -remote "https://rpc.pearl.testnets.gno.land" -data "gno.land/r/g1ut6uspuh73e02yauxpmyt8g3wwddaq8utagvm3/permbook_demo.PermissionCount()"

Result