Subscriptions
Streaming-payment contracts hold one escrow and cannot bill per request.
v0.1.0 on Solana devnet
Recurring subscriptions and x402 micropayments share a single on-chain escrow on Solana. One signature funds both flows.
Early access
Tell us what you are building. We share devnet endpoints, the IDL, and integration notes as 0.1.0 lands.
How it works
What an outside reviewer needs to see first, before the on-chain mechanics.
The subscriber deposits stablecoins (USDC on devnet) into a single on-chain escrow called the Subscription PDA. That deposit is the only signature they ever sign for the relationship.
A streaming subscription draws the monthly portion continuously. In parallel, an x402 facilitator settles per-call charges against the same escrow.
Every debit checks withdrawn ≤ deposited atomically, so a streamed period and a per-call settlement cannot double-spend the same funds. Pro-rata refund on cancel reads the same fields.
Architecture detail for developers
Subscribers prefund one Subscription PDA. Two writers debit from that balance, both bound by withdrawn ≤ deposited , so a session reservation and a streaming charge cannot double-spend the same funds.
Implementation runs on USDC on devnet. The protocol itself is token-agnostic; any SPL-token mint can be configured by the merchant at PDA creation.
The problem
Merchants who need both monthly subscriptions and per-call usage charges run two contracts, two wallet approvals, and an off-chain reconciler to keep the books straight. Subscribers see two debits, two cancel buttons, two refund flows. Credits sit in a third silo, and a fourth wallet stores the rest.
Streaming-payment contracts hold one escrow and cannot bill per request.
x402 facilitators settle per-call payments. They have no concept of a subscription.
Prepaid balances live in a custodial database. They are off-chain by default, and they do not move when the user migrates wallets.
Embedded balances need a separate approval. They never settle against the main escrow.
Deeper context on the protocol, security model, and integration. Have something else? info@nakamapay.dev
Classical streaming contracts hold one escrow and emit a continuous payout. Nakama keeps that streaming behavior but adds a second writer — an x402 facilitator — that can settle per-call charges against the same balance. Both paths share one withdrawn_amount field on-chain, so a streamed period and a per-call settlement cannot double-spend the same funds.
A single invariant — withdrawn ≤ deposited — is enforced atomically by the on-chain program on every debit. Session reservations cap facilitator authority for x402 paths without moving funds. The keeper streams under the same constraint.
The implementation runs on USDC on devnet. The protocol itself is token-agnostic; any SPL-token mint can be configured by the merchant at PDA creation.
Pro-rata refund is computed from elapsed time on cancel. No custodian is in the loop — refund math runs against the same deposited / withdrawn fields the live debits touch.
0.1.0 is on devnet, intended for partner integration and review. A formal audit lands before mainnet. The repository is open source and includes the full test suite.
No. The settlement writer is a permissioned program path; any x402-compatible facilitator can be authorized by a merchant. Switching facilitators does not migrate balances.
Subscriptions and usage payments stop being two products to integrate and start being one balance to draw from.