viz-js-lib 0.11.0 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.qoder/docs/spec/viz-dns-nameserver-spec.md +982 -0
  2. package/.qoder/docs/viz-cpp-node-docs/data-types.md +322 -0
  3. package/.qoder/docs/viz-cpp-node-docs/index.md +160 -0
  4. package/.qoder/docs/viz-cpp-node-docs/op-account-market.md +236 -0
  5. package/.qoder/docs/viz-cpp-node-docs/op-account.md +199 -0
  6. package/.qoder/docs/viz-cpp-node-docs/op-award.md +162 -0
  7. package/.qoder/docs/viz-cpp-node-docs/op-committee.md +193 -0
  8. package/.qoder/docs/viz-cpp-node-docs/op-content.md +157 -0
  9. package/.qoder/docs/viz-cpp-node-docs/op-escrow.md +224 -0
  10. package/.qoder/docs/viz-cpp-node-docs/op-invite.md +219 -0
  11. package/.qoder/docs/viz-cpp-node-docs/op-proposal.md +229 -0
  12. package/.qoder/docs/viz-cpp-node-docs/op-recovery.md +188 -0
  13. package/.qoder/docs/viz-cpp-node-docs/op-subscription.md +146 -0
  14. package/.qoder/docs/viz-cpp-node-docs/op-transfer-vesting.md +224 -0
  15. package/.qoder/docs/viz-cpp-node-docs/op-witness.md +252 -0
  16. package/.qoder/docs/viz-cpp-node-docs/plugins.md +887 -0
  17. package/.qoder/docs/viz-cpp-node-docs/virtual-operations.md +513 -0
  18. package/.qoder/repowiki/en/content/API Reference/API Reference.md +724 -0
  19. package/.qoder/repowiki/en/content/API Reference/Configuration Options.md +410 -0
  20. package/.qoder/repowiki/en/content/API Reference/Core API Methods.md +547 -0
  21. package/.qoder/repowiki/en/content/API Reference/Streaming APIs.md +380 -0
  22. package/.qoder/repowiki/en/content/API Reference/Transport Layer.md +341 -0
  23. package/.qoder/repowiki/en/content/API Reference/VIZ Blockchain Operations Coverage Status.md +427 -0
  24. package/.qoder/repowiki/en/content/Authentication & Cryptography/Authentication & Cryptography.md +430 -0
  25. package/.qoder/repowiki/en/content/Authentication & Cryptography/Digital Signatures.md +462 -0
  26. package/.qoder/repowiki/en/content/Authentication & Cryptography/Key Management.md +456 -0
  27. package/.qoder/repowiki/en/content/Authentication & Cryptography/Memo Encryption.md +331 -0
  28. package/.qoder/repowiki/en/content/Authentication & Cryptography/Security Practices.md +488 -0
  29. package/.qoder/repowiki/en/content/Broadcast Transactions/Broadcast Transactions.md +432 -0
  30. package/.qoder/repowiki/en/content/Broadcast Transactions/Network Broadcasting.md +418 -0
  31. package/.qoder/repowiki/en/content/Broadcast Transactions/Operation Construction.md +352 -0
  32. package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Preparation.md +353 -0
  33. package/.qoder/repowiki/en/content/Broadcast Transactions/Transaction Signing.md +404 -0
  34. package/.qoder/repowiki/en/content/Data Serialization/Data Serialization.md +540 -0
  35. package/.qoder/repowiki/en/content/Data Serialization/Encoding & Decoding.md +463 -0
  36. package/.qoder/repowiki/en/content/Data Serialization/Object Templates.md +413 -0
  37. package/.qoder/repowiki/en/content/Data Serialization/Type System.md +514 -0
  38. package/.qoder/repowiki/en/content/Data Serialization/Validation Rules.md +439 -0
  39. package/.qoder/repowiki/en/content/Examples & Tutorials.md +485 -0
  40. package/.qoder/repowiki/en/content/Getting Started.md +345 -0
  41. package/.qoder/repowiki/en/content/Testing & Development.md +637 -0
  42. package/.qoder/repowiki/en/content/Utilities & Helpers.md +557 -0
  43. package/.qoder/repowiki/en/meta/repowiki-metadata.json +1 -0
  44. package/VIZ-JS-LIB-COVERAGE-STATUS.md +356 -0
  45. package/config.json +3 -1
  46. package/dist/statistics.html +1 -1
  47. package/dist/viz-tests.min.js +32 -42
  48. package/dist/viz-tests.min.js.gz +0 -0
  49. package/dist/viz.min.js +8 -18
  50. package/dist/viz.min.js.gz +0 -0
  51. package/lib/api/methods.js +24 -0
  52. package/lib/auth/serializer/src/ChainTypes.js +2 -1
  53. package/lib/auth/serializer/src/operations.js +35 -2
  54. package/lib/broadcast/index.js +29 -15
  55. package/lib/broadcast/operations.js +4 -0
  56. package/lib/dns.js +658 -0
  57. package/lib/index.js +3 -1
  58. package/package.json +3 -2
  59. package/test/dns.test.js +395 -0
  60. package/webpack/makeConfig.js +3 -0
