@thruputchain/client 0.0.0-stage → 0.25.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 (182) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +935 -2
  3. package/dist/actions-CdFSUTO2.js +298 -0
  4. package/dist/actions-CdFSUTO2.js.map +1 -0
  5. package/dist/actions-DxJZ3yIv.cjs +357 -0
  6. package/dist/actions-DxJZ3yIv.cjs.map +1 -0
  7. package/dist/actions.cjs +19 -0
  8. package/dist/actions.d.cts +4 -0
  9. package/dist/actions.d.ts +4 -0
  10. package/dist/actions.js +3 -0
  11. package/dist/client-BxB6ktQd.d.cts +690 -0
  12. package/dist/client-BxB6ktQd.d.cts.map +1 -0
  13. package/dist/client-BxB6ktQd.d.ts +690 -0
  14. package/dist/client-BxB6ktQd.d.ts.map +1 -0
  15. package/dist/codec-B7HJjMzI.cjs +8190 -0
  16. package/dist/codec-B7HJjMzI.cjs.map +1 -0
  17. package/dist/codec-CX-19jac.js +8130 -0
  18. package/dist/codec-CX-19jac.js.map +1 -0
  19. package/dist/contract-BpxjDMHw.js +1105 -0
  20. package/dist/contract-BpxjDMHw.js.map +1 -0
  21. package/dist/contract-D0wCFcAN.cjs +1219 -0
  22. package/dist/contract-D0wCFcAN.cjs.map +1 -0
  23. package/dist/contract.cjs +58 -0
  24. package/dist/contract.d.cts +3 -0
  25. package/dist/contract.d.ts +3 -0
  26. package/dist/contract.js +2 -0
  27. package/dist/contracts.cjs +1050 -0
  28. package/dist/contracts.cjs.map +1 -0
  29. package/dist/contracts.d.cts +397 -0
  30. package/dist/contracts.d.cts.map +1 -0
  31. package/dist/contracts.d.ts +397 -0
  32. package/dist/contracts.d.ts.map +1 -0
  33. package/dist/contracts.js +1030 -0
  34. package/dist/contracts.js.map +1 -0
  35. package/dist/dev_wallet-BXWK5KR6.cjs +530 -0
  36. package/dist/dev_wallet-BXWK5KR6.cjs.map +1 -0
  37. package/dist/dev_wallet-C9eMQROk.js +497 -0
  38. package/dist/dev_wallet-C9eMQROk.js.map +1 -0
  39. package/dist/domainSeparator-B_vU_zUD.cjs +102 -0
  40. package/dist/domainSeparator-B_vU_zUD.cjs.map +1 -0
  41. package/dist/domainSeparator-CBCvxIj-.js +79 -0
  42. package/dist/domainSeparator-CBCvxIj-.js.map +1 -0
  43. package/dist/execution-CRDyKu45.d.ts +227 -0
  44. package/dist/execution-CRDyKu45.d.ts.map +1 -0
  45. package/dist/execution-DyxaIG4v.d.cts +227 -0
  46. package/dist/execution-DyxaIG4v.d.cts.map +1 -0
  47. package/dist/hex-DIcaALXL.js +112 -0
  48. package/dist/hex-DIcaALXL.js.map +1 -0
  49. package/dist/hex-DkGpiZ5e.cjs +189 -0
  50. package/dist/hex-DkGpiZ5e.cjs.map +1 -0
  51. package/dist/index--5LsCotr.d.ts +192 -0
  52. package/dist/index--5LsCotr.d.ts.map +1 -0
  53. package/dist/index-B5KqSHeL.d.cts +192 -0
  54. package/dist/index-B5KqSHeL.d.cts.map +1 -0
  55. package/dist/index-BZ0O5jZG.d.cts +163 -0
  56. package/dist/index-BZ0O5jZG.d.cts.map +1 -0
  57. package/dist/index-BuPQcAK2.d.ts +23 -0
  58. package/dist/index-BuPQcAK2.d.ts.map +1 -0
  59. package/dist/index-ByNNqY7S.d.cts +83 -0
  60. package/dist/index-ByNNqY7S.d.cts.map +1 -0
  61. package/dist/index-C-M-4jMR.d.cts +263 -0
  62. package/dist/index-C-M-4jMR.d.cts.map +1 -0
  63. package/dist/index-C97zw2rk.d.ts +137 -0
  64. package/dist/index-C97zw2rk.d.ts.map +1 -0
  65. package/dist/index-CIHK7Ew9.d.cts +303 -0
  66. package/dist/index-CIHK7Ew9.d.cts.map +1 -0
  67. package/dist/index-CIHK7Ew9.d.ts +303 -0
  68. package/dist/index-CIHK7Ew9.d.ts.map +1 -0
  69. package/dist/index-CXuO2Zjx.d.ts +263 -0
  70. package/dist/index-CXuO2Zjx.d.ts.map +1 -0
  71. package/dist/index-DOEBWXY2.d.cts +137 -0
  72. package/dist/index-DOEBWXY2.d.cts.map +1 -0
  73. package/dist/index-DzrLv3EA.d.cts +82 -0
  74. package/dist/index-DzrLv3EA.d.cts.map +1 -0
  75. package/dist/index-DzrLv3EA.d.ts +82 -0
  76. package/dist/index-DzrLv3EA.d.ts.map +1 -0
  77. package/dist/index-fdTURpBk.d.ts +83 -0
  78. package/dist/index-fdTURpBk.d.ts.map +1 -0
  79. package/dist/index-sAzHHayu.d.ts +163 -0
  80. package/dist/index-sAzHHayu.d.ts.map +1 -0
  81. package/dist/index-uQqRk9Ww.d.cts +23 -0
  82. package/dist/index-uQqRk9Ww.d.cts.map +1 -0
  83. package/dist/index.cjs +478 -0
  84. package/dist/index.cjs.map +1 -0
  85. package/dist/index.d.cts +173 -0
  86. package/dist/index.d.cts.map +1 -0
  87. package/dist/index.d.ts +173 -0
  88. package/dist/index.d.ts.map +1 -0
  89. package/dist/index.js +231 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/provider.cjs +101 -0
  92. package/dist/provider.cjs.map +1 -0
  93. package/dist/provider.d.cts +2 -0
  94. package/dist/provider.d.ts +2 -0
  95. package/dist/provider.js +76 -0
  96. package/dist/provider.js.map +1 -0
  97. package/dist/readError-BVbfTMLv.cjs +604 -0
  98. package/dist/readError-BVbfTMLv.cjs.map +1 -0
  99. package/dist/readError-Dn_XN98x.js +551 -0
  100. package/dist/readError-Dn_XN98x.js.map +1 -0
  101. package/dist/readViews-BKJtE5J3.d.cts +594 -0
  102. package/dist/readViews-BKJtE5J3.d.cts.map +1 -0
  103. package/dist/readViews-C_FX8wby.d.ts +594 -0
  104. package/dist/readViews-C_FX8wby.d.ts.map +1 -0
  105. package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
  106. package/dist/sendInvocation-2EZanZZr.cjs +661 -0
  107. package/dist/sendInvocation-2EZanZZr.cjs.map +1 -0
  108. package/dist/sendInvocation-C4ruTC-9.js +505 -0
  109. package/dist/sendInvocation-C4ruTC-9.js.map +1 -0
  110. package/dist/sign-BewmV_EL.cjs +139 -0
  111. package/dist/sign-BewmV_EL.cjs.map +1 -0
  112. package/dist/sign-DVIRyW8Y.js +122 -0
  113. package/dist/sign-DVIRyW8Y.js.map +1 -0
  114. package/dist/sign-Ve0eetRO.d.ts +48 -0
  115. package/dist/sign-Ve0eetRO.d.ts.map +1 -0
  116. package/dist/sign-eUT0iGQG.d.cts +48 -0
  117. package/dist/sign-eUT0iGQG.d.cts.map +1 -0
  118. package/dist/signed-op.cjs +9 -0
  119. package/dist/signed-op.d.cts +3 -0
  120. package/dist/signed-op.d.ts +3 -0
  121. package/dist/signed-op.js +3 -0
  122. package/dist/signedOp-Bluo0OAd.cjs +183 -0
  123. package/dist/signedOp-Bluo0OAd.cjs.map +1 -0
  124. package/dist/signedOp-x4fakrr4.js +166 -0
  125. package/dist/signedOp-x4fakrr4.js.map +1 -0
  126. package/dist/signed_op-BzVbBgv4.js +154 -0
  127. package/dist/signed_op-BzVbBgv4.js.map +1 -0
  128. package/dist/signed_op-DFgQ2yFj.d.ts +58 -0
  129. package/dist/signed_op-DFgQ2yFj.d.ts.map +1 -0
  130. package/dist/signed_op-LwxrDud8.d.cts +58 -0
  131. package/dist/signed_op-LwxrDud8.d.cts.map +1 -0
  132. package/dist/signed_op-z_8fqAi1.cjs +175 -0
  133. package/dist/signed_op-z_8fqAi1.cjs.map +1 -0
  134. package/dist/signers-BFP84wJP.cjs +137 -0
  135. package/dist/signers-BFP84wJP.cjs.map +1 -0
  136. package/dist/signers-CzOSedwJ.js +120 -0
  137. package/dist/signers-CzOSedwJ.js.map +1 -0
  138. package/dist/signers.cjs +5 -0
  139. package/dist/signers.d.cts +3 -0
  140. package/dist/signers.d.ts +3 -0
  141. package/dist/signers.js +2 -0
  142. package/dist/size-506oTE28.js +91 -0
  143. package/dist/size-506oTE28.js.map +1 -0
  144. package/dist/size-OAFfOthl.cjs +108 -0
  145. package/dist/size-OAFfOthl.cjs.map +1 -0
  146. package/dist/transaction-CwkQxQOx.js +24 -0
  147. package/dist/transaction-CwkQxQOx.js.map +1 -0
  148. package/dist/transaction-DrSrCJ5y.cjs +47 -0
  149. package/dist/transaction-DrSrCJ5y.cjs.map +1 -0
  150. package/dist/transaction.cjs +13 -0
  151. package/dist/transaction.d.cts +3 -0
  152. package/dist/transaction.d.ts +3 -0
  153. package/dist/transaction.js +4 -0
  154. package/dist/transactionHash-CO9ajbvU.js +24 -0
  155. package/dist/transactionHash-CO9ajbvU.js.map +1 -0
  156. package/dist/transactionHash-D5yf4KoL.cjs +29 -0
  157. package/dist/transactionHash-D5yf4KoL.cjs.map +1 -0
  158. package/dist/transport-B-P16rs6.cjs +252 -0
  159. package/dist/transport-B-P16rs6.cjs.map +1 -0
  160. package/dist/transport-DqyoNtUy.js +234 -0
  161. package/dist/transport-DqyoNtUy.js.map +1 -0
  162. package/dist/transport.cjs +19 -0
  163. package/dist/transport.d.cts +3 -0
  164. package/dist/transport.d.ts +3 -0
  165. package/dist/transport.js +4 -0
  166. package/dist/types-BE40oD_Q.d.cts +18 -0
  167. package/dist/types-BE40oD_Q.d.cts.map +1 -0
  168. package/dist/types-BE40oD_Q.d.ts +18 -0
  169. package/dist/types-BE40oD_Q.d.ts.map +1 -0
  170. package/dist/validation-4w-vDGAi.cjs +543 -0
  171. package/dist/validation-4w-vDGAi.cjs.map +1 -0
  172. package/dist/validation-eXATmgO0.js +411 -0
  173. package/dist/validation-eXATmgO0.js.map +1 -0
  174. package/dist/wallet-Bthapk8i.cjs +709 -0
  175. package/dist/wallet-Bthapk8i.cjs.map +1 -0
  176. package/dist/wallet-CwWPYoHF.js +667 -0
  177. package/dist/wallet-CwWPYoHF.js.map +1 -0
  178. package/dist/wallet.cjs +27 -0
  179. package/dist/wallet.d.cts +3 -0
  180. package/dist/wallet.d.ts +3 -0
  181. package/dist/wallet.js +3 -0
  182. package/package.json +122 -4
