@yellow-org/sdk 1.0.1-alpha.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Yellow TypeScript SDK
|
|
2
2
|
|
|
3
|
-
[](https://erc7824.org/quick_start)
|
|
3
|
+
[](https://www.npmjs.com/package/@yellow-org/sdk)
|
|
4
|
+
[](https://github.com/erc7824/nitrolite/blob/main/LICENSE)
|
|
6
5
|
|
|
7
6
|
TypeScript SDK for Clearnode payment channels providing both high-level and low-level operations in a unified client:
|
|
8
7
|
- **State Operations**: `deposit()`, `withdraw()`, `transfer()`, `closeHomeChannel()`, `acknowledge()` - build and co-sign states off-chain
|
|
@@ -10,6 +9,8 @@ TypeScript SDK for Clearnode payment channels providing both high-level and low-
|
|
|
10
9
|
- **Low-Level Operations**: Direct RPC access for custom flows and advanced use cases
|
|
11
10
|
- **Full Feature Parity**: 100% compatibility with Go SDK functionality
|
|
12
11
|
|
|
12
|
+
> If you're an old developer who is looking to upgrade from @erc7824/nitrolite@v0.5.3, please try out the [@yellow-org/sdk-compat](https://www.npmjs.com/package/@yellow-org/sdk-compat) which is a translation layer that uses this package underneath by mapping the 0.5.3 familiar api surfaces to this sdk
|
|
13
|
+
|
|
13
14
|
## Method Cheat Sheet
|
|
14
15
|
|
|
15
16
|
### State Operations (Off-Chain)
|
|
@@ -87,11 +88,11 @@ client.setHomeBlockchain(asset, chainId) // Set default blockchain for asset
|
|
|
87
88
|
## Installation
|
|
88
89
|
|
|
89
90
|
```bash
|
|
90
|
-
npm install @
|
|
91
|
+
npm install @yellow-org/sdk
|
|
91
92
|
# or
|
|
92
|
-
yarn add @
|
|
93
|
+
yarn add @yellow-org/sdk
|
|
93
94
|
# or
|
|
94
|
-
pnpm add @
|
|
95
|
+
pnpm add @yellow-org/sdk
|
|
95
96
|
```
|
|
96
97
|
|
|
97
98
|
## Quick Start
|
|
@@ -99,7 +100,7 @@ pnpm add @erc7824/nitrolite
|
|
|
99
100
|
### Unified Client (High-Level + Low-Level)
|
|
100
101
|
|
|
101
102
|
```typescript
|
|
102
|
-
import { Client, createSigners, withBlockchainRPC } from '@
|
|
103
|
+
import { Client, createSigners, withBlockchainRPC } from '@yellow-org/sdk';
|
|
103
104
|
import Decimal from 'decimal.js';
|
|
104
105
|
|
|
105
106
|
async function main() {
|
|
@@ -159,7 +160,7 @@ sdk/ts/src/
|
|
|
159
160
|
### Creating a Client
|
|
160
161
|
|
|
161
162
|
```typescript
|
|
162
|
-
import { Client, createSigners, withBlockchainRPC } from '@
|
|
163
|
+
import { Client, createSigners, withBlockchainRPC } from '@yellow-org/sdk';
|
|
163
164
|
|
|
164
165
|
// Step 1: Create signers from private key
|
|
165
166
|
const { stateSigner, txSigner } = createSigners('0x1234...');
|
|
@@ -188,7 +189,7 @@ The SDK provides two signer types matching the Go SDK patterns:
|
|
|
188
189
|
Signs channel state updates with EIP-191 "Ethereum Signed Message" prefix.
|
|
189
190
|
|
|
190
191
|
```typescript
|
|
191
|
-
import { EthereumMsgSigner } from '@
|
|
192
|
+
import { EthereumMsgSigner } from '@yellow-org/sdk';
|
|
192
193
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
193
194
|
|
|
194
195
|
// From private key
|
|
@@ -206,7 +207,7 @@ const signer2 = new EthereumMsgSigner(account);
|
|
|
206
207
|
Signs raw hashes directly without prefix for on-chain operations.
|
|
207
208
|
|
|
208
209
|
```typescript
|
|
209
|
-
import { EthereumRawSigner } from '@
|
|
210
|
+
import { EthereumRawSigner } from '@yellow-org/sdk';
|
|
210
211
|
|
|
211
212
|
const signer = new EthereumRawSigner('0x...');
|
|
212
213
|
```
|
|
@@ -216,7 +217,7 @@ const signer = new EthereumRawSigner('0x...');
|
|
|
216
217
|
#### Helper: createSigners()
|
|
217
218
|
|
|
218
219
|
```typescript
|
|
219
|
-
import { createSigners } from '@
|
|
220
|
+
import { createSigners } from '@yellow-org/sdk';
|
|
220
221
|
|
|
221
222
|
// Creates both signers at once
|
|
222
223
|
const { stateSigner, txSigner } = createSigners('0x...');
|
|
@@ -591,7 +592,7 @@ import {
|
|
|
591
592
|
withHandshakeTimeout,
|
|
592
593
|
withPingInterval,
|
|
593
594
|
withErrorHandler
|
|
594
|
-
} from '@
|
|
595
|
+
} from '@yellow-org/sdk';
|
|
595
596
|
|
|
596
597
|
const client = await Client.create(
|
|
597
598
|
wsURL,
|
|
@@ -609,7 +610,7 @@ const client = await Client.create(
|
|
|
609
610
|
### Example 1: Basic Deposit and Transfer
|
|
610
611
|
|
|
611
612
|
```typescript
|
|
612
|
-
import { Client, createSigners, withBlockchainRPC } from '@
|
|
613
|
+
import { Client, createSigners, withBlockchainRPC } from '@yellow-org/sdk';
|
|
613
614
|
import Decimal from 'decimal.js';
|
|
614
615
|
|
|
615
616
|
async function basicExample() {
|
|
@@ -658,7 +659,7 @@ basicExample().catch(console.error);
|
|
|
658
659
|
### Example 2: Multi-Chain Operations
|
|
659
660
|
|
|
660
661
|
```typescript
|
|
661
|
-
import { Client, createSigners, withBlockchainRPC } from '@
|
|
662
|
+
import { Client, createSigners, withBlockchainRPC } from '@yellow-org/sdk';
|
|
662
663
|
import Decimal from 'decimal.js';
|
|
663
664
|
|
|
664
665
|
async function multiChainExample() {
|
|
@@ -698,7 +699,7 @@ multiChainExample().catch(console.error);
|
|
|
698
699
|
### Example 3: Transaction History with Pagination
|
|
699
700
|
|
|
700
701
|
```typescript
|
|
701
|
-
import { Client, createSigners } from '@
|
|
702
|
+
import { Client, createSigners } from '@yellow-org/sdk';
|
|
702
703
|
|
|
703
704
|
async function queryTransactions() {
|
|
704
705
|
const { stateSigner, txSigner } = createSigners(process.env.PRIVATE_KEY!);
|
|
@@ -734,7 +735,7 @@ queryTransactions().catch(console.error);
|
|
|
734
735
|
### Example 4: App Session Workflow
|
|
735
736
|
|
|
736
737
|
```typescript
|
|
737
|
-
import { Client, createSigners, withBlockchainRPC } from '@
|
|
738
|
+
import { Client, createSigners, withBlockchainRPC } from '@yellow-org/sdk';
|
|
738
739
|
import Decimal from 'decimal.js';
|
|
739
740
|
|
|
740
741
|
async function appSessionExample() {
|
|
@@ -802,7 +803,7 @@ appSessionExample().catch(console.error);
|
|
|
802
803
|
### Example 5: Connection Monitoring
|
|
803
804
|
|
|
804
805
|
```typescript
|
|
805
|
-
import { Client, createSigners, withErrorHandler, withPingInterval } from '@
|
|
806
|
+
import { Client, createSigners, withErrorHandler, withPingInterval } from '@yellow-org/sdk';
|
|
806
807
|
|
|
807
808
|
async function monitorConnection() {
|
|
808
809
|
const { stateSigner, txSigner } = createSigners(process.env.PRIVATE_KEY!);
|
|
@@ -852,7 +853,7 @@ import type {
|
|
|
852
853
|
AppSessionKeyStateV1,
|
|
853
854
|
ChannelSessionKeyStateV1,
|
|
854
855
|
PaginationMetadata,
|
|
855
|
-
} from '@
|
|
856
|
+
} from '@yellow-org/sdk';
|
|
856
857
|
```
|
|
857
858
|
|
|
858
859
|
### BigInt for Chain IDs
|
|
@@ -968,31 +969,15 @@ For understanding how operations work under the hood:
|
|
|
968
969
|
- **Running Clearnode instance** or access to public node
|
|
969
970
|
- **Blockchain RPC endpoint** (for on-chain operations via `checkpoint()`)
|
|
970
971
|
|
|
971
|
-
## Documentation
|
|
972
|
-
|
|
973
|
-
For complete documentation, visit [https://erc7824.org](https://erc7824.org)
|
|
974
|
-
|
|
975
|
-
### Documentation Links
|
|
976
|
-
|
|
977
|
-
- [Quick Start Guide](https://erc7824.org/quick_start)
|
|
978
|
-
- [Channel Creation](https://erc7824.org/quick_start/initializing_channel)
|
|
979
|
-
- [ClearNode Connection](https://erc7824.org/quick_start/connect_to_the_clearnode)
|
|
980
|
-
- [Application Sessions](https://erc7824.org/quick_start/application_session)
|
|
981
|
-
- [Session Closure](https://erc7824.org/quick_start/close_session)
|
|
982
|
-
|
|
983
|
-
## Build with AI
|
|
984
|
-
|
|
985
|
-
We have generated a [llms-full.txt](https://erc7824.org/llms-full.txt) file that converts all our documentation into a single markdown document following the [llmstxt.org](https://llmstxt.org/) standard.
|
|
986
|
-
|
|
987
972
|
## License
|
|
988
973
|
|
|
989
974
|
Part of the Nitrolite project. See [LICENSE](../../LICENSE) for details.
|
|
990
975
|
|
|
991
976
|
## Related Projects
|
|
992
977
|
|
|
993
|
-
- [Nitrolite
|
|
994
|
-
- [
|
|
995
|
-
- [Nitrolite Smart Contracts](
|
|
978
|
+
- [Nitrolite TS Compat](https://www.npmjs.com/package/@yellow-org/sdk-compat) - Compatibility layer for older TypeScript versions
|
|
979
|
+
- [Nitrolite Go SDK](https://github.com/erc7824/nitrolite/tree/stable/sdk/go) - Go implementation with same API
|
|
980
|
+
- [Nitrolite Smart Contracts](https://github.com/erc7824/nitrolite/tree/stable/contracts) - On-chain contracts
|
|
996
981
|
|
|
997
982
|
---
|
|
998
983
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yellow-org/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "The Nitrolite SDK empowers developers to build high-performance, scalable web3 applications using state channels. It's designed to provide near-instant transactions and significantly improved user experiences by minimizing direct blockchain interactions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|