Architecture
System Overview
The Nitrolite protocol architecture consists of multiple layers working together to enable scalable, secure state channel operations:
Communication Patterns
On-Chain Channel Opening
The channel opening process follows a coordinated sequence between client and a clearnode:
- Client requests channel creation from a clearnode via Nitro RPC
- The clearnode returns a channel struct and signed initial state (signature at index 1)
- Client signs the initial state (signature at index 0)
- Client calls the
create(...)method of the Custody Smart Contract on the blockchain, providing the channel and initial state with both signatures - Contract verifies signatures and emits
Openedevent - Channel becomes ACTIVE immediately
- The clearnode monitors the
Openedevent and updates its internal state
Channel opening requires cooperation between both parties, ensuring mutual agreement before funds are locked.
Off-Chain Updates
Off-Chain Updates:
-
Participants exchange signed state updates:
-
For Payment Channels (User ↔ Clearnode): States are exchanged directly via Nitro RPC
-
For App Sessions (Multi-party): State exchange is managed by the App itself (peer-to-peer). Once the state has enough signatures to satisfy quorum, a responsible party submits the signed state to the Clearnode
-
-
No blockchain transactions required
-
Latest valid state maintained off-chain
-
Can be checkpointed on-chain at any time
- Current Implementation Note: While this is the ideal design goal, the current implementation does not store the state off-chain, so checkpointing is not currently supported. This functionality is under development and will be more enforced in the next version of the protocol.
Off-chain updates are instant (< 1 second) and incur zero gas fees, enabling high-frequency operations.
On-Chain Channel Closing
Channels can be closed in two ways:
Cooperative Closure:
- All participants negotiate and agree on the final state
- Each participant signs the final state with
intent = FINALIZE - Any participant submits the fully-signed final state to the Custody Contract via
close() - Contract verifies all signatures and distributes funds according to final allocations
- Channel status becomes FINAL
This is the preferred closure method. It requires only 1 transaction and is gas-efficient.
Non-Cooperative Closure:
- A participant submits the latest known state to the Custody Contract via
challenge() - Contract verifies signatures and sets channel status to DISPUTE
- A challenge period begins (e.g., 24 hours), allowing the other party to respond
- If participants decides to cooperate again, they may produce a newer valid state, and any of them can submit it via
checkpoint(), thus stopping the challenge period and moving the channel from DISPUTE back to ACTIVE status - If not, after the challenge period expires, any participant calls
close()to finalize with the latest submitted state - Contract distributes funds according to the final state allocations
This mechanism resolves disputes when parties cannot cooperate. It requires a waiting period for security and is more expensive due to multiple transactions.
Fund Flow
The following diagram illustrates how funds flow through the Nitrolite protocol:
Flow Explanation:
- Deposit: User deposits ERC-20 tokens into the Available balance of the Custody Contract.
- Resize: Funds can be moved between Available balance and Unified Balance (managed off-chain by the clearnode).
- Channel Lock: Funds can also be moved between Available balance and Channel-Locked balance via resize operations, or between Channel-Locked and Unified Balance.
- App Sessions: Funds from the Unified Balance can be allocated to App Sessions.
- Release: When app sessions close or funds are withdrawn, they return to the Unified Balance.
- Unlock/Withdraw: Funds can be moved back to Available balance (via resize/close) and then withdrawn to the User Wallet.
At every stage, funds remain cryptographically secured. Users can always recover their funds according to the latest valid signed state, even if the clearnode becomes unresponsive.