@tari-project/tarijs 0.4.0 → 0.4.2
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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +36 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +27 -0
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/ci.yml +26 -0
- package/.github/workflows/documentation-deploy.yml +44 -0
- package/.github/workflows/documentation-test-deploy.yml +20 -0
- package/.github/workflows/npm_publish.yml +26 -0
- package/.github/workflows/pr_signed_commits_check.yml +19 -0
- package/.github/workflows/pr_title.yml +30 -0
- package/.moon/toolchain.yml +6 -0
- package/.moon/workspace.yml +33 -0
- package/.prettierrc +12 -0
- package/.prototools +9 -0
- package/CODEOWNERS +3 -0
- package/README.md +66 -0
- package/TODO.md +12 -0
- package/docusaurus/tari-docs/README.md +41 -0
- package/docusaurus/tari-docs/docs/index.md +16 -0
- package/docusaurus/tari-docs/docs/installation.md +27 -0
- package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/providers/tari-universe.md +27 -0
- package/docusaurus/tari-docs/docs/providers/wallet-connect.md +52 -0
- package/docusaurus/tari-docs/docs/providers/wallet-daemon.md +37 -0
- package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
- package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
- package/docusaurus/tari-docs/docs/wallet/list-substates.md +69 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
- package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
- package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
- package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
- package/docusaurus/tari-docs/moon.yml +41 -0
- package/docusaurus/tari-docs/package.json +49 -0
- package/docusaurus/tari-docs/sidebars.ts +7 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
- package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
- package/docusaurus/tari-docs/src/css/custom.css +30 -0
- package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
- package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
- package/docusaurus/tari-docs/static/.nojekyll +0 -0
- package/docusaurus/tari-docs/static/img/favicon.png +0 -0
- package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
- package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
- package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
- package/docusaurus/tari-docs/tsconfig.json +8 -0
- package/package.json +4 -28
- package/packages/builders/moon.yml +55 -0
- package/packages/builders/package.json +30 -0
- package/packages/builders/src/helpers/index.ts +2 -0
- package/packages/builders/src/helpers/submitTransaction.ts +97 -0
- package/packages/builders/src/helpers/workspace.ts +32 -0
- package/packages/builders/src/index.ts +9 -0
- package/packages/builders/src/transaction/TransactionBuilder.ts +276 -0
- package/packages/builders/src/transaction/TransactionRequest.ts +93 -0
- package/packages/builders/src/transaction/index.ts +2 -0
- package/packages/builders/tsconfig.json +24 -0
- package/packages/metamask_provider/moon.yml +55 -0
- package/packages/metamask_provider/package.json +30 -0
- package/packages/metamask_provider/src/index.ts +232 -0
- package/packages/metamask_provider/src/utils.ts +86 -0
- package/packages/metamask_provider/tsconfig.json +21 -0
- package/packages/tari_permissions/moon.yml +55 -0
- package/packages/tari_permissions/package.json +26 -0
- package/packages/tari_permissions/src/index.ts +1 -0
- package/packages/tari_permissions/src/tari_permissions.ts +312 -0
- package/packages/tari_permissions/tsconfig.json +15 -0
- package/packages/tari_provider/moon.yml +55 -0
- package/packages/tari_provider/package.json +27 -0
- package/packages/tari_provider/src/TariProvider.ts +34 -0
- package/packages/tari_provider/src/index.ts +3 -0
- package/packages/tari_provider/src/types.ts +84 -0
- package/packages/tari_provider/tsconfig.json +11 -0
- package/packages/tari_universe/moon.yml +55 -0
- package/packages/tari_universe/package.json +31 -0
- package/packages/tari_universe/src/index.ts +3 -0
- package/packages/tari_universe/src/provider.ts +120 -0
- package/packages/tari_universe/src/types.ts +33 -0
- package/packages/tari_universe/src/utils.ts +23 -0
- package/packages/tari_universe/tsconfig.json +24 -0
- package/packages/tarijs/integration-tests/.env +1 -0
- package/packages/tarijs/integration-tests/wallet_daemon/json_rpc_provider.spec.ts +191 -0
- package/packages/tarijs/moon.yml +71 -0
- package/packages/tarijs/package.json +40 -0
- package/packages/tarijs/src/cbor.spec.ts +259 -0
- package/packages/tarijs/src/cbor.ts +114 -0
- package/packages/tarijs/src/index.ts +72 -0
- package/packages/tarijs/src/network.ts +8 -0
- package/packages/tarijs/src/templates/Account.ts +98 -0
- package/packages/tarijs/src/templates/Pool.ts +42 -0
- package/packages/tarijs/src/templates/Tariswap.ts +101 -0
- package/packages/tarijs/src/templates/TemplateFactory.ts +22 -0
- package/packages/tarijs/src/templates/TestFaucet.ts +72 -0
- package/{dist/utils.js → packages/tarijs/src/utils.ts} +4 -3
- package/packages/tarijs/tsconfig.json +39 -0
- package/packages/tarijs/vitest.config.ts +9 -0
- package/packages/tarijs_types/moon.yml +55 -0
- package/packages/tarijs_types/package.json +27 -0
- package/packages/tarijs_types/src/Amount.ts +113 -0
- package/packages/tarijs_types/src/Arg.ts +3 -0
- package/packages/tarijs_types/src/ComponentAddress.ts +3 -0
- package/packages/tarijs_types/src/ConfidentialClaim.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutput.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialOutputStatement.ts +10 -0
- package/packages/tarijs_types/src/ConfidentialStatement.ts +9 -0
- package/packages/tarijs_types/src/ConfidentialWithdrawProof.ts +8 -0
- package/packages/tarijs_types/src/ElgamalVerifiableBalance.ts +4 -0
- package/packages/tarijs_types/src/Epoch.ts +3 -0
- package/packages/tarijs_types/src/FinalizeResult.ts +17 -0
- package/packages/tarijs_types/src/Instruction.ts +29 -0
- package/packages/tarijs_types/src/ResourceAddress.ts +3 -0
- package/packages/tarijs_types/src/SubstateDiff.ts +9 -0
- package/packages/tarijs_types/src/SubstateRequirement.ts +6 -0
- package/packages/tarijs_types/src/TemplateAddress.ts +3 -0
- package/packages/tarijs_types/src/Transaction.ts +16 -0
- package/packages/tarijs_types/src/TransactionId.ts +4 -0
- package/packages/tarijs_types/src/TransactionResult.ts +26 -0
- package/packages/tarijs_types/src/TransactionSignature.ts +4 -0
- package/packages/tarijs_types/src/UnsignedTransaction.ts +15 -0
- package/packages/tarijs_types/src/VersionedSubstateId.ts +6 -0
- package/packages/tarijs_types/src/ViewableBalanceProof.ts +12 -0
- package/packages/tarijs_types/src/Workspace.ts +3 -0
- package/packages/tarijs_types/src/index.ts +25 -0
- package/packages/tarijs_types/tsconfig.json +15 -0
- package/packages/wallet_daemon/moon.yml +55 -0
- package/packages/wallet_daemon/package.json +29 -0
- package/packages/wallet_daemon/src/index.ts +5 -0
- package/packages/wallet_daemon/src/provider.ts +263 -0
- package/packages/wallet_daemon/src/webrtc.ts +229 -0
- package/packages/wallet_daemon/src/webrtc_transport.ts +27 -0
- package/packages/wallet_daemon/tsconfig.json +21 -0
- package/packages/walletconnect/moon.yml +55 -0
- package/packages/walletconnect/package.json +32 -0
- package/packages/walletconnect/src/index.ts +274 -0
- package/packages/walletconnect/tsconfig.json +21 -0
- package/pnpm-workspace.yaml +15 -0
- package/tsconfig.json +45 -0
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13
- package/dist/network.d.ts +0 -8
- package/dist/network.js +0 -9
- package/dist/templates/Account.d.ts +0 -65
- package/dist/templates/Account.js +0 -31
- package/dist/templates/Pool.d.ts +0 -29
- package/dist/templates/Pool.js +0 -20
- package/dist/templates/Tariswap.d.ts +0 -64
- package/dist/templates/Tariswap.js +0 -36
- package/dist/templates/TemplateFactory.d.ts +0 -9
- package/dist/templates/TemplateFactory.js +0 -18
- package/dist/templates/TestFaucet.d.ts +0 -49
- package/dist/templates/TestFaucet.js +0 -31
- package/dist/templates/index.js +0 -5
- package/dist/utils.d.ts +0 -2
- /package/{dist/templates/index.d.ts → packages/tarijs/src/templates/index.ts} +0 -0
|
@@ -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
|
+
```
|
package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md
ADDED
|
@@ -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
|
+
```
|
package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md
ADDED
|
@@ -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
|
+
```
|
package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md
ADDED
|
@@ -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
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 7
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# SaveVar / FromWorkspace
|
|
6
|
+
|
|
7
|
+
## saveVar
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
builder = builder
|
|
11
|
+
.callMethod(
|
|
12
|
+
{
|
|
13
|
+
componentAddress: account.address,
|
|
14
|
+
methodName: "withdraw",
|
|
15
|
+
},
|
|
16
|
+
[tokenResource, amount.toString()],
|
|
17
|
+
)
|
|
18
|
+
.saveVar("bucket")
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This saves the result of the `withdraw` instruction to the intermediate variable `bucket`, which can later be accessed using `fromWorkspace`.
|
|
22
|
+
|
|
23
|
+
## fromWorkspace
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
builder = builder
|
|
27
|
+
.callMethod(
|
|
28
|
+
{
|
|
29
|
+
componentAddress: account.address,
|
|
30
|
+
methodName: "deposit",
|
|
31
|
+
},
|
|
32
|
+
[fromWorkspace("bucket")],
|
|
33
|
+
);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
It is important to note that some methods may return *multiple values*, and you might want to access them separately.
|
|
37
|
+
In that case, you can address them using `.0`, `.1`, and so on.
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
builder = builder
|
|
41
|
+
.callMethod(
|
|
42
|
+
{
|
|
43
|
+
componentAddress: poolComponent,
|
|
44
|
+
methodName: "remove_liquidity",
|
|
45
|
+
},
|
|
46
|
+
[fromWorkspace("tokens_lp")]
|
|
47
|
+
)
|
|
48
|
+
.saveVar("buckets")
|
|
49
|
+
.callMethod(
|
|
50
|
+
{
|
|
51
|
+
componentAddress: account.address,
|
|
52
|
+
methodName: "deposit",
|
|
53
|
+
},
|
|
54
|
+
[fromWorkspace("buckets.0")]
|
|
55
|
+
)
|
|
56
|
+
.callMethod(
|
|
57
|
+
{
|
|
58
|
+
componentAddress: account.address,
|
|
59
|
+
methodName: "deposit",
|
|
60
|
+
},
|
|
61
|
+
[fromWorkspace("buckets.1")]
|
|
62
|
+
);
|
|
63
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Internals of a Transaction Request
|
|
6
|
+
|
|
7
|
+
A Transaction Request has the following parts:
|
|
8
|
+
|
|
9
|
+
- `network`: The ID of the network (e.g., LocalNet, NextNet, Igor) on which this request is expected to be executed.
|
|
10
|
+
- `accountId`: The ID of the account in which the transaction will be executed.
|
|
11
|
+
- `feeInstructions`: Instructions describing where to obtain funds to cover transaction costs.
|
|
12
|
+
- `instructions`: The core of the Transaction Request—the instructions to be executed.
|
|
13
|
+
- `inputs`: Substates involved in the transaction. Supplying these helps assign transactions to the correct shards in consensus.
|
|
14
|
+
- `minEpoch` and `maxEpoch`: Required epoch bounds for execution. These are optional.
|
|
15
|
+
- `is_dry_run`: If `true`, the transaction will be validated but not submitted.
|
|
16
|
+
- `is_seal_signer_authorized`: If `true`, the wallet's public key will be used; otherwise, the first signature of the transaction is used as the "default" owner.
|
|
17
|
+
- `detect_inputs_use_unversioned`: If `true`, dependent substates will skip the version check.
|
|
18
|
+
|
|
19
|
+
Most of these parts are covered by the *Transaction Builder*; the rest are filled by `buildTransactionRequest`.
|
|
20
|
+
|