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

ratelimitdemo/v0 package

Overview

Package ratelimitdemo is a small on-chain demo of the token-bucket rate limiter provided by the p/moul/x/daily/ratelimit(/p/moul/x/daily/ratelimit/v0) library.

It holds a single package-level ratelimit.Limiter and wires it to the chain: the tick is runtime.ChainHeight() and each caller is keyed by its address (unsafe.PreviousRealm().Address()). It contains no limiter logic of its own — refill/consume math all lives in the library.

Function

Tokens

func Tokens(addr address) int

Tokens reports how many whole tokens `addr` has available at the current block height, without mutating any state.

Param

Command

gnokey query vm/qeval -remote "https://rpc.gno.land" -data "gno.land/r/moul/x/daily/ratelimitdemo/v0.Tokens()"

Result