
Building a permissionless live streaming platform with real-time on-chain payments
About The Project
ThreeToN (3toN) is a permissionless video streaming platform that combines real-time streaming payments with NFT-based access control entirely on-chain. The core smart contract,ThreeToN.sol, orchestrates two DeFi protocols in tandem: Superfluid Finance for per-second token streams via the Constant Flow Agreement (CFA), and Unlock Protocol for NFT membership keys. When a viewer callsjoin(), the contract simultaneously opens a Superfluid payment flow from the viewer to the streamer and issues an Unlock Protocol NFT access key. CallingleaveStream()closes both atomically. Any wallet can start a stream with a custom rate, token, participant cap, and expiry, no platform approval or off-chain coordination required. The contract is deployed on Polygon, Optimism, and Goerli.

System Architecture
System Architecture diagram
Key Challenges
Real-time payment granularity
Subscriptions and one-time charges can't adapt to a live stream that may last minutes or hours. Payments needed per-second precision, stopping the moment a viewer leaves with no manual settlement.
Trustless on-chain access control
Without a central server to verify who's paying, access to the stream had to be enforced and revoked entirely on-chain automatically tied to payment status.
Coordinating two external protocols
The join() and leaveStream() flows each require atomic actions across both Superfluid Finance and Unlock Protocol. A partial failure in one must not leave the other in a dangling state.
Permissionless stream creation
Enabling any wallet to start a stream setting custom rates, participant caps, and expiry without any platform approval, KYC, or off-chain coordination.
Our Solution
Superfluid Constant Flow Agreement (CFA)
On join(), the contract calls Superfluid's createFlowByOperator to open a per-second token stream from viewer to streamer. On leaveStream(), deleteFlowByOperator closes it instantly no batching, no invoices.
Unlock Protocol NFT keys
Each stream deploys its own Unlock lock on start(). Viewers receive NFT keys via grantKeys() on join. Access is verifiable on-chain via key balance + CFA flow rate. Keys are burned via burn() on exit.
Single-transaction orchestration
ThreeToN.sol wraps all protocol calls inside join() and leaveStream(), ensuring payment and access always stay in sync. No partial state can exist across protocol boundaries.
On-chain stream registry
Stream metadata owner, rate, token, participant count, live status lives in a StreamData mapping in contract storage. Any wallet can call start() with custom parameters, with no intermediaries.
The Result
Multi-chain deployment
The contract is live on three networks Polygon, Optimism, and Goerli,using the same contract address on both Polygon and Optimism, demonstrating consistent cross-chain portability with zero architecture changes.
Fully permissionless participation
Any wallet can initiate a stream with a custom payment rate, token type, participant cap, and expiry. No platform approval, KYC, or off-chain sign-up required for streamers or viewers alike.
Per-second real-time settlement
Superfluid's CFA streams tokens from viewer wallets to streamers every second. No invoicing, no batch settlement payment starts and stops in the same transaction as access, with real-time balance tracking on-chain via earningSoFar().
On-chain access gating
Stream access is enforced entirely on-chain via Unlock Protocol NFT keys. Membership validity is verifiable by any contract or dApp by simultaneously checking CFA flow rate, key balance, and stream live status via hasJoined().
Need a similar solution?
Talk with our team about your project goals and timeline.