quantumcoin 7.0.3 → 7.0.4

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 (155) hide show
  1. package/.github/workflows/publish-npmjs.yaml +22 -22
  2. package/.gitignore +15 -15
  3. package/LICENSE +21 -21
  4. package/README-SDK.md +756 -754
  5. package/README.md +165 -150
  6. package/SPEC.md +3845 -3843
  7. package/config.d.ts +50 -50
  8. package/config.js +115 -115
  9. package/examples/AllSolidityTypes.sol +184 -184
  10. package/examples/SimpleIERC20.sol +74 -74
  11. package/examples/events.js +41 -35
  12. package/examples/events.ts +35 -0
  13. package/examples/example-generator-sdk-js.js +100 -95
  14. package/examples/example-generator-sdk-js.ts +77 -0
  15. package/examples/example-generator-sdk-ts.js +100 -95
  16. package/examples/example-generator-sdk-ts.ts +77 -0
  17. package/examples/example.js +72 -61
  18. package/examples/example.ts +61 -0
  19. package/examples/offline-signing.js +79 -73
  20. package/examples/offline-signing.ts +66 -0
  21. package/examples/package-lock.json +48 -57
  22. package/examples/package.json +32 -16
  23. package/examples/read-operations.js +32 -27
  24. package/examples/read-operations.ts +31 -0
  25. package/examples/sdk-generator-erc20.inline.json +251 -251
  26. package/examples/solidity-types.ts +43 -43
  27. package/examples/wallet-offline.js +35 -29
  28. package/examples/wallet-offline.ts +34 -0
  29. package/generate-sdk.js +1824 -1490
  30. package/index.js +12 -12
  31. package/package.json +95 -75
  32. package/scripts/copy-declarations.js +31 -0
  33. package/scripts/run-all-one-by-one.js +151 -0
  34. package/src/abi/fragments.d.ts +42 -42
  35. package/src/abi/fragments.js +63 -63
  36. package/src/abi/index.d.ts +13 -13
  37. package/src/abi/index.js +9 -9
  38. package/src/abi/interface.d.ts +128 -132
  39. package/src/abi/interface.js +590 -590
  40. package/src/abi/js-abi-coder.d.ts +8 -0
  41. package/src/abi/js-abi-coder.js +474 -474
  42. package/src/constants.d.ts +66 -61
  43. package/src/constants.js +101 -94
  44. package/src/contract/contract-factory.d.ts +28 -28
  45. package/src/contract/contract-factory.js +105 -105
  46. package/src/contract/contract.d.ts +113 -114
  47. package/src/contract/contract.js +354 -354
  48. package/src/contract/index.d.ts +9 -9
  49. package/src/contract/index.js +9 -9
  50. package/src/errors/index.d.ts +92 -92
  51. package/src/errors/index.js +188 -188
  52. package/src/generator/index.d.ts +74 -0
  53. package/src/generator/index.js +1404 -1404
  54. package/src/index.d.ts +125 -127
  55. package/src/index.js +41 -41
  56. package/src/internal/hex.d.ts +61 -61
  57. package/src/internal/hex.js +144 -144
  58. package/src/providers/extra-providers.d.ts +139 -128
  59. package/src/providers/extra-providers.js +600 -575
  60. package/src/providers/index.d.ts +17 -16
  61. package/src/providers/index.js +10 -10
  62. package/src/providers/json-rpc-provider.d.ts +12 -12
  63. package/src/providers/json-rpc-provider.js +79 -79
  64. package/src/providers/provider.d.ts +207 -203
  65. package/src/providers/provider.js +392 -371
  66. package/src/types/index.d.ts +214 -462
  67. package/src/types/index.js +9 -9
  68. package/src/utils/address.d.ts +72 -72
  69. package/src/utils/address.js +181 -182
  70. package/src/utils/encoding.d.ts +120 -120
  71. package/src/utils/encoding.js +306 -306
  72. package/src/utils/hashing.d.ts +82 -76
  73. package/src/utils/hashing.js +313 -298
  74. package/src/utils/index.d.ts +65 -55
  75. package/src/utils/index.js +13 -13
  76. package/src/utils/result.d.ts +57 -57
  77. package/src/utils/result.js +128 -128
  78. package/src/utils/rlp.d.ts +12 -12
  79. package/src/utils/rlp.js +200 -200
  80. package/src/utils/units.d.ts +29 -29
  81. package/src/utils/units.js +107 -107
  82. package/src/wallet/index.d.ts +10 -10
  83. package/src/wallet/index.js +8 -8
  84. package/src/wallet/wallet.d.ts +160 -160
  85. package/src/wallet/wallet.js +483 -489
  86. package/test/e2e/all-solidity-types.dynamic.test.js +207 -200
  87. package/test/e2e/all-solidity-types.dynamic.test.ts +191 -0
  88. package/test/e2e/all-solidity-types.fixtures.js +231 -231
  89. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +387 -368
  90. package/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +350 -0
  91. package/test/e2e/helpers.js +59 -47
  92. package/test/e2e/signing-context-and-fee.e2e.test.js +137 -0
  93. package/test/e2e/signing-context-and-fee.e2e.test.ts +128 -0
  94. package/test/e2e/simple-erc20.generated-sdks.e2e.test.js +168 -151
  95. package/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +141 -0
  96. package/test/e2e/transactional.test.js +245 -191
  97. package/test/e2e/transactional.test.ts +208 -0
  98. package/test/e2e/typed-generator.e2e.test.js +407 -404
  99. package/test/e2e/typed-generator.e2e.test.ts +337 -0
  100. package/test/fixtures/ConstructorParam.sol +23 -23
  101. package/test/fixtures/MultiContracts.sol +37 -37
  102. package/test/fixtures/SimpleStorage.sol +18 -18
  103. package/test/fixtures/StakingContract.abi.json +1 -1
  104. package/test/integration/ipc-provider.test.js +49 -44
  105. package/test/integration/ipc-provider.test.ts +44 -0
  106. package/test/integration/provider.test.js +88 -72
  107. package/test/integration/provider.test.ts +85 -0
  108. package/test/integration/ws-provider.test.js +41 -33
  109. package/test/integration/ws-provider.test.ts +38 -0
  110. package/test/security/malformed-input.test.js +37 -31
  111. package/test/security/malformed-input.test.ts +35 -0
  112. package/test/unit/_encrypted-output.txt +6 -0
  113. package/test/unit/_log-encrypted-jsons.js +45 -0
  114. package/test/unit/_write-keystore-fixture.js +16 -0
  115. package/test/unit/abi-interface.test.js +103 -98
  116. package/test/unit/abi-interface.test.ts +102 -0
  117. package/test/unit/address-wallet.test.js +355 -257
  118. package/test/unit/address-wallet.test.ts +342 -0
  119. package/test/unit/browser-provider.test.js +85 -82
  120. package/test/unit/browser-provider.test.ts +79 -0
  121. package/test/unit/contract.test.js +85 -82
  122. package/test/unit/contract.test.ts +83 -0
  123. package/test/unit/encoding-units-rlp.test.js +92 -89
  124. package/test/unit/encoding-units-rlp.test.ts +91 -0
  125. package/test/unit/errors.test.js +77 -74
  126. package/test/unit/errors.test.ts +76 -0
  127. package/test/unit/filter-by-blockhash.test.js +55 -52
  128. package/test/unit/filter-by-blockhash.test.ts +54 -0
  129. package/test/unit/fixtures/encrypted-keystores-48-32-36.js +9 -0
  130. package/test/unit/generate-contract-cli.test.js +42 -39
  131. package/test/unit/generate-contract-cli.test.ts +41 -0
  132. package/test/unit/generate-sdk-artifacts-json.test.js +113 -110
  133. package/test/unit/generate-sdk-artifacts-json.test.ts +110 -0
  134. package/test/unit/generator.test.js +102 -99
  135. package/test/unit/generator.test.ts +101 -0
  136. package/test/unit/hashing.test.js +68 -54
  137. package/test/unit/hashing.test.ts +67 -0
  138. package/test/unit/init.test.js +39 -36
  139. package/test/unit/init.test.ts +38 -0
  140. package/test/unit/interface.test.js +56 -53
  141. package/test/unit/interface.test.ts +54 -0
  142. package/test/unit/internal-hex.test.js +50 -47
  143. package/test/unit/internal-hex.test.ts +49 -0
  144. package/test/unit/populate-transaction.test.js +65 -62
  145. package/test/unit/populate-transaction.test.ts +64 -0
  146. package/test/unit/providers.test.js +200 -144
  147. package/test/unit/providers.test.ts +196 -0
  148. package/test/unit/result.test.js +80 -77
  149. package/test/unit/result.test.ts +79 -0
  150. package/test/unit/solidity-types.test.js +49 -46
  151. package/test/unit/solidity-types.test.ts +39 -0
  152. package/test/unit/utils.test.js +57 -54
  153. package/test/unit/utils.test.ts +56 -0
  154. package/test/verbose-logger.js +74 -0
  155. package/tsconfig.build.json +14 -0
