A time-boxed, transferable membership NFT. An issuer sells passes priced per fixed period; buyers
mint a pass valid for one period and renew to extend it; isValid(id) is the on-chain access gate.
Passes are ordinary ERC-721s, so a membership can be sold or transferred. Unlock-Protocol-style, minimal.
MIT.
mint(to)— paypricePerPeriod, receive a pass valid untilnow + period.renew(id)— pay to extend by one period, measured frommax(now, currentExpiry): a lapsed pass restarts from now, an early renewal stacks on the remaining time. Anyone can renew any pass (gift a membership); ownership doesn't change.isValid(id)—truewhile the pass exists andexpiry >= now. This is what your app gates on.withdrawProceeds(to, amount)— issuer withdraws collected payments (net of an optional bounded fee).
An optional protocol fee (≤ 10%) is routed to a fee recipient on each payment; the rest is the issuer's.
- Accounting (fuzzed,
fail_on_revert=true, non-hollow, 12,800 calls) — the contract's pay-token balance always equals the issuer's withdrawableproceeds(the fee is pushed out on collect; nothing else accrues). - Expiry monotonic —
renewnever decreases a pass's expiry (asserted in the fuzz handler and unit tests). Mutation-checked (renewing fromnowinstead ofmax(now, expiry)fails the early-stack test). - Transferable-and-validity-travels, lapse/restart, gift-renew, issuer-only withdraw, zero-price free passes, constructor bounds.
- The issuer sets the price/period and collects proceeds; buyers get exactly what they pay for (a period of validity) and can trade the pass. No admin path to a holder's pass or to proceeds beyond the issuer's own withdrawal.
- Standard ERC-20 pay token assumed. Unaudited reference implementation.
forge test # 11 tests: mint/renew/lapse/gift, transferable gate, fee routing, accounting invariant