@@ -0,0 +1,353 @@
1
+ # Transaction Preparation
2
+
3
+ <cite>
4
+ **Referenced Files in This Document**
5
+ - [src/broadcast/index.js](file://src/broadcast/index.js)
6
+ - [src/broadcast/operations.js](file://src/broadcast/operations.js)
7
+ - [src/api/methods.js](file://src/api/methods.js)
8
+ - [src/api/index.js](file://src/api/index.js)
9
+ - [src/api/transports/http.js](file://src/api/transports/http.js)
10
+ - [src/auth/index.js](file://src/auth/index.js)
11
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js)
12
+ - [src/config.js](file://src/config.js)
13
+ - [config.json](file://config.json)
14
+ - [test/broadcast.test.js](file://test/broadcast.test.js)
15
+ </cite>
16
+
17
+ ## Table of Contents
18
+ 1. [Introduction](#introduction)
19
+ 2. [Project Structure](#project-structure)
20
+ 3. [Core Components](#core-components)
21
+ 4. [Architecture Overview](#architecture-overview)
22
+ 5. [Detailed Component Analysis](#detailed-component-analysis)
23
+ 6. [Dependency Analysis](#dependency-analysis)
24
+ 7. [Performance Considerations](#performance-considerations)
25
+ 8. [Troubleshooting Guide](#troubleshooting-guide)
26
+ 9. [Conclusion](#conclusion)
27
+
28
+ ## Introduction
29
+ This document explains the transaction preparation functionality in the VIZ broadcast system with a focus on the `_prepareTransaction` method. It covers dynamic global properties retrieval, block reference number assignment, automatic blockchain state detection, irreversible block handling, fallback mechanisms, transaction expiration calculation, chain date synchronization, and buffer handling for block prefix extraction. Practical examples, error scenarios, and performance considerations are included for different blockchain states.
30
+
31
+ ## Project Structure
32
+ The broadcast system is composed of:
33
+ - Broadcast layer: orchestrates transaction preparation, signing, and broadcasting
34
+ - API layer: exposes blockchain methods and transports
35
+ - Authentication layer: handles transaction signing and key management
36
+ - Configuration: centralizes runtime settings
37
+
38
+ ```mermaid
39
+ graph TB
40
+ subgraph "Broadcast Layer"
41
+ BR["_prepareTransaction<br/>send"]
42
+ end
43
+ subgraph "API Layer"
44
+ API["nodeApi<br/>getDynamicGlobalPropertiesAsync<br/>getBlockAsync"]
45
+ METHODS["methods.js<br/>API method definitions"]
46
+ HTTP["HttpTransport<br/>jsonRpc"]
47
+ end
48
+ subgraph "Auth Layer"
49
+ AUTH["nodeAuth.signTransaction"]
50
+ SER["Serializer<br/>transaction/singed_transaction"]
51
+ end
52
+ CFG["config.js<br/>config.json"]
53
+ BR --> API
54
+ API --> HTTP
55
+ BR --> AUTH
56
+ AUTH --> SER
57
+ BR --> CFG
58
+ API --> METHODS
59
+ ```
60
+
61
+ **Diagram sources**
62
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
63
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
64
+ - [src/api/methods.js](file://src/api/methods.js#L183-L189)
65
+ - [src/api/transports/http.js](file://src/api/transports/http.js#L17-L52)
66
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
67
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
68
+ - [src/config.js](file://src/config.js#L1-L10)
69
+ - [config.json](file://config.json#L1-L7)
70
+
71
+ **Section sources**
72
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L1-L137)
73
+ - [src/api/index.js](file://src/api/index.js#L1-L271)
74
+ - [src/api/methods.js](file://src/api/methods.js#L1-L435)
75
+ - [src/api/transports/http.js](file://src/api/transports/http.js#L1-L53)
76
+ - [src/auth/index.js](file://src/auth/index.js#L1-L133)
77
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L1-L200)
78
+ - [src/config.js](file://src/config.js#L1-L10)
79
+ - [config.json](file://config.json#L1-L7)
80
+
81
+ ## Core Components
82
+ - Broadcast module: provides the `_prepareTransaction` method and the public `send` flow. It integrates with the API layer for dynamic global properties and block retrieval, and with the auth layer for signing.
83
+ - API module: exposes methods like `getDynamicGlobalPropertiesAsync` and `getBlockAsync`, and manages transports (HTTP/WebSocket).
84
+ - Auth module: signs transactions using chain ID and private keys, producing signed transactions.
85
+ - Serializer: defines transaction and signed_transaction structures used during signing and broadcasting.
86
+ - Configuration: holds runtime settings such as the websocket URL and broadcast behavior.
87
+
88
+ **Section sources**
89
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L16-L137)
90
+ - [src/api/index.js](file://src/api/index.js#L21-L271)
91
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
92
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
93
+ - [src/config.js](file://src/config.js#L1-L10)
94
+
95
+ ## Architecture Overview
96
+ The transaction preparation pipeline:
97
+ 1. Retrieve dynamic global properties to synchronize with the chain time and determine the best block reference strategy.
98
+ 2. If irreversible block reference is available, use it; otherwise, compute a reference from the head block with a fallback mechanism.
99
+ 3. Assign expiration based on the synchronized chain time plus a fixed buffer.
100
+ 4. Sign the prepared transaction with the provided private keys.
101
+ 5. Broadcast the signed transaction via the configured transport.
102
+
103
+ ```mermaid
104
+ sequenceDiagram
105
+ participant Client as "Client"
106
+ participant BR as "_prepareTransaction"
107
+ participant API as "nodeApi"
108
+ participant HTTP as "HttpTransport"
109
+ participant AUTH as "nodeAuth"
110
+ participant CFG as "config"
111
+ Client->>BR : "_prepareTransaction(tx)"
112
+ BR->>API : "getDynamicGlobalPropertiesAsync()"
113
+ API->>HTTP : "jsonRpc(...)"
114
+ HTTP-->>API : "dynamic properties"
115
+ API-->>BR : "properties {time, head_block_number,<br/>last_irreversible_block_ref_num,<br/>last_irreversible_block_ref_prefix}"
116
+ alt "Irreversible reference available"
117
+ BR-->>BR : "Set ref_block_num/ref_block_prefix from properties"
118
+ else "Fallback to head block"
119
+ BR->>API : "getBlockAsync(head_block_number - 2)"
120
+ API->>HTTP : "jsonRpc(...)"
121
+ HTTP-->>API : "block header"
122
+ API-->>BR : "block {previous}"
123
+ BR-->>BR : "Compute ref_block_num and ref_block_prefix"
124
+ end
125
+ BR-->>BR : "Set expiration = chainTime + buffer"
126
+ BR-->>Client : "Prepared transaction"
127
+ Client->>AUTH : "signTransaction(preparedTx, keys)"
128
+ AUTH-->>Client : "Signed transaction"
129
+ Client->>CFG : "get('broadcast_transaction_with_callback')"
130
+ alt "With callback"
131
+ Client->>API : "broadcastTransactionWithCallbackAsync(...)"
132
+ else "Without callback"
133
+ Client->>API : "broadcastTransactionAsync(...)"
134
+ end
135
+ API->>HTTP : "jsonRpc(...)"
136
+ HTTP-->>API : "Success"
137
+ API-->>Client : "Transaction broadcasted"
138
+ ```
139
+
140
+ **Diagram sources**
141
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
142
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
143
+ - [src/api/methods.js](file://src/api/methods.js#L163-L189)
144
+ - [src/api/transports/http.js](file://src/api/transports/http.js#L17-L52)
145
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
146
+ - [src/config.js](file://src/config.js#L1-L10)
147
+ - [config.json](file://config.json#L1-L7)
148
+
149
+ ## Detailed Component Analysis
150
+
151
+ ### _prepareTransaction Method Implementation
152
+ The `_prepareTransaction` method performs the following steps:
153
+ - Retrieves dynamic global properties to obtain the chain time and block metadata.
154
+ - Detects blockchain state:
155
+ - If `last_irreversible_block_ref_num` is present and non-zero, use it as the reference.
156
+ - Otherwise, compute a reference from the head block with a fallback.
157
+ - Computes the reference block number and prefix:
158
+ - Reference block number is derived from the head block number minus a fixed offset and masked to 16-bit range.
159
+ - Reference block prefix is extracted from the previous block’s ID using a 32-bit little-endian read at a specific offset.
160
+ - Sets expiration:
161
+ - Expiration is computed as the chain time plus a fixed buffer (typically a small number of minutes).
162
+ - Returns the prepared transaction augmented with reference fields and expiration.
163
+
164
+ ```mermaid
165
+ flowchart TD
166
+ Start(["Entry: _prepareTransaction(tx)"]) --> GetProps["Call getDynamicGlobalPropertiesAsync()"]
167
+ GetProps --> PropsOK{"Properties received?"}
168
+ PropsOK --> |No| Error["Reject with error"]
169
+ PropsOK --> |Yes| CheckIR["Check last_irreversible_block_ref_num"]
170
+ CheckIR --> IRPresent{"Is present and non-zero?"}
171
+ IRPresent --> |Yes| UseIR["Use last_irreversible_block_ref_num<br/>and last_irreversible_block_ref_prefix"]
172
+ IRPresent --> |No| ComputeHead["Compute ref_block_num from head_block_number"]
173
+ ComputeHead --> FetchBlock["Call getBlockAsync(head_block_number - 2)"]
174
+ FetchBlock --> BlockOK{"Block fetched?"}
175
+ BlockOK --> |No| Fallback["Fallback to default behavior"]
176
+ BlockOK --> |Yes| ExtractPrefix["Extract ref_block_prefix from block.previous"]
177
+ UseIR --> SetExp["Set expiration = chainTime + buffer"]
178
+ ExtractPrefix --> SetExp
179
+ Fallback --> SetExp
180
+ SetExp --> ReturnTx["Return prepared transaction"]
181
+ Error --> End(["Exit"])
182
+ ReturnTx --> End
183
+ ```
184
+
185
+ **Diagram sources**
186
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
187
+ - [src/api/methods.js](file://src/api/methods.js#L183-L189)
188
+
189
+ **Section sources**
190
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
191
+
192
+ ### Dynamic Global Properties Retrieval
193
+ - The method calls `getDynamicGlobalPropertiesAsync()` to obtain:
194
+ - Chain time (`time`) for synchronization.
195
+ - Head block number (`head_block_number`) for computing references.
196
+ - Last irreversible block reference fields (`last_irreversible_block_ref_num`, `last_irreversible_block_ref_prefix`) for immediate use when available.
197
+ - These properties are essential for accurate reference assignment and expiration calculation.
198
+
199
+ **Section sources**
200
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L50-L54)
201
+ - [src/api/methods.js](file://src/api/methods.js#L183-L189)
202
+
203
+ ### Block Reference Number Assignment
204
+ - Irreversible reference path:
205
+ - If `last_irreversible_block_ref_num` is available and non-zero, the method sets:
206
+ - `ref_block_num` to the irreversible reference number.
207
+ - `ref_block_prefix` to the corresponding prefix.
208
+ - Fallback path:
209
+ - If no irreversible reference is available, the method:
210
+ - Computes `ref_block_num` as `(head_block_number - 3) & 0xFFFF`.
211
+ - Retrieves the block at `head_block_number - 2` and extracts `ref_block_prefix` from the previous block ID using a 32-bit little-endian read at a specific offset.
212
+ - This ensures transactions remain valid even when the chain is not immediately producing irreversible blocks.
213
+
214
+ **Section sources**
215
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L56-L82)
216
+
217
+ ### Automatic Blockchain State Detection and Fallback Mechanisms
218
+ - State detection:
219
+ - The method checks for the presence and validity of `last_irreversible_block_ref_num`. If present and non-zero, it prioritizes the irreversible reference.
220
+ - Fallback:
221
+ - If the irreversible reference is unavailable, the method falls back to computing a reference from the head block, retrieving the appropriate block header and extracting the prefix.
222
+ - This design ensures robustness across different network conditions and chain states.
223
+
224
+ **Section sources**
225
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L56-L82)
226
+
227
+ ### Transaction Expiration Calculation and Chain Date Synchronization
228
+ - Chain date synchronization:
229
+ - The chain time is parsed from the dynamic properties and used as the baseline for expiration.
230
+ - Expiration calculation:
231
+ - Expiration is set as the chain time plus a fixed buffer (e.g., a small number of minutes).
232
+ - This guarantees that the transaction remains valid for a short period after preparation while preventing indefinite validity.
233
+
234
+ **Section sources**
235
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L54-L66)
236
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L76-L79)
237
+
238
+ ### Buffer Handling for Block Prefix Extraction
239
+ - The method extracts the reference block prefix from the previous block ID by reading a 32-bit unsigned integer in little-endian order at a specific offset.
240
+ - This ensures the prefix aligns with the blockchain’s expected format for transaction references.
241
+
242
+ **Section sources**
243
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L75)
244
+
245
+ ### Practical Examples of Transaction Preparation Workflows
246
+ - Preparing a vote transaction:
247
+ - The broadcast layer generates a specialized operation wrapper that constructs the transaction with the required fields and then calls `_prepareTransaction`.
248
+ - After preparation, the transaction is signed and broadcast.
249
+ - Broadcasting with callback:
250
+ - The configuration controls whether to use synchronous or callback-based broadcasting. The broadcast layer conditionally selects the appropriate API method.
251
+
252
+ **Section sources**
253
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L97-L129)
254
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L24-L47)
255
+ - [src/broadcast/operations.js](file://src/broadcast/operations.js#L1-L475)
256
+ - [test/broadcast.test.js](file://test/broadcast.test.js#L33-L52)
257
+ - [test/broadcast.test.js](file://test/broadcast.test.js#L75-L120)
258
+
259
+ ### Error Scenarios and Resilience
260
+ - Missing irreversible reference:
261
+ - The method gracefully falls back to computing a reference from the head block and retrieving the block header.
262
+ - Network failures:
263
+ - API calls may fail; the broadcast flow relies on promises and should propagate errors appropriately.
264
+ - Invalid or missing properties:
265
+ - The method checks for the presence of required fields and applies fallback logic when necessary.
266
+
267
+ **Section sources**
268
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L56-L82)
269
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
270
+
271
+ ### Signing and Broadcasting Integration
272
+ - Signing:
273
+ - The prepared transaction is passed to the authentication layer for signing using the chain ID and provided private keys.
274
+ - Broadcasting:
275
+ - The broadcast layer selects the appropriate API method based on configuration and sends the signed transaction via the configured transport.
276
+
277
+ **Section sources**
278
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L31-L44)
279
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
280
+ - [src/config.js](file://src/config.js#L1-L10)
281
+ - [config.json](file://config.json#L1-L7)
282
+
283
+ ## Dependency Analysis
284
+ The transaction preparation process depends on:
285
+ - API methods for dynamic properties and block retrieval.
286
+ - HTTP transport for JSON-RPC requests.
287
+ - Authentication for signing.
288
+ - Configuration for transport selection and broadcast behavior.
289
+
290
+ ```mermaid
291
+ graph LR
292
+ BR["_prepareTransaction"] --> API["nodeApi"]
293
+ API --> METHODS["methods.js"]
294
+ API --> HTTP["HttpTransport"]
295
+ BR --> AUTH["nodeAuth.signTransaction"]
296
+ AUTH --> SER["Serializer"]
297
+ BR --> CFG["config.js"]
298
+ CFG --> CJSON["config.json"]
299
+ ```
300
+
301
+ **Diagram sources**
302
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
303
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
304
+ - [src/api/methods.js](file://src/api/methods.js#L183-L189)
305
+ - [src/api/transports/http.js](file://src/api/transports/http.js#L17-L52)
306
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
307
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
308
+ - [src/config.js](file://src/config.js#L1-L10)
309
+ - [config.json](file://config.json#L1-L7)
310
+
311
+ **Section sources**
312
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
313
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
314
+ - [src/api/methods.js](file://src/api/methods.js#L183-L189)
315
+ - [src/api/transports/http.js](file://src/api/transports/http.js#L17-L52)
316
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
317
+ - [src/auth/serializer/src/operations.js](file://src/auth/serializer/src/operations.js#L73-L125)
318
+ - [src/config.js](file://src/config.js#L1-L10)
319
+ - [config.json](file://config.json#L1-L7)
320
+
321
+ ## Performance Considerations
322
+ - Minimizing API calls:
323
+ - Prefer using the irreversible reference when available to avoid an extra block retrieval.
324
+ - Batch operations:
325
+ - Group multiple operations into a single transaction to reduce overhead.
326
+ - Transport selection:
327
+ - Use HTTP for environments where WebSocket is not feasible; ensure the endpoint is reliable.
328
+ - Expiration buffer:
329
+ - Keep the expiration buffer small to prevent stale transactions while allowing sufficient time for signing and broadcasting.
330
+ - Serialization overhead:
331
+ - Reuse prepared transactions when possible and avoid unnecessary re-serialization.
332
+
333
+ [No sources needed since this section provides general guidance]
334
+
335
+ ## Troubleshooting Guide
336
+ - Transactions rejected due to invalid reference:
337
+ - Verify that the reference block number and prefix are correctly computed from the chain state.
338
+ - Expiration errors:
339
+ - Ensure the chain time is synchronized and the expiration buffer is adequate.
340
+ - Broadcasting failures:
341
+ - Check the transport configuration and network connectivity; confirm the endpoint URL is correct.
342
+ - Signing issues:
343
+ - Confirm that the chain ID matches the target network and that private keys are valid.
344
+
345
+ **Section sources**
346
+ - [src/broadcast/index.js](file://src/broadcast/index.js#L49-L84)
347
+ - [src/api/index.js](file://src/api/index.js#L98-L119)
348
+ - [src/auth/index.js](file://src/auth/index.js#L107-L130)
349
+ - [src/config.js](file://src/config.js#L1-L10)
350
+ - [config.json](file://config.json#L1-L7)
351
+
352
+ ## Conclusion
353
+ The `_prepareTransaction` method provides a robust, state-aware mechanism for preparing VIZ transactions. By leveraging dynamic global properties, detecting irreversible block availability, and applying fallback logic, it ensures transactions remain valid across varying blockchain conditions. Proper configuration, signing, and broadcasting integrate seamlessly to deliver a reliable end-to-end workflow.