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