quantum-coin-js-sdk 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +13 -0
  2. package/index.d.ts +9 -0
  3. package/index.js +37 -4
  4. package/package.json +12 -4
  5. package/wasmBase64.js +3 -2
  6. package/.idea/.name +0 -1
  7. package/.idea/modules.xml +0 -8
  8. package/.idea/quantum-coin-js-sdk.iml +0 -12
  9. package/.idea/vcs.xml +0 -6
  10. package/.vs/ProjectSettings.json +0 -3
  11. package/.vs/VSWorkspaceState.json +0 -8
  12. package/.vs/quantum-coin-js-sdk/FileContentIndex/a9d6de82-cfc3-4c22-ac38-06d706ff3673.vsidx +0 -0
  13. package/.vs/quantum-coin-js-sdk/FileContentIndex/fdc816df-1898-4153-99f2-c69ef4c2283b.vsidx +0 -0
  14. package/.vs/quantum-coin-js-sdk/config/applicationhost.config +0 -1011
  15. package/.vs/quantum-coin-js-sdk/v17/.wsuo +0 -0
  16. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.backup.json +0 -39
  17. package/.vs/quantum-coin-js-sdk/v17/DocumentLayout.json +0 -57
  18. package/.vs/slnx.sqlite +0 -0
  19. package/example/README.md +0 -14
  20. package/example/conversion-example.js +0 -19
  21. package/example/example-create-contract.js +0 -396
  22. package/example/example-encode-decode-rlp.js +0 -225
  23. package/example/example-event-pack-unpack.js +0 -391
  24. package/example/example-misc.js +0 -96
  25. package/example/example-token-pack-unpack.js +0 -960
  26. package/example/example-wallet-version4.js +0 -34
  27. package/example/example-wallet.js +0 -39
  28. package/example/example.js +0 -115
  29. package/example/node_modules/.bin/sdkgen +0 -16
  30. package/example/node_modules/.bin/sdkgen.cmd +0 -17
  31. package/example/node_modules/.bin/sdkgen.ps1 +0 -28
  32. package/example/node_modules/.package-lock.json +0 -51
  33. package/example/node_modules/quantumcoin/.github/workflows/publish-npmjs.yaml +0 -22
  34. package/example/node_modules/quantumcoin/LICENSE +0 -21
  35. package/example/node_modules/quantumcoin/README-SDK.md +0 -828
  36. package/example/node_modules/quantumcoin/README.md +0 -197
  37. package/example/node_modules/quantumcoin/config.d.ts +0 -50
  38. package/example/node_modules/quantumcoin/config.js +0 -123
  39. package/example/node_modules/quantumcoin/examples/AllSolidityTypes.sol +0 -184
  40. package/example/node_modules/quantumcoin/examples/SimpleIERC20.sol +0 -74
  41. package/example/node_modules/quantumcoin/examples/events.js +0 -41
  42. package/example/node_modules/quantumcoin/examples/events.ts +0 -35
  43. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.js +0 -100
  44. package/example/node_modules/quantumcoin/examples/example-generator-sdk-js.ts +0 -77
  45. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.js +0 -100
  46. package/example/node_modules/quantumcoin/examples/example-generator-sdk-ts.ts +0 -77
  47. package/example/node_modules/quantumcoin/examples/example.js +0 -67
  48. package/example/node_modules/quantumcoin/examples/example.ts +0 -56
  49. package/example/node_modules/quantumcoin/examples/offline-signing.js +0 -77
  50. package/example/node_modules/quantumcoin/examples/offline-signing.ts +0 -65
  51. package/example/node_modules/quantumcoin/examples/package-lock.json +0 -596
  52. package/example/node_modules/quantumcoin/examples/package.json +0 -32
  53. package/example/node_modules/quantumcoin/examples/read-operations.js +0 -32
  54. package/example/node_modules/quantumcoin/examples/read-operations.ts +0 -31
  55. package/example/node_modules/quantumcoin/examples/sdk-generator-erc20.inline.json +0 -251
  56. package/example/node_modules/quantumcoin/examples/solidity-types.ts +0 -43
  57. package/example/node_modules/quantumcoin/examples/wallet-offline.js +0 -36
  58. package/example/node_modules/quantumcoin/examples/wallet-offline.ts +0 -26
  59. package/example/node_modules/quantumcoin/generate-sdk.js +0 -1846
  60. package/example/node_modules/quantumcoin/index.js +0 -12
  61. package/example/node_modules/quantumcoin/package.json +0 -95
  62. package/example/node_modules/quantumcoin/scripts/copy-declarations.js +0 -31
  63. package/example/node_modules/quantumcoin/scripts/run-all-one-by-one.js +0 -151
  64. package/example/node_modules/quantumcoin/src/abi/fragments.d.ts +0 -42
  65. package/example/node_modules/quantumcoin/src/abi/fragments.js +0 -63
  66. package/example/node_modules/quantumcoin/src/abi/index.d.ts +0 -13
  67. package/example/node_modules/quantumcoin/src/abi/index.js +0 -9
  68. package/example/node_modules/quantumcoin/src/abi/interface.d.ts +0 -128
  69. package/example/node_modules/quantumcoin/src/abi/interface.js +0 -605
  70. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.d.ts +0 -8
  71. package/example/node_modules/quantumcoin/src/abi/js-abi-coder.js +0 -538
  72. package/example/node_modules/quantumcoin/src/constants.d.ts +0 -61
  73. package/example/node_modules/quantumcoin/src/constants.js +0 -94
  74. package/example/node_modules/quantumcoin/src/contract/contract-factory.d.ts +0 -28
  75. package/example/node_modules/quantumcoin/src/contract/contract-factory.js +0 -111
  76. package/example/node_modules/quantumcoin/src/contract/contract.d.ts +0 -113
  77. package/example/node_modules/quantumcoin/src/contract/contract.js +0 -408
  78. package/example/node_modules/quantumcoin/src/contract/index.d.ts +0 -9
  79. package/example/node_modules/quantumcoin/src/contract/index.js +0 -9
  80. package/example/node_modules/quantumcoin/src/errors/index.d.ts +0 -92
  81. package/example/node_modules/quantumcoin/src/errors/index.js +0 -200
  82. package/example/node_modules/quantumcoin/src/generator/index.d.ts +0 -81
  83. package/example/node_modules/quantumcoin/src/generator/index.js +0 -1571
  84. package/example/node_modules/quantumcoin/src/index.d.ts +0 -122
  85. package/example/node_modules/quantumcoin/src/index.js +0 -41
  86. package/example/node_modules/quantumcoin/src/internal/hex.d.ts +0 -68
  87. package/example/node_modules/quantumcoin/src/internal/hex.js +0 -180
  88. package/example/node_modules/quantumcoin/src/providers/extra-providers.d.ts +0 -139
  89. package/example/node_modules/quantumcoin/src/providers/extra-providers.js +0 -614
  90. package/example/node_modules/quantumcoin/src/providers/index.d.ts +0 -17
  91. package/example/node_modules/quantumcoin/src/providers/index.js +0 -10
  92. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.d.ts +0 -12
  93. package/example/node_modules/quantumcoin/src/providers/json-rpc-provider.js +0 -89
  94. package/example/node_modules/quantumcoin/src/providers/provider.d.ts +0 -206
  95. package/example/node_modules/quantumcoin/src/providers/provider.js +0 -524
  96. package/example/node_modules/quantumcoin/src/types/index.d.ts +0 -214
  97. package/example/node_modules/quantumcoin/src/types/index.js +0 -9
  98. package/example/node_modules/quantumcoin/src/utils/address.d.ts +0 -58
  99. package/example/node_modules/quantumcoin/src/utils/address.js +0 -144
  100. package/example/node_modules/quantumcoin/src/utils/encoding.d.ts +0 -120
  101. package/example/node_modules/quantumcoin/src/utils/encoding.js +0 -306
  102. package/example/node_modules/quantumcoin/src/utils/fixednumber.d.ts +0 -57
  103. package/example/node_modules/quantumcoin/src/utils/fixednumber.js +0 -366
  104. package/example/node_modules/quantumcoin/src/utils/hashing.d.ts +0 -76
  105. package/example/node_modules/quantumcoin/src/utils/hashing.js +0 -298
  106. package/example/node_modules/quantumcoin/src/utils/index.d.ts +0 -63
  107. package/example/node_modules/quantumcoin/src/utils/index.js +0 -14
  108. package/example/node_modules/quantumcoin/src/utils/result.d.ts +0 -57
  109. package/example/node_modules/quantumcoin/src/utils/result.js +0 -128
  110. package/example/node_modules/quantumcoin/src/utils/rlp.d.ts +0 -12
  111. package/example/node_modules/quantumcoin/src/utils/rlp.js +0 -215
  112. package/example/node_modules/quantumcoin/src/utils/units.d.ts +0 -29
  113. package/example/node_modules/quantumcoin/src/utils/units.js +0 -107
  114. package/example/node_modules/quantumcoin/src/wallet/index.d.ts +0 -10
  115. package/example/node_modules/quantumcoin/src/wallet/index.js +0 -8
  116. package/example/node_modules/quantumcoin/src/wallet/wallet.d.ts +0 -192
  117. package/example/node_modules/quantumcoin/src/wallet/wallet.js +0 -713
  118. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.js +0 -207
  119. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.dynamic.test.ts +0 -191
  120. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.fixtures.js +0 -231
  121. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.js +0 -387
  122. package/example/node_modules/quantumcoin/test/e2e/all-solidity-types.generated-sdks.e2e.test.ts +0 -350
  123. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.js +0 -165
  124. package/example/node_modules/quantumcoin/test/e2e/generator-interface.e2e.test.ts +0 -160
  125. package/example/node_modules/quantumcoin/test/e2e/helpers.js +0 -59
  126. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.js +0 -141
  127. package/example/node_modules/quantumcoin/test/e2e/signing-context-and-fee.e2e.test.ts +0 -128
  128. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.js +0 -168
  129. package/example/node_modules/quantumcoin/test/e2e/simple-erc20.generated-sdks.e2e.test.ts +0 -141
  130. package/example/node_modules/quantumcoin/test/e2e/transactional.test.js +0 -245
  131. package/example/node_modules/quantumcoin/test/e2e/transactional.test.ts +0 -208
  132. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.js +0 -407
  133. package/example/node_modules/quantumcoin/test/e2e/typed-generator.e2e.test.ts +0 -337
  134. package/example/node_modules/quantumcoin/test/fixtures/ConstructorParam.sol +0 -23
  135. package/example/node_modules/quantumcoin/test/fixtures/MultiContracts.sol +0 -37
  136. package/example/node_modules/quantumcoin/test/fixtures/SimpleStorage.sol +0 -18
  137. package/example/node_modules/quantumcoin/test/fixtures/StakingContract.abi.json +0 -1
  138. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.js +0 -49
  139. package/example/node_modules/quantumcoin/test/integration/ipc-provider.test.ts +0 -44
  140. package/example/node_modules/quantumcoin/test/integration/provider.test.js +0 -88
  141. package/example/node_modules/quantumcoin/test/integration/provider.test.ts +0 -85
  142. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.js +0 -41
  143. package/example/node_modules/quantumcoin/test/integration/ws-provider.test.ts +0 -38
  144. package/example/node_modules/quantumcoin/test/security/abi-decoder-bounds.test.js +0 -122
  145. package/example/node_modules/quantumcoin/test/security/contract-overrides.test.js +0 -112
  146. package/example/node_modules/quantumcoin/test/security/generator-injection.test.js +0 -195
  147. package/example/node_modules/quantumcoin/test/security/malformed-input.test.js +0 -330
  148. package/example/node_modules/quantumcoin/test/security/malformed-input.test.ts +0 -35
  149. package/example/node_modules/quantumcoin/test/security/rpc-numeric-bounds.test.js +0 -81
  150. package/example/node_modules/quantumcoin/test/security/rpc-trust.test.js +0 -202
  151. package/example/node_modules/quantumcoin/test/unit/_encrypted-output.txt +0 -6
  152. package/example/node_modules/quantumcoin/test/unit/_log-encrypted-jsons.js +0 -45
  153. package/example/node_modules/quantumcoin/test/unit/_write-keystore-fixture.js +0 -16
  154. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.js +0 -110
  155. package/example/node_modules/quantumcoin/test/unit/abi-interface.test.ts +0 -109
  156. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.js +0 -923
  157. package/example/node_modules/quantumcoin/test/unit/address-wallet.test.ts +0 -877
  158. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.js +0 -85
  159. package/example/node_modules/quantumcoin/test/unit/browser-provider.test.ts +0 -79
  160. package/example/node_modules/quantumcoin/test/unit/contract.test.js +0 -85
  161. package/example/node_modules/quantumcoin/test/unit/contract.test.ts +0 -83
  162. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.js +0 -127
  163. package/example/node_modules/quantumcoin/test/unit/encoding-units-rlp.test.ts +0 -91
  164. package/example/node_modules/quantumcoin/test/unit/errors.test.js +0 -77
  165. package/example/node_modules/quantumcoin/test/unit/errors.test.ts +0 -76
  166. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.js +0 -55
  167. package/example/node_modules/quantumcoin/test/unit/filter-by-blockhash.test.ts +0 -54
  168. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.js +0 -656
  169. package/example/node_modules/quantumcoin/test/unit/fixednumber.test.ts +0 -660
  170. package/example/node_modules/quantumcoin/test/unit/fixtures/encrypted-keystores-48-32-36.js +0 -9
  171. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.js +0 -42
  172. package/example/node_modules/quantumcoin/test/unit/generate-contract-cli.test.ts +0 -41
  173. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.js +0 -113
  174. package/example/node_modules/quantumcoin/test/unit/generate-sdk-artifacts-json.test.ts +0 -110
  175. package/example/node_modules/quantumcoin/test/unit/generator.test.js +0 -149
  176. package/example/node_modules/quantumcoin/test/unit/generator.test.ts +0 -148
  177. package/example/node_modules/quantumcoin/test/unit/hashing.test.js +0 -64
  178. package/example/node_modules/quantumcoin/test/unit/hashing.test.ts +0 -63
  179. package/example/node_modules/quantumcoin/test/unit/init.test.js +0 -39
  180. package/example/node_modules/quantumcoin/test/unit/init.test.ts +0 -38
  181. package/example/node_modules/quantumcoin/test/unit/interface.test.js +0 -56
  182. package/example/node_modules/quantumcoin/test/unit/interface.test.ts +0 -54
  183. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.js +0 -81
  184. package/example/node_modules/quantumcoin/test/unit/internal-hex.test.ts +0 -80
  185. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.js +0 -98
  186. package/example/node_modules/quantumcoin/test/unit/populate-transaction.test.ts +0 -64
  187. package/example/node_modules/quantumcoin/test/unit/providers.test.js +0 -252
  188. package/example/node_modules/quantumcoin/test/unit/providers.test.ts +0 -251
  189. package/example/node_modules/quantumcoin/test/unit/result.test.js +0 -80
  190. package/example/node_modules/quantumcoin/test/unit/result.test.ts +0 -79
  191. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.js +0 -49
  192. package/example/node_modules/quantumcoin/test/unit/solidity-types.test.ts +0 -39
  193. package/example/node_modules/quantumcoin/test/unit/utils.test.js +0 -57
  194. package/example/node_modules/quantumcoin/test/unit/utils.test.ts +0 -56
  195. package/example/node_modules/quantumcoin/test/verbose-logger.js +0 -74
  196. package/example/node_modules/quantumcoin/tsconfig.build.json +0 -14
  197. package/example/node_modules/seed-words/.github/workflows/publish-npmjs.yaml +0 -22
  198. package/example/node_modules/seed-words/BUILD.md +0 -7
  199. package/example/node_modules/seed-words/LICENSE +0 -121
  200. package/example/node_modules/seed-words/README.md +0 -67
  201. package/example/node_modules/seed-words/dist/seedwords.d.ts +0 -39
  202. package/example/node_modules/seed-words/package.json +0 -27
  203. package/example/node_modules/seed-words/seedwords.js +0 -315
  204. package/example/node_modules/seed-words/seedwords.txt +0 -65536
  205. package/example/node_modules/seed-words/tsconfig.json +0 -21
  206. package/example/package-lock.json +0 -60
  207. package/example/package.json +0 -15
  208. package/scripts/build-browser-tests.js +0 -29
  209. package/scripts/build-wasm.js +0 -85
  210. package/tests/browser/bundle.js +0 -97643
  211. package/tests/browser/entry.js +0 -57
  212. package/tests/browser/harness.html +0 -20
  213. package/tests/browser/run-browser.js +0 -50
  214. package/tests/encrypted-32.json +0 -1
  215. package/tests/encrypted-36.json +0 -1
  216. package/tests/encrypted-48.json +0 -1
  217. package/tests/generate-verify-vectors.js +0 -88
  218. package/tests/get-gas-price.test.js +0 -59
  219. package/tests/hashing.test.js +0 -34
  220. package/tests/non-transactional.preinit.test.js +0 -33
  221. package/tests/non-transactional.test.js +0 -1318
  222. package/tests/sign-raw-keytype5-context-null.test.js +0 -105
  223. package/tests/sign-raw-transaction.test.js +0 -194
  224. package/tests/sign-verify.test.js +0 -308
  225. package/tests/specs/assert.js +0 -74
  226. package/tests/specs/crypto.spec.js +0 -104
  227. package/tests/specs/hex.js +0 -31
  228. package/tests/specs/preinit.spec.js +0 -19
  229. package/tests/specs/sign.spec.js +0 -90
  230. package/tests/specs/wallet.spec.js +0 -98
  231. package/tests/transactional.rpc.test.js +0 -102
  232. package/tests/verify-vectors.json +0 -95035
