@chainlink/ccip-sdk 0.96.0 → 0.97.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.
Files changed (199) hide show
  1. package/dist/api/index.d.ts +17 -8
  2. package/dist/api/index.d.ts.map +1 -1
  3. package/dist/api/index.js +27 -10
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/api/types.d.ts +0 -2
  6. package/dist/api/types.d.ts.map +1 -1
  7. package/dist/aptos/exec.d.ts +2 -2
  8. package/dist/aptos/exec.d.ts.map +1 -1
  9. package/dist/aptos/exec.js.map +1 -1
  10. package/dist/aptos/hasher.d.ts.map +1 -1
  11. package/dist/aptos/hasher.js +1 -1
  12. package/dist/aptos/hasher.js.map +1 -1
  13. package/dist/aptos/index.d.ts +13 -10
  14. package/dist/aptos/index.d.ts.map +1 -1
  15. package/dist/aptos/index.js +42 -68
  16. package/dist/aptos/index.js.map +1 -1
  17. package/dist/aptos/types.d.ts +2 -19
  18. package/dist/aptos/types.d.ts.map +1 -1
  19. package/dist/aptos/types.js +0 -11
  20. package/dist/aptos/types.js.map +1 -1
  21. package/dist/chain.d.ts +532 -151
  22. package/dist/chain.d.ts.map +1 -1
  23. package/dist/chain.js +113 -18
  24. package/dist/chain.js.map +1 -1
  25. package/dist/commits.d.ts +4 -6
  26. package/dist/commits.d.ts.map +1 -1
  27. package/dist/commits.js +4 -4
  28. package/dist/commits.js.map +1 -1
  29. package/dist/errors/CCIPError.d.ts +33 -4
  30. package/dist/errors/CCIPError.d.ts.map +1 -1
  31. package/dist/errors/CCIPError.js +33 -4
  32. package/dist/errors/CCIPError.js.map +1 -1
  33. package/dist/errors/codes.d.ts +3 -0
  34. package/dist/errors/codes.d.ts.map +1 -1
  35. package/dist/errors/codes.js +3 -1
  36. package/dist/errors/codes.js.map +1 -1
  37. package/dist/errors/index.d.ts +1 -1
  38. package/dist/errors/index.d.ts.map +1 -1
  39. package/dist/errors/index.js +1 -1
  40. package/dist/errors/index.js.map +1 -1
  41. package/dist/errors/recovery.d.ts.map +1 -1
  42. package/dist/errors/recovery.js +4 -1
  43. package/dist/errors/recovery.js.map +1 -1
  44. package/dist/errors/specialized.d.ts +1695 -120
  45. package/dist/errors/specialized.d.ts.map +1 -1
  46. package/dist/errors/specialized.js +1715 -123
  47. package/dist/errors/specialized.js.map +1 -1
  48. package/dist/errors/utils.d.ts.map +1 -1
  49. package/dist/errors/utils.js +0 -1
  50. package/dist/errors/utils.js.map +1 -1
  51. package/dist/evm/abi/OffRamp_2_0.d.ts +764 -0
  52. package/dist/evm/abi/OffRamp_2_0.d.ts.map +1 -0
  53. package/dist/evm/abi/OffRamp_2_0.js +744 -0
  54. package/dist/evm/abi/OffRamp_2_0.js.map +1 -0
  55. package/dist/evm/abi/OnRamp_2_0.d.ts +925 -0
  56. package/dist/evm/abi/OnRamp_2_0.d.ts.map +1 -0
  57. package/dist/evm/abi/OnRamp_2_0.js +992 -0
  58. package/dist/evm/abi/OnRamp_2_0.js.map +1 -0
  59. package/dist/evm/const.d.ts +12 -2
  60. package/dist/evm/const.d.ts.map +1 -1
  61. package/dist/evm/const.js +8 -2
  62. package/dist/evm/const.js.map +1 -1
  63. package/dist/evm/errors.d.ts.map +1 -1
  64. package/dist/evm/errors.js +7 -2
  65. package/dist/evm/errors.js.map +1 -1
  66. package/dist/evm/extra-args.d.ts.map +1 -1
  67. package/dist/evm/extra-args.js +5 -24
  68. package/dist/evm/extra-args.js.map +1 -1
  69. package/dist/evm/hasher.d.ts.map +1 -1
  70. package/dist/evm/hasher.js +23 -13
  71. package/dist/evm/hasher.js.map +1 -1
  72. package/dist/evm/index.d.ts +73 -14
  73. package/dist/evm/index.d.ts.map +1 -1
  74. package/dist/evm/index.js +240 -141
  75. package/dist/evm/index.js.map +1 -1
  76. package/dist/evm/messages.d.ts +59 -5
  77. package/dist/evm/messages.d.ts.map +1 -1
  78. package/dist/evm/messages.js +210 -0
  79. package/dist/evm/messages.js.map +1 -1
  80. package/dist/evm/offchain.js.map +1 -1
  81. package/dist/evm/types.d.ts +7 -2
  82. package/dist/evm/types.d.ts.map +1 -1
  83. package/dist/evm/types.js +22 -1
  84. package/dist/evm/types.js.map +1 -1
  85. package/dist/execution.d.ts +62 -22
  86. package/dist/execution.d.ts.map +1 -1
  87. package/dist/execution.js +98 -61
  88. package/dist/execution.js.map +1 -1
  89. package/dist/extra-args.d.ts +13 -3
  90. package/dist/extra-args.d.ts.map +1 -1
  91. package/dist/extra-args.js +13 -3
  92. package/dist/extra-args.js.map +1 -1
  93. package/dist/gas.d.ts +25 -2
  94. package/dist/gas.d.ts.map +1 -1
  95. package/dist/gas.js +30 -4
  96. package/dist/gas.js.map +1 -1
  97. package/dist/index.d.ts +1 -1
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/requests.d.ts +85 -14
  100. package/dist/requests.d.ts.map +1 -1
  101. package/dist/requests.js +99 -16
  102. package/dist/requests.js.map +1 -1
  103. package/dist/selectors.d.ts.map +1 -1
  104. package/dist/selectors.js +12 -0
  105. package/dist/selectors.js.map +1 -1
  106. package/dist/shared/bcs-codecs.d.ts +61 -0
  107. package/dist/shared/bcs-codecs.d.ts.map +1 -0
  108. package/dist/shared/bcs-codecs.js +102 -0
  109. package/dist/shared/bcs-codecs.js.map +1 -0
  110. package/dist/shared/constants.d.ts +3 -0
  111. package/dist/shared/constants.d.ts.map +1 -0
  112. package/dist/shared/constants.js +3 -0
  113. package/dist/shared/constants.js.map +1 -0
  114. package/dist/solana/exec.d.ts +2 -2
  115. package/dist/solana/exec.d.ts.map +1 -1
  116. package/dist/solana/exec.js.map +1 -1
  117. package/dist/solana/index.d.ts +80 -17
  118. package/dist/solana/index.d.ts.map +1 -1
  119. package/dist/solana/index.js +67 -30
  120. package/dist/solana/index.js.map +1 -1
  121. package/dist/sui/hasher.d.ts.map +1 -1
  122. package/dist/sui/hasher.js +1 -1
  123. package/dist/sui/hasher.js.map +1 -1
  124. package/dist/sui/index.d.ts +14 -12
  125. package/dist/sui/index.d.ts.map +1 -1
  126. package/dist/sui/index.js +38 -34
  127. package/dist/sui/index.js.map +1 -1
  128. package/dist/sui/manuallyExec/encoder.d.ts +2 -2
  129. package/dist/sui/manuallyExec/encoder.d.ts.map +1 -1
  130. package/dist/sui/manuallyExec/encoder.js.map +1 -1
  131. package/dist/sui/manuallyExec/index.d.ts +2 -2
  132. package/dist/sui/manuallyExec/index.d.ts.map +1 -1
  133. package/dist/ton/exec.d.ts +2 -2
  134. package/dist/ton/exec.d.ts.map +1 -1
  135. package/dist/ton/exec.js.map +1 -1
  136. package/dist/ton/index.d.ts +9 -16
  137. package/dist/ton/index.d.ts.map +1 -1
  138. package/dist/ton/index.js +26 -31
  139. package/dist/ton/index.js.map +1 -1
  140. package/dist/ton/types.d.ts +2 -2
  141. package/dist/ton/types.d.ts.map +1 -1
  142. package/dist/ton/types.js.map +1 -1
  143. package/dist/types.d.ts +46 -11
  144. package/dist/types.d.ts.map +1 -1
  145. package/dist/types.js +6 -1
  146. package/dist/types.js.map +1 -1
  147. package/dist/utils.d.ts +65 -2
  148. package/dist/utils.d.ts.map +1 -1
  149. package/dist/utils.js +74 -2
  150. package/dist/utils.js.map +1 -1
  151. package/package.json +9 -9
  152. package/src/api/index.ts +33 -10
  153. package/src/api/types.ts +0 -2
  154. package/src/aptos/exec.ts +2 -2
  155. package/src/aptos/hasher.ts +1 -1
  156. package/src/aptos/index.ts +51 -89
  157. package/src/aptos/types.ts +2 -15
  158. package/src/chain.ts +581 -163
  159. package/src/commits.ts +9 -9
  160. package/src/errors/CCIPError.ts +33 -4
  161. package/src/errors/codes.ts +3 -1
  162. package/src/errors/index.ts +1 -0
  163. package/src/errors/recovery.ts +7 -1
  164. package/src/errors/specialized.ts +1726 -130
  165. package/src/errors/utils.ts +0 -1
  166. package/src/evm/abi/OffRamp_2_0.ts +743 -0
  167. package/src/evm/abi/OnRamp_2_0.ts +991 -0
  168. package/src/evm/const.ts +10 -3
  169. package/src/evm/errors.ts +6 -2
  170. package/src/evm/extra-args.ts +4 -21
  171. package/src/evm/hasher.ts +30 -18
  172. package/src/evm/index.ts +310 -166
  173. package/src/evm/messages.ts +323 -11
  174. package/src/evm/offchain.ts +2 -2
  175. package/src/evm/types.ts +20 -2
  176. package/src/execution.ts +125 -86
  177. package/src/extra-args.ts +13 -3
  178. package/src/gas.ts +29 -3
  179. package/src/index.ts +2 -2
  180. package/src/requests.ts +112 -16
  181. package/src/selectors.ts +12 -0
  182. package/src/shared/bcs-codecs.ts +132 -0
  183. package/src/shared/constants.ts +2 -0
  184. package/src/solana/exec.ts +4 -4
  185. package/src/solana/index.ts +100 -68
  186. package/src/sui/hasher.ts +1 -1
  187. package/src/sui/index.ts +50 -47
  188. package/src/sui/manuallyExec/encoder.ts +2 -2
  189. package/src/sui/manuallyExec/index.ts +2 -2
  190. package/src/ton/exec.ts +2 -2
  191. package/src/ton/index.ts +37 -40
  192. package/src/ton/types.ts +2 -2
  193. package/src/types.ts +70 -29
  194. package/src/utils.ts +73 -2
  195. package/dist/aptos/utils.d.ts +0 -12
  196. package/dist/aptos/utils.d.ts.map +0 -1
  197. package/dist/aptos/utils.js +0 -15
  198. package/dist/aptos/utils.js.map +0 -1
  199. package/src/aptos/utils.ts +0 -24
