@tari-project/tarijs 0.4.1 → 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.
Files changed (61) 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/docusaurus/tari-docs/README.md +41 -0
  7. package/docusaurus/tari-docs/docs/index.md +16 -0
  8. package/docusaurus/tari-docs/docs/installation.md +27 -0
  9. package/docusaurus/tari-docs/docs/providers/_category_.json +8 -0
  10. package/docusaurus/tari-docs/docs/providers/tari-universe.md +27 -0
  11. package/docusaurus/tari-docs/docs/providers/wallet-connect.md +52 -0
  12. package/docusaurus/tari-docs/docs/providers/wallet-daemon.md +37 -0
  13. package/docusaurus/tari-docs/docs/wallet/_category_.json +8 -0
  14. package/docusaurus/tari-docs/docs/wallet/default-account.md +51 -0
  15. package/docusaurus/tari-docs/docs/wallet/get-substate.md +110 -0
  16. package/docusaurus/tari-docs/docs/wallet/list-substates.md +69 -0
  17. package/docusaurus/tari-docs/docs/wallet/submit-transaction/_category_.json +8 -0
  18. package/docusaurus/tari-docs/docs/wallet/submit-transaction/build-execute-request.md +38 -0
  19. package/docusaurus/tari-docs/docs/wallet/submit-transaction/index.md +14 -0
  20. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/_category_.json +8 -0
  21. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-function.md +17 -0
  22. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/call-method.md +17 -0
  23. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/fee.md +28 -0
  24. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/index.md +426 -0
  25. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/inputs.md +24 -0
  26. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/instruction.md +108 -0
  27. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/min-max-epoch.md +19 -0
  28. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/raw-instructions.md +16 -0
  29. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/save-var.md +63 -0
  30. package/docusaurus/tari-docs/docs/wallet/submit-transaction/transaction-builder/transaction-internals.md +20 -0
  31. package/docusaurus/tari-docs/docs/wallet/template-definition.md +101 -0
  32. package/docusaurus/tari-docs/docusaurus.config.ts +108 -0
  33. package/docusaurus/tari-docs/moon.yml +41 -0
  34. package/docusaurus/tari-docs/package.json +49 -0
  35. package/docusaurus/tari-docs/sidebars.ts +7 -0
  36. package/docusaurus/tari-docs/src/components/HomepageFeatures/index.tsx +69 -0
  37. package/docusaurus/tari-docs/src/components/HomepageFeatures/styles.module.css +11 -0
  38. package/docusaurus/tari-docs/src/css/custom.css +30 -0
  39. package/docusaurus/tari-docs/src/pages/index.module.css +23 -0
  40. package/docusaurus/tari-docs/src/pages/index.tsx +44 -0
  41. package/docusaurus/tari-docs/static/.nojekyll +0 -0
  42. package/docusaurus/tari-docs/static/img/favicon.png +0 -0
  43. package/docusaurus/tari-docs/static/img/meta-image.png +0 -0
  44. package/docusaurus/tari-docs/static/img/tari/wallet-connect-1.png +0 -0
  45. package/docusaurus/tari-docs/static/img/tari/wallet-connect-2.png +0 -0
  46. package/docusaurus/tari-docs/static/img/tari/wallet-connect-3.png +0 -0
  47. package/docusaurus/tari-docs/static/img/tari-logo.svg +30 -0
  48. package/docusaurus/tari-docs/tsconfig.json +8 -0
  49. package/package.json +1 -1
  50. package/packages/tari_provider/package.json +1 -1
  51. package/packages/tari_provider/src/TariProvider.ts +1 -2
  52. package/packages/tari_provider/src/types.ts +2 -0
  53. package/packages/tari_universe/package.json +1 -1
  54. package/packages/tari_universe/src/provider.ts +2 -17
  55. package/packages/tarijs/moon.yml +8 -0
  56. package/packages/tarijs/package.json +1 -0
  57. package/packages/tarijs/src/cbor.spec.ts +259 -0
  58. package/packages/tarijs/src/cbor.ts +114 -0
  59. package/packages/tarijs/src/index.ts +3 -0
  60. package/pnpm-workspace.yaml +1 -0
  61. package/tsconfig.json +3 -0