@@ -1,828 +0,0 @@
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
- > **JSON-RPC QUANTITY formatting:** numeric block-tag arguments to `getBlock(n)` and `getLogs({ fromBlock: n, toBlock: n })` are encoded as spec-compliant QUANTITY hex strings — no leading zeros, with `0` encoded as `"0x0"`. This matches the [Ethereum JSON-RPC convention](https://ethereum.org/en/developers/docs/apis/json-rpc/#conventions) (e.g. `getBlock(5)` sends `"0x5"`, not `"0x05"`), so requests to spec-compliant nodes succeed for block numbers in `[1..15]`, `[256..4095]`, etc. The internal helper used is [`toQuantityHex`](./src/internal/hex.js) (aliased as `toQuantity`), which is the QuantumCoin.js equivalent of ethers.js v6 `toQuantity`. Use `normalizeHex` for **DATA** hex (addresses, bytecode, byte-arrays); use `toQuantityHex` for **QUANTITY** hex (block numbers, gas, nonces, balances).
192
-
193
- **Write operation**
194
- - `sendTransaction(tx: string | { raw: string }): Promise<TransactionResponse>`
195
- - QuantumCoin.js expects a **signed raw transaction hex string**.
196
-
197
- **Example(s):**
198
- - `examples/example.js`
199
- - `examples/read-operations.js`
200
- - `examples/events.js`
201
-
202
- ### `JsonRpcProvider` / `JsonRpcApiProvider`
203
-
204
- HTTP JSON-RPC provider.
205
-
206
- - `new JsonRpcProvider(url?: string, chainId?: number)`
207
- - If `url` is omitted, uses config default `rpcEndpoint`
208
- - If `chainId` is omitted, defaults to `123123`
209
-
210
- **Example(s):**
211
- - `examples/example.js`
212
-
213
- ### `WebSocketProvider`
214
-
215
- WebSocket JSON-RPC provider (no extra dependencies; uses Node’s global `WebSocket`).
216
-
217
- - `new WebSocketProvider(url: string, chainId?: number)`
218
- - `destroy(): void` (closes socket, rejects pending requests)
219
-
220
- **Test(s):**
221
- - `test/integration/ws-provider.test.js`
222
-
223
- ### `IpcSocketProvider`
224
-
225
- IPC JSON-RPC provider using Node’s `net`.
226
-
227
- - `new IpcSocketProvider(path: string)`
228
- - Windows example: `\\\\.\\pipe\\geth.ipc`
229
-
230
- **Test(s):**
231
- - `test/integration/ipc-provider.test.js`
232
-
233
- ### `BrowserProvider`
234
-
235
- EIP-1193 wrapper provider (for injected browser wallets).
236
-
237
- - `new BrowserProvider(eip1193Provider: { request: Function }, network?: any, options?: BrowserProviderOptions)`
238
- - `providerInfo` is supported as an option (compat)
239
-
240
- **Core methods**
241
- - `send(method: string, params?: any[] | object): Promise<any>`
242
- - `_send(payloadOrArray): Promise<any>` (compat)
243
- - `_perform(method: string, params?: any[]): Promise<any>` (delegates to `send`)
244
- - `getRpcError(payload, error): Error`
245
- - `getSigner(addressOrIndex?: string | number): Promise<JsonRpcSigner>`
246
- - `hasSigner(addressOrIndex: string | number): Promise<boolean>`
247
-
248
- **Debug event sink**
249
- - Emits `"debug"` events:
250
- - `{ action: "sendEip1193Payload", payload: { method, params } }`
251
- - `{ action: "receiveEip1193Result", result }`
252
- - `{ action: "receiveEip1193Error", error }`
253
-
254
- **Test(s):**
255
- - `test/unit/browser-provider.test.js`
256
-
257
- Reference: ethers BrowserProvider docs: [`https://docs.ethers.org/v6/api/providers/#BrowserProvider`](https://docs.ethers.org/v6/api/providers/#BrowserProvider)
258
-
259
- ### `FallbackProvider`
260
-
261
- Simple provider wrapper that tries multiple providers in order.
262
-
263
- - `new FallbackProvider(providers: AbstractProvider | AbstractProvider[])`
264
- - `_perform(method, params)` tries each provider until one succeeds
265
-
266
- ### `FilterByBlockHash`
267
-
268
- Helper for filters pinned to a specific block hash (ethers style).
269
-
270
- - `new FilterByBlockHash(blockHash: string, address?: string | string[], topics?: (string|string[]|null)[])`
271
- - `blockHash` must be **32-byte hex**
272
- - `toJSON()` returns `{ blockHash, address, topics }`
273
-
274
- **Test(s):**
275
- - `test/unit/filter-by-blockhash.test.js`
276
-
277
- Reference: ethers FilterByBlockHash docs: [`https://docs.ethers.org/v6/api/providers/#FilterByBlockHash`](https://docs.ethers.org/v6/api/providers/#FilterByBlockHash)
278
-
279
- ### `Block`
280
-
281
- Wrapper returned by `provider.getBlock(...)`.
282
-
283
- **Properties**
284
- - `hash: string | null`
285
- - `parentHash: string | null`
286
- - `number: number | null`
287
- - `timestamp: number | null`
288
- - `transactions: any[]`
289
- - `provider: AbstractProvider | null`
290
-
291
- **Methods**
292
- - `getTransaction(indexOrHash: number | string): Promise<TransactionResponse | null>`
293
- - `getTransactionReceipt(indexOrHash: number | string): Promise<TransactionReceipt | null>`
294
- - `getPrefetchedTransactions(): any[]` (currently returns `[]`)
295
-
296
- ### `TransactionResponse`
297
-
298
- Wrapper returned by `provider.sendTransaction(...)` and `provider.getTransaction(...)`.
299
-
300
- **Properties (common)**
301
- - `hash: string`
302
- - `to: string | null`
303
- - `from: string | null`
304
- - `nonce: number | null`
305
- - `data: string`
306
- - `value: bigint`
307
- - `gasLimit: bigint | null`
308
- - `chainId: number | null`
309
- - `blockNumber: number | null`
310
- - `txType: number | null` — Transaction type (e.g. `1` for a standard transfer)
311
- - `provider: AbstractProvider | null`
312
-
313
- **Methods**
314
- - `wait(confirmations?: number | null, timeoutMs?: number | null): Promise<TransactionReceipt>`
315
-
316
- ### `TransactionReceipt`
317
-
318
- Wrapper returned by `provider.getTransactionReceipt(...)` and `tx.wait()`.
319
-
320
- **Properties (common)**
321
- - `to: string | null`
322
- - `from: string | null`
323
- - `contractAddress: string | null`
324
- - `transactionHash: string`
325
- - `blockHash: string`
326
- - `blockNumber: number | null`
327
- - `transactionIndex: number | null`
328
- - `gasUsed: bigint | null`
329
- - `status: number | null`
330
- - `logs: Log[]`
331
- - `provider: AbstractProvider | null`
332
-
333
- ### `Log`
334
-
335
- Wrapper returned by `provider.getLogs(...)`.
336
-
337
- **Properties (common)**
338
- - `address: string`
339
- - `topics: string[]`
340
- - `data: string`
341
- - `blockHash: string | null`
342
- - `blockNumber: number | null`
343
- - `transactionHash: string | null`
344
- - `transactionIndex: number | null`
345
- - `logIndex: number | null`
346
- - `removed: boolean`
347
- - `provider: AbstractProvider | null`
348
-
349
- **Methods**
350
- - `getBlock(): Promise<Block | null>`
351
- - `getTransaction(): Promise<TransactionResponse | null>`
352
- - `getTransactionReceipt(): Promise<TransactionReceipt | null>`
353
-
354
- ## Wallets & Signers
355
-
356
- ### `SigningKey`
357
-
358
- - `new SigningKey(privateKeyBytes: Uint8Array, publicKeyBytes: Uint8Array)`
359
-
360
- ### `AbstractSigner`
361
-
362
- - `new AbstractSigner(provider?: AbstractProvider | null)`
363
- - `provider: AbstractProvider | null`
364
- - `getAddress(): Promise<string>` (base throws; implemented by subclasses)
365
-
366
- ### `BaseWallet`
367
-
368
- Core signing implementation.
369
-
370
- - `new BaseWallet(signingKey: SigningKey, provider?: AbstractProvider | null, precomputed?: { address: string }, qcWallet?: any)`
371
-
372
- **Properties**
373
- - `address: string`
374
- - `privateKey: string` (getter; hex string)
375
- - `publicKey: string` (getter; hex string)
376
- - `seed: string | null` (getter; pre-expansion seed as hex, or `null` if the wallet has no seed source)
377
- - `provider: AbstractProvider | null`
378
-
379
- **Methods**
380
- - `getAddress(): Promise<string>`
381
- - `signTransaction(tx: TransactionRequest): Promise<string>`
382
- - `sendTransaction(tx: TransactionRequest): Promise<TransactionResponse>`
383
-
384
- ### `Wallet`
385
-
386
- User-facing wallet class.
387
-
388
- - `new Wallet(privateKeyOrBytesOrSigningKey, provider?: AbstractProvider)`
389
-
390
- **Static methods**
391
- - `Wallet.createRandom(provider?: AbstractProvider, keyType?: number | null): Wallet` — `keyType`: `null`/`3` (default, hybrid compact) or `5` (hybrid5)
392
- - `Wallet.fromSeed(seed: number[], provider?: AbstractProvider): Wallet` — opens wallet from raw seed bytes (64/72/96 length)
393
- - `Wallet.fromEncryptedJsonSync(json: string, password: string, provider?: AbstractProvider): Wallet`
394
- - `Wallet.fromPhrase(phrase: string | string[], provider?: AbstractProvider): Wallet`
395
- - `Wallet.fromKeys(privateKey: Uint8Array | string, publicKey: Uint8Array | string, provider?: AbstractProvider): Wallet`
396
- - `Wallet.encryptSeedSync(seed: number[] | Uint8Array, password: string | Uint8Array): string` — encrypts raw seed bytes (64/72/96) into a wallet JSON string (version 5 pre-expansion format). The resulting JSON can be opened with `fromEncryptedJsonSync()` or Desktop/Mobile/Web/CLI wallet applications. Password must be at least 12 characters.
397
-
398
- **Instance methods**
399
- - `getAddress(): string`
400
- - `getBalance(blockTag?: string): Promise<bigint>`
401
- - `getTransactionCount(blockTag?: string): Promise<number>`
402
- - `encryptSync(password: string | Uint8Array): string`
403
- - `connect(provider: AbstractProvider): Wallet`
404
- - `getPhrase(): string[] | null` — returns the seed phrase (list of words) when the wallet has a seed, else `null`. Works for `createRandom`, `fromPhrase`, `fromSeed`, and `fromEncryptedJsonSync` on a version-5 keystore. Returns `null` for `fromKeys` and for v3/v4 keystores.
405
- - `getSigningContext(fullSign?: boolean | null): number` — returns the recommended signing context for this wallet (based on public key type). Setting `fullSign` to `true` may incur additional gas cost.
406
-
407
- **Seed & phrase applicability**
408
-
409
- | Factory | `seed` | `getPhrase()` |
410
- | --- | --- | --- |
411
- | `new Wallet(privateKey)` | `null` | `null` |
412
- | `Wallet.createRandom(provider?, keyType?)` | non-null | 32 or 36 words |
413
- | `Wallet.fromPhrase(phrase)` | non-null | 32 / 36 / 48 words |
414
- | `Wallet.fromSeed(seed)` | non-null | 32 / 36 / 48 words |
415
- | `Wallet.fromKeys(priv, pub)` | `null` | `null` |
416
- | `Wallet.fromEncryptedJsonSync(json, pw)` — v5 keystore (from `encryptSync` on seed-bearing wallet, or `encryptSeedSync`) | non-null | original words |
417
- | `Wallet.fromEncryptedJsonSync(json, pw)` — v3 / v4 keystore | `null` | `null` |
418
- | `wallet.connect(provider)` | same as source | same as source |
419
-
420
- **Example(s):**
421
- - `examples/wallet-offline.js`
422
-
423
- ### `NonceManager`
424
-
425
- Signer wrapper to manage nonces.
426
-
427
- - `new NonceManager(signer: AbstractSigner)`
428
-
429
- **Methods**
430
- - `getAddress(): Promise<string>`
431
- - `getTransactionCount(blockTag?: string): Promise<number>`
432
- - `sendTransaction(tx: TransactionRequest): Promise<any>`
433
- - `reset(): void`
434
- - `increment(): void`
435
-
436
- ### `JsonRpcSigner`
437
-
438
- Lightweight signer placeholder used by `BrowserProvider.getSigner(...)`.
439
-
440
- - `new JsonRpcSigner(provider, address)`
441
- - `getAddress(): Promise<string>`
442
-
443
- ### `VoidSigner`
444
-
445
- Address-only signer.
446
-
447
- - `new VoidSigner(address: string, provider?: AbstractProvider)`
448
- - `getAddress(): Promise<string>`
449
-
450
- ## Contracts
451
-
452
- ### `Contract`
453
-
454
- Dynamic contract wrapper (ethers-like).
455
-
456
- - `new Contract(address: string, abi: any[] | Interface, runner?: AbstractProvider | Wallet, bytecode?: string)`
457
-
458
- **Properties**
459
- - `address: string`
460
- - `target: string` (alias of address)
461
- - `interface: Interface`
462
- - `provider: AbstractProvider | null`
463
- - `signer: any | null`
464
-
465
- **Call / send**
466
- - `call(methodName: string, args: any[], overrides?: TransactionRequest): Promise<any>`
467
- - `send(methodName: string, args: any[], overrides?: TransactionRequest): Promise<ContractTransactionResponse>`
468
-
469
- **Logs / events**
470
- - `queryFilter(eventName: string, fromBlock?: number|string, toBlock?: number|string): Promise<EventLog[]>`
471
- - `on(eventName: string, callback: Function): this`
472
- - `once(eventName: string, callback: Function): this`
473
- - `removeListener(eventName: string, callback: Function): this`
474
- - `removeAllListeners(eventName?: string): this`
475
-
476
- **Deployment helpers**
477
- - `deployTransaction(): any | null`
478
- - `waitForDeployment(): Promise<this>`
479
- - `getDeployedCode(): Promise<string | null>`
480
-
481
- **Example(s):**
482
- - `examples/read-operations.js`
483
- - `examples/events.js`
484
-
485
- ### `ContractFactory`
486
-
487
- Deployment helper.
488
-
489
- - `new ContractFactory(abi: any[] | Interface, bytecode: string, signer: any)`
490
-
491
- **Methods**
492
- - `getDeployTransaction(...args: any[]): TransactionRequest`
493
- - `deploy(...args: any[]): Promise<Contract>`
494
- - `attach(address: string): Contract`
495
- - `connect(signer: any): ContractFactory`
496
-
497
- ### `ContractTransactionResponse`
498
-
499
- Wrapper around an underlying `TransactionResponse`.
500
-
501
- - `wait(confirmations?: number, timeoutMs?: number): Promise<any>`
502
- - `getTransaction(): any`
503
-
504
- ### `ContractTransactionReceipt`
505
-
506
- Wrapper around a receipt with convenience filters.
507
-
508
- - `getEvent(eventName: string): any | null`
509
- - `getEvents(eventName: string): any[]`
510
-
511
- ### `EventLog`
512
-
513
- Lightweight log wrapper returned by `Contract.queryFilter(...)`.
514
-
515
- ## ABI
516
-
517
- ### Fragments (`Fragment`, `FunctionFragment`, ...)
518
-
519
- Exported fragment types:
520
- - `Fragment`
521
- - `NamedFragment`
522
- - `FunctionFragment`
523
- - `EventFragment`
524
- - `ErrorFragment`
525
- - `ConstructorFragment`
526
- - `StructFragment`
527
- - `FallbackFragment`
528
-
529
- All fragments support:
530
- - `format(format?: string | null): string`
531
- - `toJSON(): any`
532
-
533
- ### `Interface`
534
-
535
- ABI encoding/decoding compatibility layer.
536
-
537
- - `new Interface(abi: any[] | Interface | null)`
538
-
539
- **Methods**
540
- - `formatJson(): string`
541
- - `format(format?: string | null): string`
542
- - `getFunction(name: string): FunctionFragment`
543
- - `getEvent(name: string): EventFragment`
544
- - `getError(name: string): ErrorFragment`
545
- - `getConstructor(): ConstructorFragment | null`
546
-
547
- **Encoding**
548
- - `encodeFunctionData(functionFragmentOrName, values?: any[] | null): string`
549
- - `decodeFunctionResult(functionFragmentOrName, data: string): any`
550
- - `encodeEventLog(eventFragmentOrName, values?: any[] | null): { topics: string[], data: string }`
551
- - `decodeEventLog(eventFragmentOrName, topics: string[], data: string): any`
552
-
553
- **Parsing**
554
- - `parseLog(log: { topics: string[], data: string }): { fragment, name, signature, topic, args }`
555
- - Uses signature topic matching and `decodeEventLog(...)`
556
-
557
- ### `AbiCoder`
558
-
559
- Minimal ABI coder for encoding/decoding tuples of values.
560
-
561
- - `encode(types: (string|any)[], values: any[]): string`
562
- - `decode(types: (string|any)[], data: string): any`
563
- - `getDefaultValue(types: (string|any)[]): any`
564
-
565
- ## Utilities
566
-
567
- ### Address utilities
568
-
569
- From `quantumcoin`:
570
-
571
- - `isAddress(address: string): boolean`
572
- - `getAddress(address: string): string`
573
- - `isAddressable(value: any): boolean`
574
- - `resolveAddress(target: any): string | Promise<string>`
575
- - `getContractAddress({ from, nonce }): string`
576
- - `getCreateAddress({ from, nonce }): string`
577
- - `getCreate2Address(from: string, salt: string, initCodeHash: string): string`
578
- - `computeAddress(publicKey: string|Uint8Array): string`
579
-
580
- **Example(s):**
581
- - `examples/wallet-offline.js`
582
-
583
- ## Solidity Types (TypeScript)
584
-
585
- QuantumCoin.js exposes core Solidity-related types for TypeScript users.
586
-
587
- - **Import path**: `quantumcoin/types`
588
-
589
- **Key exports**
590
-
591
- - `AddressLike` (currently `string`, 32-byte address)
592
- - `BytesLike` (`string | Uint8Array`)
593
- - `BigNumberish` (`string | number | bigint`)
594
- - `SolidityTypeName` (ABI type string model)
595
- - **Hard Solidity aliases** (preferred for typed wrappers):
596
- - Integers: `Uint256Like` / `Uint256`, `Int256Like` / `Int256` (and all widths `Uint8Like`…`Uint256Like`, `Int8Like`…`Int256Like`)
597
- - Fixed bytes: `Bytes32Like` / `Bytes32` (and `Bytes1Like`…`Bytes32Like`)
598
- - Arrays/tuples helpers: `SolArray<T>`, `SolFixedArray<T, N>`, `SolStruct<T>`
599
- - `SolidityInputValue<T>` / `SolidityOutputValue<T>` (advanced type-level mapping from ABI type strings to JS values; the generator no longer uses these for wrapper signatures)
600
-
601
- Example:
602
-
603
- ```ts
604
- import type { AddressLike, BigNumberish, Uint256Like, Uint256 } from "quantumcoin/types";
605
-
606
- const to: AddressLike = "0x0000000000000000000000000000000000000000000000000000000000001000";
607
- const amount: BigNumberish = "123";
608
- const asInput: Uint256Like = amount;
609
- const asOutput: Uint256 = 123n;
610
- ```
611
-
612
- ### Encoding utilities
613
-
614
- - `toUtf8String(data: BytesLike): string`
615
- - `toUtf8Bytes(str: string): Uint8Array`
616
- - `toHex(data: BytesLike): string`
617
- - `hexlify(data: BytesLike): string`
618
- - `arrayify(data: BytesLike): Uint8Array`
619
- - `isBytesLike(value: any): boolean`
620
- - `concat(items: BytesLike[]): string`
621
- - `stripZerosLeft(data: BytesLike): string`
622
- - `zeroPad(value: BytesLike, length: number): string`
623
- - `zeroPadValue(value: BytesLike, length: number): string`
624
- - `encodeBytes32String(text: string): string`
625
- - `decodeBytes32String(bytes: BytesLike): string`
626
- - `encodeBase64(data: BytesLike): string`
627
- - `decodeBase64(data: string): Uint8Array`
628
- - `encodeBase58(data: BytesLike): string`
629
- - `decodeBase58(data: string): Uint8Array`
630
- - `toUtf8CodePoints(str: string): number[]`
631
- - `solidityPacked(...)` (**throws; not implemented**)
632
- - `solidityPackedKeccak256(...)` (**throws; not implemented**)
633
- - `solidityPackedSha256(...)` (**throws; not implemented**)
634
-
635
- ### Hashing utilities
636
-
637
- - `keccak256(data: BytesLike): string`
638
- - `sha256(data: BytesLike): string`
639
- - `sha512(data: BytesLike): string`
640
- - `ripemd160(data: BytesLike): string`
641
- - `id(text: string): string` (=`keccak256(utf8Bytes(text))`)
642
- - `randomBytes(length: number): Uint8Array`
643
- - `computeHmac(algorithm: string, key: BytesLike, data: BytesLike): string`
644
- - `pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, algorithm?: string): string`
645
- - `scrypt(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): Promise<string>`
646
- - `scryptSync(password: BytesLike, salt: BytesLike, N: number, r: number, p: number, dkLen: number): string`
647
-
648
- ### Units
649
-
650
- - `formatUnits(value: BigNumberish, decimals?: number): string`
651
- - `parseUnits(value: string, decimals?: number): bigint`
652
- - `formatEther(value: BigNumberish): string`
653
- - `parseEther(value: string): bigint`
654
-
655
- ### FixedNumber (fixed-point arithmetic)
656
-
657
- Fixed-point decimal arithmetic compatible with ethers.js v5/v6.
658
-
659
- **FixedFormat type:**
660
- `number | string | { signed?: boolean, width?: number, decimals?: number }`
661
-
662
- Default format: `"fixed128x18"` (signed, 128-bit, 18 decimals).
663
-
664
- **Static factories:**
665
- - `FixedNumber.fromString(value: string, format?: FixedFormat): FixedNumber`
666
- - `FixedNumber.fromValue(value: BigNumberish, decimals?: number, format?: FixedFormat): FixedNumber`
667
- - `FixedNumber.fromBytes(value: BytesLike, format?: FixedFormat): FixedNumber`
668
- - `FixedNumber.from(value: any, format?: FixedFormat): FixedNumber` — dispatches to `fromString`, `fromBytes`, or `fromValue`
669
- - `FixedNumber.isFixedNumber(value: any): boolean`
670
-
671
- **Properties (read-only):**
672
- - `format: string` — e.g. `"fixed128x18"`
673
- - `signed: boolean`
674
- - `width: number`
675
- - `decimals: number`
676
- - `value: bigint` — raw internal integer
677
-
678
- **Arithmetic (safe throws on overflow, unsafe wraps silently):**
679
- - `add(other)` / `addUnsafe(other): FixedNumber`
680
- - `sub(other)` / `subUnsafe(other): FixedNumber`
681
- - `mul(other)` / `mulUnsafe(other): FixedNumber`
682
- - `div(other)` / `divUnsafe(other): FixedNumber`
683
- - `mulSignal(other): FixedNumber` — throws on precision loss
684
- - `divSignal(other): FixedNumber` — throws on precision loss
685
-
686
- **Comparison:**
687
- - `cmp(other): number` — returns `-1`, `0`, or `1`
688
- - `eq(other)`, `lt(other)`, `lte(other)`, `gt(other)`, `gte(other): boolean`
689
-
690
- **Rounding:**
691
- - `floor(): FixedNumber`
692
- - `ceiling(): FixedNumber`
693
- - `round(decimals?: number): FixedNumber`
694
-
695
- **Inspection:**
696
- - `isZero(): boolean`
697
- - `isNegative(): boolean`
698
-
699
- **Conversion:**
700
- - `toString(): string`
701
- - `toUnsafeFloat(): number`
702
- - `toFormat(format: FixedFormat): FixedNumber`
703
- - `toHexString(width?: number): string`
704
-
705
- ### RLP
706
-
707
- - `encodeRlp(value: any): string`
708
- - `decodeRlp(data: string): any`
709
-
710
- ### `Result` and `checkResultErrors`
711
-
712
- - `class Result extends Array`
713
- - `new Result(items?: any[], keys?: (null|string)[])`
714
- - `Result.fromItems(items: any[], keys?: (null|string)[]): Result`
715
- - `getValue(name: string): any`
716
- - `toArray(deep?: boolean | null): any[]`
717
- - `toObject(deep?: boolean | null): Record<string, any>`
718
- - `checkResultErrors(result: any): Array<{ error: Error, path: (string|number)[] }>`
719
-
720
- ## Typed SDK Generator (`generate-sdk.js`)
721
-
722
- ### Overview
723
-
724
- `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).
725
-
726
- It supports generating:
727
- - **TypeScript source** (`--lang ts`, default)
728
- - **JavaScript source + TypeScript declarations** (`--lang js`)
729
-
730
- **Typing behaviour (generated wrappers)**
731
-
732
- - **Hard types**: wrapper signatures use concrete types from `quantumcoin/types` (e.g. `Uint256Like` for inputs, `Uint256` for outputs).
733
- - **Single output unwrapping**: functions returning one value return the value directly (not `[value]`).
734
- - **Multiple outputs**: returned as a tuple type (e.g. `Promise<[Uint256, Bool]>`).
735
- - **No outputs**: `Promise<void>`.
736
- - **Structs / tuples**: emitted as `export type <Name>Input` / `export type <Name>Output` and used in signatures.
737
- - **JS typing**: JS output uses JSDoc types plus `.d.ts` files; TS users still get strong types.
738
-
739
- **Entry point**
740
- - `node generate-sdk.js ...`
741
- - or `npx sdkgen ...` (when installed)
742
-
743
- ### Input modes
744
-
745
- 1) **ABI + BIN**
746
-
747
- ```bash
748
- node generate-sdk.js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
749
-
750
- # JS output
751
- node generate-sdk.js --lang js --abi path/to/My.abi.json --bin path/to/My.bin --name MyContract --out ./out --non-interactive
752
- ```
753
-
754
- 2) **Solidity sources**
755
-
756
- ```bash
757
- node generate-sdk.js --sol ".\\contracts\\A.sol,.\\contracts\\B.sol" --solc "c:\\solc\\solc.exe" --out ./out --non-interactive
758
-
759
- # Pass additional solc args (example)
760
- node generate-sdk.js --sol ".\\contracts\\A.sol" --solc "c:\\solc\\solc.exe" --solc-args "--via-ir --evm-version london" --out ./out --non-interactive
761
- ```
762
-
763
- 3) **Artifacts JSON (multi-contract ABI+BIN list)**
764
-
765
- ```bash
766
- node generate-sdk.js --artifacts-json .\\artifacts.json --out .\\out --non-interactive
767
- ```
768
-
769
- Example `artifacts.json`:
770
-
771
- ```json
772
- [
773
- { "abi": "./Alpha.abi.json", "bin": "./Alpha.bin" },
774
- { "abi": "./Beta.abi.json", "bin": "./Beta.bin", "name": "Beta" },
775
- {
776
- "name": "Gamma",
777
- "abi": "[{\"type\":\"function\",\"name\":\"set\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"outputs\":[]}]",
778
- "bin": "0x6000600055..."
779
- }
780
- ]
781
- ```
782
-
783
- ### Package scaffolding mode
784
-
785
- Use `--create-package` to create a full npm package (source, tests, examples, README).
786
-
787
- ```bash
788
- node generate-sdk.js --artifacts-json .\\artifacts.json ^
789
- --lang ts ^
790
- --create-package --package-dir .\\tmp --package-name my-typed-package ^
791
- --package-description "My typed package" --package-author "me" ^
792
- --package-license MIT --package-version 0.0.1 ^
793
- --non-interactive
794
- ```
795
-
796
- ### Generated package layout
797
-
798
- When `--create-package` is used, the generator produces:
799
-
800
- - `src/` contract wrappers + factories
801
- - TS mode: `*.ts` (compiled output in `dist/` after `npm run build:ts`)
802
- - JS mode: `*.js` with `*.d.ts` types (no build step required)
803
- - `test/e2e/*.e2e.test.js` per-contract transactional tests
804
- - `examples/` deploy/read/write/events scripts
805
- - `README.md` generated by the generator (includes ABI-derived API overview)
806
- - `index.js` + `index.d.ts` (package entry shims)
807
-
808
- **Interface contracts:** if a generated contract has empty bytecode (typically a Solidity `interface` whose `.bin` is empty, or any artifact whose `bytecode` is `null`/`undefined`/`""`/`"0x"`), the generated `test/e2e/<name>.e2e.test.js` will still deploy and validate the transaction receipt status, but will **not** assert that `provider.getCode(contract.target)` is non-empty — interfaces deploy with no runtime code by design. For concrete contracts (non-empty bytecode), the bytecode assertion is preserved. Detection is done by `_isInterfaceBytecode` in `src/generator/index.js` and is exercised by the unit tests and the `generator-interface.e2e.test.js` end-to-end test listed below.
809
-
810
- ### Running generated transactional tests
811
-
812
- Generated package tests broadcast transactions and require:
813
-
814
- - `QC_RPC_URL` (RPC endpoint)
815
- - `QC_CHAIN_ID` (optional, default `123123`)
816
-
817
- ### Generator tests
818
-
819
- - Unit tests:
820
- - `test/unit/generate-contract-cli.test.js`
821
- - `test/unit/generator.test.js`
822
- - `test/unit/generate-sdk-artifacts-json.test.js`
823
- - E2E generator tests (transactional; require `QC_RPC_URL` and optionally `QC_CHAIN_ID`):
824
- - `test/e2e/typed-generator.e2e.test.js`
825
- - `test/e2e/simple-erc20.generated-sdks.e2e.test.js`
826
- - `test/e2e/all-solidity-types.generated-sdks.e2e.test.js`
827
- - `test/e2e/generator-interface.e2e.test.js` (verifies that the generated test for an interface contract passes against a real chain — no `provider.getCode(...)` bytecode assertion is emitted, and the deploy + receipt-status assertions succeed end-to-end)
828
-