package/dist/chain.d.ts CHANGED
@@ -7,7 +7,7 @@ import type { EVMExtraArgsV1, EVMExtraArgsV2, ExtraArgs, GenericExtraArgsV3, SVM
7
7
  import type { LeafHasher } from './hasher/common.ts';
8
8
  import type { UnsignedSolanaTx } from './solana/types.ts';
9
9
  import type { UnsignedTONTx } from './ton/types.ts';
10
- import { type AnyMessage, type CCIPCommit, type CCIPExecution, type CCIPMessage, type CCIPRequest, type ChainFamily, type ChainTransaction, type CommitReport, type ExecutionReceipt, type ExecutionReport, type Lane, type Log_, type Logger, type MessageInput, type NetworkInfo, type OffchainTokenData, type WithLogger } from './types.ts';
10
+ import { type AnyMessage, type CCIPExecution, type CCIPMessage, type CCIPRequest, type CCIPVerifications, type ChainFamily, type ChainTransaction, type CommitReport, type ExecutionInput, type ExecutionReceipt, type Lane, type Log_, type Logger, type MessageInput, type NetworkInfo, type OffchainTokenData, type WithLogger } from './types.ts';
11
11
  import { util } from './utils.ts';
12
12
  /**
13
13
  * Context for Chain class initialization.
@@ -21,7 +21,7 @@ import { util } from './utils.ts';
21
21
  *
22
22
  * @example Custom API endpoint
23
23
  * ```typescript
24
- * const api = new CCIPAPIClient('https://staging-api.example.com', { logger })
24
+ * const api = CCIPAPIClient.fromUrl('https://staging-api.example.com', { logger })
25
25
  * const chain = await EVMChain.fromUrl(rpcUrl, { apiClient: api, logger })
26
26
  * ```
27
27
  *
@@ -220,13 +220,20 @@ export type SendMessageOpts = {
220
220
  approveMax?: boolean;
221
221
  };
222
222
  /**
223
- * Common options for {@link Chain.generateUnsignedExecuteReport} and {@link Chain.executeReport} methods.
223
+ * Common options for {@link Chain.generateUnsignedExecute} and {@link Chain.execute} methods.
224
224
  */
225
- export type ExecuteReportOpts = {
225
+ export type ExecuteOpts = ({
226
226
  /** address of the OffRamp contract */
227
227
  offRamp: string;
228
- /** execution report */
229
- execReport: ExecutionReport;
228
+ /** input payload to execute message; contains proofs for v1 and verifications for v2 */
229
+ input: ExecutionInput;
230
+ } | {
231
+ /**
232
+ * messageId of message to execute; requires `apiClient`.
233
+ * @remarks Currently throws CCIPNotImplementedError - API endpoint pending.
234
+ */
235
+ messageId: string;
236
+ }) & {
230
237
  /** gasLimit or computeUnits limit override for the ccipReceive call */
231
238
  gasLimit?: number;
232
239
  /** For EVM, overrides gasLimit on tokenPool call */
@@ -259,24 +266,63 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
259
266
  /** Cleanup method to release resources (e.g., close connections). */
260
267
  destroy?(): void | Promise<void>;
261
268
  /**
262
- * Fetch the timestamp of a given block
263
- * @param block - positive block number, negative finality depth or 'finalized' tag
264
- * @returns timestamp of the block, in seconds
269
+ * Fetch the timestamp of a given block.
270
+ *
271
+ * @param block - Positive block number, negative finality depth, or 'finalized' tag
272
+ * @returns Promise resolving to timestamp of the block, in seconds
273
+ *
265
274
  * @throws {@link CCIPBlockNotFoundError} if block does not exist
275
+ *
276
+ * @example Get finalized block timestamp
277
+ * ```typescript
278
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
279
+ * const timestamp = await chain.getBlockTimestamp('finalized')
280
+ * console.log(`Finalized at: ${new Date(timestamp * 1000).toISOString()}`)
281
+ * ```
266
282
  */
267
283
  abstract getBlockTimestamp(block: number | 'finalized'): Promise<number>;
268
284
  /**
269
- * Fetch a transaction by its hash
270
- * @param hash - transaction hash
271
- * @returns generic transaction details
272
- * @throws {@link CCIPTransactionNotFoundError} if transaction not found
285
+ * Fetch a transaction by its hash.
286
+ *
287
+ * @param hash - Transaction hash
288
+ * @returns Promise resolving to generic transaction details
289
+ *
290
+ * @throws {@link CCIPTransactionNotFoundError} if transaction does not exist (transient)
291
+ *
292
+ * @example Fetch transaction details
293
+ * ```typescript
294
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
295
+ * try {
296
+ * const tx = await chain.getTransaction('0xabc123...')
297
+ * console.log(`Block: ${tx.blockNumber}, Timestamp: ${tx.timestamp}`)
298
+ * } catch (err) {
299
+ * if (err instanceof CCIPTransactionNotFoundError && err.isTransient) {
300
+ * // Transaction may be pending
301
+ * }
302
+ * }
303
+ * ```
273
304
  */
274
305
  abstract getTransaction(hash: string): Promise<ChainTransaction>;
275
306
  /**
276
307
  * Confirm a log tx is finalized or wait for it to be finalized.
308
+ *
277
309
  * @param opts - Options containing the request, finality level, and optional cancel promise
278
310
  * @returns true when the transaction is finalized
311
+ *
279
312
  * @throws {@link CCIPTransactionNotFinalizedError} if the transaction is not included (e.g., due to a reorg)
313
+ *
314
+ * @example Wait for message finality
315
+ * ```typescript
316
+ * const request = await source.getMessagesInTx(txHash)
317
+ * try {
318
+ * await source.waitFinalized({ request: request[0] })
319
+ * console.log('Transaction finalized')
320
+ * } catch (err) {
321
+ * if (err instanceof CCIPTransactionNotFinalizedError) {
322
+ * console.log('Transaction not yet finalized')
323
+ * }
324
+ * }
325
+ * ```
280
326
  */
281
327
  waitFinalized({ request: { log, tx }, finality, cancel$, }: {
282
328
  request: SetOptional<PickDeep<CCIPRequest, `log.${'address' | 'blockNumber' | 'transactionHash' | 'topics' | 'tx.timestamp'}` | 'tx.timestamp'>, 'tx'>;
@@ -309,10 +355,22 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
309
355
  */
310
356
  abstract getLogs(opts: LogFilter): AsyncIterableIterator<Log_>;
311
357
  /**
312
- * Fetch all CCIP requests in a transaction
358
+ * Fetch all CCIP requests in a transaction.
359
+ *
313
360
  * @param tx - ChainTransaction or txHash to fetch requests from
314
- * @returns CCIP messages in the transaction (at least one)
315
- * @throws {@link CCIPMessageNotFoundInTxError} if no CCIP messages found in transaction
361
+ * @returns Promise resolving to CCIP messages in the transaction (at least one)
362
+ *
363
+ * @throws {@link CCIPTransactionNotFoundError} if transaction does not exist
364
+ * @throws {@link CCIPMessageNotFoundInTxError} if no CCIPSendRequested events in tx
365
+ *
366
+ * @example Get messages from transaction
367
+ * ```typescript
368
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
369
+ * const requests = await chain.getMessagesInTx('0xabc123...')
370
+ * for (const req of requests) {
371
+ * console.log(`Message ID: ${req.message.messageId}`)
372
+ * }
373
+ * ```
316
374
  */
317
375
  getMessagesInTx(tx: string | ChainTransaction): Promise<CCIPRequest[]>;
318
376
  /**
@@ -340,94 +398,183 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
340
398
  * @returns CCIPRequest with `metadata` populated from API
341
399
  * @throws {@link CCIPApiClientNotAvailableError} if API disabled
342
400
  * @throws {@link CCIPMessageIdNotFoundError} if message not found
401
+ * @throws {@link CCIPOnRampRequiredError} if onRamp is required but not provided
343
402
  * @throws {@link CCIPHttpError} if API request fails
344
- **/
403
+ */
345
404
  getMessageById(messageId: string, _opts?: {
346
405
  page?: number;
347
406
  onRamp?: string;
348
407
  }): Promise<CCIPRequest>;
349
408
  /**
350
409
  * Fetches all CCIP messages contained in a given commit batch.
351
- * @param request - CCIPRequest to fetch batch for.
352
- * @param commit - CommitReport range (min, max).
353
- * @param opts - Optional parameters (e.g., `page` for pagination width).
354
- * @returns Array of messages in the batch.
410
+ * To be implemented for chains supporting CCIPVersion &lt;= v1.6.0
411
+ *
412
+ * @param request - CCIPRequest to fetch batch for
413
+ * @param range - batch range \{ minSeqnr, maxSeqNr \}, e.g. from [[CommitReport]]
414
+ * @param opts - Optional parameters (e.g., `page` for pagination width)
415
+ * @returns Array of messages in the batch
416
+ *
355
417
  * @throws {@link CCIPMessageBatchIncompleteError} if not all messages in range could be fetched
418
+ *
419
+ * @example Get all messages in a batch
420
+ * ```typescript
421
+ * const verifications = await dest.getVerifications({ offRamp, request })
422
+ * const messages = await source.getMessagesInBatch(request, verifications.report)
423
+ * console.log(`Found ${messages.length} messages in batch`)
424
+ * ```
356
425
  */
357
- abstract getMessagesInBatch<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, commit: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
426
+ getMessagesInBatch?<R extends PickDeep<CCIPRequest, 'lane' | `log.${'topics' | 'address' | 'blockNumber'}` | 'message.sequenceNumber'>>(request: R, range: Pick<CommitReport, 'minSeqNr' | 'maxSeqNr'>, opts?: {
358
427
  page?: number;
359
428
  }): Promise<R['message'][]>;
360
429
  /**
361
- * Fetch typeAndVersion for a given CCIP contract address
430
+ * Fetch input data needed for executing messages
431
+ * Should be called on the *source* instance
432
+ * @param opts - getExecutionInput options containing request and verifications
433
+ * @returns `input` payload to be passed to [[execute]]
434
+ * @see {@link execute} - method to execute a message
435
+ */
436
+ getExecutionInput({ request, verifications, ...opts }: {
437
+ request: CCIPRequest;
438
+ verifications: CCIPVerifications;
439
+ } & Pick<LogFilter, 'page'>): Promise<ExecutionInput>;
440
+ /**
441
+ * Fetch typeAndVersion for a given CCIP contract address.
442
+ *
362
443
  * @param address - CCIP contract address
363
- * @returns type - parsed type of the contract, e.g. `OnRamp`
364
- * @returns version - parsed version of the contract, e.g. `1.6.0`
365
- * @returns typeAndVersion - original (unparsed) typeAndVersion() string
366
- * @returns suffix - suffix of the version, if any (e.g. `-dev`)
367
- * @throws {@link CCIPTypeVersionInvalidError} if contract doesn't have valid typeAndVersion
444
+ * @returns Promise resolving to tuple:
445
+ * - `type` - Parsed type of the contract, e.g. `OnRamp`
446
+ * - `version` - Parsed version of the contract, e.g. `1.6.0`
447
+ * - `typeAndVersion` - Original (unparsed) typeAndVersion() string
448
+ * - `suffix` - Suffix of the version, if any (e.g. `-dev`)
449
+ *
450
+ * @throws {@link CCIPTypeVersionInvalidError} if typeAndVersion string cannot be parsed
451
+ *
452
+ * @example Check contract version
453
+ * ```typescript
454
+ * const [type, version] = await chain.typeAndVersion(contractAddress)
455
+ * console.log(`Contract: ${type} v${version}`)
456
+ * if (version < '1.6.0') {
457
+ * console.log('Legacy contract detected')
458
+ * }
459
+ * ```
368
460
  */
369
461
  abstract typeAndVersion(address: string): Promise<[type: string, version: string, typeAndVersion: string, suffix?: string]>;
370
462
  /**
371
- * Fetch the Router address set in OnRamp config
372
- * Used to discover OffRamp connected to OnRamp
463
+ * Fetch the Router address set in OnRamp config.
464
+ * Used to discover OffRamp connected to OnRamp.
465
+ *
373
466
  * @param onRamp - OnRamp contract address
374
- * @param destChainSelector - destination chain selector
375
- * @returns Router address
467
+ * @param destChainSelector - Destination chain selector
468
+ * @returns Promise resolving to Router address
469
+ *
470
+ * @throws {@link CCIPContractTypeInvalidError} if address is not an OnRamp
471
+ *
472
+ * @example Get router from onRamp
473
+ * ```typescript
474
+ * const router = await chain.getRouterForOnRamp(onRampAddress, destSelector)
475
+ * console.log(`Router: ${router}`)
476
+ * ```
376
477
  */
377
478
  abstract getRouterForOnRamp(onRamp: string, destChainSelector: bigint): Promise<string>;
378
479
  /**
379
- * Fetch the Router address set in OffRamp config
480
+ * Fetch the Router address set in OffRamp config.
481
+ *
380
482
  * @param offRamp - OffRamp contract address
381
- * @param sourceChainSelector - source chain selector
382
- * @returns Router address
483
+ * @param sourceChainSelector - Source chain selector
484
+ * @returns Promise resolving to Router address
485
+ *
486
+ * @throws {@link CCIPContractTypeInvalidError} if address is not an OffRamp
487
+ *
488
+ * @example Get router from offRamp
489
+ * ```typescript
490
+ * const router = await chain.getRouterForOffRamp(offRampAddress, sourceSelector)
491
+ * console.log(`Router: ${router}`)
492
+ * ```
383
493
  */
384
494
  abstract getRouterForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
385
495
  /**
386
- * Get the native token address for a Router
387
- * @param router - router contract address
388
- * @returns native token address (usually wrapped)
496
+ * Get the native token address for a Router.
497
+ *
498
+ * @param router - Router contract address
499
+ * @returns Promise resolving to native token address (usually wrapped)
500
+ *
501
+ * @example Get wrapped native token
502
+ * ```typescript
503
+ * const weth = await chain.getNativeTokenForRouter(routerAddress)
504
+ * console.log(`Wrapped native: ${weth}`)
505
+ * ```
389
506
  */
390
507
  abstract getNativeTokenForRouter(router: string): Promise<string>;
391
508
  /**
392
- * Fetch the OffRamps allowlisted in a Router
393
- * Used to discover OffRamp connected to an OnRamp
509
+ * Fetch the OffRamps allowlisted in a Router.
510
+ * Used to discover OffRamp connected to an OnRamp.
511
+ *
394
512
  * @param router - Router contract address
395
- * @param sourceChainSelector - source chain selector
396
- * @returns array of OffRamp addresses
513
+ * @param sourceChainSelector - Source chain selector
514
+ * @returns Promise resolving to array of OffRamp addresses
515
+ *
516
+ * @example Get offRamps for a source chain
517
+ * ```typescript
518
+ * const offRamps = await dest.getOffRampsForRouter(routerAddress, sourceSelector)
519
+ * console.log(`Found ${offRamps.length} offRamp(s)`)
520
+ * ```
397
521
  */
398
522
  abstract getOffRampsForRouter(router: string, sourceChainSelector: bigint): Promise<string[]>;
399
523
  /**
400
- * Fetch the OnRamp registered in a Router for a destination chain
524
+ * Fetch the OnRamp registered in a Router for a destination chain.
525
+ *
401
526
  * @param router - Router contract address
402
- * @param destChainSelector - destination chain selector
403
- * @returns OnRamp addresses
527
+ * @param destChainSelector - Destination chain selector
528
+ * @returns Promise resolving to OnRamp address
529
+ *
530
+ * @throws {@link CCIPLaneNotFoundError} if no lane exists to destination
531
+ *
532
+ * @example Get onRamp for destination
533
+ * ```typescript
534
+ * const onRamp = await source.getOnRampForRouter(routerAddress, destSelector)
535
+ * console.log(`OnRamp: ${onRamp}`)
536
+ * ```
404
537
  */
405
538
  abstract getOnRampForRouter(router: string, destChainSelector: bigint): Promise<string>;
406
539
  /**
407
- * Fetch the OnRamp address set in OffRamp config
408
- * Used to discover OffRamp connected to an OnRamp
540
+ * Fetch the OnRamps addresses set in OffRamp config.
541
+ * Used to discover OffRamp connected to an OnRamp.
542
+ *
409
543
  * @param offRamp - OffRamp contract address
410
- * @param sourceChainSelector - source chain selector
411
- * @returns OnRamp address
412
- */
413
- abstract getOnRampForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string>;
414
- /**
415
- * Fetch the CommitStore set in OffRamp config (CCIP v1.5 and earlier).
416
- * For CCIP v1.6 and later, it should return the offRamp address.
417
- * @param offRamp - OffRamp contract address.
418
- * @returns CommitStore address.
544
+ * @param sourceChainSelector - Source chain selector
545
+ * @returns Promise resolving to OnRamps addresses
546
+ *
547
+ * @example Get onRamp from offRamp config
548
+ * ```typescript
549
+ * const [onRamp] = await dest.getOnRampsForOffRamp(offRampAddress, sourceSelector)
550
+ * console.log(`OnRamp: ${onRamp}`)
551
+ * ```
419
552
  */
420
- abstract getCommitStoreForOffRamp(offRamp: string): Promise<string>;
553
+ abstract getOnRampsForOffRamp(offRamp: string, sourceChainSelector: bigint): Promise<string[]>;
421
554
  /**
422
- * Fetch the TokenPool's token/mint
555
+ * Fetch the TokenPool's token/mint.
556
+ *
423
557
  * @param tokenPool - TokenPool address
424
- * @returns Token or mint address
558
+ * @returns Promise resolving to token or mint address
559
+ *
560
+ * @example Get token for pool
561
+ * ```typescript
562
+ * const token = await chain.getTokenForTokenPool(tokenPoolAddress)
563
+ * console.log(`Token: ${token}`)
564
+ * ```
425
565
  */
426
566
  abstract getTokenForTokenPool(tokenPool: string): Promise<string>;
427
567
  /**
428
- * Fetch token metadata
568
+ * Fetch token metadata.
569
+ *
429
570
  * @param token - Token address
430
- * @returns Token symbol and decimals, and optionally name
571
+ * @returns Promise resolving to token symbol, decimals, and optionally name
572
+ *
573
+ * @example Get token info
574
+ * ```typescript
575
+ * const info = await chain.getTokenInfo(tokenAddress)
576
+ * console.log(`${info.symbol}: ${info.decimals} decimals`)
577
+ * ```
431
578
  */
432
579
  abstract getTokenInfo(token: string): Promise<TokenInfo>;
433
580
  /**
@@ -439,14 +586,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
439
586
  *
440
587
  * @example Query native token balance
441
588
  * ```typescript
442
- * const balance = await chain.getBalance({ address: '0x123...' })
589
+ * const balance = await chain.getBalance({ holder: '0x123...' })
443
590
  * console.log(`Native balance: ${balance}`) // balance in wei
444
591
  * ```
445
592
  *
446
593
  * @example Query ERC20 token balance
447
594
  * ```typescript
448
595
  * const balance = await chain.getBalance({
449
- * address: '0x123...',
596
+ * holder: '0x123...',
450
597
  * token: '0xLINK...'
451
598
  * })
452
599
  * console.log(`LINK balance: ${balance}`) // balance in smallest units
@@ -454,22 +601,52 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
454
601
  */
455
602
  abstract getBalance(opts: GetBalanceOpts): Promise<bigint>;
456
603
  /**
457
- * Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc
458
- * Needed to map a source token to its dest counterparts
459
- * @param address - Some contract for which we can fetch a TokenAdminRegistry (OnRamp, Router, etc.)
460
- * @returns TokenAdminRegistry address
604
+ * Fetch TokenAdminRegistry configured in a given OnRamp, Router, etc.
605
+ * Needed to map a source token to its dest counterparts.
606
+ *
607
+ * @param address - Contract address (OnRamp, Router, etc.)
608
+ * @returns Promise resolving to TokenAdminRegistry address
609
+ *
610
+ * @example Get token registry
611
+ * ```typescript
612
+ * const registry = await chain.getTokenAdminRegistryFor(onRampAddress)
613
+ * console.log(`Registry: ${registry}`)
614
+ * ```
461
615
  */
462
616
  abstract getTokenAdminRegistryFor(address: string): Promise<string>;
463
617
  /**
464
- * Fetch the current fee for a given intended message
618
+ * Fetch the current fee for a given intended message.
619
+ *
465
620
  * @param opts - {@link SendMessageOpts} without approveMax
466
621
  * @returns Fee amount in the feeToken's smallest units
622
+ *
623
+ * @example Calculate message fee
624
+ * ```typescript
625
+ * const fee = await chain.getFee({
626
+ * router: routerAddress,
627
+ * destChainSelector: destSelector,
628
+ * message: { receiver: '0x...', data: '0x' },
629
+ * })
630
+ * console.log(`Fee: ${fee} wei`)
631
+ * ```
467
632
  */
468
633
  abstract getFee(opts: Omit<SendMessageOpts, 'approveMax'>): Promise<bigint>;
469
634
  /**
470
- * Generate unsigned txs for ccipSend'ing a message
635
+ * Generate unsigned txs for ccipSend'ing a message.
636
+ *
471
637
  * @param opts - {@link SendMessageOpts} with sender address
472
- * @returns chain-family specific unsigned txs
638
+ * @returns Promise resolving to chain-family specific unsigned txs
639
+ *
640
+ * @example Generate unsigned transaction
641
+ * ```typescript
642
+ * const unsignedTx = await chain.generateUnsignedSendMessage({
643
+ * router: routerAddress,
644
+ * destChainSelector: destSelector,
645
+ * message: { receiver: '0x...', data: '0x1337' },
646
+ * sender: walletAddress,
647
+ * })
648
+ * // Sign and send with external wallet
649
+ * ```
473
650
  */
474
651
  abstract generateUnsignedSendMessage(opts: SendMessageOpts & {
475
652
  /** Sender address (address of wallet which will send the message) */
@@ -477,11 +654,14 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
477
654
  }): Promise<UnsignedTx[F]>;
478
655
  /**
479
656
  * Send a CCIP message through a router using provided wallet.
657
+ *
480
658
  * @param opts - {@link SendMessageOpts} with chain-specific wallet for signing
481
- * @returns CCIP request
482
- * @throws {@link CCIPWalletNotSignerError} if wallet cannot sign transactions
659
+ * @returns Promise resolving to CCIP request with message details
483
660
  *
484
- * @example
661
+ * @throws {@link CCIPWalletNotSignerError} if wallet is not a valid signer
662
+ * @throws {@link CCIPLaneNotFoundError} if no lane exists to destination
663
+ *
664
+ * @example Send cross-chain message
485
665
  * ```typescript
486
666
  * const request = await chain.sendMessage({
487
667
  * router: '0x...',
@@ -502,64 +682,87 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
502
682
  wallet: unknown;
503
683
  }): Promise<CCIPRequest>;
504
684
  /**
505
- * Fetch supported offchain token data for a request from this network
685
+ * Fetch supported offchain token data for a request from this network.
686
+ *
506
687
  * @param request - CCIP request, with tx, logs and message
507
- * @returns array with one offchain token data for each token transfer in request
688
+ * @returns Promise resolving to array with one offchain token data for each token transfer
689
+ *
690
+ * @throws {@link CCIPUsdcAttestationError} if USDC attestation fetch fails (transient)
691
+ * @throws {@link CCIPLbtcAttestationError} if LBTC attestation fetch fails (transient)
692
+ *
693
+ * @example Get offchain token data for USDC transfer
694
+ * ```typescript
695
+ * const offchainData = await source.getOffchainTokenData(request)
696
+ * // Use in execution report
697
+ * ```
508
698
  */
509
699
  abstract getOffchainTokenData(request: CCIPRequest): Promise<OffchainTokenData[]>;
510
700
  /**
511
- * Generate unsigned tx to manuallyExecute a message
512
- * @param opts - {@link ExecuteReportOpts} with payer address which will send the exec tx
513
- * @returns chain-family specific unsigned txs
701
+ * Generate unsigned tx to manuallyExecute a message.
702
+ *
703
+ * @param opts - {@link ExecuteOpts} with payer address which will send the exec tx
704
+ * @returns Promise resolving to chain-family specific unsigned txs
705
+ *
706
+ * @example Generate unsigned execution tx
707
+ * ```typescript
708
+ * const unsignedTx = await dest.generateUnsignedExecute({
709
+ * offRamp: offRampAddress,
710
+ * execReport,
711
+ * payer: walletAddress,
712
+ * })
713
+ * // Sign and send with external wallet
714
+ * ```
514
715
  */
515
- abstract generateUnsignedExecuteReport(opts: ExecuteReportOpts & {
716
+ abstract generateUnsignedExecute(opts: ExecuteOpts & {
516
717
  /** address which will be used to send the report tx */
517
718
  payer: string;
518
719
  }): Promise<UnsignedTx[F]>;
519
720
  /**
520
- * Execute messages in report in an offRamp
521
- * @param opts - {@link ExecuteReportOpts} with chain-specific wallet to sign and send tx
522
- * @returns transaction of the execution
721
+ * Execute messages in report in an offRamp.
523
722
  *
524
- * @example
723
+ * @param opts - {@link ExecuteOpts} with chain-specific wallet to sign and send tx
724
+ * @returns Promise resolving to transaction of the execution
725
+ *
726
+ * @throws {@link CCIPWalletNotSignerError} if wallet is not a valid signer
727
+ * @throws {@link CCIPExecTxRevertedError} if execution transaction reverts
728
+ * @throws {@link CCIPMerkleRootMismatchError} if merkle proof is invalid
729
+ *
730
+ * @example Manual execution of pending message
525
731
  * ```typescript
526
- * const execReportProof = calculateManualExecProof(
527
- * messagesInBatch: await source.getMessagesInBatch(request, commit.report),
528
- * request.lane,
529
- * request.message.messageId,
530
- * commit.report.merkleRoot,
531
- * dest,
532
- * )
533
- * const receipt = await dest.executeReport({
534
- * offRamp,
535
- * execReport: {
536
- * ...execReportProof,
537
- * message: request.message,
538
- * offchainTokenData: await source.getOffchainTokenData(request),
539
- * },
540
- * wallet,
541
- * })
542
- * console.log(`Message ID: ${request.message.messageId}`)
732
+ * const input = await source.getExecutionInput({ request, verifications })
733
+ * const receipt = await dest.execute({ offRamp, input, wallet })
734
+ * console.log(`Executed: ${receipt.log.transactionHash}`)
543
735
  * ```
544
736
  * @throws {@link CCIPWalletNotSignerError} if wallet cannot sign transactions
545
737
  * @throws {@link CCIPExecTxNotConfirmedError} if execution transaction fails to confirm
546
738
  */
547
- abstract executeReport(opts: ExecuteReportOpts & {
739
+ abstract execute(opts: ExecuteOpts & {
548
740
  wallet: unknown;
549
741
  }): Promise<CCIPExecution>;
550
742
  /**
551
- * Look for a CommitReport at dest for given CCIP request
552
- * May be specialized by some subclasses
553
- * @param opts - getCommitReport options
743
+ * Look for a CommitReport at dest for given CCIP request.
744
+ * May be specialized by some subclasses.
745
+ *
746
+ * @param opts - getVerifications options
554
747
  * @returns CCIPCommit info
555
- * @throws {@link CCIPCommitNotFoundError} if no commit found for the request
748
+ *
749
+ * @throws {@link CCIPCommitNotFoundError} if no commit found for the request (transient)
750
+ *
751
+ * @example Get commit for a request
752
+ * ```typescript
753
+ * const verifications = await dest.getVerifications({
754
+ * offRamp: offRampAddress,
755
+ * request,
756
+ * })
757
+ * console.log(`Committed at block: ${verifications.log.blockNumber}`)
758
+ * ```
556
759
  */
557
- getCommitReport({ commitStore, request, ...hints }: {
558
- /** address of commitStore (OffRamp in \>=v1.6) */
559
- commitStore: string;
760
+ getVerifications({ offRamp, request, ...hints }: {
761
+ /** address of offRamp or commitStore contract */
762
+ offRamp: string;
560
763
  /** CCIPRequest subset object */
561
- request: PickDeep<CCIPRequest, 'lane' | 'message.sequenceNumber' | 'tx.timestamp'>;
562
- } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPCommit>;
764
+ request: PickDeep<CCIPRequest, 'lane' | `message.${'sequenceNumber' | 'messageId'}` | 'tx.timestamp'>;
765
+ } & Pick<LogFilter, 'page' | 'watch' | 'startBlock'>): Promise<CCIPVerifications>;
563
766
  /**
564
767
  * Fetches estimated lane latency to a destination chain.
565
768
  * Uses this chain's selector as the source.
@@ -594,11 +797,25 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
594
797
  */
595
798
  getLaneLatency(destChainSelector: bigint): Promise<LaneLatencyResponse>;
596
799
  /**
597
- * Default/generic implementation of getExecutionReceipts
800
+ * Default/generic implementation of getExecutionReceipts.
801
+ * Yields execution receipts for a given offRamp.
802
+ *
598
803
  * @param opts - getExecutionReceipts options
599
804
  * @returns Async generator of CCIPExecution receipts
805
+ *
806
+ * @example Watch for execution receipts
807
+ * ```typescript
808
+ * for await (const exec of dest.getExecutionReceipts({
809
+ * offRamp: offRampAddress,
810
+ * messageId: request.message.messageId,
811
+ * startBlock: commit.log.blockNumber,
812
+ * })) {
813
+ * console.log(`State: ${exec.receipt.state}`)
814
+ * if (exec.receipt.state === ExecutionState.Success) break
815
+ * }
816
+ * ```
600
817
  */
601
- getExecutionReceipts({ offRamp, messageId, sourceChainSelector, commit, ...hints }: {
818
+ getExecutionReceipts({ offRamp, messageId, sourceChainSelector, verifications, ...hints }: {
602
819
  /** address of OffRamp contract */
603
820
  offRamp: string;
604
821
  /** filter: yield only executions for this message */
@@ -606,21 +823,36 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
606
823
  /** filter: yield only executions for this source chain */
607
824
  sourceChainSelector?: bigint;
608
825
  /** optional commit associated with the request, can be used for optimizations in some families */
609
- commit?: CCIPCommit;
826
+ verifications?: CCIPVerifications;
610
827
  } & Pick<LogFilter, 'page' | 'watch' | 'startBlock' | 'startTime'>): AsyncIterableIterator<CCIPExecution>;
611
828
  /**
612
829
  * Fetch first execution receipt inside a transaction.
830
+ *
613
831
  * @internal
614
- * @param tx - transaction hash or transaction object
832
+ * @param tx - Transaction hash or transaction object
615
833
  * @returns CCIP execution object
834
+ *
616
835
  * @throws {@link CCIPExecTxRevertedError} if no execution receipt found in transaction
836
+ *
837
+ * @example Get receipt from execution tx
838
+ * ```typescript
839
+ * const exec = await dest.getExecutionReceiptInTx(execTxHash)
840
+ * console.log(`State: ${exec.receipt.state}`)
841
+ * ```
617
842
  */
618
843
  getExecutionReceiptInTx(tx: string | ChainTransaction): Promise<CCIPExecution>;
619
844
  /**
620
845
  * List tokens supported by given TokenAdminRegistry contract.
846
+ *
621
847
  * @param address - Usually TokenAdminRegistry, but chain may support receiving Router, OnRamp, etc.
622
- * @param opts - Optional parameters (e.g., `page` for pagination range).
623
- * @returns Array of supported token addresses.
848
+ * @param opts - Optional parameters (e.g., `page` for pagination range)
849
+ * @returns Promise resolving to array of supported token addresses
850
+ *
851
+ * @example Get all supported tokens
852
+ * ```typescript
853
+ * const tokens = await chain.getSupportedTokens(registryAddress)
854
+ * console.log(`${tokens.length} tokens supported`)
855
+ * ```
624
856
  */
625
857
  abstract getSupportedTokens(address: string, opts?: {
626
858
  page?: number;
@@ -651,21 +883,27 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
651
883
  * Fetch configuration of a token pool.
652
884
  *
653
885
  * @remarks
654
- * Returns the core configuration of a token pool including which token it manages
655
- * and which router it's registered with.
886
+ * Return type varies by chain:
887
+ * - **EVM**: `typeAndVersion` is always present (required)
888
+ * - **Solana**: Includes extra `tokenPoolProgram` field
889
+ * - **Aptos**: Standard fields only
890
+ * - **Sui/TON**: Throws {@link CCIPNotImplementedError}
656
891
  *
657
- * @example Query pool configuration
892
+ * @example Type-safe access to chain-specific fields
658
893
  * ```typescript
659
- * const config = await chain.getTokenPoolConfig(poolAddress)
660
- * console.log(`Manages token: ${config.token}`)
661
- * console.log(`Router: ${config.router}`)
662
- * if (config.typeAndVersion) {
663
- * console.log(`Version: ${config.typeAndVersion}`)
894
+ * // Use instanceof to narrow the chain type
895
+ * if (chain instanceof SolanaChain) {
896
+ * const config = await chain.getTokenPoolConfig(poolAddress)
897
+ * console.log(config.tokenPoolProgram) // TypeScript knows this exists!
898
+ * } else if (chain instanceof EVMChain) {
899
+ * const config = await chain.getTokenPoolConfig(poolAddress)
900
+ * console.log(config.typeAndVersion) // TypeScript knows this is required!
664
901
  * }
665
902
  * ```
666
903
  *
667
904
  * @param tokenPool - Token pool contract address.
668
905
  * @returns {@link TokenPoolConfig} containing token, router, and version info.
906
+ * @throws {@link CCIPNotImplementedError} on Sui or TON chains
669
907
  */
670
908
  abstract getTokenPoolConfig(tokenPool: string): Promise<TokenPoolConfig>;
671
909
  /**
@@ -731,11 +969,26 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
731
969
  getTokenPoolRemote(tokenPool: string, remoteChainSelector: bigint): Promise<TokenPoolRemote>;
732
970
  /**
733
971
  * Fetch list and info of supported feeTokens.
734
- * @param router - Router address on this chain.
735
- * @returns Mapping of token addresses to respective TokenInfo objects.
972
+ *
973
+ * @param router - Router address on this chain
974
+ * @returns Promise resolving to mapping of token addresses to TokenInfo objects
975
+ *
976
+ * @example Get available fee tokens
977
+ * ```typescript
978
+ * const feeTokens = await chain.getFeeTokens(routerAddress)
979
+ * for (const [addr, info] of Object.entries(feeTokens)) {
980
+ * console.log(`${info.symbol}: ${addr}`)
981
+ * }
982
+ * ```
736
983
  */
737
984
  abstract getFeeTokens(router: string): Promise<Record<string, TokenInfo>>;
738
- /** {@inheritDoc ChainStatic.buildMessageForDest} */
985
+ /**
986
+ * Returns a copy of a message, populating missing fields like `extraArgs` with defaults.
987
+ * It's expected to return a message suitable at least for basic token transfers.
988
+ *
989
+ * @param message - AnyMessage (from source), containing at least `receiver`
990
+ * @returns A message suitable for `sendMessage` to this destination chain family
991
+ */
739
992
  static buildMessageForDest(message: Parameters<ChainStatic['buildMessageForDest']>[0]): AnyMessage;
740
993
  /**
741
994
  * Estimate `ccipReceive` execution cost (gas, computeUnits) for this *dest*
@@ -757,29 +1010,71 @@ export declare abstract class Chain<F extends ChainFamily = ChainFamily> {
757
1010
  };
758
1011
  }): Promise<number>;
759
1012
  }
760
- /** Static methods and properties available on Chain class constructors. */
1013
+ /**
1014
+ * Static methods and properties available on Chain class constructors.
1015
+ *
1016
+ * @example Using static methods
1017
+ * ```typescript
1018
+ * // Create chain from URL
1019
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1020
+ *
1021
+ * // Decode message from log
1022
+ * const message = EVMChain.decodeMessage(log)
1023
+ *
1024
+ * // Validate address format
1025
+ * const normalized = EVMChain.getAddress('0xABC...')
1026
+ * ```
1027
+ */
761
1028
  export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
762
1029
  readonly family: F;
763
1030
  readonly decimals: number;
764
1031
  /**
765
- * async constructor: builds a Chain from a rpc endpoint url
766
- * @param url - rpc endpoint url
767
- * @param ctx - optional context with logger and API client configuration
1032
+ * Async constructor: builds a Chain from an RPC endpoint URL.
1033
+ *
1034
+ * @param url - RPC endpoint URL
1035
+ * @param ctx - Optional context with logger and API client configuration
1036
+ * @returns Promise resolving to Chain instance
1037
+ *
1038
+ * @throws {@link CCIPChainNotFoundError} if chain cannot be identified
1039
+ *
1040
+ * @example Create chain from RPC
1041
+ * ```typescript
1042
+ * const chain = await EVMChain.fromUrl('https://eth-mainnet.example.com')
1043
+ * console.log(`Connected to: ${chain.network.name}`)
1044
+ * ```
768
1045
  */
769
1046
  fromUrl(url: string, ctx?: ChainContext): Promise<Chain<F>>;
770
1047
  /**
771
- * Try to decode a CCIP message *from* a log/event *originated* from this *source* chain,
772
- * but which may *target* other dest chain families
773
- * iow: the parsing is specific to this chain family, but content may be intended to alien chains
774
- * e.g: EVM-born (abi.encoded) bytearray may output message.computeUnits for Solana
1048
+ * Try to decode a CCIP message from a log/event originated from this source chain.
1049
+ * The parsing is specific to this chain family, but content may target other chains.
1050
+ *
775
1051
  * @param log - Chain generic log
776
- * @returns decoded CCIP message with merged extraArgs
1052
+ * @returns Decoded CCIP message with merged extraArgs, or undefined if not a CCIP message
1053
+ *
1054
+ * @example Decode message from log
1055
+ * ```typescript
1056
+ * const message = EVMChain.decodeMessage(log)
1057
+ * if (message) {
1058
+ * console.log(`Message ID: ${message.messageId}`)
1059
+ * }
1060
+ * ```
777
1061
  */
778
1062
  decodeMessage(log: Pick<Log_, 'data'>): CCIPMessage | undefined;
779
1063
  /**
780
- * Try to decode an extraArgs array serialized for this chain family
781
- * @param extraArgs - extra args bytes (Uint8Array, HexString or base64)
782
- * @returns object containing decoded extraArgs and their tags
1064
+ * Try to decode an extraArgs array serialized for this chain family.
1065
+ *
1066
+ * @param extraArgs - Extra args bytes (Uint8Array, HexString or base64)
1067
+ * @returns Object containing decoded extraArgs and their tag, or undefined
1068
+ *
1069
+ * @throws {@link CCIPExtraArgsParseError} if bytes cannot be decoded
1070
+ *
1071
+ * @example Decode extra args
1072
+ * ```typescript
1073
+ * const decoded = EVMChain.decodeExtraArgs(message.extraArgs)
1074
+ * if (decoded?._tag === 'EVMExtraArgsV2') {
1075
+ * console.log(`Gas limit: ${decoded.gasLimit}`)
1076
+ * }
1077
+ * ```
783
1078
  */
784
1079
  decodeExtraArgs(extraArgs: BytesLike): (EVMExtraArgsV1 & {
785
1080
  _tag: 'EVMExtraArgsV1';
@@ -792,54 +1087,140 @@ export type ChainStatic<F extends ChainFamily = ChainFamily> = Function & {
792
1087
  }) | (SuiExtraArgsV1 & {
793
1088
  _tag: 'SuiExtraArgsV1';
794
1089
  }) | undefined;
1090
+ /**
1091
+ * Encode extraArgs for this chain family.
1092
+ *
1093
+ * @param extraArgs - Extra args object to encode
1094
+ * @returns Encoded hex string
1095
+ *
1096
+ * @example Encode extra args
1097
+ * ```typescript
1098
+ * const encoded = EVMChain.encodeExtraArgs({
1099
+ * gasLimit: 200000n,
1100
+ * strict: false,
1101
+ * })
1102
+ * ```
1103
+ */
795
1104
  encodeExtraArgs(extraArgs: ExtraArgs): string;
796
1105
  /**
797
- * Decode a commit (CommitReportAccepted) event
1106
+ * Decode a commit (CommitReportAccepted) event.
1107
+ *
798
1108
  * @param log - Chain generic log
799
- * @param lane - if passed, filter or validate reports by lane
800
- * @returns Array of commit reports contained in the log
1109
+ * @param lane - If passed, filter or validate reports by lane
1110
+ * @returns Array of commit reports contained in the log, or undefined
1111
+ *
1112
+ * @example Decode commit from log
1113
+ * ```typescript
1114
+ * const commits = EVMChain.decodeCommits(log, lane)
1115
+ * if (commits) {
1116
+ * console.log(`Found ${commits.length} commit(s)`)
1117
+ * }
1118
+ * ```
801
1119
  */
802
1120
  decodeCommits(log: Pick<Log_, 'data'>, lane?: Lane): CommitReport[] | undefined;
803
1121
  /**
804
- * Decode a receipt (ExecutionStateChanged) event
1122
+ * Decode a receipt (ExecutionStateChanged) event.
1123
+ *
805
1124
  * @param log - Chain generic log
806
1125
  * @returns ExecutionReceipt or undefined if not a recognized receipt
1126
+ *
1127
+ * @example Decode execution receipt
1128
+ * ```typescript
1129
+ * const receipt = EVMChain.decodeReceipt(log)
1130
+ * if (receipt) {
1131
+ * console.log(`State: ${receipt.state}, Message: ${receipt.messageId}`)
1132
+ * }
1133
+ * ```
807
1134
  */
808
1135
  decodeReceipt(log: Pick<Log_, 'data'>): ExecutionReceipt | undefined;
809
1136
  /**
810
- * Receive a bytes array and try to decode and normalize it as an address of this chain family
1137
+ * Receive a bytes array and try to decode and normalize it as an address of this chain family.
1138
+ *
811
1139
  * @param bytes - Bytes array (Uint8Array, HexString or Base64)
812
1140
  * @returns Address in this chain family's format
1141
+ *
1142
+ * @throws {@link CCIPAddressInvalidEvmError} if invalid EVM address
1143
+ * @throws {@link CCIPDataFormatUnsupportedError} if invalid Aptos/Sui address
1144
+ *
1145
+ * @example Normalize address
1146
+ * ```typescript
1147
+ * const normalized = EVMChain.getAddress('0xABC123...')
1148
+ * console.log(normalized) // checksummed address
1149
+ * ```
813
1150
  */
814
1151
  getAddress(bytes: BytesLike): string;
815
1152
  /**
816
- * Validates a transaction hash format for this chain family
1153
+ * Validates a transaction hash format for this chain family.
1154
+ *
1155
+ * @param v - Value to validate
1156
+ * @returns True if value is a valid transaction hash format
1157
+ *
1158
+ * @example Validate transaction hash
1159
+ * ```typescript
1160
+ * if (EVMChain.isTxHash(userInput)) {
1161
+ * const tx = await chain.getTransaction(userInput)
1162
+ * }
1163
+ * ```
817
1164
  */
818
1165
  isTxHash(v: unknown): v is string;
819
1166
  /**
820
1167
  * Format an address for human-friendly display.
821
1168
  * Defaults to getAddress if not overridden.
1169
+ *
822
1170
  * @param address - Address string in any recognized format
823
1171
  * @returns Human-friendly address string for display
1172
+ *
1173
+ * @example Format address for display
1174
+ * ```typescript
1175
+ * const display = EVMChain.formatAddress?.(rawAddress) ?? rawAddress
1176
+ * console.log(display)
1177
+ * ```
824
1178
  */
825
1179
  formatAddress?(address: string): string;
826
1180
  /**
827
1181
  * Format a transaction hash for human-friendly display.
1182
+ *
828
1183
  * @param hash - Transaction hash string
829
1184
  * @returns Human-friendly hash string for display
1185
+ *
1186
+ * @example Format tx hash for display
1187
+ * ```typescript
1188
+ * const display = EVMChain.formatTxHash?.(rawHash) ?? rawHash
1189
+ * console.log(display)
1190
+ * ```
830
1191
  */
831
1192
  formatTxHash?(hash: string): string;
832
1193
  /**
833
- * Create a leaf hasher for this dest chain and lane
834
- * @param lane - source, dest and onramp lane info
835
- * @param ctx - context object containing logger
836
- * @returns LeafHasher is a function that takes a message and returns a hash of it
1194
+ * Create a leaf hasher for this dest chain and lane.
1195
+ *
1196
+ * @param lane - Source, dest and onramp lane info
1197
+ * @param ctx - Context object containing logger
1198
+ * @returns LeafHasher function that takes a message and returns its hash
1199
+ *
1200
+ * @throws {@link CCIPHasherVersionUnsupportedError} if hasher version unsupported
1201
+ *
1202
+ * @example Create leaf hasher
1203
+ * ```typescript
1204
+ * const hasher = EVMChain.getDestLeafHasher(lane, { logger })
1205
+ * const leafHash = hasher(message)
1206
+ * ```
837
1207
  */
838
1208
  getDestLeafHasher(lane: Lane, ctx?: WithLogger): LeafHasher;
839
1209
  /**
840
- * Try to parse an error or bytearray generated by this chain family
1210
+ * Try to parse an error or bytearray generated by this chain family.
1211
+ *
841
1212
  * @param data - Caught object, string or bytearray
842
- * @returns Ordered record with messages/properties, or undefined if not a recognized error
1213
+ * @returns Ordered record with messages/properties, or undefined/null if not recognized
1214
+ *
1215
+ * @example Parse contract error
1216
+ * ```typescript
1217
+ * try {
1218
+ * await chain.sendMessage(opts)
1219
+ * } catch (err) {
1220
+ * const parsed = EVMChain.parse?.(err)
1221
+ * if (parsed) console.log('Contract error:', parsed)
1222
+ * }
1223
+ * ```
843
1224
  */
844
1225
  parse?(data: unknown): Record<string, unknown> | undefined | null;
845
1226
  /**