On-Chain Migration Guide
Covers deposits, withdrawals, channel operations, amount handling, and contract addresses when migrating from v0.5.3.
Deposits
Before (v0.5.3): Manual approve → deposit → createChannel
await approveToken(custody, tokenAddress, amount);
await sendRequest(createDepositMessage(signer.sign, { token: tokenAddress, amount }));
await sendRequest(createCreateChannelMessage(signer.sign, { token: tokenAddress, amount }));
After (compat): Single call — approval and channel creation are implicit
await client.deposit(tokenAddress, amount);
Withdrawals
Before (v0.5.3): Manual close → checkpoint → withdraw
const closeMsg = await createCloseChannelMessage(signer.sign, { channel_id });
const raw = await sendRequest(closeMsg);
await sendRequest(createWithdrawMessage(signer.sign, { token, amount }));
After (compat): Single call
await client.withdrawal(tokenAddress, amount);
Channel Operations
| Operation | v0.5.3 | Compat |
|---|---|---|
| Create | Explicit createChannel() | Implicit on first deposit() |
| Close | createCloseChannelMessage + send + parse | client.closeChannel() |
| Resize | createResizeChannelMessage + send + parse | client.resizeChannel({ allocate_amount, token }) |
Amount Handling
Before (v0.5.3): Raw BigInt everywhere; app must handle decimals
const amount = 11_000_000n; // 11 USDC (6 decimals)
After (compat): Accepts both; conversion handled internally
// Raw BigInt still works
await client.deposit(tokenAddress, 11_000_000n);
// Or use helpers
const formatted = client.formatAmount(tokenAddress, 11_000_000n); // "11.0"
const parsed = client.parseAmount(tokenAddress, "11.0"); // 11_000_000n
For transfers and allocations, compat accepts human-readable strings: { asset: 'usdc', amount: '5.0' }.
Contract Addresses
Before (v0.5.3): Manual config
const addresses = { custody: '0x...', adjudicator: '0x...' };
After (compat): Fetched from clearnode get_config — no manual setup. The addresses field in config is deprecated and ignored.