@@ -22,4 +22,5 @@ jobs:
22
22
  with:
23
23
  auto-install: true
24
24
  - run: pnpm install
25
- - run: moon :build
25
+ - run: moon :build
26
+ - run: moon :test
@@ -0,0 +1,44 @@
1
+ name: Deploy documentation to GitHub Pages
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ build:
10
+ name: Build Docusaurus
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: 'moonrepo/setup-toolchain@v0'
17
+ with:
18
+ auto-install: true
19
+ - run: pnpm install
20
+ - run: moon tari-docs:build
21
+ - name: Upload Build Artifact
22
+ uses: actions/upload-pages-artifact@v3
23
+ with:
24
+ path: docusaurus/tari-docs/build
25
+
26
+ deploy:
27
+ name: Deploy to GitHub Pages
28
+ needs: build
29
+
30
+ # Grant GITHUB_TOKEN the permissions required to make a Pages deployment
31
+ permissions:
32
+ pages: write # to deploy to Pages
33
+ id-token: write # to verify the deployment originates from an appropriate source
34
+
35
+ # Deploy to the github-pages environment
36
+ environment:
37
+ name: github-pages
38
+ url: ${{ steps.deployment.outputs.page_url }}
39
+
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - name: Deploy to GitHub Pages
43
+ id: deployment
44
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,20 @@
1
+ name: Test documentation deployment
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ test-deploy:
10
+ name: Test documentation deployment
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ fetch-depth: 0
16
+ - uses: 'moonrepo/setup-toolchain@v0'
17
+ with:
18
+ auto-install: true
19
+ - run: pnpm install
20
+ - run: moon tari-docs:build
@@ -14,6 +14,7 @@ $schema: 'https://moonrepo.dev/schemas/workspace.json'
14
14
  projects:
15
15
  - 'apps/*'
16
16
  - 'packages/*'
17
+ - 'docusaurus/*'
17
18
 
18
19
 
19
20
 
