func Authorized
ActionAuthorized reports whether principal may exercise capability id for the given coin amount right now — the check a target realm runs before acting. It never mutates state or consumes a use.
Package capwallet issues narrow, bounded, revocable capabilities to agents — instead of handing an agent a wallet key...
Package capwallet issues narrow, bounded, revocable capabilities to agents — instead of handing an agent a wallet key and hoping its prompt stays safe.
The demo makes three ideas that are usually conflated stand apart:
A capability is the third thing: a least-privilege grant with a ceiling, an expiry, a use counter and a kill switch. Other realms consult Authorized() before honoring an agent action; the granter revokes with one call the instant something looks wrong.
Authorized reports whether principal may exercise capability id for the given coin amount right now — the check a target realm runs before acting. It never mutates state or consumes a use.
Count returns the number of capabilities issued.
Exercise consumes one use of a capability. Only the principal may call it, and every bound is checked: not revoked, not expired, uses remaining, and coins within the ceiling. On success the use is recorded and the counter decremented.
Grant issues a capability. The caller becomes its granter and can revoke it later. validUntil is an absolute block height (0 = no expiry).
Render shows all capabilities, or one capability's detail + usage at :<id>.
Revoke disables a capability immediately. Only the granter may revoke.
Get returns a copy of a capability.
1type Capability struct {
2 ID uint64
3 Granter address
4 Principal address // the only address that may exercise it
5 TargetRealm string // realm the capability is scoped to
6 Function string // function the capability authorizes
7 MaxCoins int64 // per-exercise ceiling in ugnot (0 = none allowed)
8 ValidUntil int64 // block height after which it expires (0 = never)
9 RemainingUses uint32 // exercises left (0 = exhausted)
10 ArgsPolicy string // human-readable note on allowed arguments
11 Revoked bool
12 GrantedAt int64
13 Uses []Use
14}Capability is a least-privilege grant from a granter to a principal.
Use records one exercise of a capability.