@tari-project/tarijs 0.4.1 → 0.5.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 (108) hide show
  1. package/.github/workflows/ci.yml +2 -1
  2. package/.github/workflows/documentation-deploy.yml +44 -0
  3. package/.github/workflows/documentation-test-deploy.yml +20 -0
  4. package/.moon/workspace.yml +1 -0
  5. package/README.md +19 -0
  6. package/TODO.md +2 -6
  7. package/docusaurus/tari-docs/README.md +41 -0
  8. package/docusaurus/tari-docs/docs/index.md +21 -0
  9. package/docusaurus/tari-docs/docs/installation.md +27 -0
  10. package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
  11. package/docusaurus/tari-docs/docs/providers/indexer-provider.md +32 -0
  12. package/docusaurus/tari-docs/docs/signers/_category_.json +8 -0
  13. package/docusaurus/tari-docs/docs/signers/tari-universe.md +27 -0
  14. package/docusaurus/tari-docs/docs/signers/wallet-connect.md +51 -0
  15. package/docusaurus/tari-docs/docs/signers/wallet-daemon.md +37 -0
  16. package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
  17. package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
  18. package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
  19. package/docusaurus/tari-docs/docs/wallet/list-substates.md +68 -0
  20. package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
  21. package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
  22. package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
  23. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
  24. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
  25. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
  26. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
  27. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
  28. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
  29. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
  30. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
  31. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
  32. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
  33. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
  34. package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
  35. package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
  36. package/docusaurus/tari-docs/moon.yml +41 -0
  37. package/docusaurus/tari-docs/package.json +49 -0
  38. package/docusaurus/tari-docs/sidebars.ts +7 -0
  39. package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
  40. package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
  41. package/docusaurus/tari-docs/src/css/custom.css +30 -0
  42. package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
  43. package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
  44. package/docusaurus/tari-docs/static/.nojekyll +0 -0
  45. package/docusaurus/tari-docs/static/img/favicon.png +0 -0
  46. package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
  47. package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
  48. package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
  49. package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
  50. package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
  51. package/docusaurus/tari-docs/tsconfig.json +10 -0
  52. package/package.json +1 -1
  53. package/packages/builders/package.json +3 -3
  54. package/packages/builders/src/helpers/submitTransaction.ts +8 -8
  55. package/packages/builders/tsconfig.json +2 -4
  56. package/packages/indexer_provider/package.json +31 -0
  57. package/packages/indexer_provider/src/index.ts +2 -0
  58. package/packages/indexer_provider/src/provider.ts +105 -0
  59. package/packages/indexer_provider/src/transports/IndexerProviderClient.ts +144 -0
  60. package/packages/indexer_provider/src/transports/fetch.ts +46 -0
  61. package/packages/indexer_provider/src/transports/index.ts +3 -0
  62. package/packages/indexer_provider/src/transports/rpc.ts +19 -0
  63. package/packages/indexer_provider/tsconfig.json +22 -0
  64. package/packages/metamask_signer/moon.yml +55 -0
  65. package/packages/{metamask_provider → metamask_signer}/package.json +3 -3
  66. package/packages/{metamask_provider → metamask_signer}/src/index.ts +11 -6
  67. package/packages/metamask_signer/tsconfig.json +19 -0
  68. package/packages/tari_permissions/package.json +2 -3
  69. package/packages/tari_permissions/src/helpers.ts +33 -0
  70. package/packages/tari_permissions/src/index.ts +2 -1
  71. package/packages/tari_permissions/src/tari_permissions.ts +59 -42
  72. package/packages/tari_provider/package.json +1 -1
  73. package/packages/tari_provider/src/TariProvider.ts +7 -23
  74. package/packages/tari_provider/src/index.ts +1 -2
  75. package/packages/tari_provider/src/types.ts +38 -24
  76. package/packages/tari_signer/moon.yml +55 -0
  77. package/packages/tari_signer/package.json +28 -0
  78. package/packages/tari_signer/src/TariSigner.ts +35 -0
  79. package/packages/tari_signer/src/index.ts +2 -0
  80. package/packages/tari_signer/src/types.ts +84 -0
  81. package/packages/{metamask_provider → tari_signer}/tsconfig.json +0 -3
  82. package/packages/tari_universe/package.json +3 -3
  83. package/packages/tari_universe/src/index.ts +1 -1
  84. package/packages/tari_universe/src/{provider.ts → signer.ts} +32 -33
  85. package/packages/tari_universe/src/types.ts +15 -10
  86. package/packages/tari_universe/src/utils.ts +8 -8
  87. package/packages/tari_universe/tsconfig.json +2 -4
  88. package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +44 -44
  89. package/packages/tarijs/moon.yml +8 -0
  90. package/packages/tarijs/package.json +9 -6
  91. package/packages/tarijs/src/cbor.spec.ts +259 -0
  92. package/packages/tarijs/src/cbor.ts +114 -0
  93. package/packages/tarijs/src/index.ts +31 -15
  94. package/packages/tarijs/tsconfig.json +7 -1
  95. package/packages/tarijs_types/package.json +1 -1
  96. package/packages/tarijs_types/src/helpers/index.ts +62 -0
  97. package/packages/tarijs_types/src/index.ts +12 -1
  98. package/packages/wallet_daemon/package.json +4 -3
  99. package/packages/wallet_daemon/src/index.ts +1 -1
  100. package/packages/wallet_daemon/src/{provider.ts → signer.ts} +45 -47
  101. package/packages/wallet_daemon/tsconfig.json +4 -1
  102. package/packages/walletconnect/package.json +4 -3
  103. package/packages/walletconnect/src/index.ts +42 -43
  104. package/packages/walletconnect/tsconfig.json +4 -1
  105. package/pnpm-workspace.yaml +4 -3
  106. package/tsconfig.json +11 -2
  107. /package/packages/{metamask_provider → indexer_provider}/moon.yml +0 -0
  108. /package/packages/{metamask_provider → metamask_signer}/src/utils.ts +0 -0
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Transaction Builder",
3
+ "position": 1,
4
+ "link": {
5
+ "type": "doc",
6
+ "id": "transaction-builder-index"
7
+ }
8
+ }
@@ -0,0 +1,17 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # CallFunction
6
+
7
+ `callFunction` can be used to create instances of components or call other *static* methods.
8
+
9
+ ```js
10
+ builder = builder.callFunction(
11
+ {
12
+ templateAddress,
13
+ functionName: "new",
14
+ },
15
+ [1, 2, 3]
16
+ );
17
+ ```
@@ -0,0 +1,17 @@
1
+ ---
2
+ sidebar_position: 5
3
+ ---
4
+
5
+ # CallMethod
6
+
7
+ `callMethod` calls a method on an instance of a template—in other words, on a component.
8
+
9
+ ```js
10
+ const amount = 10;
11
+ const tokenResource = "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57";
12
+
13
+ builder = builder.callMethod({
14
+ componentAddress: account.address,
15
+ methodName: "withdraw",
16
+ }, [tokenResource, amount.toString()]);
17
+ ```
@@ -0,0 +1,28 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Fee
6
+
7
+ Executing a transaction requires a fee. This fee can originate from sources other than the transaction sender's account.
8
+
9
+ ```js
10
+ const account = await provider.getAccount();
11
+ const fee = new Amount(2000);
12
+ builder = builder
13
+ .feeTransactionPayFromComponent(account.address, fee.getStringValue());
14
+ ```
15
+
16
+ Under the hood, `feeTransactionPayFromComponent` creates an instruction that calls the `pay_fee` method on a component.
17
+
18
+ ```js
19
+ builder.addFeeInstruction({
20
+ CallMethod: {
21
+ component_address: componentAddress,
22
+ method: "pay_fee",
23
+ args: [maxFee],
24
+ },
25
+ });
26
+ ```
27
+
28
+ You might need to take this explicit route if the fee payment method is named something other than `pay_fee`.
@@ -0,0 +1,426 @@
1
+ ---
2
+ id: transaction-builder-index
3
+ title: Transaction Builder
4
+ description: Overview of a transaction builder
5
+ ---
6
+
7
+ # Transaction Builder
8
+
9
+ A transaction consists of one or more instructions, which are executed as a single batch. It is possible to save the intermediate result of one instruction and pass it to the next within the same transaction. This can be done using `saveVar()` and `fromWorkspace()`.
10
+
11
+ ## Create an instance of Transaction Builder
12
+
13
+ ```js
14
+ import {
15
+ Amount,
16
+ buildTransactionRequest,
17
+ fromWorkspace,
18
+ Network,
19
+ submitAndWaitForTransaction,
20
+ TransactionBuilder,
21
+ } from "@tari-project/tarijs";
22
+
23
+ let builder = new TransactionBuilder();
24
+ ```
25
+
26
+ ## Fee
27
+
28
+ Specify the minimum fee and where it should come from.
29
+
30
+ ```js
31
+ const account = await provider.getAccount();
32
+ const fee = new Amount(2000);
33
+ builder = builder
34
+ .feeTransactionPayFromComponent(account.address, fee.getStringValue());
35
+ ```
36
+
37
+ ## Build transaction
38
+
39
+ Build a transaction that withdraws _10_ tokens and deposits them back.
40
+
41
+ ```js
42
+ const amount = 10;
43
+ const tokenResource = "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57";
44
+
45
+ builder = builder.callMethod({
46
+ componentAddress: account.address,
47
+ methodName: "withdraw",
48
+ }, [tokenResource, amount.toString()])
49
+ .saveVar("bucket")
50
+ .callMethod(
51
+ {
52
+ componentAddress: account.address,
53
+ methodName: "deposit",
54
+ },
55
+ [fromWorkspace("bucket")]
56
+ );
57
+ const transaction = builder.build();
58
+ ```
59
+
60
+ ## Execute the transaction and wait for fulfillment.
61
+
62
+ ```js
63
+ const isDryRun = false;
64
+ const inputRefs = undefined;
65
+ const network = Network.LocalNet;
66
+ const requiredSubstates = [{ substate_id: account.address }];
67
+ const submitTransactionRequest = buildTransactionRequest(
68
+ transaction,
69
+ account.account_id,
70
+ requiredSubstates,
71
+ inputRefs,
72
+ isDryRun,
73
+ network
74
+ );
75
+
76
+ const txResult = await submitAndWaitForTransaction(provider, submitTransactionRequest);
77
+ ```
78
+
79
+
80
+ ## Output only for information purposes
81
+
82
+ ```json
83
+ {
84
+ "response": {
85
+ "transaction_id": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
86
+ },
87
+ "result": {
88
+ "transaction_id": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857",
89
+ "status": 3,
90
+ "result": {
91
+ "events": [
92
+ {
93
+ "payload": {
94
+ "amount": "2000"
95
+ },
96
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
97
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
98
+ "topic": "pay_fee",
99
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
100
+ },
101
+ {
102
+ "payload": {
103
+ "amount": "10",
104
+ "resource": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57"
105
+ },
106
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
107
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
108
+ "topic": "withdraw",
109
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
110
+ },
111
+ {
112
+ "payload": {
113
+ "amount": "10",
114
+ "resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
115
+ "resource_type": "Fungible",
116
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa"
117
+ },
118
+ "substate_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
119
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
120
+ "topic": "std.vault.withdraw",
121
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
122
+ },
123
+ {
124
+ "payload": {
125
+ "amount": "10",
126
+ "resource": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57"
127
+ },
128
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
129
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
130
+ "topic": "deposit",
131
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
132
+ },
133
+ {
134
+ "payload": {
135
+ "amount": "10",
136
+ "resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
137
+ "resource_type": "Fungible",
138
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa"
139
+ },
140
+ "substate_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
141
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
142
+ "topic": "std.vault.deposit",
143
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
144
+ }
145
+ ],
146
+ "execution_results": [
147
+ {
148
+ "indexed": {
149
+ "indexed": {
150
+ "bucket_ids": [
151
+ 0
152
+ ],
153
+ "component_addresses": [],
154
+ "metadata": [],
155
+ "non_fungible_addresses": [],
156
+ "proof_ids": [],
157
+ "published_template_addresses": [],
158
+ "resource_addresses": [],
159
+ "transaction_receipt_addresses": [],
160
+ "unclaimed_confidential_output_address": [],
161
+ "validator_node_fee_pools": [],
162
+ "vault_ids": []
163
+ },
164
+ "value": {
165
+ "Tag": [
166
+ 133,
167
+ {
168
+ "Integer": 0
169
+ }
170
+ ]
171
+ }
172
+ },
173
+ "return_type": {
174
+ "Other": {
175
+ "name": "Bucket"
176
+ }
177
+ }
178
+ },
179
+ {
180
+ "indexed": {
181
+ "indexed": {
182
+ "bucket_ids": [],
183
+ "component_addresses": [],
184
+ "metadata": [],
185
+ "non_fungible_addresses": [],
186
+ "proof_ids": [],
187
+ "published_template_addresses": [],
188
+ "resource_addresses": [],
189
+ "transaction_receipt_addresses": [],
190
+ "unclaimed_confidential_output_address": [],
191
+ "validator_node_fee_pools": [],
192
+ "vault_ids": []
193
+ },
194
+ "value": "Null"
195
+ },
196
+ "return_type": "Unit"
197
+ },
198
+ {
199
+ "indexed": {
200
+ "indexed": {
201
+ "bucket_ids": [],
202
+ "component_addresses": [],
203
+ "metadata": [],
204
+ "non_fungible_addresses": [],
205
+ "proof_ids": [],
206
+ "published_template_addresses": [],
207
+ "resource_addresses": [],
208
+ "transaction_receipt_addresses": [],
209
+ "unclaimed_confidential_output_address": [],
210
+ "validator_node_fee_pools": [],
211
+ "vault_ids": []
212
+ },
213
+ "value": "Null"
214
+ },
215
+ "return_type": "Unit"
216
+ }
217
+ ],
218
+ "fee_receipt": {
219
+ "cost_breakdown": {
220
+ "breakdown": {
221
+ "Events": 5,
222
+ "Logs": 3,
223
+ "RuntimeCall": 27,
224
+ "Storage": 90
225
+ }
226
+ },
227
+ "total_fee_payment": 2000,
228
+ "total_fees_paid": 125
229
+ },
230
+ "logs": [
231
+ {
232
+ "level": "Info",
233
+ "message": "Dispatcher called with function pay_fee"
234
+ },
235
+ {
236
+ "level": "Info",
237
+ "message": "Dispatcher called with function withdraw"
238
+ },
239
+ {
240
+ "level": "Info",
241
+ "message": "Dispatcher called with function deposit"
242
+ }
243
+ ],
244
+ "result": {
245
+ "Accept": {
246
+ "down_substates": [
247
+ [
248
+ "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35bf23f7b434c7e61c4d0b7057",
249
+ 32
250
+ ],
251
+ [
252
+ "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
253
+ 3
254
+ ]
255
+ ],
256
+ "up_substates": [
257
+ [
258
+ "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35bf23f7b434c7e61c4d0b7057",
259
+ {
260
+ "substate": {
261
+ "Vault": {
262
+ "resource_container": {
263
+ "Confidential": {
264
+ "address": "resource_0101010101010101010101010101010101010101010101010101010101010101",
265
+ "commitments": {},
266
+ "locked_commitments": {},
267
+ "locked_revealed_amount": 0,
268
+ "revealed_amount": 999994831
269
+ }
270
+ }
271
+ }
272
+ },
273
+ "version": 33
274
+ }
275
+ ],
276
+ [
277
+ "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
278
+ {
279
+ "substate": {
280
+ "Vault": {
281
+ "resource_container": {
282
+ "Fungible": {
283
+ "address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
284
+ "amount": 990,
285
+ "locked_amount": 0
286
+ }
287
+ }
288
+ }
289
+ },
290
+ "version": 4
291
+ }
292
+ ],
293
+ [
294
+ "txreceipt_e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857",
295
+ {
296
+ "substate": {
297
+ "TransactionReceipt": {
298
+ "events": [
299
+ {
300
+ "payload": {
301
+ "amount": "2000"
302
+ },
303
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
304
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
305
+ "topic": "pay_fee",
306
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
307
+ },
308
+ {
309
+ "payload": {
310
+ "amount": "10",
311
+ "resource": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57"
312
+ },
313
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
314
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
315
+ "topic": "withdraw",
316
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
317
+ },
318
+ {
319
+ "payload": {
320
+ "amount": "10",
321
+ "resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
322
+ "resource_type": "Fungible",
323
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa"
324
+ },
325
+ "substate_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
326
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
327
+ "topic": "std.vault.withdraw",
328
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
329
+ },
330
+ {
331
+ "payload": {
332
+ "amount": "10",
333
+ "resource": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57"
334
+ },
335
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
336
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
337
+ "topic": "deposit",
338
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
339
+ },
340
+ {
341
+ "payload": {
342
+ "amount": "10",
343
+ "resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
344
+ "resource_type": "Fungible",
345
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa"
346
+ },
347
+ "substate_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
348
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000",
349
+ "topic": "std.vault.deposit",
350
+ "tx_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
351
+ }
352
+ ],
353
+ "fee_receipt": {
354
+ "cost_breakdown": {
355
+ "breakdown": {
356
+ "Events": 5,
357
+ "Logs": 3,
358
+ "RuntimeCall": 27,
359
+ "Storage": 90
360
+ }
361
+ },
362
+ "total_fee_payment": 2000,
363
+ "total_fees_paid": 125
364
+ },
365
+ "logs": [
366
+ {
367
+ "level": "Info",
368
+ "message": "Dispatcher called with function pay_fee"
369
+ },
370
+ {
371
+ "level": "Info",
372
+ "message": "Dispatcher called with function withdraw"
373
+ },
374
+ {
375
+ "level": "Info",
376
+ "message": "Dispatcher called with function deposit"
377
+ }
378
+ ],
379
+ "transaction_hash": [
380
+ 232,
381
+ 236,
382
+ 4,
383
+ 56,
384
+ 49,
385
+ 0,
386
+ 45,
387
+ 159,
388
+ 108,
389
+ 132,
390
+ 129,
391
+ 106,
392
+ 70,
393
+ 11,
394
+ 0,
395
+ 0,
396
+ 158,
397
+ 189,
398
+ 228,
399
+ 159,
400
+ 47,
401
+ 211,
402
+ 102,
403
+ 233,
404
+ 28,
405
+ 77,
406
+ 65,
407
+ 242,
408
+ 43,
409
+ 170,
410
+ 8,
411
+ 87
412
+ ]
413
+ }
414
+ },
415
+ "version": 0
416
+ }
417
+ ]
418
+ ]
419
+ }
420
+ },
421
+ "transaction_hash": "e8ec043831002d9f6c84816a460b00009ebde49f2fd366e91c4d41f22baa0857"
422
+ }
423
+ }
424
+ }
425
+ ```
426
+
@@ -0,0 +1,24 @@
1
+ ---
2
+ sidebar_position: 6
3
+ ---
4
+
5
+ # Inputs
6
+
7
+ Inputs are required substates for a transaction. Supplying these helps to assign transactions to correct shards in consensus.
8
+
9
+ A required substate has one of the following types:
10
+
11
+ - Component
12
+ - Resource
13
+ - Vault
14
+ - UnclaimedConfidentialOutput
15
+ - NonFungible
16
+ - NonFungibleIndex
17
+ - TransactionReceipt
18
+ - Template
19
+ - ValidatorFeePool
20
+
21
+
22
+ ```js
23
+ builder = builder.withInputs([{ substateId: { Component: account.address } }]);
24
+ ```
@@ -0,0 +1,108 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # Instructions
6
+
7
+ There are nine types of instructions. In most cases, you will not need to create raw instructions yourself but will instead use one of the methods provided by the Transaction Builder.
8
+
9
+ ## CreateAccount
10
+
11
+ ```json
12
+ {
13
+ "CreateAccount": {
14
+ "owner_public_key": string,
15
+ "workspace_bucket": string | null
16
+ }
17
+ }
18
+ ```
19
+
20
+ ## CallFunction
21
+
22
+ ```json
23
+ {
24
+ "CallFunction": {
25
+ "template_address": string,
26
+ "function": string,
27
+ "args": any[]
28
+ }
29
+ }
30
+ ```
31
+
32
+ ## CallMethod
33
+
34
+ ```json
35
+ {
36
+ "CallMethod": {
37
+ "component_address": string,
38
+ "method": string,
39
+ "args": any[]
40
+ }
41
+ }
42
+ ```
43
+
44
+ ## PutLastInstructionOutputOnWorkspace
45
+
46
+ ```json
47
+ {
48
+ "PutLastInstructionOutputOnWorkspace": {
49
+ "key": number[]
50
+ }
51
+ }
52
+ ```
53
+
54
+ ## EmitLog
55
+
56
+ ```json
57
+ {
58
+ "EmitLog": {
59
+ "level": "Error" | "Warn" | "Info" | "Debug",
60
+ "message": string
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## ClaimBurn
66
+
67
+
68
+ ```json
69
+ {
70
+ "ClaimBurn": {
71
+ "claim": {
72
+ "publicKey": string,
73
+ "outputAddress": string,
74
+ "rangeProof": number[],
75
+ "proofOfKnowledge": string,
76
+ "withdrawProof": ConfidentialWithdrawProof | null,
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ ## ClaimValidatorFees
83
+
84
+ ```json
85
+ {
86
+ "ClaimValidatorFees": {
87
+ "epoch": number,
88
+ "validator_public_key": string
89
+ }
90
+ }
91
+ ```
92
+
93
+ ## DropAllProofsInWorkspace
94
+
95
+ ```json
96
+ DropAllProofsInWorkspace
97
+ ```
98
+
99
+ ## CreateFreeTestCoins
100
+
101
+ ```json
102
+ {
103
+ "CreateFreeTestCoins": {
104
+ "revealed_amount": string,
105
+ "output": ConfidentialOutput | null
106
+ }
107
+ }
108
+ ```
@@ -0,0 +1,19 @@
1
+ ---
2
+ sidebar_position: 7
3
+ ---
4
+
5
+ # WithMinEpoch / WithMaxEpoch
6
+
7
+ In some circumstances, it is important to limit the time window during which a transaction is valid for execution. These bounds can be specified using `withMinEpoch` and `withMaxEpoch`.
8
+
9
+ ## withMinEpoch
10
+
11
+ ```js
12
+ builder = builder.withMinEpoch(2);
13
+ ```
14
+
15
+ ## withMaxEpoch
16
+
17
+ ```js
18
+ builder = builder.withMaxEpoch(10000);
19
+ ```
@@ -0,0 +1,16 @@
1
+ ---
2
+ sidebar_position: 8
3
+ ---
4
+
5
+ # Raw instructions
6
+
7
+ Sometimes the functionality of the *Transaction Builder* is insufficient, and you might need to execute one of the raw [instructions](./instruction.md). In that case, use the `addInstruction` method:
8
+
9
+ ```js
10
+ builder = builder.addInstruction({
11
+ EmitLog: {
12
+ level: "Info",
13
+ message: "Test log",
14
+ },
15
+ });
16
+ ```