Yellow Network 開発ベストプラクティス
Yellow NetworkとNitrolite(ERC-7824)を活用し、ステートチャネルアプリケーションを構築する際の開発のベストプラクティスを提供するSkill。
📜 元の英語説明(参考)
Yellow Network and Nitrolite (ERC-7824) development best practices for building state channel applications. Use when building apps with Yellow SDK, implementing state channels, connecting to ClearNodes, managing off-chain transactions, or working with application sessions.
🇯🇵 日本人クリエイター向け解説
Yellow NetworkとNitrolite(ERC-7824)を活用し、ステートチャネルアプリケーションを構築する際の開発のベストプラクティスを提供するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o yellow-best-practices.zip https://jpskill.com/download/5863.zip && unzip -o yellow-best-practices.zip && rm yellow-best-practices.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/5863.zip -OutFile "$d\yellow-best-practices.zip"; Expand-Archive "$d\yellow-best-practices.zip" -DestinationPath $d -Force; ri "$d\yellow-best-practices.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
yellow-best-practices.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
yellow-best-practicesフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-17
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Yellow Network & Nitrolite ベストプラクティス
Yellow Network のステートチャネルインフラストラクチャと Nitrolite SDK (ERC-7824) を使用して、高性能な分散型アプリケーションを構築するためのガイドラインです。
クイックスタート
npm install @erc7824/nitrolite
ClearNode WebSocket URL: wss://clearnet.yellow.com/ws
コアコンセプト
Yellow Network とは?
Yellow Network は、ステートチャネルを使用して複数のブロックチェーン間でブローカー、取引所、アプリケーションを接続する分散型クリアリングおよび決済ネットワークです。主な機能は以下の通りです。
- チェーン抽象化: 複数のチェーンにわたる統一された残高
- オフチェーン処理: 1秒あたり最大100,000トランザクション
- 非カストディアル: ユーザー資金はスマートコントラクトによって管理されます
- ERC-7824 プロトコル: 資金回収のためのチャレンジ・紛争メカニズム
アーキテクチャ
┌─────────────────┐ ┌─────────────────┐
│ Your App │────▶│ ClearNode │
│ (Nitrolite SDK)│◀────│ (Broker) │
└─────────────────┘ └─────────────────┘
│ │
└───────────┬───────────┘
▼
┌───────────────┐
│ Blockchain │
│ (Settlement) │
└───────────────┘
カテゴリ別ルール
詳細なルールについては、rules/ ディレクトリを参照してください。
- 01-connection.md - ClearNode 接続パターン (重要)
- 02-authentication.md - 認証フロー (重要)
- 03-app-sessions.md - アプリケーションセッション管理 (高)
- 04-state-management.md - 状態および残高管理 (高)
- 05-security.md - セキュリティのベストプラクティス (重要)
- 06-error-handling.md - エラー処理パターン (中)
必須パターン
1. ClearNode 接続
常に指数バックオフによる再接続ロジックを実装してください。
class ClearNodeConnection {
constructor(url) {
this.url = url;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
this.reconnectInterval = 3000;
}
connect() {
this.ws = new WebSocket(this.url);
this.ws.onopen = () => {
this.reconnectAttempts = 0;
// Proceed with authentication
};
this.ws.onclose = () => this.attemptReconnect();
}
attemptReconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) return;
this.reconnectAttempts++;
const delay = this.reconnectInterval * Math.pow(2, this.reconnectAttempts - 1);
setTimeout(() => this.connect(), delay);
}
}
2. 認証フロー
EIP-712 構造化データ署名を使用してください。
import {
createAuthRequestMessage,
createAuthVerifyMessage,
createEIP712AuthMessageSigner,
parseRPCResponse,
RPCMethod,
} from '@erc7824/nitrolite';
// 1. Send auth_request
const authRequest = await createAuthRequestMessage({
address: walletAddress,
session_key: signerAddress,
application: 'YourAppDomain',
expires_at: (Math.floor(Date.now() / 1000) + 3600).toString(),
scope: 'console',
allowances: [],
});
// 2. Handle auth_challenge and send auth_verify
// 3. Store JWT token for reconnection
3. メッセージ署名
プレーンな JSON ペイロードを署名してください (EIP-191 ではありません)。
const messageSigner = async (payload) => {
const wallet = new ethers.Wallet(privateKey);
const messageBytes = ethers.utils.arrayify(
ethers.utils.id(JSON.stringify(payload))
);
const flatSignature = await wallet._signingKey().signDigest(messageBytes);
return ethers.utils.joinSignature(flatSignature);
};
4. アプリケーションセッション
import { createAppSessionMessage } from '@erc7824/nitrolite';
const appDefinition = {
protocol: 'nitroliterpc',
participants: [participantA, participantB],
weights: [100, 0],
quorum: 100,
challenge: 0,
nonce: Date.now(),
};
const allocations = [
{ participant: participantA, asset: 'usdc', amount: '1000000' },
{ participant: participantB, asset: 'usdc', amount: '0' },
];
const message = await createAppSessionMessage(signer, [{
definition: appDefinition,
allocations,
}]);
重要なルール
DO (すべきこと)
- 常に
wss://を使用する - 暗号化されていない WebSocket 接続は絶対に使用しないでください。 - タイムアウトを実装する - すべての非同期操作にタイムアウト (10~30秒) を追加してください。
- JWT トークンを保存する - 再認証ではなく、再接続のためにトークンを再利用してください。
- リスナーをクリーンアップする - メモリリークを防ぐためにメッセージイベントリスナーを削除してください。
- 署名を検証する - 受信したメッセージの署名を常に検証してください。
- セッションキーを使用する - メインウォレットのキーではなく、署名用に一時的なキーを生成してください。
DON'T (すべきでないこと)
- 秘密鍵を公開しない - 秘密鍵をハードコードしたり、ログに出力したりしないでください。
- エラー処理をスキップしない - WebSocket エラーや認証失敗は常に処理してください。
- タイムアウトを無視しない - すべての操作に対して適切なタイムアウト処理を実装してください。
- EIP-191 プレフィックスを使用しない - プレフィックス付きメッセージではなく、プレーンな JSON を署名してください。
- セッションを閉じ忘れない - 完了したら常にアプリセッションを適切に閉じてください。
SDK コンポーネント
| コンポーネント | 目的 |
|---|---|
NitroliteRPC |
メッセージの構築と署名 |
NitroliteClient |
高レベルなチャネル管理 |
createAuthRequestMessage |
認証リクエストの作成 |
createAuthVerifyMessage |
チャレンジ応答 |
createAppSessionMessage |
アプリセッションの作成 |
createCloseAppSessionMessage |
セッションの終了 |
createGetLedgerBalancesMessage |
残高照会 |
parseRPCResponse |
応答の解析 |
その他のリソース
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Yellow Network & Nitrolite Best Practices
Guidelines for building high-performance decentralized applications using Yellow Network's state channel infrastructure and the Nitrolite SDK (ERC-7824).
Quick Start
npm install @erc7824/nitrolite
ClearNode WebSocket URL: wss://clearnet.yellow.com/ws
Core Concepts
What is Yellow Network?
Yellow Network is a decentralized clearing and settlement network that connects brokers, exchanges, and applications across multiple blockchains using state channels. Key features:
- Chain Abstraction: Unified balance across multiple chains
- Off-chain Processing: Up to 100,000 transactions per second
- Non-custodial: User funds are governed by smart contracts
- ERC-7824 Protocol: Challenge-dispute mechanism for fund recovery
Architecture
┌─────────────────┐ ┌─────────────────┐
│ Your App │────▶│ ClearNode │
│ (Nitrolite SDK)│◀────│ (Broker) │
└─────────────────┘ └─────────────────┘
│ │
└───────────┬───────────┘
▼
┌───────────────┐
│ Blockchain │
│ (Settlement) │
└───────────────┘
Rules by Category
For detailed rules, see the rules/ directory:
- 01-connection.md - ClearNode connection patterns (Critical)
- 02-authentication.md - Authentication flow (Critical)
- 03-app-sessions.md - Application session management (High)
- 04-state-management.md - State and balance management (High)
- 05-security.md - Security best practices (Critical)
- 06-error-handling.md - Error handling patterns (Medium)
Essential Patterns
1. ClearNode Connection
Always implement reconnection logic with exponential backoff:
class ClearNodeConnection {
constructor(url) {
this.url = url;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
this.reconnectInterval = 3000;
}
connect() {
this.ws = new WebSocket(this.url);
this.ws.onopen = () => {
this.reconnectAttempts = 0;
// Proceed with authentication
};
this.ws.onclose = () => this.attemptReconnect();
}
attemptReconnect() {
if (this.reconnectAttempts >= this.maxReconnectAttempts) return;
this.reconnectAttempts++;
const delay = this.reconnectInterval * Math.pow(2, this.reconnectAttempts - 1);
setTimeout(() => this.connect(), delay);
}
}
2. Authentication Flow
Use EIP-712 structured data signatures:
import {
createAuthRequestMessage,
createAuthVerifyMessage,
createEIP712AuthMessageSigner,
parseRPCResponse,
RPCMethod,
} from '@erc7824/nitrolite';
// 1. Send auth_request
const authRequest = await createAuthRequestMessage({
address: walletAddress,
session_key: signerAddress,
application: 'YourAppDomain',
expires_at: (Math.floor(Date.now() / 1000) + 3600).toString(),
scope: 'console',
allowances: [],
});
// 2. Handle auth_challenge and send auth_verify
// 3. Store JWT token for reconnection
3. Message Signing
Sign plain JSON payloads (NOT EIP-191):
const messageSigner = async (payload) => {
const wallet = new ethers.Wallet(privateKey);
const messageBytes = ethers.utils.arrayify(
ethers.utils.id(JSON.stringify(payload))
);
const flatSignature = await wallet._signingKey().signDigest(messageBytes);
return ethers.utils.joinSignature(flatSignature);
};
4. Application Sessions
import { createAppSessionMessage } from '@erc7824/nitrolite';
const appDefinition = {
protocol: 'nitroliterpc',
participants: [participantA, participantB],
weights: [100, 0],
quorum: 100,
challenge: 0,
nonce: Date.now(),
};
const allocations = [
{ participant: participantA, asset: 'usdc', amount: '1000000' },
{ participant: participantB, asset: 'usdc', amount: '0' },
];
const message = await createAppSessionMessage(signer, [{
definition: appDefinition,
allocations,
}]);
Critical Rules
DO
- Always use
wss://- Never use unencrypted WebSocket connections - Implement timeouts - Add timeouts to all async operations (10-30 seconds)
- Store JWT tokens - Reuse tokens for reconnection instead of re-authenticating
- Clean up listeners - Remove message event listeners to prevent memory leaks
- Verify signatures - Always verify received message signatures
- Use session keys - Generate temporary keys for signing, not main wallet keys
DON'T
- Don't expose private keys - Never hardcode or log private keys
- Don't skip error handling - Always handle WebSocket errors and auth failures
- Don't ignore timeouts - Implement proper timeout handling for all operations
- Don't use EIP-191 prefix - Sign plain JSON, not prefixed messages
- Don't forget to close sessions - Always properly close app sessions when done
SDK Components
| Component | Purpose |
|---|---|
NitroliteRPC |
Message construction and signing |
NitroliteClient |
High-level channel management |
createAuthRequestMessage |
Auth request creation |
createAuthVerifyMessage |
Challenge response |
createAppSessionMessage |
App session creation |
createCloseAppSessionMessage |
Session closure |
createGetLedgerBalancesMessage |
Balance queries |
parseRPCResponse |
Response parsing |