package/README.md CHANGED
@@ -45,3 +45,22 @@ moon tarijs:build
45
45
  ```
46
46
  The distribution files will be under the `example/dist` folder.
47
47
 
48
+ ## Documentation
49
+
50
+ This monorepo includes a documentation site located in the `docusaurus` folder. It's built using [Docusaurus](https://docusaurus.io/) and generates a static website.
51
+
52
+ ### Modifying the Documentation
53
+
54
+ To start the documentation site:
55
+
56
+ ```bash
57
+ $ moon tari-docs:start
58
+ ```
59
+
60
+ This will open the documentation site in your browser at `http://localhost:3000/tari.js/`
61
+
62
+ You can now update the documentation by editing files in the `docusaurus/tari-docs/docs/` folder. Changes will be reflected automatically.
63
+
64
+ ### Publishing documentation
65
+
66
+ The documentation is hosted on GitHub Pages and served from the `/docs` folder of the `gh-pages` branch. The `documentation-deploy.yml` workflow defines the deployment process.
@@ -0,0 +1,41 @@
1
+ # Website
2
+
3
+ This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4
+
5
+ ### Installation
6
+
7
+ ```
8
+ $ yarn
9
+ ```
10
+
11
+ ### Local Development
12
+
13
+ ```
14
+ $ yarn start
15
+ ```
16
+
17
+ This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18
+
19
+ ### Build
20
+
21
+ ```
22
+ $ yarn build
23
+ ```
24
+
25
+ This command generates static content into the `build` directory and can be served using any static contents hosting service.
26
+
27
+ ### Deployment
28
+
29
+ Using SSH:
30
+
31
+ ```
32
+ $ USE_SSH=true yarn deploy
33
+ ```
34
+
35
+ Not using SSH:
36
+
37
+ ```
38
+ $ GIT_USER=<Your GitHub username> yarn deploy
39
+ ```
40
+
41
+ If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -0,0 +1,16 @@
1
+ ---
2
+ sidebar_position: 1
3
+ slug: /
4
+ ---
5
+
6
+ # Overview
7
+
8
+ This is the documentation of `tari.js` library, which enables interaction with Tari L2 (Ootle) wallet using TypeScript or JavaScript.
9
+
10
+ At its core, `TariProvider` is an abstract interface implemented by multiple concrete providers. To access a wallet, you need to create an instance of one of these providers:
11
+
12
+ * [Tari WalletConnect provider](./providers/wallet-connect.md)
13
+ * [Tari Universe provider](./providers/tari-universe.md)
14
+ * [Tari Wallet Daemon provider](./providers/wallet-daemon.md)
15
+ * Tari Metamask provider
16
+
@@ -0,0 +1,27 @@
1
+ ---
2
+ sidebar_position: 2
3
+ title: Installation
4
+ ---
5
+
6
+ # Installation
7
+
8
+ `tari.js` consists of a set of [packages](https://github.com/tari-project/tari.js/tree/main/packages).
9
+
10
+ Usually, you will need to install the base package and at least one package that implements a concrete provider.
11
+
12
+ ## Install base package
13
+
14
+ ```bash npm2yarn
15
+ npm install @tari-project/tarijs
16
+ ```
17
+
18
+ ## Install a provider
19
+
20
+ For this documentation, we will use the `Wallet Daemon Provider`, which allows direct connection to the wallet if you are hosting it locally.
21
+ However, you are free to install any other available provider.
22
+
23
+ ```bash npm2yarn
24
+ npm install @tari-project/wallet-daemon-provider
25
+ ```
26
+
27
+ We will review all providers on their dedicated pages.
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Providers",
3
+ "position": 3,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "List of all available providers."
7
+ }
8
+ }
@@ -0,0 +1,27 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # Tari Universe provider
6
+
7
+ This provider is designed for building Tari Universe apps.
8
+
9
+ ## Install required dependencies
10
+
11
+ ```bash npm2yarn
12
+ npm install @tari-project/tari-universe-provider @tari-project/tari-permissions
13
+ ```
14
+
15
+ ## Establish the connection
16
+
17
+ ```js
18
+ import { TariPermissions } from "@tari-project/tari-permissions";
19
+ import { TariUniverseProvider } from "@tari-project/tari-universe-provider";
20
+
21
+ const permissions = new TariPermissions().addPermission("Admin");
22
+ const optionalPermissions = new TariPermissions();
23
+ const provider = new TariUniverseProvider({
24
+ permissions,
25
+ optionalPermissions,
26
+ });
27
+ ```
@@ -0,0 +1,52 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+
6
+ # WalletConnect provider
7
+
8
+ [WalletConnect](https://walletconnect.network/) is an open-source protocol that lets users connect their cryptocurrency wallets to decentralized applications (dApps) in a secure way. It uses QR codes or deep linking to establish a connection between the wallet and the dApp, allowing users to interact with dApps without exposing their private keys.
9
+
10
+ ## Install required dependencies
11
+
12
+ ```bash npm2yarn
13
+ npm install @tari-project/wallet-connect-provider
14
+ ```
15
+
16
+ `WalletConnect` provider is browser only. This means it requires user interaction.
17
+
18
+ Establishing connection requires multiple steps.
19
+
20
+ ## Obtain WalletConnect Project ID
21
+
22
+ Obtain a WalletConnect Project ID by registering your project on the WalletConnect Cloud. This ID is then used to connect your dApp to the WalletConnect infrastructure, facilitating communication between the dApp and user wallets.
23
+
24
+ ## Request a connection and display wallet connect dialog
25
+
26
+ ```js
27
+ import { WalletConnectTariProvider } from "@tari-project/wallet-connect-provider";
28
+
29
+ const projectId = "1825b9dd9c17b5a33063ae91cbc48a6e";
30
+ const provider = new WalletConnectTariProvider(projectId);
31
+ await provider.connect();
32
+ ```
33
+
34
+ You should see `WalletConnect` dialog:
35
+
36
+ ![WalletConnect](/img/tari/wallet-connect-1.png)
37
+
38
+ ## Copy connection link to clipboard
39
+
40
+ Click the copy link icon in the top right corner.
41
+
42
+ ## Authorize the connection in your wallet
43
+
44
+ Authorize the connection by clicking `Connect with WalletConnect` button in your wallet.
45
+
46
+ ![WalletConnect](/img/tari/wallet-connect-2.png)
47
+
48
+ ![WalletConnect](/img/tari/wallet-connect-3.png)
49
+
50
+ ## Success!
51
+
52
+ Go back to your web application, and the connection should now be established.
@@ -0,0 +1,37 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # Wallet daemon provider
6
+
7
+ This is the only provider that works in both Node.js and browser environments. It enables a direct connection to a wallet via JSON-RPC.
8
+
9
+ ## Install required dependencies
10
+
11
+ ```bash npm2yarn
12
+ npm install @tari-project/wallet-daemon-provider @tari-project/tari-permissions
13
+ ```
14
+
15
+ ## Establish and test the connection
16
+
17
+ ```js
18
+ import { TariPermissions } from "@tari-project/tari-permissions";
19
+ import { WalletDaemonTariProvider } from "@tari-project/wallet-daemon-provider";
20
+
21
+ const permissions = new TariPermissions().addPermission("Admin");
22
+ const serverUrl = "http://127.0.0.1:12010/json_rpc";
23
+ const provider = await WalletDaemonTariProvider.buildFetchProvider({
24
+ permissions,
25
+ serverUrl,
26
+ });
27
+
28
+ // Test connection
29
+ const account = await provider.getAccount();
30
+ console.log(`Account address: ${account.address}`);
31
+ ```
32
+
33
+ If the connection is successful, it should output an account address similar to the following:
34
+
35
+ ```txt
36
+ Account id: component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710
37
+ ```
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Interaction with the wallet",
3
+ "position": 4,
4
+ "link": {
5
+ "type": "generated-index",
6
+ "description": "Features of TariProvider."
7
+ }
8
+ }
@@ -0,0 +1,51 @@
1
+ ---
2
+ sidebar_position: 1
3
+ ---
4
+
5
+ # Account
6
+
7
+ The provider is linked to an account in your wallet.
8
+
9
+ ```js
10
+ const account = await provider.getAccount();
11
+ ```
12
+
13
+ This call returns the account details:
14
+
15
+ ```json
16
+ {
17
+ "account_id": 1,
18
+ "address": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
19
+ "public_key": "a6534c991a5c034b2f81af809b9577fe6b5425f810de292c0a4d4d43793a8f50",
20
+ "resources": [
21
+ {
22
+ "type": "Confidential",
23
+ "resource_address": "resource_0101010101010101010101010101010101010101010101010101010101010101",
24
+ "balance": 999999643,
25
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35bf23f7b434c7e61c4d0b7057",
26
+ "token_symbol": "XTR"
27
+ },
28
+ {
29
+ "type": "Fungible",
30
+ "resource_address": "resource_217d58767480fbaa48693e11de34baf7fd727e33ee7627f0c4e5b78def378e57",
31
+ "balance": 990,
32
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35ba5d265d0bfc518baa4de2fa",
33
+ "token_symbol": "token-a"
34
+ },
35
+ {
36
+ "type": "Fungible",
37
+ "resource_address": "resource_9cdad1188895b080885a64abb71a66a4a4cb1d81d1a55f018a0472b91ee2b47b",
38
+ "balance": 990,
39
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d352289e045361315cf27335067",
40
+ "token_symbol": "token-b"
41
+ },
42
+ {
43
+ "type": "Fungible",
44
+ "resource_address": "resource_c3df71792220ec8f3d3896991d49e100096020f8e26bce2cd16ba5c27831f988",
45
+ "balance": 20,
46
+ "vault_id": "vault_24b679b98056c7ca7e3d9f9266fec928c7f29d35f2bfd6b4ca0aa2ba2fcc4769",
47
+ "token_symbol": "LP"
48
+ }
49
+ ]
50
+ }
51
+ ```
@@ -0,0 +1,110 @@
1
+ ---
2
+ sidebar_position: 4
3
+ ---
4
+
5
+ # Get substate
6
+
7
+ It is possible to get substate details by substate address:
8
+
9
+ ```js
10
+ const substateAddress = "component_9cdad1188895b080885a64abb71a66a4a4cb1d8117679d85c8b35a4ec5d02243";
11
+ const substate = await provider.getSubstate(substateAddress);
12
+ ```
13
+
14
+ ```json
15
+ {
16
+ "value": {
17
+ "substate": {
18
+ "Component": {
19
+ "access_rules": {
20
+ "default": "AllowAll",
21
+ "method_access": {}
22
+ },
23
+ "body": {
24
+ "state": {
25
+ "Map": [
26
+ [
27
+ {
28
+ "Text": "vault"
29
+ },
30
+ {
31
+ "Tag": [
32
+ 132,
33
+ {
34
+ "Bytes": [
35
+ 156,
36
+ 218,
37
+ 209,
38
+ 24,
39
+ 136,
40
+ 149,
41
+ 176,
42
+ 128,
43
+ 136,
44
+ 90,
45
+ 100,
46
+ 171,
47
+ 183,
48
+ 26,
49
+ 102,
50
+ 164,
51
+ 164,
52
+ 203,
53
+ 29,
54
+ 129,
55
+ 22,
56
+ 248,
57
+ 9,
58
+ 1,
59
+ 100,
60
+ 31,
61
+ 71,
62
+ 132,
63
+ 87,
64
+ 88,
65
+ 252,
66
+ 4
67
+ ]
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ ]
73
+ }
74
+ },
75
+ "entity_id": [
76
+ 156,
77
+ 218,
78
+ 209,
79
+ 24,
80
+ 136,
81
+ 149,
82
+ 176,
83
+ 128,
84
+ 136,
85
+ 90,
86
+ 100,
87
+ 171,
88
+ 183,
89
+ 26,
90
+ 102,
91
+ 164,
92
+ 164,
93
+ 203,
94
+ 29,
95
+ 129
96
+ ],
97
+ "module_name": "TestFaucet",
98
+ "owner_key": "a6534c991a5c034b2f81af809b9577fe6b5425f810de292c0a4d4d43793a8f50",
99
+ "owner_rule": "OwnedBySigner",
100
+ "template_address": "20a814546424dae7496451a170325ddaed52d118e4fcf46c1abd32b3d6ee8163"
101
+ }
102
+ },
103
+ "version": 0
104
+ },
105
+ "address": {
106
+ "substate_id": "component_9cdad1188895b080885a64abb71a66a4a4cb1d8117679d85c8b35a4ec5d02243",
107
+ "version": 0
108
+ }
109
+ }
110
+ ```
@@ -0,0 +1,69 @@
1
+ ---
2
+ sidebar_position: 3
3
+ ---
4
+
5
+ # List substates
6
+
7
+ In the Tari network, substates are discrete units of state within the Tari Digital Assets Network. Each substate encapsulates a specific piece of data—such as ownership records, smart contract states, or asset balances.
8
+ Substates follow a create-spend lifecycle, meaning they are created, referenced, and eventually consumed or modified according to network rules.
9
+
10
+ You can query substates using the `listSubstates` method of a `TariProvider`.
11
+
12
+ ```ts
13
+ listSubstates(
14
+ filter_by_template: string | null,
15
+ filter_by_type: SubstateType | null,
16
+ limit: number | null,
17
+ offset: number | null
18
+ ): Promise<ListSubstatesResponse>;
19
+ ```
20
+
21
+
22
+ ## List by template
23
+
24
+ ```js
25
+ const accountTemplate = "0000000000000000000000000000000000000000000000000000000000000000";
26
+ const accountSubstates = await provider.listSubstates(accountTemplate, null, 1, 0);
27
+ ```
28
+
29
+ The result could be similar to:
30
+
31
+ ```json
32
+ {
33
+ "substates": [
34
+ {
35
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
36
+ "module_name": "Account",
37
+ "version": 3,
38
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000"
39
+ }
40
+ ]
41
+ }
42
+ ```
43
+
44
+ ## List by substate type
45
+
46
+ ```js
47
+ const accountSubstatesByType = await provider.listSubstates(null, "Component", 2, 0);
48
+ ```
49
+
50
+ Output:
51
+
52
+ ```json
53
+ {
54
+ "substates": [
55
+ {
56
+ "substate_id": "component_24b679b98056c7ca7e3d9f9266fec928c7f29d35e7aec546ed69f532aff40710",
57
+ "module_name": "Account",
58
+ "version": 3,
59
+ "template_address": "0000000000000000000000000000000000000000000000000000000000000000"
60
+ },
61
+ {
62
+ "substate_id": "component_1120a9ce46a820a955580cd7d07ee6b93a2ce16ee1671e4dcefd72dfbd33a168",
63
+ "module_name": "TariswapIndex",
64
+ "version": 1,
65
+ "template_address": "60041a6b62a9aa5dbbcc99d8be3ac59765f619c522fd387906dd30c9a9a78d3f"
66
+ }
67
+ ]
68
+ }
69
+ ```
@@ -0,0 +1,8 @@
1
+ {
2
+ "label": "Submit transaction",
3
+ "position": 5,
4
+ "link": {
5
+ "type": "doc",
6
+ "id": "transactions-index"
7
+ }
8
+ }
@@ -0,0 +1,38 @@
1
+ ---
2
+ sidebar_position: 2
3
+ ---
4
+
5
+ # Build and execute a request
6
+
7
+ ## Build a transaction
8
+
9
+ After constructing an instance of the *Transaction Builder*, you can build a transaction as follows:
10
+
11
+ ```js
12
+ const transaction = builder.build();
13
+ ```
14
+
15
+ ## Build a transaction request
16
+
17
+ The transaction request has additional parameters. Therefore, you build it using `buildTransactionRequest`:
18
+
19
+ ```js
20
+ const isDryRun = false;
21
+ const inputRefs = undefined; // Obsolete
22
+ const network = Network.LocalNet;
23
+ const requiredSubstates = []; // Soon to be retired. Use `builder.withInputs()` instead.
24
+ const submitTransactionRequest = buildTransactionRequest(
25
+ transaction,
26
+ account.account_id,
27
+ requiredSubstates,
28
+ inputRefs,
29
+ isDryRun,
30
+ network
31
+ );
32
+ ```
33
+
34
+ ## Execute a transaction
35
+
36
+ ```js
37
+ const txResult = await submitAndWaitForTransaction(provider, submitTransactionRequest);
38
+ ```
@@ -0,0 +1,14 @@
1
+ ---
2
+ id: transactions-index
3
+ title: Submit Transaction
4
+ description: A detailed explanation of submitting transactions.
5
+ ---
6
+
7
+ # Submit transaction
8
+
9
+ The provider exposes the `submitTransaction` and `getTransactionResult` methods. The first submits the transaction, while the second polls the current status of the transaction using its ID. These methods are low-level, so it is recommended to use the transaction builder and other helpers instead.
10
+
11
+ ```ts
12
+ submitTransaction(req: SubmitTransactionRequest): Promise<SubmitTransactionResponse>;
13
+ getTransactionResult(transactionId: string): Promise<TransactionResult>;
14
+ ```
@@ -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
+ ```