Skip to content

Commit 8e4512a

Browse files
committed
YNU-864: Address quickstart review comments
- Align Node TypeScript config with the runnable lifecycle example. - Remove internal checklist terminology and internal stress endpoint defaults from PR1 docs. - Make app-session nonce and version snippets copy-paste safe. - Clarify home-channel vs app-session deposit amounts and the Node local-account transaction shim. - Tighten key-term definitions and footer metadata from review feedback.
1 parent bd7a17d commit 8e4512a

6 files changed

Lines changed: 36 additions & 16 deletions

File tree

docs/nitrolite/build/getting-started/key-terms.mdx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords: [terminology, glossary, concepts, state channels, mental models]
1010
Nitrolite uses one shared vocabulary across the SDK, protocol docs, and on-chain contracts. Learn these terms first and the rest of the docs become much easier to scan.
1111

1212
:::info Canonical source
13-
The protocol source of truth is [Protocol Terminology](../../protocol/terminology). PR7 will add a dedicated Learn glossary; until then, use this page as the builder-facing quick reference.
13+
The protocol source of truth is [Protocol Terminology](../../protocol/terminology). Use this page as the builder-facing quick reference for the SDK docs.
1414
:::
1515

1616
## Core mental model
@@ -22,15 +22,16 @@ Nitrolite lets a user and Nitronode exchange signed channel states off-chain, th
2222
| Term | What it means | Builder cue |
2323
|------|---------------|-------------|
2424
| **Channel** | A state container shared by a user and Nitronode for one unified asset. | The thing your deposits, transfers, withdrawals, and checkpoints update. |
25-
| **Home Channel** | The default user-Nitronode channel whose home ledger is enforced on its home chain. | Most apps start here. `deposit()`, `transfer()`, and `checkpoint()` act on the home channel for an asset. |
25+
| **Home Channel** (for a specific Asset) | The default user-Nitronode channel whose home ledger for the Asset is enforced on its home chain. | Most apps start here. `deposit()`, `transfer()`, and `checkpoint()` act on the home channel for an asset. |
2626
| **Escrow Channel** | A temporary cross-chain channel derived from a home channel for escrow operations. | You meet this when funds move between chains. |
2727
| **Channel State** | The current agreed channel configuration: ledgers, version, and transition data. | SDK state operations return a state before you decide whether to checkpoint it. |
2828
| **Channel Definition** | The immutable channel parameters: user, node, asset, nonce, challenge duration, and signature validators. | Fixed at channel creation. Do not model it as app-level mutable config. |
2929
| **Ledger** | A record of asset allocations and net flows for a specific blockchain inside a channel state. | Ledger math must balance exactly. |
3030
| **Home Ledger** | The ledger tied to the chain where the current channel state is enforced. | This is the authoritative ledger for checkpoint and challenge flows. |
3131
| **Non-Home Ledger** | A secondary ledger for a blockchain other than the home chain. | Used by escrow and migration flows, not as a synonym for home channel. |
32-
| **Vault** | Nitronode's per-chain pool of available funds used to cover required locking during transitions. | Cross-chain availability depends on node liquidity in the right vault. |
32+
| **(Node) Vault** | Nitronode's per-chain pool of available funds used to cover required locking during transitions. | Cross-chain availability depends on node liquidity in the right vault. |
3333
| **Asset** | A logical value unit, such as USDC, with a symbol and decimal precision independent of any one chain. | The SDK takes asset symbols like `'usdc'`, not token addresses, for high-level channel operations. |
34+
| **Token** | The per-blockchain contract representation of an Asset. | Nitronode asset config maps an asset symbol to the token address used on each supported chain. |
3435
| **Decimal** | An exact decimal amount represented with `decimal.js`. | Use `new Decimal(5)`, not JavaScript floating-point numbers, for SDK amounts. |
3536
| **App Session** | An application extension that commits channel funds into a multi-party off-chain session. | Games, matching, escrow, and other multi-party flows live here. |
3637
| **Quorum** | The minimum weighted approval needed for an app session state update. | If weights are `[40, 40, 50]` and quorum is `80`, two participants may be enough. |
@@ -39,7 +40,7 @@ Nitrolite lets a user and Nitronode exchange signed channel states off-chain, th
3940
| **Checkpoint** | The operation of submitting a signed state to the blockchain layer for enforcement. | `client.checkpoint('usdc')` settles the latest agreed state for that asset. |
4041
| **Nitronode** | The v1 off-chain coordinator that serves RPC, co-signs valid states, tracks channels, and coordinates app sessions. | This is the node your SDK client connects to over WebSocket. |
4142
| **ChannelHub** | The v1 on-chain entrypoint for channel create, deposit, withdraw, checkpoint, challenge, and close operations. | The SDK hides most contract calls, but this is the contract enforcing the state. |
42-
| **Migration** | A transition that moves the channel's home-chain relationship as part of cross-chain operation. | Treat it as protocol state movement, not a package upgrade. |
43+
| **Migration** | A transition that moves the home-chain channel of a specific Asset to another blockchain. | Treat it as protocol state enforcement configuration, not a package upgrade. |
4344
| **Transition** | A typed operation explaining why the channel state changed. | Every state advancement carries one transition type. |
4445

