Skip to main content

Message Envelope (RPC Protocol)

In this guide, you will learn the essentials of how messages are structured and transmitted in Yellow Network.

Goal: Understand the Nitro RPC protocol at a conceptual level.


Protocol Overview

Nitro RPC is a lightweight RPC protocol optimized for state channel communication:

FeatureBenefit
Compact format~30% smaller than traditional JSON-RPC
Signature-based authEvery message is cryptographically verified
BidirectionalReal-time updates via WebSocket
Ordered timestampsReplay attack prevention

Message Structure

Every Nitro RPC message uses a compact JSON array format:

ComponentTypeDescription
requestIduint64Unique identifier for correlation
methodstringRPC method name (snake_case)
params/resultobjectMethod-specific data
timestampuint64Unix milliseconds

Request Wrapper

{ "req": [requestId, method, params, timestamp], "sig": [...] }

Response Wrapper

{ "res": [requestId, method, result, timestamp], "sig": [...] }

Error Response

{ "res": [requestId, "error", { "error": "description" }, timestamp], "sig": [...] }

Signature Format

Each signature is a 65-byte ECDSA signature (r + s + v) represented as a 0x-prefixed hex string.

ContextWhat's SignedWho Signs
RequestsJSON payload hashSession key (or main wallet)
ResponsesJSON payload hashClearnode

Method Categories

CategoryMethods
Authauth_request, auth_verify
Channelscreate_channel, close_channel, resize_channel
Transferstransfer
App Sessionscreate_app_session, submit_app_state, close_app_session
Queriesget_ledger_balances, get_channels, get_app_sessions, etc.

Notifications

The Clearnode pushes real-time updates:

NotificationWhen Sent
bu (balance update)Balance changed
cu (channel update)Channel status changed
tr (transfer)Incoming/outgoing transfer
asu (app session update)App session state changed

Communication Flow


Protocol Versions

VersionStatusKey Features
NitroRPC/0.2LegacyBasic state updates
NitroRPC/0.4CurrentIntent system, enhanced validation

Always use NitroRPC/0.4 for new implementations.


Key Points

  1. Compact arrays instead of verbose JSON objects
  2. Every message signed for authenticity
  3. Timestamps prevent replay attacks
  4. Bidirectional WebSocket for real-time updates

Deep Dive

For complete technical specifications: