Migrating from v0.5.3 to Compat
Use this guide when an existing app depends on @erc7824/[email protected] and needs a staged path onto the v1 runtime. Compat preserves the supported app-facing surface, but it does not promise full 0.5.3 package parity.
Start With the Codemod
Run the codemod before hand-editing. It rewrites imports, migrates client constructors, renames auth fields, updates dependencies, and leaves TODO [codemod] comments where a human needs to collapse a workflow.
git clone https://github.com/layer-3/yellow-sdk-codemod.git
cd yellow-sdk-codemod
npm install
npm run build
node dist/cli.js scan --path /path/to/your-app/src
node dist/cli.js run --path /path/to/your-app --update-deps
Then search for the manual markers:
rg "TODO \\[codemod\\]" /path/to/your-app
See the overview for the command sequence and node dist/cli.js list for available transforms.
MCP-Assisted Migration
:::tip Available now
Yellow SDK MCP is available from npm as @yellow-org/sdk-mcp. Connect it to your AI coding tool when you want a second pass on migration leftovers.
:::
After the codemod, use the MCP server as a second review pass:
- Set up Yellow SDK MCP in Claude Code, Codex, Cursor, Windsurf, VS Code Copilot, or another MCP-compatible tool.
- Ask it to walk through changed files and unresolved
TODO [codemod]markers. - Ask it to check whether uncertain imports belong to
@yellow-org/sdk-compator native@yellow-org/sdk. - Ask it to map old
create*Message+sendRequest+parse*Responseflows onto v1 SDK calls where possible. - Ask it to verify direct v1 SDK replacements before reaching for
client.innerClient.
MCP assistance does not replace the manual checklist below. Treat it as a practical review partner that can keep the SDK, RPC catalogue, examples, and migration guidance in the same conversation.
Install Compat
npm install @yellow-org/sdk-compat
npm install @yellow-org/sdk viem
Client Construction
Before: app-owned WebSocket plus helper calls.
const msg = await createGetChannelsMessage(signer.sign, address);
const raw = await sendRequest(msg);
const parsed = parseGetChannelsResponse(raw);
After: one compat client backed by the v1 SDK.
import { NitroliteClient, blockchainRPCsFromEnv } from '@yellow-org/sdk-compat';
const client = await NitroliteClient.create({
wsURL: 'wss://nitronode-sandbox.yellow.org/v1/ws',
walletClient,
chainId: 11155111,
blockchainRPCs: blockchainRPCsFromEnv(),
});
const channels = await client.getChannels();
:::info Public Nitronode endpoints
Use wss://nitronode-sandbox.yellow.org/v1/ws for migration tests with sandbox assets. Use wss://nitronode.yellow.org/v1/ws only when you intentionally connect migrated code to production/mainnet assets.
:::
Migration Matrix
| Legacy use | Compat status | Direct v1 replacement |
|---|---|---|
| Auth helpers | Available: createAuthRequestMessage, createAuthVerifyMessage, createAuthVerifyMessageWithJWT, createEIP712AuthMessageSigner | SDK client auth flow |
| Channel create or resize helpers | Unsupported or fail-fast where no honest v1 mapping exists | Native client.innerClient.deposit(...), client.innerClient.checkpoint(asset), lifecycle methods |
| Transfer | Available with raw-amount caveat | Client.transfer(recipient, asset, Decimal) |
| App sessions | Available with v1 remapping | Native app-session methods on Client |
Amount Rules
Do not flatten all amounts into one convention. Compat intentionally keeps separate units for separate method families.
deposit,withdrawal, and token allowance helpers use raw token-unitbigint.transferuses raw asset-unit strings, for example{ asset: 'usdc', amount: '5000000' }for 5 USDC with 6 decimals.- App-session allocations use human-readable decimal strings, for example
'5.0'. - Direct native v1 calls use
Decimal.
See the canonical amount-units table.
What Changes
| Concern | v0.5.3 habit | Compat behavior |
|---|---|---|
| WebSocket ownership | App creates and manages WebSocket | NitroliteClient manages the connection |
| Signing | App passes signer.sign into each helper | Client methods sign internally with walletClient |
| Contract addresses | App hard-codes custody and adjudicator addresses | Compat reads current node config and asset metadata |
| Channel creation | App calls createChannel() | First deposit() creates the home channel when needed |
| Server-push events | App handles pushed channel and balance events | Use EventPoller |
| Errors | App matches raw strings | Use typed errors and Errors and recovery |
Manual Review Checklist
After the codemod runs, review each changed area before shipping:
| Area | What to check |
|---|---|
| Imports | @erc7824/nitrolite, @layer-3/nitrolite, and vendored tarballs are gone from app source |
| Client setup | new NitroliteClient(...) and createNitroliteClient(...) are replaced with NitroliteClient.create({ wsURL, walletClient, chainId, blockchainRPCs }) |
| Auth | app_name, expire, participant, and challenge are migrated to application, expires_at, session_key, scope, and allowances |
| RPC chains | create*Message + sendRequest + parse*Response call chains are replaced with client methods or consciously kept as transitional helpers |
| Channel operations | createChannel, depositToChannel, and old approveToken wrappers are replaced with deposit, withdrawal, approveTokens, or a direct innerClient call |
| Events | WebSocket push handlers are replaced with EventPoller or app-owned polling |
| Contract config | custody, adjudicator, CUSTODIES, and ADJUDICATORS constants are removed; config comes from Nitronode |
| Amounts | Transfer amounts are raw asset-unit strings; app-session allocations are human-readable decimal strings |
| Errors | Raw string matching is replaced with NitroliteClient.classifyError() and getUserFacingMessage() |
| SSR | Do not import Client from @yellow-org/sdk-compat; import SDK classes directly from @yellow-org/sdk |
Unsupported Surfaces
The following names can still appear in migrated code, but they are not full live replacements:
checkpointChannel(...)fails fast; useclient.innerClient.checkpoint(asset).- Workflow-only
create*Messagehelpers such ascreateTransferMessage,createCreateChannelMessage,createCloseChannelMessage, andcreateResizeChannelMessagefail fast with migration guidance. parse*Responsehelpers normalize known v1 payloads into 0.5.x-shaped responses, but they are not a replacement for an app-owned RPC transport.get_session_keysdirectory-style APIs andget_rpc_historyare not preserved.
Next Steps
- On-Chain Changes - deposits, withdrawals, channel operations, and raw token units
- Off-Chain Changes - auth helpers, app sessions, transfers, and ledger queries
- EventPoller - replace server-push handlers with polling callbacks
- Errors and recovery - classify wallet, allowance, funds, and transition errors