package/README.md CHANGED
@@ -1,3 +1,936 @@
1
- # Temporary Holding Version
1
+ # @thruputchain/client
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ TypeScript client for the [Thruput](https://github.com/thruputchain) blockchain.
4
+
5
+ It provides typed JSON-RPC actions, transaction construction and signing,
6
+ HTTP and mock transports, and generated contract bindings. Generated methods
7
+ share one descriptor API for invocations, typed views, root-receipt decoding,
8
+ returns, and contract exceptions. Generated events provide strict decoding,
9
+ named topic filters, and receipt extraction.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ npm install @thruputchain/client
15
+ ```
16
+
17
+ Requires Node.js 22.12.0 or newer. Public npm installs need no authentication.
18
+ Remove any GitHub Packages registry override for `@thruputchain` when using npm
19
+ releases. Repository development still uses [registry auth](#registry-auth-one-time-setup)
20
+ during the npm migration.
21
+
22
+ ## Usage
23
+
24
+ This checkout pins RPC wire format **14.1.1**. Block queries require a compatible
25
+ RPC server and a node with the block-query index. RPC addresses, public keys,
26
+ validator IDs and hashes use unprefixed, case-sensitive base58. Opaque payloads
27
+ (including signed transactions, calldata, return data, storage keys, raw event
28
+ topics) retain `0x`-prefixed hex. Cursors are opaque strings, preserved unchanged.
29
+ Methods accept and return
30
+ typed byte arrays; they apply the encoding at the transport boundary.
31
+
32
+ All 64-bit and wider integers
33
+ are canonical decimal strings in JSON and `bigint` in the client API, including
34
+ heights, nanosecond timestamps, gas, mempool counts, wide server limits, and
35
+ airdrop retry intervals. Smaller bounded fields, such as page limits and event
36
+ sequence numbers, remain JSON numbers. Numeric JSON for wide fields is rejected,
37
+ even when the value is small. Live qualification requires a matching wire-14
38
+ CLI and runtime.
39
+
40
+ Pass heights as `bigint` (for example, `42n`). The actions serialize them as
41
+ decimal strings and validate protocol bounds. When persisting client results,
42
+ convert bigint fields explicitly to decimal strings; `JSON.stringify` does not
43
+ serialize bigint values by itself.
44
+
45
+ ```ts
46
+ import { createThruputClient, futurenet, toBase58 } from "@thruputchain/client";
47
+
48
+ const client = await createThruputClient({
49
+ cluster: futurenet(),
50
+ });
51
+
52
+ const tip = await client.getChainTip();
53
+ console.log(tip.blockHeight.toString(), toBase58(tip.blockHash));
54
+ ```
55
+
56
+ ### Read a committed block
57
+
58
+ ```ts
59
+ const blockHeight = 42n;
60
+ const block = await client.getBlockByHeight({ blockHeight });
61
+ if (block !== null) {
62
+ for await (const page of client.iterateTransactionsByBlock({
63
+ blockHeight,
64
+ start: { order: "ascending" },
65
+ limit: 50,
66
+ })) {
67
+ console.log(page.transactions);
68
+ }
69
+ }
70
+ ```
71
+
72
+ References use unsigned hash order, not execution order. The walker checks
73
+ coverage for the target block, preserves the opaque cursor and rejects duplicate
74
+ or out-of-order rows. Completion covers that block only. A missing block returns
75
+ `null`; backend failures remain errors. Invalid cursors never restart the walk.
76
+ All reads accept `{ signal }` as the final argument.
77
+
78
+ Enable HTTP batching to group concurrent calls into one JSON-RPC array:
79
+
80
+ ```ts
81
+ import { HttpTransport } from "@thruputchain/client";
82
+
83
+ const client = await createThruputClient({
84
+ transport: new HttpTransport("https://rpc.example.com", {
85
+ batch: true, // defaults to { maxSize: 100, waitMs: 0 }
86
+ }),
87
+ });
88
+
89
+ const [tip, version] = await Promise.all([
90
+ client.getChainTip(),
91
+ client.getVersionInfo(),
92
+ ]);
93
+ ```
94
+
95
+ Batching is opt-in and requires an endpoint that accepts JSON-RPC arrays.
96
+ It reduces HTTP requests but does not guarantee a shared snapshot, execution
97
+ order, or atomicity. Await dependent calls separately. See `HttpTransportOptions`
98
+ in the API reference for timeout, cancellation, and error behavior.
99
+
100
+ Pass a cluster to fetch the endpoint's network identity during connection and
101
+ verify it against the cluster's `networkHash`, if supplied:
102
+
103
+ ```ts
104
+ import { createThruputClient, futurenet, toBase58 } from "@thruputchain/client";
105
+
106
+ const client = await createThruputClient({
107
+ cluster: futurenet(),
108
+ });
109
+
110
+ console.log(toBase58(client.network.networkHash));
111
+ ```
112
+
113
+ `futurenet()` connects to Futurenet at `https://rpc.thruput.network`. Applications with an explicit
114
+ `rpcUrl`, `HttpTransport` URL, or environment configuration should update that
115
+ value to use the stable endpoint; upgrading the package preserves overrides.
116
+
117
+ Development clusters expose a typed airdrop action. It generates a
118
+ client nonce, calls the faucet once, then uses read-only status and receipt polling
119
+ when a pending response identifies a transaction:
120
+
121
+ ```ts
122
+ const airdrop = await client.requestAirdrop({ recipient: accountAddress });
123
+ console.log(airdrop.transactionHash, airdrop.rawAmount);
124
+ ```
125
+
126
+ Remote airdrops retain the faucet's per-recipient cooldown and share the
127
+ gateway's configured aggregate quota. Localnet has no hosted cooldown, but its
128
+ funding journal retains at most 1024 attempts per chain across `requestAirdrop`
129
+ and `dev_fundAccount`. It rejects new requests at capacity and keeps existing requests
130
+ available for reconciliation. The generated nonce is not persisted. For crash
131
+ recovery, generate and persist `clientNonce`, recipient and network hash before
132
+ calling `requestAirdrop({ recipient, clientNonce })`. Use `requestAirdropAttempt`
133
+ to control read-only observation yourself. Faucet errors and pending responses
134
+ without a transaction hash stop immediately. The SDK never repeats the faucet request.
135
+
136
+ The predefined clusters are `mainnet`, `futurenet`, and `localnet`. Declare a
137
+ deployment-specific cluster inline, or use `defineCluster` when the descriptor
138
+ will be reused. Futurenet and localnet include default RPC URLs; pass `rpcUrl` to
139
+ override them. Mainnet has no default endpoint yet. Supply a `networkHash` when
140
+ the application must pin the protocol identity used for transaction signing.
141
+ `futurenet()` is unpinned by default; use `futurenet({ networkHash })` to pin it.
142
+ The deprecated `devnet()` helper and `DEVNET_RPC_URL` constant remain available
143
+ for existing applications. `devnet()` retains its legacy `name: "devnet"`;
144
+ `futurenet()` returns `name: "futurenet"`. Both use the same endpoint and capabilities.
145
+ Identity is checked at connection, not continuously after network resets.
146
+ Pass an explicit transport for custom headers or request handling. Omit
147
+ `cluster` to discover an endpoint without pinning a particular network. Both forms
148
+ validate wire 14 and advertised methods; declared capabilities must be advertised.
149
+
150
+ ```ts
151
+ const client = await createThruputClient({
152
+ cluster: {
153
+ name: "private-devnet",
154
+ rpcUrl: "https://rpc.example.com",
155
+ capabilities: ["airdrop"],
156
+ },
157
+ });
158
+ ```
159
+
160
+ Common protocol types and constructors are available directly from
161
+ `@thruputchain/client`: addresses, hashes, block heights, gas amounts,
162
+ `ContractEntrypointID`, `Calldata`, `TimePoint`, and `InvokeFlagSet`. The client also
163
+ exports `Invocation`, `Transaction`, `SignedTransaction`, `InvokeFlag`, and
164
+ `ExecResult`. These are the original protocol definitions; the full protocol and
165
+ XDR API remains available from `@thruputchain/protocol`.
166
+
167
+ ```ts
168
+ import { gasAmount, type ContractAddress } from "@thruputchain/client";
169
+ ```
170
+
171
+ Generated contract bindings are exported separately. Each interface nests its
172
+ methods and their argument, result, and exception types under the major version
173
+ its entrypoints hash (`ERC20.v0_1.transfer`, `ERC20.v0_1.TransferArgs`); named
174
+ types, enum values, and event descriptors nest under the declaring crate and
175
+ major (`thruput_erc20_if.v0_1.events.TransferEvent`).
176
+
177
+ ```ts
178
+ import { ERC20 } from "@thruputchain/client/contracts";
179
+
180
+ const balance = await ERC20.v0_1.getBalanceOf.view({
181
+ client,
182
+ address: tokenAddress,
183
+ args: { addr: accountAddress },
184
+ });
185
+
186
+ const transfer = ERC20.v0_1.transfer.invocation(tokenAddress, gasLimit, {
187
+ receiver: recipientAddress,
188
+ amount: 1_000n,
189
+ });
190
+ ```
191
+
192
+ ### Exact amounts
193
+
194
+ Convert user input without floating-point arithmetic:
195
+
196
+ ```ts
197
+ import { parseUnits, formatUnits } from "@thruputchain/client";
198
+
199
+ const amount = parseUnits("12.05", 2); // 1205n
200
+ console.log(formatUnits(amount, 2)); // "12.05"
201
+ ```
202
+
203
+ Parsing rejects malformed input and excess precision rather than rounding.
204
+ Applications still check token positivity and size limits. See the
205
+ [amount guide](https://docs.thruput.network/tools/typescript-sdk/#exact-amounts-and-common-types)
206
+ for error handling and supported inputs.
207
+
208
+ ### Cancellable reads
209
+
210
+ Pass request options to public actions and put `signal` inside generated view options:
211
+
212
+ ```ts
213
+ const controller = new AbortController();
214
+ const { signal } = controller;
215
+ const tip = await client.getChainTip({}, { signal });
216
+ const balance = await ERC20.v0_1.getBalanceOf.view({
217
+ client,
218
+ address: tokenAddress,
219
+ args: { addr: accountAddress },
220
+ signal,
221
+ });
222
+ ```
223
+
224
+ Call `controller.abort()` from the application's cleanup handler. Bound views also
225
+ accept a signal. `classifyReadError(error, { signal })` helps distinguish cancellation
226
+ from infrastructure failures; applications own retry policy. Canceling observation
227
+ does not cancel a transaction. See [read errors](https://docs.thruput.network/tools/typescript-sdk/#cancellation-and-read-errors).
228
+
229
+ ### Inspect arguments
230
+
231
+ Use the descriptor for the known method to decode calldata:
232
+
233
+ ```ts
234
+ const { receiver, amount } = ERC20.v0_1.transfer.decodeArgs(transfer.calldata);
235
+ ```
236
+
237
+ `decodeArgs` returns typed arguments and rejects incomplete or trailing bytes.
238
+ It returns `undefined` for methods without arguments. Decoding does not verify the
239
+ target contract's behavior.
240
+
241
+ ### Release diagnostics
242
+
243
+ ```ts
244
+ const version = await client.getVersionInfo();
245
+ console.log(
246
+ version.wireFormat,
247
+ version.releaseVersion,
248
+ version.bundleManifestDigest,
249
+ );
250
+ ```
251
+
252
+ Release identity and bundle digest can be omitted;
253
+ they help diagnose installations. Use `wireFormat` for RPC compatibility decisions.
254
+
255
+ ### Read after confirmation
256
+
257
+ Use the height from a successful receipt as a freshness floor for a single read:
258
+
259
+ ```ts
260
+ const balance = await ERC20.v0_1.getBalanceOf.view({
261
+ client,
262
+ address: tokenAddress,
263
+ args: { addr: accountAddress },
264
+ minStateBlockHeight: receipt.blockHeight,
265
+ });
266
+ ```
267
+
268
+ This requires a matching RPC wire format 14.1.1 endpoint and also works with `.viewOutcome()`, bound
269
+ views, and raw `client.simulateInvocation()`. The result must come from a committed snapshot at
270
+ or above that height. An older snapshot produces `stateHeightUnavailable`
271
+ (`NativeRpcErrorCode.StateHeightUnavailable`, `-32012`) with requested and observed heights. It does not undo transaction
272
+ confirmation. The SDK does not poll, wait, or retry; your application decides how
273
+ to handle a backend that is behind. Omit `minStateBlockHeight` for an unconstrained read.
274
+
275
+ ### Simulated authorization
276
+
277
+ Generated `.view()`, `.viewOutcome()` and `.viewRequest()` accept an optional
278
+ protocol `AuthClaim` as `assumedAuth`, including `account.authClaim`. The descriptor
279
+ converts it to the native typed request. Raw `simulateInvocation` accepts the
280
+ native `RpcAssumedAuth` object. Simulation assumes authorization; it does not verify
281
+ signatures or persist writes. Contract permission checks still run.
282
+
283
+ `caller` supplies a parent address. To simulate a root DefaultWallet invocation,
284
+ use the wallet's `address`, supply its matching `assumedAuth`, and omit `caller`.
285
+ Batch entries are independent invocations against the same state snapshot.
286
+
287
+ ### Reads at one snapshot
288
+
289
+ Use `readViews` when several contract reads must use the same committed state:
290
+
291
+ ```ts
292
+ const snapshot = await client.readViews({
293
+ calls: [
294
+ ERC20.v0_1.totalSupply.viewRequest({ address: tokenAddress }),
295
+ ERC20.v0_1.getBalanceOf.viewRequest({
296
+ address: tokenAddress,
297
+ args: { addr: accountAddress },
298
+ }),
299
+ ],
300
+ minStateBlockHeight: receipt.blockHeight,
301
+ });
302
+
303
+ const [supply, balance] = snapshot.results;
304
+ if (supply.kind === "return" && balance.kind === "return") {
305
+ console.log(snapshot.stateBlockHeight, supply.value, balance.value);
306
+ }
307
+ ```
308
+
309
+ Each tuple position retains its generated return and exception types. Results are
310
+ `return`, `abort`, `fault`, or `unsupported`, with events. Simulated writes stay within each call.
311
+ Omit `minStateBlockHeight` if no freshness floor is needed. If the selected snapshot is
312
+ behind, the server returns `stateHeightUnavailable` with requested and observed
313
+ heights. The request neither waits for a block nor forces a refresh; your
314
+ application decides whether and when to retry.
315
+
316
+ This requires `simulateInvocations` (RPC wire format 14.1.1). Existing generated
317
+ bindings gain `viewRequest` through the runtime. The low-level API is
318
+ `client.simulateInvocations({ invocations, minStateBlockHeight })`. Neither API splits calls or falls back
319
+ to separate views. HTTP transport batching alone does not share snapshots.
320
+
321
+ Operators set batch limits; inspect `(await client.getServerLimits()).simulationBatch`
322
+ when you need the endpoint's policy. Per-call view and transport limits also
323
+ apply. The server retries an abandoned snapshot as a whole group, at most three
324
+ times. Its configured deadline bounds the response wait, but running backend
325
+ work can outlive it. Pass `{ signal }` as the second argument to cancel the
326
+ client's wait.
327
+
328
+ ### Event and sender history
329
+
330
+ ```ts
331
+ import { thruput_erc20_if } from "@thruputchain/client/contracts";
332
+ const { TransferEvent } = thruput_erc20_if.v0_1.events;
333
+ const page = await client.getContractEvents({
334
+ event: TransferEvent,
335
+ addresses: [tokenAddress],
336
+ topics: { to: accountAddress },
337
+ start: { order: "ascending", anchor: { kind: "atBeginning" } },
338
+ limit: 20,
339
+ });
340
+ for (const transfer of page.events) {
341
+ console.log(
342
+ transfer.transactionHash,
343
+ transfer.blockHeight,
344
+ transfer.fields.amount,
345
+ );
346
+ }
347
+ ```
348
+
349
+ This makes one request. To continue, repeat filters and pass `cursor: page.nextCursor`
350
+ without `start`. Stop at `nextCursor: null`; an empty page can still have a cursor.
351
+ Typed event filters convert address topics to the token's fixed-byte representation.
352
+ `getTransactionsByRootAddress` returns transactions sent by the root address;
353
+ incoming transfers use the token's Transfer event.
354
+
355
+ `iterateEventPages` and `iterateTransactionsByRootAddress` start an explicit range
356
+ and retain its initial upper watermark W. They reject regressed coverage, duplicate
357
+ identities, out-of-order rows and cursor cycles. No retries, prefetching or silent
358
+ restart occur. Cursor-only continuation remains available on the raw RPC methods.
359
+
360
+ A range generator returns `HistoryCompletion` only when resumed after the terminal
361
+ page has been processed. For ascending walks, `completedThroughBlockHeight` is W;
362
+ it is absent if the starting height was above W. Descending completion is not an
363
+ ingestion checkpoint. Persist processed rows and the checkpoint together. Start the
364
+ next ascending range inclusively at W and deduplicate the boundary. Page bounds
365
+ are serving availability, not processed checkpoints. No cross-reset durability is
366
+ implied. Breaking or cancelling a walk produces no completed checkpoint.
367
+
368
+ `for await` discards a generator's return value. Use `.next()` when you need
369
+ `HistoryCompletion`; `processPage` below is your application's durable processing:
370
+
371
+ ```ts
372
+ const pages = client.iterateEventPages({
373
+ filters: [{ addresses: [tokenAddress] }],
374
+ start: {
375
+ order: "ascending",
376
+ anchor: { kind: "atHeight", blockHeight: fromHeight },
377
+ },
378
+ });
379
+ let completion;
380
+ for (;;) {
381
+ const step = await pages.next();
382
+ if (step.done) {
383
+ completion = step.value;
384
+ break;
385
+ }
386
+ await processPage(step.value);
387
+ }
388
+ ```
389
+
390
+ Walkers retain seen identities and cursors, so memory grows with rows and pages.
391
+ Start near your saved checkpoint; use per-block transaction walks for large
392
+ transaction backfills. A page limit bounds each response, not the whole walk.
393
+
394
+ Local applications own their signing keys. A schema-5 local manifest contains
395
+ public allocations and a public faucet address; it cannot produce a signer.
396
+ Use `Ed25519Signer` with `createPubkeyAccount`, then request an airdrop or
397
+ supply its public key in the node's initial allocations. Stored CLI keys can be
398
+ exported explicitly through `thruput keys export`; never log that output.
399
+
400
+ ## Native RPC client
401
+
402
+ `createRpcClient` exposes the native wire-14 methods directly. It validates the
403
+ wire version, configured methods and optional expected network before returning.
404
+ Requests use byte arrays and bigints; cursors remain opaque strings.
405
+
406
+ ```ts
407
+ import { createRpcClient, HttpTransport } from "@thruputchain/client";
408
+
409
+ const rpc = await createRpcClient({
410
+ transport: new HttpTransport("http://127.0.0.1:9545"),
411
+ requiredMethods: ["getChainTip", "getBalance"],
412
+ });
413
+ const tip = await rpc.getChainTip();
414
+ const balance = await rpc.getBalance({ address: accountAddress });
415
+ ```
416
+
417
+ Each method makes one RPC call. There are no retries, transaction signing or
418
+ receipt waits in this layer. Unknown response variants retain their original
419
+ payload in `UnsupportedRpcValue`; malformed known results throw
420
+ `RpcDecodingError`. Invalid local inputs throw `RpcRequestValidationError`
421
+ before dispatch. `NativeRpcError.decoded` distinguishes known, valid evidence
422
+ from unclassified errors; both retain the complete raw error. Neither classification
423
+ authorizes retries. Transaction evidence is compared with the requested hash.
424
+ Malformed HTTP reply envelopes throw `RpcResponseError` with the raw reply.
425
+ `refreshDiscovery()` performs only discovery reads and never replays writes.
426
+
427
+ ## Wallet clients
428
+
429
+ Human address inputs use `parseAddress(text)`, which accepts base58 or a Thruput
430
+ `Z...` StrKey. `addressToStrkey(address)` formats the same bytes with the Z prefix.
431
+ Stellar `C...` addresses are rejected. Z does not distinguish Thruput networks;
432
+ select the intended cluster. RPC and wallet-provider identifiers remain base58.
433
+ Ed25519 public keys and seeds retain their G and S StrKey formats.
434
+
435
+ A wallet client binds account authorization and signers to an existing client:
436
+
437
+ ```ts
438
+ import {
439
+ createThruputClient,
440
+ createPubkeyAccount,
441
+ createWalletClient,
442
+ futurenet,
443
+ Ed25519Signer,
444
+ } from "@thruputchain/client";
445
+
446
+ const client = await createThruputClient({ cluster: futurenet() });
447
+ const signer = Ed25519Signer.fromSeed(secretKey);
448
+ const account = createPubkeyAccount({ signer, nonce: 0n });
449
+ const wallet = createWalletClient({ client, account });
450
+
451
+ await wallet.requestAirdrop();
452
+ const balance = await wallet.getBalance();
453
+ ```
454
+
455
+ For local funding with an explicit raw amount, call `client.dev_fundAccount` once. Persist the request, network hash and public
456
+ faucet address before sending. An uncertain response does not authorize a repeat. The response carries
457
+ the admitted hash and exact signed bytes. Wait for a receipt to learn execution.
458
+ `requestAirdrop` retains its fixed amount and hosted behavior.
459
+
460
+ Pubkey accounts can also be authorized by an ML-DSA-65 (FIPS 204) key. The
461
+ account address commits to a hash of the scheme-tagged key, and each signed
462
+ transaction carries the key itself, so signatures and keys are larger
463
+ (3,309 and 1,952 bytes) but the flow is the same:
464
+
465
+ ```ts
466
+ import { MlDsa65Signer, createPubkeyAccount } from "@thruputchain/client";
467
+
468
+ const signer = MlDsa65Signer.fromSeed(seed); // 32-byte seed
469
+ const account = createPubkeyAccount({ signer, nonce: 0n });
470
+ ```
471
+
472
+ ML-DSA keys have no StrKey (`G...`/`S...`) form; those encodings remain
473
+ Ed25519-only.
474
+
475
+ Both built-in signers implement the same `Signer` interface and are created
476
+ the same way, with `Ed25519Signer.fromSeed` or `MlDsa65Signer.fromSeed`.
477
+
478
+ Use `createSourceAddressAccount` with the appropriate invocation adapter for
479
+ an existing account contract. Saved legacy contract-wallet identities remain
480
+ separate from the native bootstrap accounts.
481
+
482
+ Wallet clients prepare fresh transaction expiry and replay nonces, sign with
483
+ the account's configured signers, and submit transactions. Pubkey accounts use
484
+ the native-compatible DefaultWallet adapter automatically. The signing network
485
+ comes from a cluster-validated client's `networkHash`.
486
+ When binding an unqualified client, pass an explicit `networkHash` to
487
+ `createWalletClient`.
488
+
489
+ Choose a workload-specific root gas budget: it reserves scheduling capacity
490
+ against the sender's free native-token balance even though gas is not burned.
491
+ New storage also needs native-token deposits at the address that owns it. See
492
+ [gas and storage funding](#gas-and-storage-funding) before copying
493
+ budgets or sending a small first credit to a fresh address.
494
+
495
+ Source-address accounts expose `execute` when configured with an adapter:
496
+
497
+ ```ts
498
+ const txHash = await wallet.execute({
499
+ invocation: innerInvocation,
500
+ gasLimit: walletGasLimit,
501
+ });
502
+ const receipt = await wallet.waitForTransactionReceipt(txHash);
503
+ ```
504
+
505
+ Use `prepareExecution` to inspect the wrapped transaction before signing. Both
506
+ execution methods accept `nonce`, `blockExpiryHeight`, `expiryBlocks`, and
507
+ `contractsToDeploy` overrides.
508
+
509
+ Native wallets deploy through one atomic operation with an explicit funding
510
+ amount and an optional initializer. Prepare the deployment identity first, then
511
+ compose an initializer using the generated contract binding:
512
+
513
+ ```ts
514
+ import { prepareContractDeployment } from "@thruputchain/client/wallet";
515
+ import { Counter } from "./generated/counter.js";
516
+
517
+ const deployment = prepareContractDeployment({
518
+ deployer: wallet.account.address,
519
+ contract: rv32Artifact,
520
+ });
521
+ const result = await wallet.deployContractAndWait(deployment, {
522
+ gasLimit: deploymentGas,
523
+ amount: authorizedFunding,
524
+ initializer: Counter.v0_1.initialize.invocation(deployment.address, initGas, {
525
+ initialValue: 42n,
526
+ }),
527
+ });
528
+ ```
529
+
530
+ `amount` is a raw native-token amount, chosen by the caller; `0n` skips the
531
+ transfer. The target's existing balance plus this amount must cover deployment
532
+ and initialized storage.
533
+ There is no automatic cost estimate or prefunding transaction. The initializer
534
+ must target the predicted address, sees the wallet as its caller, and returns no
535
+ value to the deployment client. An abort or fault rolls back all three steps.
536
+ Omit `initializer` when no call is required.
537
+
538
+ This API requires the unified native `DefaultWallet.v0_1.deploy` runtime ABI; older
539
+ nodes are unsupported and there is no two-transaction fallback. The legacy
540
+ DevWallet adapter supports calls, but rejects this deployment API. Provider
541
+ wallets accept the same deployment options and retain their explicit signing
542
+ and approval-persistence boundary.
543
+
544
+ The explicit root-invocation APIs remain available for advanced workflows:
545
+
546
+ ```ts
547
+ const transaction = await wallet.prepareTransaction({
548
+ invocation: rootInvocation,
549
+ expiryBlocks: 100n,
550
+ });
551
+ const signed = await wallet.signTransaction(transaction);
552
+ const { transactionHash: submittedHash } = await wallet.sendTransaction({
553
+ signedTransaction: serializeSignedTransaction(signed),
554
+ });
555
+
556
+ const txHash = await wallet.sendInvocation({ invocation: rootInvocation });
557
+ const receipt = await wallet.waitForTransactionReceipt(txHash);
558
+ ```
559
+
560
+ `prepareTransaction` accepts explicit `nonce`, `blockExpiryHeight`,
561
+ `expiryBlocks`, and `contractsToDeploy` overrides. Without overrides it uses a
562
+ cryptographically random 64-bit nonce and expires 100 blocks after the current
563
+ chain tip.
564
+
565
+ The SDK includes `defaultWalletAdapter` and `devWalletAdapter`. Custom account
566
+ contracts can publish their generated binding and a structural adapter without
567
+ changing the SDK:
568
+
569
+ ```ts
570
+ const customWalletAdapter = defineWalletInvocationAdapter({
571
+ createRootInvocation(accountAddress, request: CustomWalletRequest) {
572
+ return CustomWallet.v0_1.execute.invocation(
573
+ accountAddress,
574
+ request.gasLimit,
575
+ {
576
+ call: request.invocation,
577
+ policy: request.policy,
578
+ },
579
+ );
580
+ },
581
+ });
582
+ ```
583
+
584
+ Wallet binding returns an independent object without changing the supplied public
585
+ client. Multiple accounts can share one public client. Use `executeAndWait` to
586
+ require successful execution, or `executeCallsAndWait` to also decode ordered,
587
+ typed child results. Provider-backed helpers require `onSigned` to persist signed
588
+ evidence before broadcast. Generated API docs describe the full lifecycle.
589
+
590
+ ### Gas and storage funding
591
+
592
+ Gas is not burned, but the declared root budget reserves scheduling capacity
593
+ against the sender's free native-token balance. Funding a target contract's
594
+ storage does not fund the sender's capacity. Use measured budgets for each workload; `walletGasLimit`
595
+ sums explicit child budgets and a calibrated overhead, without estimating gas.
596
+
597
+ A new native-token balance item needs a deposit at the recipient address. A
598
+ large enough first credit can fund it; a small credit can be excluded with a scheduler
599
+ `retry` outcome. The transfer example funds both accounts first
600
+ because its 1,000-unit credit cannot cover a new balance item's deposit.
601
+
602
+ The live funding test verifies an excluded 1,000-unit first credit, a successful
603
+ 100,000-unit first credit with a deposit deduction, and a later 1,000-unit credit
604
+ without another balance-item deposit. It uses 500,000 child gas and 1,000,000 root
605
+ gas. Storage costs depend on runtime configuration.
606
+
607
+ A deployed contract's storage needs native tokens at its address too. The
608
+ native deployment API above transfers the explicit `amount` before deploying and optionally
609
+ initializing the contract in the same transaction. Size that amount for the code
610
+ and initialized storage, and budget root gas for the complete operation.
611
+
612
+ The standard ERC20 binding uses `adjustAllowance` with
613
+ `{ spender, difference }`, not `approve`. `difference` is signed: positive
614
+ increases the allowance, negative reduces it. Adjustments may merge with
615
+ concurrent spending and adjustments, so reading the current allowance and
616
+ submitting a delta cannot guarantee an exact target. To set an absolute
617
+ allowance, call `deleteAllowance({ spender })` and then `adjustAllowance` in
618
+ the same transaction: the delete's exclusive lock covers the following write,
619
+ so a concurrent change conflicts instead of interleaving. That lock does not
620
+ make an earlier off-chain read current. Interface 0.1.68 removed
621
+ `adjustAllowance`'s `exclusive` flag in favor of this pattern.
622
+ `deleteAllowance({ spender })` revokes an allowance, deletes its storage
623
+ entry, and emits `AllowanceDeleteEvent` with the stored amount removed.
624
+ `deleteBalance()` deletes the caller's empty balance entry and throws for a
625
+ nonzero balance. Allowance changes emit `AllowanceChangeEvent` with the signed
626
+ `difference`. Interface 0.1.68 has no `burn` method or `BurnEvent`, and amounts
627
+ are signed 128-bit integers in `0..=i128::MAX`.
628
+
629
+ A receipt proves commitment; inspect its `execution.result`. A `committed`
630
+ status always includes `blockHeight`, even when the receipt is not indexed yet.
631
+ `pending`, `retry`, and `dropped` can include a best-effort `recentFailure`
632
+ diagnostic with an `attemptBlockHeight` and `cause`. It may describe an earlier
633
+ attempt, not the scheduler's current attempt. The standalone `recentFailure`
634
+ status reports that diagnostic when the scheduler has no retained status.
635
+
636
+ The observer reports statuses through `onStatus` and retains them on timeout.
637
+ Once commitment is observed, later scheduler statuses cannot erase it. Failed
638
+ attempts, timeout, and cancellation do not prove nonexecution or permit automatic
639
+ resubmission. Preserve signed evidence and resume observing the original hash
640
+ instead of automatically re-signing.
641
+
642
+ ## Signed operations
643
+
644
+ A signed operation authorizes an on-chain action off-chain: the signer signs a
645
+ `#[contract_type]` payload together with the network, the verifying contract,
646
+ and a replay guard (a signer-chosen nonce plus an expiry height), and anyone
647
+ can submit it. The contract verifies it with the `thruput-signed-op` Rust
648
+ component against the key it holds; nothing on the wire names the signer. The
649
+ `@thruputchain/client/signed-op` entrypoint is the client half.
650
+
651
+ ```ts
652
+ import {
653
+ defineSignedOperation,
654
+ randomNonce,
655
+ } from "@thruputchain/client/signed-op";
656
+ import { spec, MyWallet, type my_wallet } from "./generated/my_wallet.js";
657
+
658
+ // Bind the payload type from the contract's generated spec. Its definition is
659
+ // part of the signed bytes, so a payload with the same encoding but a
660
+ // different type never shares a signature. When another crate or module also
661
+ // declares `Transfer`, pass its full spec id ({ crate_name, major,
662
+ // module_path, declared }) as `typeName` instead.
663
+ const transfer = defineSignedOperation<my_wallet.v0_1.Transfer>({
664
+ typeDefs: spec.type_defs,
665
+ typeName: "Transfer",
666
+ });
667
+
668
+ // Nothing on chain needs reading before signing: the contract consumes each
669
+ // (nonce, expiry) pair once, in any order, and forgets it after the expiry.
670
+ const { op, signature } = await transfer.sign(signer, {
671
+ network: networkHash,
672
+ verifyingContract: walletAddress,
673
+ blockExpiryHeight: currentHeight + 100n,
674
+ nonce: randomNonce(),
675
+ body: { to: recipient, amount: 42n },
676
+ });
677
+
678
+ // `op` and `signature` are the arguments of whichever entrypoint hands the
679
+ // operation to the verifying contract; the submitter need not be the signer.
680
+ const invocation = MyWallet.v0_1.submit.invocation(walletAddress, gasLimit, {
681
+ op,
682
+ signature,
683
+ });
684
+ ```
685
+
686
+ `signedOperationPreimage` exposes the exact bytes a signature covers, for
687
+ signers this package does not drive.
688
+
689
+ ## Examples
690
+
691
+ - [`chain-tip.ts`](https://github.com/thruputchain/thruput-sdk-ts/blob/main/examples/chain-tip.ts) connects to Futurenet and reads its latest block.
692
+ - [`transfer-native-token.ts`](https://github.com/thruputchain/thruput-sdk-ts/blob/main/examples/transfer-native-token.ts) funds two pubkey accounts and transfers native tokens on Futurenet.
693
+ - [`view-native-token-balance.ts`](https://github.com/thruputchain/thruput-sdk-ts/blob/main/examples/view-native-token-balance.ts) reads an explicitly supplied public account’s native-token balance.
694
+ - [`deploy-counter.ts`](https://github.com/thruputchain/thruput-sdk-ts/blob/main/examples/deploy-counter.ts) deploys and calls a Counter contract through DefaultWallet.
695
+
696
+ See the [examples guide](https://github.com/thruputchain/thruput-sdk-ts/blob/main/examples/README.md) for local-node setup and configuration.
697
+
698
+ Use the root entrypoint for the client and common runtime APIs. Focused
699
+ entrypoints are available for transactions, transports, contract runtime
700
+ helpers, generated standard contracts, signers, and standalone actions.
701
+
702
+ ## What's in this repo
703
+
704
+ - `src/client.ts` — async `createThruputClient` factory for unqualified and cluster-validated clients.
705
+ - `src/actions/` — RPC actions grouped by namespace:
706
+ - `public/` — chain, account, contract-view, event, and transaction queries.
707
+ - `wallet/` — write methods (`sendTransaction`).
708
+ - `src/transaction/` — transaction build, serialize, and sign helpers.
709
+ - `src/contract/` — reusable codecs, typed method and event descriptors, fixed-length values, and contract spec helpers.
710
+ - `src/contracts/` — generated standard contract bindings exported through `@thruputchain/client/contracts`.
711
+ - `src/transport/` — `HttpTransport` (JSON-RPC over HTTP) and `MockTransport` for tests.
712
+ - `src/signers/` — `Signer` interface, `Ed25519Signer` (ed25519 via `@noble/ed25519`), and `MlDsa65Signer` (ML-DSA-65 via `@noble/post-quantum`).
713
+ - `src/signedOp/` — off-chain signing of `SignedOp` operations: preimage construction and payload binding, plus the generated `SignedOp` binding re-exported from `src/contracts/signed_op.ts`.
714
+ - `src/types/rpc.ts` — typed RPC request/response shapes.
715
+ - `specs/native-openrpc.json` — Rust-owned native OpenRPC snapshot; `scripts/regen-openrpc.sh` refreshes it with recorded provenance. `npm run rpc:check` verifies generated codecs and types; `src/rpc/client.test.ts` checks every method’s named params and results.
716
+ - `docs/api/` — generated TypeDoc output from `npm run docs` (ignored by git; see [API docs](#api-docs)).
717
+ - `Caddyfile` and `Staticfile` — configure the private TypeDoc host that serves `docs/api/`; they are not part of the published package.
718
+
719
+ ## Subpath exports
720
+
721
+ The package exposes focused entry points alongside the root: `./transaction`,
722
+ `./transport`, `./contract`, `./contracts`, `./signers`, `./actions`,
723
+ `./signed-op`, `./wallet`, and `./provider`.
724
+
725
+ Browser wallets use the framework-neutral [wallet provider contract](https://docs.thruput.network/tools/wallet-provider/). See [Wallet Integration](https://docs.thruput.network/tools/wallet-integration/) for discovery, connection, and the prepare/sign/persist/submit flow.
726
+ `./provider` exports wire types, strict validation, and multi-wallet discovery.
727
+ `./wallet` exports the existing local-signer wallet API and
728
+ `createProviderWalletClient`, with separate prepare, sign, and submit steps so apps
729
+ can persist the canonical transaction hash before requesting broadcast.
730
+
731
+ ### Atomic batches with an external wallet
732
+
733
+ Providers can advertise `supportedMethods: ["getCapabilities"]` alongside
734
+ `info`, `request`, and `on`. This leaves existing session and identity objects
735
+ unchanged. Older SDKs ignore the optional discovery field. Without it, new SDKs
736
+ use legacy single-call behavior without sending an unknown request to the bridge.
737
+
738
+ `getCapabilities` takes `{ account, networkHash }` and returns the same scope
739
+ plus `atomicBatch: { maxCalls }`, or `atomicBatch: null` when unsupported.
740
+ The current DefaultWallet limit is 16 calls. The provider must verify origin,
741
+ account, and network authorization without prompting. Error 4200 also means
742
+ unsupported; other failures and malformed responses remain errors.
743
+
744
+ An external `ProviderWalletClient` exposes `getCapabilities()` and
745
+ `prepareBatchExecution({ invocations, gasLimit, ...transactionOptions })`.
746
+ The adapter rechecks the session and capability limit when preparing a batch.
747
+ It creates one root DefaultWallet execution and copies the ordered call inputs
748
+ before asynchronous work. Each call has its own gas limit; the root budget must
749
+ cover the calls and wallet overhead.
750
+
751
+ Use the existing sign, persist, and submit sequence for the resulting transaction.
752
+ Decode the root receipt with `DefaultWallet.v0_1.execute.decodeReceipt(receipt)`;
753
+ its `value` contains one return payload per call, in order. Decode each payload
754
+ with that call's generated `decodeReturn` method. A failed inner call rolls back
755
+ the batch. A successfully enqueued request can still fail during later queue
756
+ processing, which is a separate transaction and outcome.
757
+
758
+ Choose legacy execution before signing when batching is unsupported. Never turn
759
+ a rejection or uncertain batch submission into automatic individual retries.
760
+ Recover an uncertain submission through its original saved transaction hash.
761
+
762
+ ## Documentation
763
+
764
+ - [TypeScript SDK guide](https://docs.thruput.network/tools/typescript-sdk/) and the
765
+ [end-to-end tutorial](https://docs.thruput.network/tutorials/work-with-thruput-from-typescript/)
766
+ on the Thruput developer site.
767
+ - [JSON-RPC API reference](https://docs.thruput.network/reference/json-rpc-api/) for the
768
+ methods behind each action.
769
+ - The TypeDoc API reference is generated from this package's entry points with
770
+ `npm run docs` (see [API docs](#api-docs)).
771
+
772
+ ## API docs
773
+
774
+ Generate local API reference docs with TypeDoc:
775
+
776
+ ```sh
777
+ npm run docs
778
+ ```
779
+
780
+ The generated HTML is written to `docs/api/`. That directory is ignored and should not be committed.
781
+
782
+ To validate that API docs still build without writing output:
783
+
784
+ ```sh
785
+ npm run docs:check
786
+ ```
787
+
788
+ The API reference is generated from the package's public entry points, matching the root and subpath exports listed above.
789
+
790
+ ## Developing
791
+
792
+ ### Registry auth (one-time setup)
793
+
794
+ The `@thruputchain/*` dependencies are hosted on GitHub Packages, which
795
+ requires a GitHub token even to download — a plain `npm install` on a fresh
796
+ machine fails with `401 Unauthorized` from `npm.pkg.github.com`. To set up
797
+ auth using the `gh` CLI:
798
+
799
+ ```sh
800
+ # Add the read:packages scope to your gh login (one-time, opens github.com)
801
+ gh auth refresh -h github.com -s read:packages
802
+ ```
803
+
804
+ Then add this line to `~/.npmrc` (it holds no secret — npm expands
805
+ `${ENV_VARS}` from the environment; it cannot run commands like
806
+ `$(gh auth token)` itself):
807
+
808
+ ```
809
+ @thruputchain:registry=https://npm.pkg.github.com
810
+ //npm.pkg.github.com/:_authToken=${GH_NPM_TOKEN}
811
+ ```
812
+
813
+ And run installs with the token pulled from gh's keychain:
814
+
815
+ ```sh
816
+ GH_NPM_TOKEN="$(gh auth token)" npm install
817
+ ```
818
+
819
+ If you forget the prefix, npm fails with `Failed to replace env in config` —
820
+ that's your reminder.
821
+
822
+ ## Scripts
823
+
824
+ - `npm run build` — bundle ESM, CommonJS, source maps, and declarations with `tsdown`.
825
+ - `npm test` / `npm run test:watch` — run `vitest`.
826
+ - `npm run typecheck` — `tsc --noEmit`.
827
+ - `npm run test:package-boundary` — compile a consumer fixture against the built package declarations.
828
+ - `npm run test:smoke` — load every built package entrypoint as ESM and CommonJS.
829
+ - `npm run test:integration` — build the package and test it against an isolated real local node (Linux).
830
+ - `npm run test:integration:cli-transfer` — build the package and read back a CLI transfer from an existing node.
831
+ - `npm run contracts:generate` — regenerate all checked-in contract bindings from pinned specs.
832
+ - `npm run contracts:check` — verify generated bindings match their pinned specs and generator.
833
+ - `npm run docs` — generate TypeDoc API reference HTML in `docs/api/`.
834
+ - `npm run docs:check` — validate TypeDoc generation without writing output.
835
+ - `npm run format` / `format:check` — `prettier`.
836
+
837
+ ### Live integration tests
838
+
839
+ The wallet provider contract is now version `2.0.0`. Account addresses, public
840
+ keys, network hashes and transaction hashes use case-sensitive, unprefixed
841
+ base58. Transaction and signed-transaction XDR remain canonical `0x` hex,
842
+ with binary signatures intact.
843
+
844
+ Run on Linux with Node 24. CI installs the published CLI crate and public devnode
845
+ artifact pinned in
846
+ [`scripts/integration-versions.json`](scripts/integration-versions.json): CLI
847
+ 0.39.0, devnode 0.1.31-rc.16 and wire 14.1.1. CI qualification uses the crate-built
848
+ CLI; it does not verify a packaged CLI bundle. Locally, install that CLI version on
849
+ `PATH` or set `THRUPUT_CLI` to its executable. The harness installs the pinned
850
+ devnode when no runtime override is supplied.
851
+
852
+ ```sh
853
+ npm run test:integration
854
+ ```
855
+
856
+ The harness checks that the executable runs and starts a fresh node on an OS-assigned
857
+ loopback port. The host must provide the devnode's native runtime libraries;
858
+ CI uses the same Ubuntu 26.04 Namespace profile as the RPC repository. Tests
859
+ import the built package and check connection, local funding, a native-token
860
+ transfer, receipts, events, contract views, and RPC errors. `npm test` remains node-independent.
861
+
862
+ The tools smoke harness can also create a transfer and run the SDK readback
863
+ check against its existing node:
864
+
865
+ ```sh
866
+ THRUPUT_CLI_TRANSFER_RESULT=/absolute/path/to/result.json npm run test:integration:cli-transfer
867
+ ```
868
+
869
+ This command reads the harness's transfer evidence and checks the receipt,
870
+ event, balance and network identity. The tools harness owns the node lifecycle;
871
+ the normal integration command always starts its own node and runs its suite.
872
+
873
+ The transfer workflow also checks grouped reads and view freshness, an
874
+ authenticated wallet simulation, and recovery of admitted local-funding bytes
875
+ after a lost response. This profile requires wire 14.1.1, base58 identifiers
876
+ and ML-DSA-65 pubkey accounts.
877
+
878
+ An explicit `THRUPUT_CLI` must match the configured version and any configured
879
+ source pin. The harness verifies the serving RPC version and wire version, and
880
+ checks source identity when a source pin is configured.
881
+ For an unpinned local candidate, set `THRUPUT_ALLOW_LOCAL_CANDIDATE=1` together
882
+ with `THRUPUT_CLI`. Runtime, wire and protocol overrides also require this mode;
883
+ CI rejects them. An explicit devnode skips runtime installation. Use
884
+ `HOGD_PROTOCOL_OVERRIDE` only for a compatible runtime with a different handshake
885
+ token. Qualification logs record these deviations.
886
+
887
+ The harness isolates configuration and state, stops its child processes, and
888
+ retains logs and node state on failure at the printed temporary path. Set
889
+ `THRUPUT_INTEGRATION_LOG_DIR` to retain logs at a chosen location; CI uploads
890
+ them as `live-node-logs`.
891
+
892
+ The matching devnode must support unified native deployment. The standard integration
893
+ run requires atomic funding, deployment, initialization and state readback to
894
+ pass. To qualify another matching runtime, start a disposable node and run the
895
+ built package tests against its reported URL and manifest:
896
+
897
+ ```sh
898
+ npm run build
899
+ THRUPUT_RPC_URL=http://127.0.0.1:9545 \
900
+ THRUPUT_RUNTIME_MANIFEST=/absolute/path/to/runtime-manifest.json \
901
+ node --test --test-concurrency=1 tests/integration/live-node.test.mjs
902
+ ```
903
+
904
+ Client creation checks network identity, wire version and supported methods.
905
+ The tests fail on unsupported runtimes; they do not fall back.
906
+
907
+ Block-query qualification uses the same CLI and runtime pins.
908
+ It starts an isolated interval-driven node, submits known
909
+ transactions, compares both page orders with their receipts, checks empty blocks,
910
+ parent linkage and the canonical tip hash, and rejects zero limits:
911
+
912
+ ```sh
913
+ npm run test:integration:blocks
914
+ ```
915
+
916
+ Use the same optional `HOGD_PROTOCOL_OVERRIDE` rule as above. This profile requires
917
+ wire 14.1.1 and fails on unsupported nodes. The final native tools/runtime artifact
918
+ set must pass both profiles before this SDK is released. Unit tests do not qualify
919
+ a live node. `scripts/regen-openrpc.sh` imports a reviewed Rust-generated wire-14
920
+ snapshot or generator via explicit source path and commit; it does not install an
921
+ older released generator.
922
+
923
+ For local funding recovery, retain the original request before sending it.
924
+ A known `localFundingUnresolved` error can preserve `transactionHash` and exact
925
+ `signedTransaction` evidence. Inspect the hash through read-only status/receipt
926
+ calls. Neither an uncertain response nor a later rejection authorizes a new nonce,
927
+ replacement transaction or automatic funding repeat.
928
+
929
+ ## Publishing
930
+
931
+ The manual release workflow targets public npm and defaults to dry-run.
932
+ See [RELEASING.md](RELEASING.md) for authentication, release order, and retries.
933
+ Repository installs retain GitHub Packages during the first npm release;
934
+ consumer registry settings and lockfiles switch after all seven packages exist.
935
+
936
+ Published versions are immutable. Use a new version for each release.