# `gno.land/p/moul/x/daily/ratelimit/v0`
**Deterministic token-bucket rate limiter** — a port of `golang.org/x/time/rate`
with the wall clock replaced by a caller-supplied monotonic tick (on-chain, the
block height).
A `Limiter` owns a set of per-key token buckets sharing one `rate`/`burst`
config. Each bucket refills at `rate` tokens per tick up to `burst`; the caller
picks what a key is (typically an address) and passes the current tick on every
call. Pure integer/float math over persistent avl state — no chain imports, no
ambient state, fully replayable.
```go
import "gno.land/p/moul/x/daily/ratelimit/v0"
l := ratelimit.New(0.5, 5.0) // 0.5 tokens/tick, capacity 5
l.Allow("g1caller", height) // consume one token; false if empty
l.AllowN("g1caller", height, 3) // consume 3 atomically; false if <3
l.Tokens("g1caller", height) // read-only balance (whole tokens)
```
**Live demo:** [`r/moul/x/daily/ratelimitdemo`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/ratelimitdemo/v0)
· render it at [`/r/moul/x/daily/ratelimitdemo/v0`](https://gno.land/r/moul/x/daily/ratelimitdemo/v0).
<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->
---
Part of **[moul/gno-contracts](https://github.com/moul/gno-contracts)** — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.
**Dependency graph:**

> 🧪 **Highly experimental — potentially vibe-coded.** Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: [DISCLAIMER](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).
<!-- END GNOCONTRACTS FOOTER -->
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.