@agglayer/sdk 1.0.0-beta.18 → 1.0.0-beta.8

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 CHANGED
@@ -3,644 +3,349 @@
3
3
  [![License: ISC](https://img.shields.io/badge/License-ISC-blue.svg?style=flat-square)](https://opensource.org/licenses/ISC)
4
4
  [![TypeScript](https://img.shields.io/badge/TypeScript-4.9+-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
5
5
  [![Node.js](https://img.shields.io/badge/Node.js-18+-green?style=flat-square&logo=node.js)](https://nodejs.org/)
6
- [![NPM Version](https://img.shields.io/npm/v/@agglayer/sdk?style=flat-square)](https://www.npmjs.com/package/@agglayer/sdk)
6
+ [![Bun](https://img.shields.io/badge/Bun-1.0+-black?style=flat-square&logo=bun)](https://bun.sh/)
7
7
 
8
- A comprehensive TypeScript SDK for interacting with the AggLayer ecosystem, providing seamless integration with ARC API services and blockchain operations. Engineered with enterprise-grade architecture, **flexible zero-config setup**, strict type safety, and exceptional developer experience.
8
+ A comprehensive TypeScript SDK for interacting with AggLayer's ARC API and blockchain operations. Built with modular architecture, type safety, and developer experience in mind.
9
9
 
10
10
  ## 🚀 Quick Start
11
11
 
12
12
  ### Installation
13
13
 
14
14
  ```bash
15
- # Production (stable) - NOT YET AVAILABLE
15
+ # Install latest stable version
16
16
  npm install @agglayer/sdk
17
17
 
18
- # Beta (testing)
18
+ # Install beta version (for testing)
19
19
  npm install @agglayer/sdk@beta
20
+
21
+ # Install alpha version (experimental)
22
+ npm install @agglayer/sdk@alpha
20
23
  ```
21
24
 
22
25
  ### Basic Usage
23
26
 
24
27
  ```typescript
25
- import { AggLayerSDK, SDK_MODES } from '@agglayer/sdk';
28
+ import { AggLayerSDK } from '@agglayer/sdk';
26
29
 
27
- // 🎯 NEW: Flexible Configuration - Zero setup required!
28
- // No configuration needed - uses intelligent defaults
30
+ // Initialize SDK with default Core module
29
31
  const sdk = new AggLayerSDK();
32
+ ```
30
33
 
31
- // Or explicitly configure modes and settings
32
- const sdkWithConfig = new AggLayerSDK({
33
- mode: [SDK_MODES.CORE, SDK_MODES.NATIVE],
34
- core: {
35
- apiBaseUrl: 'https://api.agglayer.com',
36
- apiTimeout: 30000,
37
- },
38
- native: {
39
- defaultNetwork: 1, // Ethereum mainnet
40
- },
41
- });
34
+ ## 📋 Release Channels
42
35
 
43
- // Access modules
44
- const core = sdk.getCore();
45
- const native = sdkWithConfig.getNative();
46
- ```
36
+ | Channel | Description | Stability | Usage |
37
+ | -------- | -------------------------------- | ------------------- | --------------------------------- |
38
+ | `latest` | Stable releases (v1.0.0, v2.0.0) | ✅ Production Ready | `npm install @agglayer/sdk` |
39
+ | `beta` | Beta releases (v1.0.0-beta.1) | ⚠️ Testing | `npm install @agglayer/sdk@beta` |
40
+ | `alpha` | Alpha releases (v1.0.0-alpha.1) | 🚧 Experimental | `npm install @agglayer/sdk@alpha` |
41
+ | `dev` | Development releases | 🔧 Development | `npm install @agglayer/sdk@dev` |
42
+
43
+ ## 🏗️ Architecture
44
+
45
+ The SDK is built with a modular architecture supporting two main modules:
46
+
47
+ ### Core Module
48
+
49
+ - **ARC API Integration**: Interact with AggLayer's REST API
50
+ - **Chain Metadata**: Retrieve supported chains and tokens
51
+ - **Route Discovery**: Find optimal bridging routes
52
+ - **Transaction Building**: Build complex multi-step transactions
47
53
 
48
- ## Usage Examples
54
+ ### Native Module
49
55
 
50
- ### Core Module - ARC API Operations
56
+ - **ERC20 Operations**: Token balance, transfers, approvals
57
+ - **Bridge Operations**: Cross-chain bridge interactions
58
+ - **Multi-Chain Support**: Work with multiple blockchain networks
59
+ - **Raw Wei Handling**: All amounts returned as unformatted Wei strings
51
60
 
52
- The Core module provides high-level abstractions for AggLayer's ARC API, enabling route discovery, transaction building, and chain metadata management.
61
+ ## 📖 Usage Examples
53
62
 
54
- #### Chain & Token Metadata
63
+ ### Core Module - API Operations
55
64
 
56
65
  ```typescript
66
+ // Get Core client
57
67
  const core = sdk.getCore();
58
68
 
59
- // Retrieve metadata for all supported chains
69
+ // Retrieve all supported chains
60
70
  const chains = await core.getAllChains();
61
- console.log(`Found ${chains.chains.length} supported chains`);
71
+ console.log('Supported chains:', chains);
62
72
 
63
- // Get specific chain metadata by Chain ID
73
+ // Get chain metadata for specific networks
64
74
  const chainData = await core.getChainMetadataByChainIds([1, 137, 11155111]);
65
75
  console.log('Chain metadata:', chainData);
66
76
 
67
- // Get all tokens grouped by Chain (expensive operation - use sparingly)
68
- const allTokens = await core.getAllTokens();
69
-
70
- // Recommended: Get chain data with tokens for specific chains
71
- const chainTokenData = await core.getChainDataAndTokensByChainIds([1, 137]);
72
-
73
- // NOTE: All above functions manage pagination internally
74
- ```
75
-
76
- #### Route Discovery & Transaction Building
77
-
78
- ```typescript
79
- // Find optimal bridging routes
77
+ // Find bridging routes
80
78
  const routes = await core.getRoutes({
81
- fromChainId: 1, // Ethereum Mainnet
82
- toChainId: 137, // Polygon
79
+ fromChainId: 1,
80
+ toChainId: 137,
83
81
  fromTokenAddress: '0xA0b86a33E6441b8c4C8C0e4b8c4C8C0e4b8c4C8C0',
84
82
  toTokenAddress: '0xB0b86a33E6441b8c4C8C0e4b8c4C8C0e4b8c4C8C0',
85
83
  amount: '1000000000000000000', // 1 token in wei
86
- fromAddress: '0x2254E4D1B41F2Dd3969a79b994E6ee8C3C6F2C71',
87
- slippage: 0.5, // 0.5% slippage tolerance
84
+ fromAddress: '0x1234567890123456789012345678901234567890',
88
85
  });
89
86
 
90
- // Get unsigned transaction from route
91
- const unsignedTx = await core.getUnsignedTransaction(routes);
92
- console.log('Transaction data:', unsignedTx.data);
93
-
94
- // Build claim transaction for completed bridge
95
- const claimTx = await core.getClaimUnsignedTransaction({
96
- sourceNetworkId: 1,
97
- depositCount: 12345,
98
- });
99
- ```
100
-
101
- > NOTE: `getClaimUnsignedTransaction()` expects Agglayer Network ID, not Chain ID
102
-
103
- #### Transaction History & Monitoring
104
-
105
- ```typescript
106
- // Get transaction history with pagination
107
- const transactions = await core.getTransactions({
108
- limit: 50,
109
- startAfter: 'nextStartAfterCursor', // cursor-based pagination
87
+ // Build transaction from route steps
88
+ const transaction = await core.buildTransaction({
89
+ steps: routes.steps,
90
+ fromAddress: '0x1234567890123456789012345678901234567890',
110
91
  });
111
-
112
- console.log(`Retrieved ${transactions.transactions.length} transactions`);
113
92
  ```
114
93
 
115
94
  ### Native Module - Blockchain Operations
116
95
 
117
- The Native module provides direct blockchain interaction capabilities with agglayer chains.
118
- Majority of interaction will happen via the `ERC20` class
119
-
120
- #### Network & Balance Management
121
-
122
96
  ```typescript
97
+ // Get Native client
123
98
  const native = sdk.getNative();
124
99
 
125
- const chainDetails = getNetwork(1);
126
- // Get native token balance (ETH, MATIC, etc.)
100
+ // Get native token balance
127
101
  const nativeBalance = await native.getNativeBalance(
128
- '0xFromAddress12345678901234567890123456789012345',
129
- 1
102
+ '0x1234567890123456789012345678901234567890',
103
+ 11155111 // Sepolia
130
104
  );
131
- console.log(`ETH balance: ${nativeBalance} wei`);
105
+ console.log('Native balance (wei):', nativeBalance);
132
106
 
133
- // Access chain registry for network information
134
- const chainRegistry = native.getChainRegistry();
135
- const ethereumConfig = chainRegistry.getChain(1);
136
- const ethereumConfig = native.getNetwork(1); // OR for convinence
137
- console.log(`RPC URL: ${sepoliaConfig.rpcUrl}`);
138
- ```
139
-
140
- #### ERC20 Token Operations (balance, approve, transfer)
141
-
142
- ```typescript
143
- // Create ERC20 instance for USDC on Sepolia
144
- const usdc = native.erc20(
145
- '0x44499312f493F62f2DFd3C6435Ca3603EbFCeeBa',
107
+ // Create ERC20 instance
108
+ const erc20 = native.erc20(
109
+ '0x1234567890123456789012345678901234567890', // USDC on Sepolia
146
110
  11155111
147
111
  );
148
112
 
149
- // Read operations
150
- const balance = await usdc.getBalance(
151
- '0xFromAddress12345678901234567890123456789012345'
152
- );
153
- const allowance = await usdc.getAllowance(
154
- '0xFromAddress12345678901234567890123456789012345', // owner
155
- '0x1234567890123456789012345678901234567890' // spender
156
- );
157
-
158
- // Build approve transaction (not executed)
159
- const approveTx = await usdc.buildApprove(
160
- '0xSpenderAddress1234567890123456789012345678901', // spender
161
- '1000000', // 1 USDC allowance
162
- '0xFromAddress12345678901234567890123456789012345' // from
113
+ // Get ERC20 token balance
114
+ const tokenBalance = await erc20.getBalance(
115
+ '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd'
163
116
  );
117
+ console.log('Token balance (wei):', tokenBalance);
164
118
 
165
- // Build transaction parameters (not executed)
166
- const transferTx = await usdc.buildTransfer(
167
- '0xRecipientAddress123456789012345678901234567890',
168
- '1000000', // 1 USDC (6 decimals)
169
- '0xFromAddress12345678901234567890123456789012345' // from
119
+ // Build transfer transaction
120
+ const transferTx = await erc20.buildTransfer(
121
+ '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd', // recipient
122
+ '1000000000', // 1000 USDC (6 decimals) in wei
123
+ '0x1111111111111111111111111111111111111111' // from address
170
124
  );
171
125
 
172
- // Build transferFrom transaction
173
- const transferFromTx = await usdc.buildTransferFrom(
174
- '0xFromAddress12345678901234567890123456789012345', // from
175
- '0xToAddress1234567890123456789012345678901234567', // to
176
- '500000', // 0.5 USDC
177
- '0xFromAddress12345678901234567890123456789012345' // spender
126
+ // Build approval transaction
127
+ const approvalTx = await erc20.buildApprove(
128
+ '0x2222222222222222222222222222222222222222', // spender
129
+ '1000000000', // amount in wei
130
+ '0x1111111111111111111111111111111111111111' // from address
178
131
  );
179
132
  ```
180
133
 
181
- #### Cross-Chain Bridge Operations
134
+ ### Bridge Operations
182
135
 
183
136
  ```typescript
184
- // Direct token bridging via ERC20 instance
185
- const bridgeTx = await usdc.bridgeTo(
186
- 137, // Polygon destination
187
- '0xRecipientOnPolygon1234567890123456789012345678',
188
- '1000000', // 1 USDC
189
- '0xFromAddress12345678901234567890123456789012345', // from
190
- {
191
- forceUpdateGlobalExitRoot: true,
192
- permitData: '0x', // optional permit data
193
- }
194
- );
195
-
196
- // Advanced bridge operations via Bridge instance
137
+ // Create bridge instance
197
138
  const bridge = native.bridge(
198
- '0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582', // bridge contract
139
+ '0x3333333333333333333333333333333333333333', // bridge contract
199
140
  11155111 // Sepolia
200
141
  );
201
142
 
202
- // Build bridge asset transaction
203
- const bridgeAssetTx = await bridge.buildBridgeAsset(
204
- {
205
- destinationNetwork: 137,
206
- destinationAddress: '0xRecipientAddress123456789012345678901234567890',
207
- amount: '1000000000000000000', // 1 token in wei
208
- token: '0x44499312f493F62f2DFd3C6435Ca3603EbFCeeBa',
209
- forceUpdateGlobalExitRoot: true,
210
- },
211
- '0xFromAddress12345678901234567890123456789012345'
212
- );
213
-
214
- // Build claim transaction from bridge tx hash
215
- const claimAssetTx = await bridge.buildClaimAssetFromHash(
216
- '0xBridgeTxHash123456789012345678901234567890123456789012345678',
217
- 11155111, // source network where bridge tx occurred
218
- 0, // bridge event index in tx (usually 0)
219
- '0xFromAddress12345678901234567890123456789012345' // claimer address
220
- );
221
-
222
- // Check if bridge deposit is already claimed
223
- const isClaimed = await bridge.isClaimed({
224
- leafIndex: 12345,
225
- sourceBridgeNetwork: 11155111,
226
- });
227
-
228
- // Get wrapped token address on destination chain
229
- const wrappedToken = await bridge.getWrappedTokenAddress({
230
- originNetwork: 11155111,
231
- originTokenAddress: '0x44499312f493F62f2DFd3C6435Ca3603EbFCeeBa',
143
+ // Build bridge transaction
144
+ const bridgeTx = await bridge.buildBridgeTransaction({
145
+ toChainId: 137, // Polygon
146
+ tokenAddress: '0x1234567890123456789012345678901234567890',
147
+ amount: '1000000000',
148
+ recipient: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcd',
149
+ fromAddress: '0x1111111111111111111111111111111111111111',
232
150
  });
233
151
  ```
234
152
 
235
- #### Bridge Message Operations
236
-
237
- ```typescript
238
- // Build bridge message transaction (for arbitrary data)
239
- const bridgeMessageTx = await bridge.buildBridgeMessage(
240
- {
241
- destinationNetwork: 137,
242
- destinationAddress: '0xRecipientContract123456789012345678901234567',
243
- forceUpdateGlobalExitRoot: true,
244
- metadata: '0x1234', // arbitrary data payload
245
- },
246
- '0xFromAddress12345678901234567890123456789012345'
247
- );
248
-
249
- // Build claim message transaction from bridge tx hash
250
- const claimMessageTx = await bridge.buildClaimMessageFromHash(
251
- '0xBridgeMessageTxHash12345678901234567890123456789012345678901234',
252
- 11155111, // source network
253
- 0, // message event index
254
- '0xFromAddress12345678901234567890123456789012345' // claimer
255
- );
256
- ```
257
-
258
153
  ## ⚙️ Configuration
259
154
 
260
- ### SDK Configuration Options
261
-
262
- The SDK provides comprehensive configuration capabilities for both modules with sensible defaults and extensive customization options.
263
-
264
- #### Complete Configuration Example
155
+ ### SDK Configuration
265
156
 
266
157
  ```typescript
267
158
  import { AggLayerSDK, SDK_MODES } from '@agglayer/sdk';
268
159
 
269
160
  const sdk = new AggLayerSDK({
270
- // Module Selection - Choose which modules to enable
271
- mode: [SDK_MODES.CORE, SDK_MODES.NATIVE],
272
-
273
- // Core Module Configuration
161
+ mode: [SDK_MODES.CORE, SDK_MODES.NATIVE], // Enable both modules
274
162
  core: {
275
- // ARC API Configuration
276
- apiBaseUrl: 'https://api.agglayer.com', // Default: 'https://api.agglayer.com'
277
- apiTimeout: 30000, // Default: 30000 (30 seconds)
278
- // Implementation pending for websocket
279
- // websocketBaseUrl: 'wss://ws.agglayer.com', // Optional: For transactions history
163
+ apiBaseUrl: 'https://api.agglayer.com',
164
+ apiTimeout: 30000, // 30 seconds
280
165
  },
281
-
282
- // Native Module Configuration
283
166
  native: {
284
- // Default network for operations
285
- defaultNetwork: 1, // Default: 1 (Ethereum)
286
-
287
- // Custom chain configurations
167
+ defaultNetwork: 11155111, // Default chain ID
288
168
  chains: [
289
169
  {
290
- chainId: 1,
291
- networkId: 1,
170
+ id: 1,
292
171
  name: 'Ethereum Mainnet',
293
- rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/your-api-key',
294
- nativeCurrency: {
295
- name: 'Ether',
296
- symbol: 'ETH',
297
- decimals: 18,
298
- },
299
- blockExplorer: {
300
- name: 'Etherscan',
301
- url: 'https://etherscan.io',
302
- },
303
- bridgeAddress: '0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe',
304
- proofApiUrl: 'https://proof-api.polygonzkevmchain.com',
305
- isTestnet: false,
172
+ rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/your-key',
173
+ nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
306
174
  },
307
175
  {
308
- chainId: 137,
309
- networkId: 137,
310
- name: 'Polygon Mainnet',
311
- rpcUrl: 'https://polygon-mainnet.g.alchemy.com/v2/your-api-key',
312
- nativeCurrency: {
313
- name: 'MATIC',
314
- symbol: 'MATIC',
315
- decimals: 18,
316
- },
317
- bridgeAddress: '0x2a3DD3EB832aF982ec71669E178424b10Dca2EDe',
318
- isTestnet: false,
176
+ id: 137,
177
+ name: 'Polygon',
178
+ rpcUrl: 'https://polygon-rpc.com',
179
+ nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
319
180
  },
320
181
  ],
321
-
322
- // Override RPC URLs for existing chains
323
182
  customRpcUrls: {
324
- 1: 'https://your-premium-ethereum-rpc.com',
325
- 137: 'https://your-premium-polygon-rpc.com',
326
- 11155111: 'https://sepolia.infura.io/v3/your-project-id',
183
+ 1: 'https://your-custom-eth-rpc.com',
184
+ 137: 'https://your-custom-polygon-rpc.com',
327
185
  },
328
186
  },
329
187
  });
330
188
  ```
331
189
 
332
- #### Core Module Configuration
190
+ ### Module-Specific Usage
333
191
 
334
192
  ```typescript
335
- interface CoreConfig {
336
- apiBaseUrl?: string; // ARC API base URL
337
- apiTimeout?: number; // Request timeout in milliseconds
338
- // websocketBaseUrl?: string; // WebSocket endpoint for real-time updates
339
- }
340
- ```
341
-
342
- **Default Values:**
343
-
344
- - `apiBaseUrl`: `'https://arc-api.polygon.technology'`
345
- - `apiTimeout`: `30000` (30 seconds)
346
-
347
- #### Native Module Configuration
348
-
349
- ```typescript
350
- interface NativeConfig {
351
- defaultNetwork?: number; // Default chain ID for operations
352
- chains?: ChainConfig[]; // Custom chain configurations
353
- customRpcUrls?: Record<number, string>; // Override RPC URLs by chain ID
354
- }
355
-
356
- interface ChainConfig {
357
- chainId: number; // EIP-155 chain identifier
358
- networkId: number; // Network identifier (usually same as chainId)
359
- name: string; // Human-readable chain name
360
- rpcUrl: string; // RPC endpoint URL
361
- nativeCurrency: {
362
- // Native token configuration
363
- name: string;
364
- symbol: string;
365
- decimals: number;
366
- };
367
- blockExplorer?: {
368
- // Optional block explorer
369
- name: string;
370
- url: string;
371
- };
372
- bridgeAddress?: string; // Bridge contract address
373
- proofApiUrl?: string; // Proof generation API endpoint
374
- isTestnet?: boolean; // Network type flag
375
- isLocal?: boolean; // Local development network flag
376
- }
377
- ```
378
-
379
- **Default Values:**
380
-
381
- - `defaultNetwork`: `1` (Ethereum mainnet)
382
- - `chains`: Built-in registry with major networks
383
- - `customRpcUrls`: `{}`
384
-
385
- ### Module-Specific Configurations
386
-
387
- #### Core-Only Setup (API Integration)
388
-
389
- ```typescript
390
- const coreOnlySDK = new AggLayerSDK({
193
+ // Core-only configuration
194
+ const coreOnlySdk = new AggLayerSDK({
391
195
  mode: [SDK_MODES.CORE],
392
196
  core: {
393
197
  apiBaseUrl: 'https://api.agglayer.com',
394
- apiTimeout: 45000, // Increased timeout for complex operations
395
- // websocketBaseUrl: 'wss://ws.agglayer.com'
396
198
  },
199
+ native: {} as any, // Required but unused
397
200
  });
398
201
 
399
- const core = coreOnlySDK.getCore();
400
- ```
401
-
402
- #### Native-Only Setup (Blockchain Operations)
403
-
404
- ```typescript
405
- const nativeOnlySDK = new AggLayerSDK({
202
+ // Native-only configuration
203
+ const nativeOnlySdk = new AggLayerSDK({
406
204
  mode: [SDK_MODES.NATIVE],
205
+ core: {} as any, // Required but unused
407
206
  native: {
408
- defaultNetwork: 1, // Ethereum Mainnet
409
- customRpcUrls: {
410
- 1: 'https://eth-mainnet.g.alchemy.com/v2/your-key',
411
- 137: 'https://polygon-mainnet.g.alchemy.com/v2/your-key',
412
- },
207
+ defaultNetwork: 11155111,
208
+ chains: [
209
+ /* your chains */
210
+ ],
413
211
  },
414
212
  });
415
-
416
- const native = nativeOnlySDK.getNative();
417
213
  ```
418
214
 
419
- #### Environment-Specific Configurations
215
+ ## 🚀 Release Process
420
216
 
421
- ```typescript
422
- // Development Configuration
423
- const devConfig = {
424
- mode: [SDK_MODES.CORE, SDK_MODES.NATIVE],
425
- core: {
426
- apiBaseUrl: 'http://localhost:3001', // Local development server
427
- apiTimeout: 10000,
428
- },
429
- native: {
430
- defaultNetwork: 11155111, // Sepolia testnet
431
- customRpcUrls: {
432
- 11155111: 'http://localhost:8545', // Local Ethereum fork
433
- },
434
- },
435
- };
217
+ The SDK uses a tag-based release workflow for all releases:
436
218
 
437
- // Production Configuration
438
- const prodConfig = {
439
- mode: [SDK_MODES.CORE, SDK_MODES.NATIVE],
440
- core: {
441
- apiBaseUrl: 'https://api.agglayer.com',
442
- apiTimeout: 30000,
443
- },
444
- native: {
445
- defaultNetwork: 1, // Ethereum Mainnet
446
- customRpcUrls: {
447
- 1: process.env.ETHEREUM_RPC_URL,
448
- 137: process.env.POLYGON_RPC_URL,
449
- },
450
- },
451
- };
219
+ ### **Tag-Based Releases**
452
220
 
453
- // Use environment-appropriate config
454
- const config = process.env.NODE_ENV === 'production' ? prodConfig : devConfig;
455
- const sdk = new AggLayerSDK(config);
221
+ ```bash
222
+ # Create and push a tag to trigger release
223
+ git tag v1.0.0-beta.1
224
+ git push origin v1.0.0-beta.1
456
225
  ```
457
226
 
458
- ### Built-in Chain Registry
227
+ ### **Manual Releases**
459
228
 
460
- The SDK includes a comprehensive registry of popular networks:
229
+ 1. Go to GitHub Actions "Tag Release"
230
+ 2. Choose release type and channel
231
+ 3. Click "Run workflow"
461
232
 
462
- - **Ethereum Mainnet** (Chain ID: 1)
463
- - **Katana** (Chain ID: 747474)
464
- - **Sepolia Testnet** (Chain ID: 11155111)
465
- <!-- - **Bokuto Testnet** (Chain ID: 2442) -->
233
+ ### **Release Types**
466
234
 
467
- Additional networks can be added via the `chains` configuration option.
235
+ - **Stable**: `v1.0.0` `latest` channel
236
+ - **Beta**: `v1.0.0-beta.1` → `beta` channel
237
+ - **Alpha**: `v1.0.0-alpha.1` → `alpha` channel
238
+ - **Dev**: `v1.0.0-dev.1` → `dev` channel
468
239
 
469
- ## 🔧 Architecture & Design Principles
240
+ ## 🔧 Development
470
241
 
471
- The SDK employs a **modular microservice architecture** with strict separation of concerns:
472
-
473
- ### Core Module (`SDK_MODES.CORE`)
474
-
475
- Core module primarily supports the features based on ARC API
476
-
477
- - **Chain Registry**: Comprehensive chain management
478
- - **Route Discovery**: Intelligently find routes for bridging, across agglayer bridge and other aggregators
479
- - **Transaction Orchestration**: Prepare unsigned executable transactions based on routes
480
- - **Transactions Activity and History**: Track status of transactions to perform aadditional functions like claim or view history of transactions.
481
-
482
- ### Native Module (`SDK_MODES.NATIVE`)
483
-
484
- Interact with blockchain and agglayer bridge directly, this does not involve any additional APIs(except for proof generation)
485
-
486
- - **ERC20 Token Operations**: Standards-compliant token interactions(getBalance, getAllowance, buildApprove, etc)
487
- - **Bridge Infrastructure**: Cross-chain asset transfer protocols (like bridgeTo, claimAsset, etc via ERC20 interface)
488
-
489
- ### Key Design Principles
242
+ ### Prerequisites
490
243
 
491
- - **Type-First Development**: 100% TypeScript with strict mode enabled
492
- - **Flexible Configuration**: Zero-config defaults with progressive customization
493
- - **Immutable Data Structures**: Predictable state management
494
- - **Error-First Callbacks**: Comprehensive error handling patterns
495
- - **Smart Defaults**: Intelligent fallbacks that work out-of-the-box
496
- - **Modular Loading**: Tree-shakeable imports for optimized bundles
244
+ - Node.js 18+
245
+ - npm or bun
497
246
 
498
- ## � Release Channels & Versioning
247
+ ### Setup
499
248
 
500
- The SDK follows semantic versioning with multiple release channels for different stability requirements:
249
+ ```bash
250
+ # Clone the repository
251
+ git clone https://github.com/agglayer/sdk.git
252
+ cd sdk
501
253
 
502
- | Channel | Description | Stability | Installation | Use Case |
503
- | -------- | -------------------------- | ------------------- | --------------------------------- | ------------------------------- |
504
- | `latest` | Stable production releases | ✅ Production Ready | `npm install @agglayer/sdk` | Production applications |
505
- | `beta` | Release candidates | ⚠️ Testing | `npm install @agglayer/sdk@beta` | Pre-production testing |
506
- | `alpha` | Early feature previews | 🚧 Experimental | `npm install @agglayer/sdk@alpha` | Feature development |
507
- | `dev` | Internal use | 🔧 Development | `npm install @agglayer/sdk@dev` | SDK development & bleeding edge |
254
+ # Install dependencies
255
+ npm install
508
256
 
509
- ### Release Strategy
257
+ # Build the project
258
+ npm run build
259
+ ```
510
260
 
511
- - **Stable releases** (`v1.0.0`, `v2.0.0`): Thoroughly tested, API-stable versions
512
- - **Beta releases** (`v1.0.0-beta.1`): Feature-complete candidates with minimal changes expected
513
- - **Alpha releases** (`v1.0.0-alpha.1`): Early access to new features, API may change
514
- - **Dev releases** (`v1.0.0-dev.1`): Internal use
261
+ ### Available Scripts
515
262
 
516
- ## Quick Reference
263
+ | Script | Description |
264
+ | ----------------------- | ----------------------------------- |
265
+ | `npm run build` | Build the library for production |
266
+ | `npm run dev` | Build in watch mode for development |
267
+ | `npm run test` | Run test suite |
268
+ | `npm run test:coverage` | Run tests with coverage report |
269
+ | `npm run test:watch` | Run tests in watch mode |
270
+ | `npm run lint` | Run ESLint |
271
+ | `npm run lint:fix` | Fix ESLint issues automatically |
272
+ | `npm run format` | Format code with Prettier |
273
+ | `npm run format:check` | Check code formatting |
274
+ | `npm run typecheck` | Type check with TypeScript |
517
275
 
518
- ### Common Configuration Patterns
276
+ ### Testing
519
277
 
520
- ```typescript
521
- // Development with testnet
522
- const devSdk = new AggLayerSDK({
523
- mode: [SDK_MODES.CORE, SDK_MODES.NATIVE],
524
- core: {
525
- apiBaseUrl: 'https://api-testnet.agglayer.com',
526
- },
527
- native: {
528
- defaultNetwork: 11155111, // Sepolia testnet
529
- },
530
- });
278
+ ```bash
279
+ # Run all tests
280
+ npm run test
531
281
 
532
- // Production with custom timeouts
533
- const prodSdk = new AggLayerSDK({
534
- core: {
535
- apiTimeout: 60000, // 60 second timeout
536
- },
537
- });
282
+ # Run tests with coverage
283
+ npm run test:coverage
538
284
 
539
- // Multi-chain setup
540
- const multiChainSdk = new AggLayerSDK({
541
- mode: [SDK_MODES.NATIVE],
542
- native: {
543
- defaultNetwork: 1,
544
- customRpcUrls: {
545
- 1: 'https://ethereum-mainnet.infura.io/v3/YOUR_KEY',
546
- 137: 'https://polygon-mainnet.infura.io/v3/YOUR_KEY',
547
- 42161: 'https://arbitrum-mainnet.infura.io/v3/YOUR_KEY',
548
- },
549
- },
550
- });
285
+ # Run tests in watch mode
286
+ npm run test:watch
551
287
  ```
552
288
 
553
- ## 🔧 Development & Contributing
289
+ ## 🎯 Key Features
554
290
 
555
- ### Prerequisites
556
-
557
- - **Node.js** 18+ or **Bun** 1.0+
558
- - **TypeScript** 4.9+
559
- - **Git** for version control
291
+ ### Type Safety
560
292
 
561
- ### Local Development Setup
562
-
563
- ```bash
564
- # Clone the repository
565
- git clone https://github.com/agglayer/sdk.git
566
- cd sdk
293
+ - Full TypeScript support with strict configuration
294
+ - Comprehensive type definitions for all operations
295
+ - IntelliSense support for better developer experience
567
296
 
568
- # Install dependencies (npm, yarn, or bun)
569
- npm install
570
- # or
571
- bun install
297
+ ### Modular Design
572
298
 
573
- # Build the project
574
- npm run build
299
+ - **Core Module**: ARC API integration for route discovery and transaction building
300
+ - **Native Module**: Direct blockchain interactions for ERC20 and bridge operations
301
+ - Flexible configuration allowing module-specific usage
575
302
 
576
- # Start development mode with hot reload
577
- npm run dev
578
- ```
303
+ ### Multi-Chain Support
579
304
 
580
- ### Available Development Scripts
305
+ - Built-in support for major EVM chains
306
+ - Custom chain configuration
307
+ - Custom RPC URL support
308
+ - Chain registry for easy network management
581
309
 
582
- | Script | Description | Usage |
583
- | ----------------------- | ------------------------------------------ | ------------------------------------- |
584
- | `npm run build` | Production build with optimizations | CI/CD and release preparation |
585
- | `npm run dev` | Development build with watch mode | Local development with hot reload |
586
- | `npm run typecheck` | TypeScript type checking without emit | Validate types before commits |
587
- | `npm run test` | Run complete test suite | Continuous testing during development |
588
- | `npm run test:run` | Single test run without watch | CI/CD pipeline testing |
589
- | `npm run test:coverage` | Generate test coverage reports | Quality assurance metrics |
590
- | `npm run test:watch` | Interactive test runner with file watching | TDD development workflow |
591
- | `npm run lint` | ESLint code quality analysis | Code style enforcement |
592
- | `npm run lint:fix` | Auto-fix ESLint issues | Automated code style corrections |
593
- | `npm run format` | Prettier code formatting | Consistent code style across codebase |
594
- | `npm run format:check` | Validate code formatting | CI/CD formatting verification |
595
- | `npm run clean` | Remove build artifacts | Clean slate rebuilds |
310
+ ### Raw Wei Handling
596
311
 
597
- ## 🚨 Error Handling & Debugging
312
+ - All token amounts returned as unformatted Wei strings
313
+ - No automatic decimal conversion for precision control
314
+ - Consistent number formatting across all operations
598
315
 
599
- ### Comprehensive Error Types
316
+ ### Lightweight & Efficient
600
317
 
601
- The SDK provides detailed error information for all failure scenarios:
318
+ - Minimal dependencies (only viem for blockchain interactions)
319
+ - Tree-shakeable modules
320
+ - Optimized bundle size
602
321
 
603
- ```typescript
604
- try {
605
- const routes = await core.getRoutes({
606
- fromChainId: 1,
607
- toChainId: 137,
608
- fromTokenAddress: '0xinvalid',
609
- toTokenAddress: '0x...',
610
- amount: '1000000000000000000',
611
- fromAddress: '0x...',
612
- });
613
- } catch (error) {
614
- if (error instanceof ValidationError) {
615
- console.error('Input validation failed:', error.message);
616
- console.error('Field:', error.field);
617
- console.error('Value:', error.value);
618
- } else if (error instanceof NetworkError) {
619
- console.error('Network request failed:', error.message);
620
- console.error('Status:', error.status);
621
- console.error('Endpoint:', error.url);
622
- } else if (error instanceof ContractError) {
623
- console.error('Contract interaction failed:', error.message);
624
- console.error('Contract:', error.address);
625
- console.error('Function:', error.functionName);
626
- }
627
- }
628
- ```
322
+ ## 🤝 Contributing
629
323
 
630
- ## 📈 Roadmap & Future Development
324
+ We welcome contributions! Please follow these steps:
631
325
 
632
- ### Upcoming Features
326
+ 1. **Fork the repository**
327
+ 2. **Create a feature branch**: `git checkout -b feature/your-feature-name`
328
+ 3. **Make your changes** following our coding standards
329
+ 4. **Run tests**: `npm run test`
330
+ 5. **Run linting**: `npm run lint`
331
+ 6. **Format code**: `npm run format`
332
+ 7. **Submit a pull request**
633
333
 
634
- - User input validations
635
- - Runtime api response validation using zod
636
- - WebSocket support for real-time updates of transactions and their status
334
+ ### Code Quality Standards
637
335
 
638
- ---
336
+ - **TypeScript**: Strict type checking enabled
337
+ - **ESLint**: Enforced code quality rules
338
+ - **Prettier**: Consistent code formatting
339
+ - **Vitest**: Comprehensive test coverage
340
+ - **Husky**: Pre-commit hooks for quality assurance
639
341
 
640
- <div align="center">
342
+ ## 📄 License
641
343
 
642
- **Built with ❤️ by the AggLayer Team**
344
+ ISC License - see [LICENSE](LICENSE) file for details.
643
345
 
644
- [⭐ Star us on GitHub](https://github.com/agglayer/sdk) • [🐛 Report Issues](https://github.com/agglayer/sdk/issues)
346
+ ## 🔗 Links
645
347
 
646
- </div>
348
+ - [GitHub Repository](https://github.com/agglayer/sdk)
349
+ - [NPM Package](https://www.npmjs.com/package/@agglayer/sdk)
350
+ - [Documentation](https://docs.agglayer.com)
351
+ - [Issues](https://github.com/agglayer/sdk/issues)