4546
## Channel lifecycle statuses

docs/nitrolite/build/getting-started/prerequisites.mdx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ Create `tsconfig.json`:
8989
{
9090
"compilerOptions": {
9191
"target": "ES2022",
92-
"module": "ESNext",
93-
"moduleResolution": "bundler",
92+
"module": "NodeNext",
93+
"moduleResolution": "NodeNext",
9494
"strict": true,
9595
"esModuleInterop": true,
9696
"skipLibCheck": true,
@@ -101,6 +101,8 @@ Create `tsconfig.json`:
101101
}
102102
```
103103

104+
This config matches the checked-in Node.js lifecycle example. If your app is built by Vite, webpack, or another bundler, `moduleResolution: "bundler"` can be valid there, but do not use it for a plain `tsc` + `node dist/...` script.
105+
104106
Update `package.json`:
105107

106108
```json
@@ -121,14 +123,14 @@ Create `.env` for sensitive values:
121123
# .env - never commit this file
122124
USER_PRIVATE_KEY=0x...
123125
APP_PRIVATE_KEY=0x...
124-
NITRONODE_WS_URL=wss://nitronode-stress.yellow.org/v1/ws
126+
NITRONODE_WS_URL=<sandbox-url-coming-soon>
125127
RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
126128
CHAIN_ID=11155111
127129
ASSET=yellow
128130
```
129131

130132
:::info Test endpoint
131-
`NITRONODE_WS_URL` should point at a v1 Nitronode endpoint for the environment you are testing against. The quickstart lifecycle example uses the current public stress endpoint and Sepolia test assets.
133+
`NITRONODE_WS_URL` should point at a v1 Nitronode endpoint for the environment you are testing against. Use the current sandbox or test endpoint provided for your environment until the public sandbox URL is pinned.
132134
:::
133135

134136
Add local files to `.gitignore`:
@@ -165,7 +167,7 @@ node dist/scripts/create-wallet.js
165167

166168
### Get Test Tokens
167169

168-
<!-- coming soon: faucet endpoint pending; OQ-6
170+
<!-- coming soon: faucet endpoint pending
169171

170172
```bash
171173
curl -XPOST https://clearnet-sandbox.yellow.com/faucet/requestTokens \

docs/nitrolite/build/getting-started/quickstart.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Edit `.env`:
3939
```bash title=".env"
4040
USER_PRIVATE_KEY=0x...
4141
APP_PRIVATE_KEY=0x...
42-
NITRONODE_WS_URL=wss://nitronode-stress.yellow.org/v1/ws
42+
NITRONODE_WS_URL=<sandbox-url-coming-soon>
4343
RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
4444
CHAIN_ID=11155111
4545
ASSET=yellow
@@ -50,6 +50,8 @@ OPERATE_AMOUNT=0.001
5050
WITHDRAW_AMOUNT=0.002
5151
```
5252

53+
`CHANNEL_DEPOSIT_AMOUNT` is the amount available in the user's home channel. `APP_DEPOSIT_AMOUNT` is the smaller amount committed from that home-channel balance into the app session.
54+
5355
Use a dedicated test wallet. Do not reuse a wallet that holds mainnet funds.
5456

5557
## Step 2: Connect clients
@@ -70,6 +72,8 @@ const user = await Client.create(
7072

7173
`createSigners()` derives both signer types the SDK needs: off-chain state signing and on-chain transaction signing.
7274

75+
The checked-in Node.js script also applies `enableNodeLocalAccountTransactions()` after client creation. Public RPC transports need the local account preserved on `writeContract()` calls, otherwise `approveToken()` and `checkpoint()` can fail with viem account errors. Browser wallet apps do not need this shim.
76+
7377
## Step 3: Prepare the home channel
7478

7579
The script loads Nitronode config, checks the configured asset, sets the asset home blockchain, and prepares the user home channel.
@@ -100,7 +104,7 @@ const definition: AppDefinitionV1 = {
100104
{ walletAddress: appAddress, signatureWeight: 1 },
101105
],
102106
quorum: 2,
103-
nonce: BigInt(Date.now()) * 1_000_000n,
107+
nonce: BigInt(Date.now()) * 1_000_000n + BigInt(Math.floor(Math.random() * 1_000_000)),
104108
};
105109

106110
const payload = packCreateAppSessionRequestV1(definition, sessionData);
@@ -115,18 +119,25 @@ const created = await client.createAppSession(definition, sessionData, [userSig,
115119
The user commits part of the home-channel balance into the app session with a deposit intent:
116120

117121
```typescript
122+
const { sessions } = await client.getAppSessions({ appSessionId: created.appSessionId });
123+
const session = sessions[0];
124+
118125
const update: AppStateUpdateV1 = {
119126
appSessionId: created.appSessionId,
120127
intent: AppStateUpdateIntent.Deposit,
121-
version: 2n,
128+
version: session.version + 1n,
122129
allocations: [
123130
{ participant: userAddress, asset, amount: appDepositAmount },
124131
{ participant: appAddress, asset, amount: new Decimal(0) },
125132
],
126133
sessionData: JSON.stringify({ intent: 'user_deposit' }),
127134
};
128135

129-
await client.submitAppSessionDeposit(update, [userSig, appSig], asset, appDepositAmount);
136+
const updatePayload = packAppStateUpdateV1(update);
137+
const updateUserSig = await userSessionSigner.signMessage(updatePayload);
138+
const updateAppSig = await appSessionSigner.signMessage(updatePayload);
139+
140+
await client.submitAppSessionDeposit(update, [updateUserSig, updateAppSig], asset, appDepositAmount);
130141
```
131142

132143
## Step 6: Operate, withdraw, and close

examples/nitrolite-v1-lifecycle/.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ USER_PRIVATE_KEY=0x...
33
APP_PRIVATE_KEY=0x...
44

55
# Native v1 Nitronode and matching chain RPC.
6-
NITRONODE_WS_URL=wss://nitronode-stress.yellow.org/v1/ws
6+
NITRONODE_WS_URL=<sandbox-url-coming-soon>
77
RPC_URL=https://ethereum-sepolia-rpc.publicnode.com
88
CHAIN_ID=11155111
99
ASSET=yellow
1010

11-
# Keep these tiny for docs verification. Adjust for the faucet asset and chain.
11+
# Keep these tiny for docs verification. CHANNEL_DEPOSIT_AMOUNT funds the
12+
# user's home channel; APP_DEPOSIT_AMOUNT is committed from that balance into
13+
# the app session. Adjust both for the faucet asset and chain.
1214
CHANNEL_DEPOSIT_AMOUNT=0.01
1315
APP_DEPOSIT_AMOUNT=0.005
1416
OPERATE_AMOUNT=0.001

examples/nitrolite-v1-lifecycle/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ npm run lifecycle
2222

2323
Use disposable test wallets only. The app signer can be an unfunded test wallet; the user wallet needs Sepolia gas and the selected test asset.
2424

25+
Set `NITRONODE_WS_URL` to the current v1 sandbox or test endpoint provided for your environment before running `npm run lifecycle`.
26+
27+
The script calls `enableNodeLocalAccountTransactions()` after creating each SDK client. This keeps viem's local account attached to `writeContract()` requests in Node.js so `approveToken()` and `checkpoint()` can send transactions through public RPC endpoints. Browser wallet apps do not need this shim.
28+
2529
Set `CLOSE_HOME_CHANNEL=true` only when you intentionally want to close the example home channel after the app-session lifecycle.

i18n/en/docusaurus-theme-classic/footer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"link.item.label.Build": {
2323
"message": "Build",
24-
"description": "The label of footer link with label=Build linking to /docs/build/quick-start"
24+
"description": "The label of footer link with label=Build linking to /nitrolite/build/getting-started/quickstart"
2525
},
2626
"link.item.label.Guides": {
2727
"message": "Guides",

0 commit comments

Comments
 (0)