package/README-SDK.md CHANGED
@@ -1,754 +1,756 @@
1
- > **CAUTION:** This is an experimental SDK. Use at your own risk.
2
-
3
- # QuantumCoin.js — Comprehensive SDK Documentation
4
-
5
- This document is the **complete, detailed SDK reference** for QuantumCoin.js (ethers.js v6-compatible surface), including **every exported class/function**, their **parameters**, and links to **examples** and **tests** in this repository.
6
-
7
- > Reminder: QuantumCoin.js requires calling `Initialize()` before using features that depend on `quantum-coin-js-sdk` (address validation, ABI encoding/decoding, signing, etc.).
8
-
9
- ## Table of Contents
10
-
11
- - [Getting started](#getting-started)
12
- - [Install](#install)
13
- - [Initialization (required)](#initialization-required)
14
- - [Key differences vs ethers/Ethereum](#key-differences-vs-ethersethereum)
15
- - [Configuration (`quantumcoin/config`)](#configuration-quantumcoinconfig)
16
- - [`Config`](#config)
17
- - [`Initialize(config)`](#initializeconfig)
18
- - [`isInitialized()`](#isinitialized)
19
- - [`getConfig()`](#getconfig)
20
- - [Constants](#constants)
21
- - [Errors](#errors)
22
- - [`makeError`, `assert`, `assertArgument`, `isError`, `isCallException`](#makeerror-assert-assertargument-iserror-iscallexception)
23
- - [`ProviderError`, `TransactionError`, `ContractError`](#providererror-transactionerror-contracterror)
24
- - [Providers](#providers)
25
- - [`Provider`](#provider)
26
- - [`AbstractProvider`](#abstractprovider)
27
- - [`JsonRpcProvider` / `JsonRpcApiProvider`](#jsonrpcprovider--jsonrpcapiprovider)
28
- - [`WebSocketProvider`](#websocketprovider)
29
- - [`IpcSocketProvider`](#ipcsocketprovider)
30
- - [`BrowserProvider`](#browserprovider)
31
- - [`FallbackProvider`](#fallbackprovider)
32
- - [`FilterByBlockHash`](#filterbyblockhash)
33
- - [`Block`](#block)
34
- - [`TransactionResponse`](#transactionresponse)
35
- - [`TransactionReceipt`](#transactionreceipt)
36
- - [`Log`](#log)
37
- - [Wallets & Signers](#wallets--signers)
38
- - [`SigningKey`](#signingkey)
39
- - [`AbstractSigner`](#abstractsigner)
40
- - [`BaseWallet`](#basewallet)
41
- - [`Wallet`](#wallet)
42
- - [`NonceManager`](#noncemanager)
43
- - [`JsonRpcSigner`](#jsonrpcsigner)
44
- - [`VoidSigner`](#voidsigner)
45
- - [Contracts](#contracts)
46
- - [`Contract`](#contract)
47
- - [`ContractFactory`](#contractfactory)
48
- - [`ContractTransactionResponse`](#contracttransactionresponse)
49
- - [`ContractTransactionReceipt`](#contracttransactionreceipt)
50
- - [`EventLog`](#eventlog)
51
- - [ABI](#abi)
52
- - [Fragments (`Fragment`, `FunctionFragment`, ...)](#fragments-fragment-functionfragment-)
53
- - [`Interface`](#interface)
54
- - [`AbiCoder`](#abicoder)
55
- - [Utilities](#utilities)
56
- - [Address utilities](#address-utilities)
57
- - [Encoding utilities](#encoding-utilities)
58
- - [Hashing utilities](#hashing-utilities)
59
- - [Units](#units)
60
- - [RLP](#rlp)
61
- - [`Result` and `checkResultErrors`](#result-and-checkresulterrors)
62
- - [Typed SDK Generator (`generate-sdk.js`)](#typed-sdk-generator-generate-sdkjs)
63
- - [Overview](#overview)
64
- - [Input modes](#input-modes)
65
- - [Package scaffolding mode](#package-scaffolding-mode)
66
- - [Generated package layout](#generated-package-layout)
67
- - [Running generated transactional tests](#running-generated-transactional-tests)
68
- - [Generator tests](#generator-tests)
69
-
70
- ## Getting started
71
-
72
- ### Install
73
-
74
- ```bash
75
- npm install quantumcoin
76
- ```
77
-
78
- ### Initialization (required)
79
-
80
- ```js
81
- const { Initialize } = require("quantumcoin/config");
82
-
83
- // Initialize with defaults (chainId=123123 and default RPC endpoint)
84
- await Initialize(null);
85
- ```
86
-
87
- If you need to override the RPC endpoint used by `JsonRpcProvider` defaults:
88
-
89
- ```js
90
- const { Config, Initialize } = require("quantumcoin/config");
91
- await Initialize(new Config(123123, "https://public.rpc.quantumcoinapi.com"));
92
- ```
93
-
94
- **Example(s):**
95
- - `examples/example.js`
96
-
97
- ### Key differences vs ethers/Ethereum
98
-
99
- - **Addresses are 32 bytes** (66 hex chars including `0x`)
100
- - **Signing and ABI encoding/decoding** are delegated to `quantum-coin-js-sdk` (WASM)
101
- - **Initialize must be called** once at startup for wallet/address/ABI helpers
102
-
103
- ## Configuration (`quantumcoin/config`)
104
-
105
- ### `Config`
106
-
107
- **Constructor**
108
-
109
- - `new Config(chainId?: number, rpcEndpoint?: string)`
110
- - **chainId**: defaults to `123123`
111
- - **rpcEndpoint**: defaults to `https://public.rpc.quantumcoinapi.com`
112
-
113
- ### `Initialize(config)`
114
-
115
- - `Initialize(config: Config | null | undefined): Promise<boolean>`
116
- - If `config` is `null` / `undefined`, defaults are used
117
- - Initializes `quantum-coin-js-sdk` internally (WASM + crypto)
118
-
119
- ### `isInitialized()`
120
-
121
- - `isInitialized(): boolean`
122
- - Returns true after `Initialize(...)` succeeds
123
-
124
- ### `getConfig()`
125
-
126
- - `getConfig(): Config | null`
127
- - Returns the active config (or `null` if not initialized)
128
-
129
- ## Constants
130
-
131
- Exported from `quantumcoin`:
132
-
133
- - `version: string`
134
- - `ZeroAddress: string` (32-byte zero address)
135
- - `ZeroHash: string` (32-byte zero hash)
136
- - `MaxUint256: bigint`
137
- - `MaxUint160: bigint`
138
- - `MinInt256: bigint`
139
- - `MaxInt256: bigint`
140
- - `NumericFault: string` (=`"NUMERIC_FAULT"`)
141
- - `NumericFaultCode: string` (=`"NUMERIC_FAULT"`)
142
- - `WeiPerEther: bigint` (=`1000000000000000000n`)
143
- - `EtherSymbol: string` (=`"Ξ"`)
144
- - `N: bigint` (compat placeholder)
145
-
146
- ## Errors
147
-
148
- ### `makeError`, `assert`, `assertArgument`, `isError`, `isCallException`
149
-
150
- - `makeError(message: string, code: ErrorCode, info?: object): Error & { code, shortMessage }`
151
- - `assert(check: any, message: string, code: ErrorCode, info?: object): void`
152
- - `assertArgument(check: any, message: string, name: string, value: any): void`
153
- - `isError(error: any, code: string): boolean`
154
- - `isCallException(error: any): boolean`
155
-
156
- **Notes**
157
- - Most SDK errors are `Error`/`TypeError` with `.code` and `.shortMessage` (ethers-like).
158
-
159
- ### `ProviderError`, `TransactionError`, `ContractError`
160
-
161
- - `new ProviderError(message: string, info?: object)`
162
- - `new TransactionError(message: string, info?: object)`
163
- - `new ContractError(message: string, info?: object)`
164
-
165
- ## Providers
166
-
167
- ### `Provider`
168
-
169
- Base class extending Node’s `EventEmitter`. Used primarily for API surface parity.
170
-
171
- ### `AbstractProvider`
172
-
173
- Base provider implementation. Subclasses implement `_perform`.
174
-
175
- **Core method**
176
- - `_perform(method: string, params?: any[]): Promise<any>` (**subclass responsibility**)
177
-
178
- **Read operations**
179
- - `getBlockNumber(): Promise<number>`
180
- - `getBlock(blockNumber: number | "latest"): Promise<Block>`
181
- - `getTransaction(txHash: string): Promise<TransactionResponse | null>`
182
- - `getTransactionReceipt(txHash: string): Promise<TransactionReceipt | null>`
183
- - `getBalance(address: string): Promise<bigint>`
184
- - `getTransactionCount(address: string, blockTag?: string | null): Promise<number>`
185
- - `call(tx: TransactionRequest, blockTag?: string | null): Promise<string>`
186
- - `estimateGas(tx: TransactionRequest): Promise<bigint>`
187
- - `getCode(address: string, blockTag?: string | null): Promise<string>`
188
- - `getStorageAt(address: string, position: bigint, blockTag?: string | null): Promise<string>`
189
- - `getLogs(filter: Filter | FilterByBlockHash): Promise<Log[]>`
190
-
191
- **Write operation**
192
- - `sendTransaction(tx: string | { raw: string }): Promise<TransactionResponse>`
193
- - QuantumCoin.js expects a **signed raw transaction hex string**.
194
-
195
- **Example(s):**
196
- - `examples/example.js`
197
- - `examples/read-operations.js`
198
- - `examples/events.js`
199
-
200
- ### `JsonRpcProvider` / `JsonRpcApiProvider`
201
-
202
- HTTP JSON-RPC provider.
203
-
204
- - `new JsonRpcProvider(url?: string, chainId?: number)`
205
- - If `url` is omitted, uses config default `rpcEndpoint`
206
- - If `chainId` is omitted, defaults to `123123`
207
-
208
- **Example(s):**
209
- - `examples/example.js`
210
-
211
- ### `WebSocketProvider`
212
-
213
- WebSocket JSON-RPC provider (no extra dependencies; uses Node’s global `WebSocket`).
214
-
215
- - `new WebSocketProvider(url: string, chainId?: number)`
216
- - `destroy(): void` (closes socket, rejects pending requests)
217
-
218
- **Test(s):**
219
- - `test/integration/ws-provider.test.js`
220
-
221
- ### `IpcSocketProvider`
222
-
223
- IPC JSON-RPC provider using Node’s `net`.
224
-
225
- - `new IpcSocketProvider(path: string)`
226
- - Windows example: `\\\\.\\pipe\\geth.ipc`
227
-
228
- **Test(s):**
229
- - `test/integration/ipc-provider.test.js`
230
-
231
- ### `BrowserProvider`
232
-
233
- EIP-1193 wrapper provider (for injected browser wallets).
234
-
235
- - `new BrowserProvider(eip1193Provider: { request: Function }, network?: any, options?: BrowserProviderOptions)`
236
- - `providerInfo` is supported as an option (compat)
237
-
238
- **Core methods**
239
- - `send(method: string, params?: any[] | object): Promise<any>`
240
- - `_send(payloadOrArray): Promise<any>` (compat)
241
- - `_perform(method: string, params?: any[]): Promise<any>` (delegates to `send`)
242
- - `getRpcError(payload, error): Error`
243
- - `getSigner(addressOrIndex?: string | number): Promise<JsonRpcSigner>`
244
- - `hasSigner(addressOrIndex: string | number): Promise<boolean>`
245
-
246
- **Debug event sink**
247
- - Emits `"debug"` events:
248
- - `{ action: "sendEip1193Payload", payload: { method, params } }`
249
- - `{ action: "receiveEip1193Result", result }`
250
- - `{ action: "receiveEip1193Error", error }`
251
-
252
- **Test(s):**
253
- - `test/unit/browser-provider.test.js`
254
-
255
- Reference: ethers BrowserProvider docs: [`https://docs.ethers.org/v6/api/providers/#BrowserProvider`](https://docs.ethers.org/v6/api/providers/#BrowserProvider)
256
-
257
- ### `FallbackProvider`
258
-
259
- Simple provider wrapper that tries multiple providers in order.
260
-
261
- - `new FallbackProvider(providers: AbstractProvider | AbstractProvider[])`
262
- - `_perform(method, params)` tries each provider until one succeeds
263
-
264
- ### `FilterByBlockHash`
265
-
266
- Helper for filters pinned to a specific block hash (ethers style).
267
-
268
- - `new FilterByBlockHash(blockHash: string, address?: string | string[], topics?: (string|string[]|null)[])`
269
- - `blockHash` must be **32-byte hex**
270
- - `toJSON()` returns `{ blockHash, address, topics }`
271
-
272
- **Test(s):**
273
- - `test/unit/filter-by-blockhash.test.js`
274
-
275
- Reference: ethers FilterByBlockHash docs: [`https://docs.ethers.org/v6/api/providers/#FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash)
276
-
277
- ### `Block`
278
-
279
- Wrapper returned by `provider.getBlock(...)`.
280
-
281
- **Properties**
282
- - `hash: string | null`
283
- - `parentHash: string | null`
284
- - `number: number | null`
285
- - `timestamp: number | null`
286
- - `transactions: any[]`
287
- - `provider: AbstractProvider | null`
288
-
289
- **Methods**
290
- - `getTransaction(indexOrHash: number | string): Promise<TransactionResponse | null>`
291
- - `getTransactionReceipt(indexOrHash: number | string): Promise<TransactionReceipt | null>`
292
- - `getPrefetchedTransactions(): any[]` (currently returns `[]`)
293
-
294
- ### `TransactionResponse`
295
-
296
- Wrapper returned by `provider.sendTransaction(...)` and `provider.getTransaction(...)`.
297
-
298
- **Properties (common)**
299
- - `hash: string`
300
- - `to: string | null`
301
- - `from: string | null`
302
- - `nonce: number | null`
303
- - `data: string`
304
- - `value: bigint`
305
- - `gasLimit: bigint | null`
306
- - `gasPrice: bigint | null`
307
- - `chainId: number | null`
308
- - `blockNumber: number | null`
309
- - `provider: AbstractProvider | null`
310
-
311
- **Methods**
312
- - `wait(confirmations?: number | null, timeoutMs?: number | null): Promise<TransactionReceipt>`
313
-
314
- ### `TransactionReceipt`
315
-
316
- Wrapper returned by `provider.getTransactionReceipt(...)` and `tx.wait()`.
317
-
318
- **Properties (common)**
319
- - `to: string | null`
320
- - `from: string | null`
321
- - `contractAddress: string | null`
322
- - `transactionHash: string`
323
- - `blockHash: string`
324
- - `blockNumber: number | null`
325
- - `transactionIndex: number | null`
326
- - `gasUsed: bigint | null`
327
- - `status: number | null`
328
- - `logs: Log[]`
329
- - `provider: AbstractProvider | null`
330
-
331
- ### `Log`
332
-
333
- Wrapper returned by `provider.getLogs(...)`.
334
-
335
- **Properties (common)**
336
- - `address: string`
337
- - `topics: string[]`
338
- - `data: string`
339
- - `blockHash: string | null`
340
- - `blockNumber: number | null`
341
- - `transactionHash: string | null`
342
- - `transactionIndex: number | null`
343
- - `logIndex: number | null`
344
- - `removed: boolean`
345
- - `provider: AbstractProvider | null`
346
-
347
- **Methods**
348
- - `getBlock(): Promise<Block | null>`
349
- - `getTransaction(): Promise<TransactionResponse | null>`
350
- - `getTransactionReceipt(): Promise<TransactionReceipt | null>`
351
-
352
- ## Wallets & Signers
353
-
354
- ### `SigningKey`
355
-
356
- - `new SigningKey(privateKeyBytes: Uint8Array, publicKeyBytes: Uint8Array)`
357
-
358
- ### `AbstractSigner`
359
-
360
- - `new AbstractSigner(provider?: AbstractProvider | null)`
361
- - `provider: AbstractProvider | null`
362
- - `getAddress(): Promise<string>` (base throws; implemented by subclasses)
363
-
364
- ### `BaseWallet`
365
-
366
- Core signing implementation.
367
-
368
- - `new BaseWallet(signingKey: SigningKey, provider?: AbstractProvider | null, precomputed?: { address: string }, qcWallet?: any)`
369
-
370
- **Properties**
371
- - `address: string`
372
- - `privateKey: string` (getter; hex string)
373
- - `provider: AbstractProvider | null`
374
-
375
- **Methods**
376
- - `getAddress(): Promise<string>`
377
- - `signMessageSync(message: string | Uint8Array): string`
378
- - `signTransaction(tx: TransactionRequest): Promise<string>`
379
- - `sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>`
380
-
381
- ### `Wallet`
382
-
383
- User-facing wallet class.
384
-
385
- - `new Wallet(privateKeyOrBytesOrSigningKey, provider?: AbstractProvider)`
386
-
387
- **Static methods**
388
- - `Wallet.createRandom(provider?: AbstractProvider): Wallet`
389
- - `Wallet.fromEncryptedJsonSync(json: string, password: string, provider?: AbstractProvider): Wallet`
390
- - `Wallet.fromPhrase(phrase: string | string[], provider?: AbstractProvider): Wallet`
391
-
392
- **Instance methods**
393
- - `getAddress(): string`
394
- - `getBalance(blockTag?: string): Promise<bigint>`
395
- - `getTransactionCount(blockTag?: string): Promise<number>`
396
- - `encryptSync(password: string | Uint8Array): string`
397
- - `connect(provider: AbstractProvider): Wallet`
398
-
399
- **Example(s):**
400
- - `examples/wallet-offline.js`
401
-
402
- ### `NonceManager`
403
-
404
- Signer wrapper to manage nonces.
405
-
406
- - `new NonceManager(signer: AbstractSigner)`
407
-
408
- **Methods**
409
- - `getAddress(): Promise<string>`
410
- - `getTransactionCount(blockTag?: string): Promise<number>`
411
- - `sendTransaction(tx: TransactionRequest): Promise<any>`
412
- - `reset(): void`
413
- - `increment(): void`
414
-
415
- ### `JsonRpcSigner`
416
-
417
- Lightweight signer placeholder used by `BrowserProvider.getSigner(...)`.
418
-
419
- - `new JsonRpcSigner(provider, address)`
420
- - `getAddress(): Promise<string>`
421
-
422
- ### `VoidSigner`
423
-
424
- Address-only signer.
425
-
426
- - `new VoidSigner(address: string, provider?: AbstractProvider)`
427
- - `getAddress(): Promise<string>`
428
-
429
- ## Contracts
430
-
431
- ### `Contract`
432
-
433
- Dynamic contract wrapper (ethers-like).
434
-
435
- - `new Contract(address: string, abi: any[] | Interface, runner?: AbstractProvider | Wallet, bytecode?: string)`
436
-
437
- **Properties**
438
- - `address: string`
439
- - `target: string` (alias of address)
440
- - `interface: Interface`
441
- - `provider: AbstractProvider | null`
442
- - `signer: any | null`
443
-
444
- **Call / send**
445
- - `call(methodName: string, args: any[], overrides?: TransactionRequest): Promise<any>`
446
- - `send(methodName: string, args: any[], overrides?: TransactionRequest): Promise<ContractTransactionResponse>`
447
-
448
- **Logs / events**
449
- - `queryFilter(eventName: string, fromBlock?: number|string, toBlock?: number|string): Promise<EventLog[]>`
450
- - `on(eventName: string, callback: Function): this`
451
- - `once(eventName: string, callback: Function): this`
452
- - `removeListener(eventName: string, callback: Function): this`
453
- - `removeAllListeners(eventName?: string): this`
454
-
455
- **Deployment helpers**
456
- - `deployTransaction(): any | null`
457
- - `waitForDeployment(): Promise<this>`
458
- - `getDeployedCode(): Promise<string | null>`
459
-
460
- **Example(s):**
461
- - `examples/read-operations.js`
462
- - `examples/events.js`
463
-
464
- ### `ContractFactory`
465
-
466
- Deployment helper.
467
-
468
- - `new ContractFactory(abi: any[] | Interface, bytecode: string, signer: any)`
469
-
470
- **Methods**
471
- - `getDeployTransaction(...args: any[]): TransactionRequest`
472
- - `deploy(...args: any[]): Promise<Contract>`
473
- - `attach(address: string): Contract`
474
- - `connect(signer: any): ContractFactory`
475
-
476
- ### `ContractTransactionResponse`
477
-
478
- Wrapper around an underlying `TransactionResponse`.
479
-
480
- - `wait(confirmations?: number, timeoutMs?: number): Promise<any>`
481
- - `getTransaction(): any`
482
-
483
- ### `ContractTransactionReceipt`
484
-
485
- Wrapper around a receipt with convenience filters.
486
-
487
- - `getEvent(eventName: string): any | null`
488
- - `getEvents(eventName: string): any[]`
489
-
490
- ### `EventLog`
491
-
492
- Lightweight log wrapper returned by `Contract.queryFilter(...)`.
493
-
494
- ## ABI
495
-
496
- ### Fragments (`Fragment`, `FunctionFragment`, ...)
497
-
498
- Exported fragment types:
499
- - `Fragment`
500
- - `NamedFragment`
501
- - `FunctionFragment`
502
- - `EventFragment`
503
- - `ErrorFragment`
504
- - `ConstructorFragment`
505
- - `StructFragment`
506
- - `FallbackFragment`
507
-
508
- All fragments support:
509
- - `format(format?: string | null): string`
510
- - `toJSON(): any`
511
-
512
- ### `Interface`
513
-
514
- ABI encoding/decoding compatibility layer.
515
-
516
- - `new Interface(abi: any[] | Interface | null)`
517
-
518
- **Methods**
519
- - `formatJson(): string`
520
- - `format(format?: string | null): string`
521
- - `getFunction(name: string): FunctionFragment`
522
- - `getEvent(name: string): EventFragment`
523
- - `getError(name: string): ErrorFragment`
524
- - `getConstructor(): ConstructorFragment | null`
525
-
526
- **Encoding**
527
- - `encodeFunctionData(functionFragmentOrName, values?: any[] | null): string`
528
- - `decodeFunctionResult(functionFragmentOrName, data: string): any`
529
- - `encodeEventLog(eventFragmentOrName, values?: any[] | null): { topics: string[], data: string }`
530
- - `decodeEventLog(eventFragmentOrName, topics: string[], data: string): any`
531
-
532
- **Parsing**
533
- - `parseLog(log: { topics: string[], data: string }): { fragment, name, signature, topic, args }`
534
- - Uses signature topic matching and `decodeEventLog(...)`
535
-
536
- ### `AbiCoder`
537
-
538
- Minimal ABI coder for encoding/decoding tuples of values.
539
-
540
- - `encode(types: (string|any)[], values: any[]): string`
541
- - `decode(types: (string|any)[], data: string): any`
542
- - `getDefaultValue(types: (string|any)[]): any`
543
-
544
- ## Utilities
545
-
546
- ### Address utilities
547
-
548
- From `quantumcoin`:
549
-
550
- - `isAddress(address: string): boolean`
551
- - `getAddress(address: string): string`
552
- - `isAddressable(value: any): boolean`
553
- - `resolveAddress(target: any): string | Promise<string>`
554
- - `getContractAddress({ from, nonce }): string`
555
- - `getCreateAddress({ from, nonce }): string`
556
- - `getCreate2Address(from: string, salt: string, initCodeHash: string): string`
557
- - `computeAddress(publicKey: string|Uint8Array): string`
558
- - `verifyMessage(message: string|Uint8Array, signature: string): string`
559
- - `recoverAddress(message: string|Uint8Array, signature: string): string`
560
-
561
- **Example(s):**
562
- - `examples/wallet-offline.js`
563
-
564
- ## Solidity Types (TypeScript)
565
-
566
- QuantumCoin.js exposes core Solidity-related types for TypeScript users.
567
-
568
- - **Import path**: `quantumcoin/types`
569
-
570
- **Key exports**
571
-
572
- - `AddressLike` (currently `string`, 32-byte address)
573
- - `BytesLike` (`string | Uint8Array`)
574
- - `BigNumberish` (`string | number | bigint`)
575
- - `SolidityTypeName` (ABI type string model)
576
- - **Hard Solidity aliases** (preferred for typed wrappers):
577
- - Integers: `Uint256Like` / `Uint256`, `Int256Like` / `Int256` (and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`)
578
- - Fixed bytes: `Bytes32Like` / `Bytes32` (and `Bytes1Like`…`Bytes32Like`)
579
- - Arrays/tuples helpers: `SolArray<T>`, `SolFixedArray<T, N>`, `SolStruct<T>`
580
- - `SolidityInputValue<T>` / `SolidityOutputValue<T>` (advanced type-level mapping from ABI type strings to JS values; the generator no longer uses these for wrapper signatures)
581
-
582
- Example:
583
-
584
- ```ts
585
- import type { AddressLike, BigNumberish, Uint256Like, Uint256 } from "quantumcoin/types";
586
-
587
- const to: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
588
- const amount: BigNumberish = "123";
589
- const asInput: Uint256Like = amount;
590
- const asOutput: Uint256 = 123n;
591
- ```
592
-
593
- ### Encoding utilities
594
-
595
- - `toUtf8String(data: BytesLike): string`
596
- - `toUtf8Bytes(str: string): Uint8Array`
597
- - `toHex(data: BytesLike): string`
598
- - `hexlify(data: BytesLike): string`
599
- - `arrayify(data: BytesLike): Uint8Array`
600
- - `isBytesLike(value: any): boolean`
601
- - `concat(items: BytesLike[]): string`
602
- - `stripZerosLeft(data: BytesLike): string`
603
- - `zeroPad(value: BytesLike, length: number): string`
604
- - `zeroPadValue(value: BytesLike, length: number): string`
605
- - `encodeBytes32String(text: string): string`
606
- - `decodeBytes32String(bytes: BytesLike): string`
607
- - `encodeBase64(data: BytesLike): string`
608
- - `decodeBase64(data: string): Uint8Array`
609
- - `encodeBase58(data: BytesLike): string`
610
- - `decodeBase58(data: string): Uint8Array`
611
- - `toUtf8CodePoints(str: string): number[]`
612
- - `solidityPacked(...)` (**throws; not implemented**)
613
- - `solidityPackedKeccak256(...)` (**throws; not implemented**)
614
- - `solidityPackedSha256(...)` (**throws; not implemented**)
615
-
616
- ### Hashing utilities
617
-
618
- - `keccak256(data: BytesLike): string`
619
- - `sha256(data: BytesLike): string`
620
- - `sha512(data: BytesLike): string`
621
- - `ripemd160(data: BytesLike): string`
622
- - `id(text: string): string` (=`keccak256(utf8Bytes(text))`)
623
- - `randomBytes(length: number): Uint8Array`
624
- - `computeHmac(algorithm: string, key: BytesLike, data: BytesLike): string`
625
- - `pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, algorithm?: string): string`
626
- - `scrypt(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): Promise<string>`
627
- - `scryptSync(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): string`
628
-
629
- ### Units
630
-
631
- - `formatUnits(value: BigNumberish, decimals?: number): string`
632
- - `parseUnits(value: string, decimals?: number): bigint`
633
- - `formatEther(value: BigNumberish): string`
634
- - `parseEther(value: string): bigint`
635
-
636
- ### RLP
637
-
638
- - `encodeRlp(value: any): string`
639
- - `decodeRlp(data: string): any`
640
-
641
- ### `Result` and `checkResultErrors`
642
-
643
- - `class Result extends Array`
644
- - `new Result(items?: any[], keys?: (null|string)[])`
645
- - `Result.fromItems(items: any[], keys?: (null|string)[]): Result`
646
- - `getValue(name: string): any`
647
- - `toArray(deep?: boolean | null): any[]`
648
- - `toObject(deep?: boolean | null): Record<string, any>`
649
- - `checkResultErrors(result: any): Array<{ error: Error, path: (string|number)[] }>`
650
-
651
- ## Typed SDK Generator (`generate-sdk.js`)
652
-
653
- ### Overview
654
-
655
- `generate-sdk.js` creates **typed contract wrappers** for one or more contracts, and can optionally scaffold a complete npm package (with examples and transactional tests).
656
-
657
- It supports generating:
658
- - **TypeScript source** (`--lang ts`, default)
659
- - **JavaScript source + TypeScript declarations** (`--lang js`)
660
-
661
- **Typing behaviour (generated wrappers)**
662
-
663
- - **Hard types**: wrapper signatures use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
664
- - **Single output unwrapping**: functions returning one value return the value directly (not `[value]`).
665
- - **Multiple outputs**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
666
- - **No outputs**: `Promise<void>`.
667
- - **Structs / tuples**: emitted as `export type <Name>Input` / `export type <Name>Output` and used in signatures.
668
- - **JS typing**: JS output uses JSDoc types plus `.d.ts` files; TS users still get strong types.
669
-
670
- **Entry point**
671
- - `node generate-sdk.js ...`
672
- - or `npx sdkgen ...` (when installed)
673
-
674
- ### Input modes
675
-
676
- 1) **ABI + BIN**
677
-
678
- ```bash
679
- node generate-sdk.js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
680
-
681
- # JS output
682
- node generate-sdk.js --lang js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
683
- ```
684
-
685
- 2) **Solidity sources**
686
-
687
- ```bash
688
- node generate-sdk.js --sol ".\\contracts\\A.sol,.\\contracts\\B.sol" --solc "c:\\solc\\solc.exe" --out ./out --non-interactive
689
-
690
- # Pass additional solc args (example)
691
- node generate-sdk.js --sol ".\\contracts\\A.sol" --solc "c:\\solc\\solc.exe" --solc-args "--via-ir --evm-version london" --out ./out --non-interactive
692
- ```
693
-
694
- 3) **Artifacts JSON (multi-contract ABI+BIN list)**
695
-
696
- ```bash
697
- node generate-sdk.js --artifacts-json .\\artifacts.json --out .\\out --non-interactive
698
- ```
699
-
700
- Example `artifacts.json`:
701
-
702
- ```json
703
- [
704
- { "abi": "./Alpha.abi.json", "bin": "./Alpha.bin" },
705
- { "abi": "./Beta.abi.json", "bin": "./Beta.bin", "name": "Beta" },
706
- {
707
- "name": "Gamma",
708
- "abi": "[{\"type\":\"function\",\"name\":\"set\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"outputs\":[]}]",
709
- "bin": "0x6000600055..."
710
- }
711
- ]
712
- ```
713
-
714
- ### Package scaffolding mode
715
-
716
- Use `--create-package` to create a full npm package (source, tests, examples, README).
717
-
718
- ```bash
719
- node generate-sdk.js --artifacts-json .\\artifacts.json ^
720
- --lang ts ^
721
- --create-package --package-dir .\\tmp --package-name my-typed-package ^
722
- --package-description "My typed package" --package-author "me" ^
723
- --package-license MIT --package-version 0.0.1 ^
724
- --non-interactive
725
- ```
726
-
727
- ### Generated package layout
728
-
729
- When `--create-package` is used, the generator produces:
730
-
731
- - `src/` contract wrappers + factories
732
- - TS mode: `*.ts` (compiled output in `dist/` after `npm run build:ts`)
733
- - JS mode: `*.js` with `*.d.ts` types (no build step required)
734
- - `test/e2e/*.e2e.test.js` per-contract transactional tests
735
- - `examples/` deploy/read/write/events scripts
736
- - `README.md` generated by the generator (includes ABI-derived API overview)
737
- - `index.js` + `index.d.ts` (package entry shims)
738
-
739
- ### Running generated transactional tests
740
-
741
- Generated package tests broadcast transactions and require:
742
-
743
- - `QC_RPC_URL` (RPC endpoint)
744
- - `QC_CHAIN_ID` (optional, default `123123`)
745
-
746
- ### Generator tests
747
-
748
- - Unit tests:
749
- - `test/unit/generate-contract-cli.test.js`
750
- - `test/unit/generator.test.js`
751
- - `test/unit/generate-sdk-artifacts-json.test.js`
752
- - E2E generator tests (transactional):
753
- - `test/e2e/typed-generator.e2e.test.js`
754
-
1
+ > **CAUTION:** This is an experimental SDK. Use at your own risk.
2
+
3
+ # QuantumCoin.js — Comprehensive SDK Documentation
4
+
5
+ This document is the **complete, detailed SDK reference** for QuantumCoin.js (ethers.js v6-compatible surface), including **every exported class/function**, their **parameters**, and links to **examples** and **tests** in this repository.
6
+
7
+ > Reminder: QuantumCoin.js requires calling `Initialize()` before using features that depend on `quantum-coin-js-sdk` (address validation, ABI encoding/decoding, signing, etc.).
8
+
9
+ ## Table of Contents
10
+
11
+ - [Getting started](#getting-started)
12
+ - [Install](#install)
13
+ - [Initialization (required)](#initialization-required)
14
+ - [Key differences vs ethers/Ethereum](#key-differences-vs-ethersethereum)
15
+ - [Configuration (`quantumcoin/config`)](#configuration-quantumcoinconfig)
16
+ - [`Config`](#config)
17
+ - [`Initialize(config)`](#initializeconfig)
18
+ - [`isInitialized()`](#isinitialized)
19
+ - [`getConfig()`](#getconfig)
20
+ - [Constants](#constants)
21
+ - [Errors](#errors)
22
+ - [`makeError`, `assert`, `assertArgument`, `isError`, `isCallException`](#makeerror-assert-assertargument-iserror-iscallexception)
23
+ - [`ProviderError`, `TransactionError`, `ContractError`](#providererror-transactionerror-contracterror)
24
+ - [Providers](#providers)
25
+ - [`Provider`](#provider)
26
+ - [`AbstractProvider`](#abstractprovider)
27
+ - [`JsonRpcProvider` / `JsonRpcApiProvider`](#jsonrpcprovider--jsonrpcapiprovider)
28
+ - [`WebSocketProvider`](#websocketprovider)
29
+ - [`IpcSocketProvider`](#ipcsocketprovider)
30
+ - [`BrowserProvider`](#browserprovider)
31
+ - [`FallbackProvider`](#fallbackprovider)
32
+ - [`FilterByBlockHash`](#filterbyblockhash)
33
+ - [`Block`](#block)
34
+ - [`TransactionResponse`](#transactionresponse)
35
+ - [`TransactionReceipt`](#transactionreceipt)
36
+ - [`Log`](#log)
37
+ - [Wallets & Signers](#wallets--signers)
38
+ - [`SigningKey`](#signingkey)
39
+ - [`AbstractSigner`](#abstractsigner)
40
+ - [`BaseWallet`](#basewallet)
41
+ - [`Wallet`](#wallet)
42
+ - [`NonceManager`](#noncemanager)
43
+ - [`JsonRpcSigner`](#jsonrpcsigner)
44
+ - [`VoidSigner`](#voidsigner)
45
+ - [Contracts](#contracts)
46
+ - [`Contract`](#contract)
47
+ - [`ContractFactory`](#contractfactory)
48
+ - [`ContractTransactionResponse`](#contracttransactionresponse)
49
+ - [`ContractTransactionReceipt`](#contracttransactionreceipt)
50
+ - [`EventLog`](#eventlog)
51
+ - [ABI](#abi)
52
+ - [Fragments (`Fragment`, `FunctionFragment`, ...)](#fragments-fragment-functionfragment-)
53
+ - [`Interface`](#interface)
54
+ - [`AbiCoder`](#abicoder)
55
+ - [Utilities](#utilities)
56
+ - [Address utilities](#address-utilities)
57
+ - [Encoding utilities](#encoding-utilities)
58
+ - [Hashing utilities](#hashing-utilities)
59
+ - [Units](#units)
60
+ - [RLP](#rlp)
61
+ - [`Result` and `checkResultErrors`](#result-and-checkresulterrors)
62
+ - [Typed SDK Generator (`generate-sdk.js`)](#typed-sdk-generator-generate-sdkjs)
63
+ - [Overview](#overview)
64
+ - [Input modes](#input-modes)
65
+ - [Package scaffolding mode](#package-scaffolding-mode)
66
+ - [Generated package layout](#generated-package-layout)
67
+ - [Running generated transactional tests](#running-generated-transactional-tests)
68
+ - [Generator tests](#generator-tests)
69
+
70
+ ## Getting started
71
+
72
+ ### Install
73
+
74
+ ```bash
75
+ npm install quantumcoin
76
+ ```
77
+
78
+ ### Initialization (required)
79
+
80
+ ```js
81
+ const { Initialize } = require("quantumcoin/config");
82
+
83
+ // Initialize with defaults (chainId=123123 and default RPC endpoint)
84
+ await Initialize(null);
85
+ ```
86
+
87
+ If you need to override the RPC endpoint used by `JsonRpcProvider` defaults:
88
+
89
+ ```js
90
+ const { Config, Initialize } = require("quantumcoin/config");
91
+ await Initialize(new Config(123123, "https://public.rpc.quantumcoinapi.com"));
92
+ ```
93
+
94
+ **Example(s):**
95
+ - `examples/example.js`
96
+
97
+ ### Key differences vs ethers/Ethereum
98
+
99
+ - **Addresses are 32 bytes** (66 hex chars including `0x`)
100
+ - **Signing and ABI encoding/decoding** are delegated to `quantum-coin-js-sdk` (WASM)
101
+ - **Initialize must be called** once at startup for wallet/address/ABI helpers
102
+
103
+ ## Configuration (`quantumcoin/config`)
104
+
105
+ ### `Config`
106
+
107
+ **Constructor**
108
+
109
+ - `new Config(chainId?: number, rpcEndpoint?: string)`
110
+ - **chainId**: defaults to `123123`
111
+ - **rpcEndpoint**: defaults to `https://public.rpc.quantumcoinapi.com`
112
+
113
+ ### `Initialize(config)`
114
+
115
+ - `Initialize(config: Config | null | undefined): Promise<boolean>`
116
+ - If `config` is `null` / `undefined`, defaults are used
117
+ - Initializes `quantum-coin-js-sdk` internally (WASM + crypto)
118
+
119
+ ### `isInitialized()`
120
+
121
+ - `isInitialized(): boolean`
122
+ - Returns true after `Initialize(...)` succeeds
123
+
124
+ ### `getConfig()`
125
+
126
+ - `getConfig(): Config | null`
127
+ - Returns the active config (or `null` if not initialized)
128
+
129
+ ## Constants
130
+
131
+ Exported from `quantumcoin`:
132
+
133
+ - `version: string`
134
+ - `ZeroAddress: string` (32-byte zero address)
135
+ - `ZeroHash: string` (32-byte zero hash)
136
+ - `MaxUint256: bigint`
137
+ - `MaxUint160: bigint`
138
+ - `MinInt256: bigint`
139
+ - `MaxInt256: bigint`
140
+ - `NumericFault: string` (=`"NUMERIC_FAULT"`)
141
+ - `NumericFaultCode: string` (=`"NUMERIC_FAULT"`)
142
+ - `WeiPerEther: bigint` (=`1000000000000000000n`)
143
+ - `EtherSymbol: string` (=`"Ξ"`)
144
+ - `N: bigint` (compat placeholder)
145
+
146
+ ## Errors
147
+
148
+ ### `makeError`, `assert`, `assertArgument`, `isError`, `isCallException`
149
+
150
+ - `makeError(message: string, code: ErrorCode, info?: object): Error & { code, shortMessage }`
151
+ - `assert(check: any, message: string, code: ErrorCode, info?: object): void`
152
+ - `assertArgument(check: any, message: string, name: string, value: any): void`
153
+ - `isError(error: any, code: string): boolean`
154
+ - `isCallException(error: any): boolean`
155
+
156
+ **Notes**
157
+ - Most SDK errors are `Error`/`TypeError` with `.code` and `.shortMessage` (ethers-like).
158
+
159
+ ### `ProviderError`, `TransactionError`, `ContractError`
160
+
161
+ - `new ProviderError(message: string, info?: object)`
162
+ - `new TransactionError(message: string, info?: object)`
163
+ - `new ContractError(message: string, info?: object)`
164
+
165
+ ## Providers
166
+
167
+ ### `Provider`
168
+
169
+ Base class extending Node’s `EventEmitter`. Used primarily for API surface parity.
170
+
171
+ ### `AbstractProvider`
172
+
173
+ Base provider implementation. Subclasses implement `_perform`.
174
+
175
+ **Core method**
176
+ - `_perform(method: string, params?: any[]): Promise<any>` (**subclass responsibility**)
177
+
178
+ **Read operations**
179
+ - `getBlockNumber(): Promise<number>`
180
+ - `getBlock(blockNumber: number | "latest"): Promise<Block>`
181
+ - `getTransaction(txHash: string): Promise<TransactionResponse | null>`
182
+ - `getTransactionReceipt(txHash: string): Promise<TransactionReceipt | null>`
183
+ - `getBalance(address: string): Promise<bigint>`
184
+ - `getTransactionCount(address: string, blockTag?: string | null): Promise<number>`
185
+ - `call(tx: TransactionRequest, blockTag?: string | null): Promise<string>`
186
+ - `estimateGas(tx: TransactionRequest): Promise<bigint>`
187
+ - `getCode(address: string, blockTag?: string | null): Promise<string>`
188
+ - `getStorageAt(address: string, position: bigint, blockTag?: string | null): Promise<string>`
189
+ - `getLogs(filter: Filter | FilterByBlockHash): Promise<Log[]>`
190
+
191
+ **Write operation**
192
+ - `sendTransaction(tx: string | { raw: string }): Promise<TransactionResponse>`
193
+ - QuantumCoin.js expects a **signed raw transaction hex string**.
194
+
195
+ **Example(s):**
196
+ - `examples/example.js`
197
+ - `examples/read-operations.js`
198
+ - `examples/events.js`
199
+
200
+ ### `JsonRpcProvider` / `JsonRpcApiProvider`
201
+
202
+ HTTP JSON-RPC provider.
203
+
204
+ - `new JsonRpcProvider(url?: string, chainId?: number)`
205
+ - If `url` is omitted, uses config default `rpcEndpoint`
206
+ - If `chainId` is omitted, defaults to `123123`
207
+
208
+ **Example(s):**
209
+ - `examples/example.js`
210
+
211
+ ### `WebSocketProvider`
212
+
213
+ WebSocket JSON-RPC provider (no extra dependencies; uses Node’s global `WebSocket`).
214
+
215
+ - `new WebSocketProvider(url: string, chainId?: number)`
216
+ - `destroy(): void` (closes socket, rejects pending requests)
217
+
218
+ **Test(s):**
219
+ - `test/integration/ws-provider.test.js`
220
+
221
+ ### `IpcSocketProvider`
222
+
223
+ IPC JSON-RPC provider using Node’s `net`.
224
+
225
+ - `new IpcSocketProvider(path: string)`
226
+ - Windows example: `\\\\.\\pipe\\geth.ipc`
227
+
228
+ **Test(s):**
229
+ - `test/integration/ipc-provider.test.js`
230
+
231
+ ### `BrowserProvider`
232
+
233
+ EIP-1193 wrapper provider (for injected browser wallets).
234
+
235
+ - `new BrowserProvider(eip1193Provider: { request: Function }, network?: any, options?: BrowserProviderOptions)`
236
+ - `providerInfo` is supported as an option (compat)
237
+
238
+ **Core methods**
239
+ - `send(method: string, params?: any[] | object): Promise<any>`
240
+ - `_send(payloadOrArray): Promise<any>` (compat)
241
+ - `_perform(method: string, params?: any[]): Promise<any>` (delegates to `send`)
242
+ - `getRpcError(payload, error): Error`
243
+ - `getSigner(addressOrIndex?: string | number): Promise<JsonRpcSigner>`
244
+ - `hasSigner(addressOrIndex: string | number): Promise<boolean>`
245
+
246
+ **Debug event sink**
247
+ - Emits `"debug"` events:
248
+ - `{ action: "sendEip1193Payload", payload: { method, params } }`
249
+ - `{ action: "receiveEip1193Result", result }`
250
+ - `{ action: "receiveEip1193Error", error }`
251
+
252
+ **Test(s):**
253
+ - `test/unit/browser-provider.test.js`
254
+
255
+ Reference: ethers BrowserProvider docs: [`https://docs.ethers.org/v6/api/providers/#BrowserProvider`](https://docs.ethers.org/v6/api/providers/#BrowserProvider)
256
+
257
+ ### `FallbackProvider`
258
+
259
+ Simple provider wrapper that tries multiple providers in order.
260
+
261
+ - `new FallbackProvider(providers: AbstractProvider | AbstractProvider[])`
262
+ - `_perform(method, params)` tries each provider until one succeeds
263
+
264
+ ### `FilterByBlockHash`
265
+
266
+ Helper for filters pinned to a specific block hash (ethers style).
267
+
268
+ - `new FilterByBlockHash(blockHash: string, address?: string | string[], topics?: (string|string[]|null)[])`
269
+ - `blockHash` must be **32-byte hex**
270
+ - `toJSON()` returns `{ blockHash, address, topics }`
271
+
272
+ **Test(s):**
273
+ - `test/unit/filter-by-blockhash.test.js`
274
+
275
+ Reference: ethers FilterByBlockHash docs: [`https://docs.ethers.org/v6/api/providers/#FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash)
276
+
277
+ ### `Block`
278
+
279
+ Wrapper returned by `provider.getBlock(...)`.
280
+
281
+ **Properties**
282
+ - `hash: string | null`
283
+ - `parentHash: string | null`
284
+ - `number: number | null`
285
+ - `timestamp: number | null`
286
+ - `transactions: any[]`
287
+ - `provider: AbstractProvider | null`
288
+
289
+ **Methods**
290
+ - `getTransaction(indexOrHash: number | string): Promise<TransactionResponse | null>`
291
+ - `getTransactionReceipt(indexOrHash: number | string): Promise<TransactionReceipt | null>`
292
+ - `getPrefetchedTransactions(): any[]` (currently returns `[]`)
293
+
294
+ ### `TransactionResponse`
295
+
296
+ Wrapper returned by `provider.sendTransaction(...)` and `provider.getTransaction(...)`.
297
+
298
+ **Properties (common)**
299
+ - `hash: string`
300
+ - `to: string | null`
301
+ - `from: string | null`
302
+ - `nonce: number | null`
303
+ - `data: string`
304
+ - `value: bigint`
305
+ - `gasLimit: bigint | null`
306
+ - `gasPrice: bigint | null`
307
+ - `chainId: number | null`
308
+ - `blockNumber: number | null`
309
+ - `provider: AbstractProvider | null`
310
+
311
+ **Methods**
312
+ - `wait(confirmations?: number | null, timeoutMs?: number | null): Promise<TransactionReceipt>`
313
+
314
+ ### `TransactionReceipt`
315
+
316
+ Wrapper returned by `provider.getTransactionReceipt(...)` and `tx.wait()`.
317
+
318
+ **Properties (common)**
319
+ - `to: string | null`
320
+ - `from: string | null`
321
+ - `contractAddress: string | null`
322
+ - `transactionHash: string`
323
+ - `blockHash: string`
324
+ - `blockNumber: number | null`
325
+ - `transactionIndex: number | null`
326
+ - `gasUsed: bigint | null`
327
+ - `status: number | null`
328
+ - `logs: Log[]`
329
+ - `provider: AbstractProvider | null`
330
+
331
+ ### `Log`
332
+
333
+ Wrapper returned by `provider.getLogs(...)`.
334
+
335
+ **Properties (common)**
336
+ - `address: string`
337
+ - `topics: string[]`
338
+ - `data: string`
339
+ - `blockHash: string | null`
340
+ - `blockNumber: number | null`
341
+ - `transactionHash: string | null`
342
+ - `transactionIndex: number | null`
343
+ - `logIndex: number | null`
344
+ - `removed: boolean`
345
+ - `provider: AbstractProvider | null`
346
+
347
+ **Methods**
348
+ - `getBlock(): Promise<Block | null>`
349
+ - `getTransaction(): Promise<TransactionResponse | null>`
350
+ - `getTransactionReceipt(): Promise<TransactionReceipt | null>`
351
+
352
+ ## Wallets & Signers
353
+
354
+ ### `SigningKey`
355
+
356
+ - `new SigningKey(privateKeyBytes: Uint8Array, publicKeyBytes: Uint8Array)`
357
+
358
+ ### `AbstractSigner`
359
+
360
+ - `new AbstractSigner(provider?: AbstractProvider | null)`
361
+ - `provider: AbstractProvider | null`
362
+ - `getAddress(): Promise<string>` (base throws; implemented by subclasses)
363
+
364
+ ### `BaseWallet`
365
+
366
+ Core signing implementation.
367
+
368
+ - `new BaseWallet(signingKey: SigningKey, provider?: AbstractProvider | null, precomputed?: { address: string }, qcWallet?: any)`
369
+
370
+ **Properties**
371
+ - `address: string`
372
+ - `privateKey: string` (getter; hex string)
373
+ - `provider: AbstractProvider | null`
374
+
375
+ **Methods**
376
+ - `getAddress(): Promise<string>`
377
+ - `signMessageSync(message: string | Uint8Array): string`
378
+ - `signTransaction(tx: TransactionRequest): Promise<string>`
379
+ - `sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>`
380
+
381
+ ### `Wallet`
382
+
383
+ User-facing wallet class.
384
+
385
+ - `new Wallet(privateKeyOrBytesOrSigningKey, provider?: AbstractProvider)`
386
+
387
+ **Static methods**
388
+ - `Wallet.createRandom(provider?: AbstractProvider): Wallet`
389
+ - `Wallet.fromEncryptedJsonSync(json: string, password: string, provider?: AbstractProvider): Wallet`
390
+ - `Wallet.fromPhrase(phrase: string | string[], provider?: AbstractProvider): Wallet`
391
+
392
+ **Instance methods**
393
+ - `getAddress(): string`
394
+ - `getBalance(blockTag?: string): Promise<bigint>`
395
+ - `getTransactionCount(blockTag?: string): Promise<number>`
396
+ - `encryptSync(password: string | Uint8Array): string`
397
+ - `connect(provider: AbstractProvider): Wallet`
398
+
399
+ **Example(s):**
400
+ - `examples/wallet-offline.js`
401
+
402
+ ### `NonceManager`
403
+
404
+ Signer wrapper to manage nonces.
405
+
406
+ - `new NonceManager(signer: AbstractSigner)`
407
+
408
+ **Methods**
409
+ - `getAddress(): Promise<string>`
410
+ - `getTransactionCount(blockTag?: string): Promise<number>`
411
+ - `sendTransaction(tx: TransactionRequest): Promise<any>`
412
+ - `reset(): void`
413
+ - `increment(): void`
414
+
415
+ ### `JsonRpcSigner`
416
+
417
+ Lightweight signer placeholder used by `BrowserProvider.getSigner(...)`.
418
+
419
+ - `new JsonRpcSigner(provider, address)`
420
+ - `getAddress(): Promise<string>`
421
+
422
+ ### `VoidSigner`
423
+
424
+ Address-only signer.
425
+
426
+ - `new VoidSigner(address: string, provider?: AbstractProvider)`
427
+ - `getAddress(): Promise<string>`
428
+
429
+ ## Contracts
430
+
431
+ ### `Contract`
432
+
433
+ Dynamic contract wrapper (ethers-like).
434
+
435
+ - `new Contract(address: string, abi: any[] | Interface, runner?: AbstractProvider | Wallet, bytecode?: string)`
436
+
437
+ **Properties**
438
+ - `address: string`
439
+ - `target: string` (alias of address)
440
+ - `interface: Interface`
441
+ - `provider: AbstractProvider | null`
442
+ - `signer: any | null`
443
+
444
+ **Call / send**
445
+ - `call(methodName: string, args: any[], overrides?: TransactionRequest): Promise<any>`
446
+ - `send(methodName: string, args: any[], overrides?: TransactionRequest): Promise<ContractTransactionResponse>`
447
+
448
+ **Logs / events**
449
+ - `queryFilter(eventName: string, fromBlock?: number|string, toBlock?: number|string): Promise<EventLog[]>`
450
+ - `on(eventName: string, callback: Function): this`
451
+ - `once(eventName: string, callback: Function): this`
452
+ - `removeListener(eventName: string, callback: Function): this`
453
+ - `removeAllListeners(eventName?: string): this`
454
+
455
+ **Deployment helpers**
456
+ - `deployTransaction(): any | null`
457
+ - `waitForDeployment(): Promise<this>`
458
+ - `getDeployedCode(): Promise<string | null>`
459
+
460
+ **Example(s):**
461
+ - `examples/read-operations.js`
462
+ - `examples/events.js`
463
+
464
+ ### `ContractFactory`
465
+
466
+ Deployment helper.
467
+
468
+ - `new ContractFactory(abi: any[] | Interface, bytecode: string, signer: any)`
469
+
470
+ **Methods**
471
+ - `getDeployTransaction(...args: any[]): TransactionRequest`
472
+ - `deploy(...args: any[]): Promise<Contract>`
473
+ - `attach(address: string): Contract`
474
+ - `connect(signer: any): ContractFactory`
475
+
476
+ ### `ContractTransactionResponse`
477
+
478
+ Wrapper around an underlying `TransactionResponse`.
479
+
480
+ - `wait(confirmations?: number, timeoutMs?: number): Promise<any>`
481
+ - `getTransaction(): any`
482
+
483
+ ### `ContractTransactionReceipt`
484
+
485
+ Wrapper around a receipt with convenience filters.
486
+
487
+ - `getEvent(eventName: string): any | null`
488
+ - `getEvents(eventName: string): any[]`
489
+
490
+ ### `EventLog`
491
+
492
+ Lightweight log wrapper returned by `Contract.queryFilter(...)`.
493
+
494
+ ## ABI
495
+
496
+ ### Fragments (`Fragment`, `FunctionFragment`, ...)
497
+
498
+ Exported fragment types:
499
+ - `Fragment`
500
+ - `NamedFragment`
501
+ - `FunctionFragment`
502
+ - `EventFragment`
503
+ - `ErrorFragment`
504
+ - `ConstructorFragment`
505
+ - `StructFragment`
506
+ - `FallbackFragment`
507
+
508
+ All fragments support:
509
+ - `format(format?: string | null): string`
510
+ - `toJSON(): any`
511
+
512
+ ### `Interface`
513
+
514
+ ABI encoding/decoding compatibility layer.
515
+
516
+ - `new Interface(abi: any[] | Interface | null)`
517
+
518
+ **Methods**
519
+ - `formatJson(): string`
520
+ - `format(format?: string | null): string`
521
+ - `getFunction(name: string): FunctionFragment`
522
+ - `getEvent(name: string): EventFragment`
523
+ - `getError(name: string): ErrorFragment`
524
+ - `getConstructor(): ConstructorFragment | null`
525
+
526
+ **Encoding**
527
+ - `encodeFunctionData(functionFragmentOrName, values?: any[] | null): string`
528
+ - `decodeFunctionResult(functionFragmentOrName, data: string): any`
529
+ - `encodeEventLog(eventFragmentOrName, values?: any[] | null): { topics: string[], data: string }`
530
+ - `decodeEventLog(eventFragmentOrName, topics: string[], data: string): any`
531
+
532
+ **Parsing**
533
+ - `parseLog(log: { topics: string[], data: string }): { fragment, name, signature, topic, args }`
534
+ - Uses signature topic matching and `decodeEventLog(...)`
535
+
536
+ ### `AbiCoder`
537
+
538
+ Minimal ABI coder for encoding/decoding tuples of values.
539
+
540
+ - `encode(types: (string|any)[], values: any[]): string`
541
+ - `decode(types: (string|any)[], data: string): any`
542
+ - `getDefaultValue(types: (string|any)[]): any`
543
+
544
+ ## Utilities
545
+
546
+ ### Address utilities
547
+
548
+ From `quantumcoin`:
549
+
550
+ - `isAddress(address: string): boolean`
551
+ - `getAddress(address: string): string`
552
+ - `isAddressable(value: any): boolean`
553
+ - `resolveAddress(target: any): string | Promise<string>`
554
+ - `getContractAddress({ from, nonce }): string`
555
+ - `getCreateAddress({ from, nonce }): string`
556
+ - `getCreate2Address(from: string, salt: string, initCodeHash: string): string`
557
+ - `computeAddress(publicKey: string|Uint8Array): string`
558
+ - `verifyMessage(message: string|Uint8Array, signature: string): string`
559
+ - `recoverAddress(message: string|Uint8Array, signature: string): string`
560
+
561
+ **Example(s):**
562
+ - `examples/wallet-offline.js`
563
+
564
+ ## Solidity Types (TypeScript)
565
+
566
+ QuantumCoin.js exposes core Solidity-related types for TypeScript users.
567
+
568
+ - **Import path**: `quantumcoin/types`
569
+
570
+ **Key exports**
571
+
572
+ - `AddressLike` (currently `string`, 32-byte address)
573
+ - `BytesLike` (`string | Uint8Array`)
574
+ - `BigNumberish` (`string | number | bigint`)
575
+ - `SolidityTypeName` (ABI type string model)
576
+ - **Hard Solidity aliases** (preferred for typed wrappers):
577
+ - Integers: `Uint256Like` / `Uint256`, `Int256Like` / `Int256` (and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`)
578
+ - Fixed bytes: `Bytes32Like` / `Bytes32` (and `Bytes1Like`…`Bytes32Like`)
579
+ - Arrays/tuples helpers: `SolArray<T>`, `SolFixedArray<T, N>`, `SolStruct<T>`
580
+ - `SolidityInputValue<T>` / `SolidityOutputValue<T>` (advanced type-level mapping from ABI type strings to JS values; the generator no longer uses these for wrapper signatures)
581
+
582
+ Example:
583
+
584
+ ```ts
585
+ import type { AddressLike, BigNumberish, Uint256Like, Uint256 } from "quantumcoin/types";
586
+
587
+ const to: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
588
+ const amount: BigNumberish = "123";
589
+ const asInput: Uint256Like = amount;
590
+ const asOutput: Uint256 = 123n;
591
+ ```
592
+
593
+ ### Encoding utilities
594
+
595
+ - `toUtf8String(data: BytesLike): string`
596
+ - `toUtf8Bytes(str: string): Uint8Array`
597
+ - `toHex(data: BytesLike): string`
598
+ - `hexlify(data: BytesLike): string`
599
+ - `arrayify(data: BytesLike): Uint8Array`
600
+ - `isBytesLike(value: any): boolean`
601
+ - `concat(items: BytesLike[]): string`
602
+ - `stripZerosLeft(data: BytesLike): string`
603
+ - `zeroPad(value: BytesLike, length: number): string`
604
+ - `zeroPadValue(value: BytesLike, length: number): string`
605
+ - `encodeBytes32String(text: string): string`
606
+ - `decodeBytes32String(bytes: BytesLike): string`
607
+ - `encodeBase64(data: BytesLike): string`
608
+ - `decodeBase64(data: string): Uint8Array`
609
+ - `encodeBase58(data: BytesLike): string`
610
+ - `decodeBase58(data: string): Uint8Array`
611
+ - `toUtf8CodePoints(str: string): number[]`
612
+ - `solidityPacked(...)` (**throws; not implemented**)
613
+ - `solidityPackedKeccak256(...)` (**throws; not implemented**)
614
+ - `solidityPackedSha256(...)` (**throws; not implemented**)
615
+
616
+ ### Hashing utilities
617
+
618
+ - `keccak256(data: BytesLike): string`
619
+ - `sha256(data: BytesLike): string`
620
+ - `sha512(data: BytesLike): string`
621
+ - `ripemd160(data: BytesLike): string`
622
+ - `id(text: string): string` (=`keccak256(utf8Bytes(text))`)
623
+ - `randomBytes(length: number): Uint8Array`
624
+ - `computeHmac(algorithm: string, key: BytesLike, data: BytesLike): string`
625
+ - `pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, algorithm?: string): string`
626
+ - `scrypt(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): Promise<string>`
627
+ - `scryptSync(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): string`
628
+
629
+ ### Units
630
+
631
+ - `formatUnits(value: BigNumberish, decimals?: number): string`
632
+ - `parseUnits(value: string, decimals?: number): bigint`
633
+ - `formatEther(value: BigNumberish): string`
634
+ - `parseEther(value: string): bigint`
635
+
636
+ ### RLP
637
+
638
+ - `encodeRlp(value: any): string`
639
+ - `decodeRlp(data: string): any`
640
+
641
+ ### `Result` and `checkResultErrors`
642
+
643
+ - `class Result extends Array`
644
+ - `new Result(items?: any[], keys?: (null|string)[])`
645
+ - `Result.fromItems(items: any[], keys?: (null|string)[]): Result`
646
+ - `getValue(name: string): any`
647
+ - `toArray(deep?: boolean | null): any[]`
648
+ - `toObject(deep?: boolean | null): Record<string, any>`
649
+ - `checkResultErrors(result: any): Array<{ error: Error, path: (string|number)[] }>`
650
+
651
+ ## Typed SDK Generator (`generate-sdk.js`)
652
+
653
+ ### Overview
654
+
655
+ `generate-sdk.js` creates **typed contract wrappers** for one or more contracts, and can optionally scaffold a complete npm package (with examples and transactional tests).
656
+
657
+ It supports generating:
658
+ - **TypeScript source** (`--lang ts`, default)
659
+ - **JavaScript source + TypeScript declarations** (`--lang js`)
660
+
661
+ **Typing behaviour (generated wrappers)**
662
+
663
+ - **Hard types**: wrapper signatures use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
664
+ - **Single output unwrapping**: functions returning one value return the value directly (not `[value]`).
665
+ - **Multiple outputs**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
666
+ - **No outputs**: `Promise<void>`.
667
+ - **Structs / tuples**: emitted as `export type <Name>Input` / `export type <Name>Output` and used in signatures.
668
+ - **JS typing**: JS output uses JSDoc types plus `.d.ts` files; TS users still get strong types.
669
+
670
+ **Entry point**
671
+ - `node generate-sdk.js ...`
672
+ - or `npx sdkgen ...` (when installed)
673
+
674
+ ### Input modes
675
+
676
+ 1) **ABI + BIN**
677
+
678
+ ```bash
679
+ node generate-sdk.js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
680
+
681
+ # JS output
682
+ node generate-sdk.js --lang js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
683
+ ```
684
+
685
+ 2) **Solidity sources**
686
+
687
+ ```bash
688
+ node generate-sdk.js --sol ".\\contracts\\A.sol,.\\contracts\\B.sol" --solc "c:\\solc\\solc.exe" --out ./out --non-interactive
689
+
690
+ # Pass additional solc args (example)
691
+ node generate-sdk.js --sol ".\\contracts\\A.sol" --solc "c:\\solc\\solc.exe" --solc-args "--via-ir --evm-version london" --out ./out --non-interactive
692
+ ```
693
+
694
+ 3) **Artifacts JSON (multi-contract ABI+BIN list)**
695
+
696
+ ```bash
697
+ node generate-sdk.js --artifacts-json .\\artifacts.json --out .\\out --non-interactive
698
+ ```
699
+
700
+ Example `artifacts.json`:
701
+
702
+ ```json
703
+ [
704
+ { "abi": "./Alpha.abi.json", "bin": "./Alpha.bin" },
705
+ { "abi": "./Beta.abi.json", "bin": "./Beta.bin", "name": "Beta" },
706
+ {
707
+ "name": "Gamma",
708
+ "abi": "[{\"type\":\"function\",\"name\":\"set\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"outputs\":[]}]",
709
+ "bin": "0x6000600055..."
710
+ }
711
+ ]
712
+ ```
713
+
714
+ ### Package scaffolding mode
715
+
716
+ Use `--create-package` to create a full npm package (source, tests, examples, README).
717
+
718
+ ```bash
719
+ node generate-sdk.js --artifacts-json .\\artifacts.json ^
720
+ --lang ts ^
721
+ --create-package --package-dir .\\tmp --package-name my-typed-package ^
722
+ --package-description "My typed package" --package-author "me" ^
723
+ --package-license MIT --package-version 0.0.1 ^
724
+ --non-interactive
725
+ ```
726
+
727
+ ### Generated package layout
728
+
729
+ When `--create-package` is used, the generator produces:
730
+
731
+ - `src/` contract wrappers + factories
732
+ - TS mode: `*.ts` (compiled output in `dist/` after `npm run build:ts`)
733
+ - JS mode: `*.js` with `*.d.ts` types (no build step required)
734
+ - `test/e2e/*.e2e.test.js` per-contract transactional tests
735
+ - `examples/` deploy/read/write/events scripts
736
+ - `README.md` generated by the generator (includes ABI-derived API overview)
737
+ - `index.js` + `index.d.ts` (package entry shims)
738
+
739
+ ### Running generated transactional tests
740
+
741
+ Generated package tests broadcast transactions and require:
742
+
743
+ - `QC_RPC_URL` (RPC endpoint)
744
+ - `QC_CHAIN_ID` (optional, default `123123`)
745
+
746
+ ### Generator tests
747
+
748
+ - Unit tests:
749
+ - `test/unit/generate-contract-cli.test.js`
750
+ - `test/unit/generator.test.js`
751
+ - `test/unit/generate-sdk-artifacts-json.test.js`
752
+ - E2E generator tests (transactional; require `QC_RPC_URL` and optionally `QC_CHAIN_ID`):
753
+ - `test/e2e/typed-generator.e2e.test.js`
754
+ - `test/e2e/simple-erc20.generated-sdks.e2e.test.js`
755
+ - `test/e2e/all-solidity-types.generated-sdks.e2e.test.js`
756
+