├── .gitbook.yaml ├── .gitbook └── assets │ ├── scr1.jpg │ └── ton-sdk-blue.png ├── .github └── workflows │ └── npmpublish.yml ├── .gitignore ├── .npmignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── __tests__ ├── basic.ts ├── tsconfig.json └── utils │ ├── Hello.abi.json │ ├── Hello.sol │ ├── Hello.tvc │ └── index.ts ├── babel.config.js ├── docs ├── .nojekyll ├── assets │ ├── highlight.css │ ├── icons.css │ ├── icons.png │ ├── icons@2x.png │ ├── main.js │ ├── search.js │ ├── style.css │ ├── widgets.png │ └── widgets@2x.png ├── classes │ ├── Account.html │ └── AccountError.html ├── enums │ └── AccountType.html ├── index.html ├── interfaces │ └── AccountGiver.html └── modules.html ├── gitbook ├── SUMMARY.md └── guides │ ├── appkit_guides.md │ ├── configure_appkit.md │ ├── custom_giver.md │ ├── deploy.md │ ├── run_abi_get_method.md │ ├── run_onchain.md │ └── work_with_events.md ├── jest.config.js ├── package.json ├── src ├── account.ts └── index.ts ├── tsconfig.base.json └── tsconfig.json /.gitbook.yaml: -------------------------------------------------------------------------------- 1 | root: ./gitbook/ 2 | 3 | structure: 4 | readme: ../README.md 5 | summary: ./SUMMARY.md -------------------------------------------------------------------------------- /.gitbook/assets/scr1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/.gitbook/assets/scr1.jpg -------------------------------------------------------------------------------- /.gitbook/assets/ton-sdk-blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/.gitbook/assets/ton-sdk-blue.png -------------------------------------------------------------------------------- /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | name: npm publish 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | publish-npm: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | - uses: actions/setup-node@v1 13 | with: 14 | node-version: 12 15 | registry-url: https://registry.npmjs.org/ 16 | 17 | - name: appkit-js 18 | run: npm publish --access public 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | **/*.swp 5 | **/*.swo 6 | .idea/ 7 | .vscode/ 8 | node_modules/ 9 | package-lock.json 10 | /__tests__/*.dylib 11 | /__tests__/*.node 12 | /coverage/ 13 | Jenkinsfile 14 | /reinstall.sh 15 | /uninstall.sh 16 | **/*.a 17 | **/*.so 18 | **/*.dylib 19 | **/*.node 20 | **/*.wasm 21 | **/dist/ 22 | **/*.map 23 | **/*.tsbuildinfo 24 | **/Cargo.lock 25 | **/publish/** 26 | **/target/** 27 | **/*.tgz 28 | **/BUCK 29 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | !src/**/* 3 | !dist/**/* 4 | dist/**/*.test.* 5 | !package.json 6 | !README.md 7 | **/*.map 8 | src/ 9 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "tabWidth": 4, 4 | "semi": false, 5 | "singleQuote": false, 6 | "printWidth": 80, 7 | "arrowParens": "avoid", 8 | "bracketSpacing": true, 9 | "endOfLine": "lf", 10 | "proseWrap": "preserve", 11 | "quoteProps": "as-needed", 12 | "requirePragma": false, 13 | "useTabs": false 14 | } 15 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | 6 | ## [0.3.8] – 2023-05-12 7 | 8 | - AccountGiver.sendTo now returns ResultOfProcessMessage 9 | 10 | ## [0.3.7] – 2023-05-11 11 | 12 | - Support giver v3 13 | 14 | ## [0.3.6] – 2023-03-02 15 | 16 | - Fixed giver 17 | 18 | ## [0.3.5] – 2022-12-23 19 | 20 | - Improved error handling in case of network errors 21 | 22 | ## [0.3.4] – 2022-11-17 23 | 24 | - Improved error handling in case of network errors 25 | 26 | ## [0.3.3] – 2022-11-14 27 | 28 | ### Fix 29 | 30 | - Fixed a bug that caused the error to disappear instead of being thrown. 31 | 32 | - Fixed a test that started to fail after improving message processing speed in Evernode-SE. 33 | 34 | 35 | ## [0.3.2] – 2022-10-18 36 | ### Fix 37 | - Minor fix, considering accounts with type "NonExist", which BOC is empty. 38 | 39 | ## [0.3.1] – 2022-03-22 40 | 41 | ### New 42 | - Rebranding to ever-appkit-js (@eversdk/appkit) 43 | 44 | ## [0.3.0] – 2021-12-03 45 | 46 | ### Improved 47 | - Add `useCachedState` flag. If set to true, appkit aggressively caches account state, that can be useful for running `deployLocal` and `runLocal` functions in tests (local emulation of contract deployment and execution). 48 | 49 | ## [0.2.0] – 2021-04-08 50 | 51 | ### New 52 | - `Account.deployLocal` emulates deploy on local TVM. 53 | - `AccountType` enumeration with available values for `acc_type` field of the parsed account. 54 | - `Account.calcDeployFees` and `Account.calcRunFees` calculates estimated fees for deploy and run message processing. 55 | 56 | ### Fixed 57 | - Before `Account.getAccount` failed if the account did not exist in the blockchain. Now it returns parsed account with only field `acc_type` equals to `AccountType.nonExist`. If account does not exist in the blockchain and `deployLocal` is executed, it will return a full account object. 58 | 59 | ### Documentation 60 | - API Reference documentation is now hosted at https://tonlabs.github.io/appkit-js/ 61 | 62 | ## [0.1.0] – 2021-03-19 63 | 64 | ### New 65 | - AppKit first release. 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Everscale JS Application Kit 2 | 3 | This library is a part of Everscale SDK for JavaScript. 4 | 5 | AppKit is built over the [@eversdk/core](https://github.com/tonlabs/ever-sdk-js) package and purposed to simplify writing applications on Everscale. 6 | 7 | Full API reference: [https://tonlabs.github.io/ever-appkit-js/](https://tonlabs.github.io/ever-appkit-js/) 8 | 9 | If this package helped you, please give it a star:) 10 | 11 | **Have a question? Get quick help in our channel:** 12 | 13 | [](https://t.me/ton\_sdk) 14 | 15 | ## Table of Contents 16 | 17 | * [Useful links](./#useful-links) 18 | * [Before You Start](./#before-you-start) 19 | * [Installation](./#installation) 20 | * [Setup Client Library](./#setup-client-library) 21 | * [NodeJs:](./#nodejs) 22 | * [Web:](./#web) 23 | * [React Native:](./#react-native) 24 | * [Create Client Instance](./#create-client-instance) 25 | * [A Few Words about the Code](./#a-few-words-about-the-code) 26 | * [Use Account Object](./#use-account-object) 27 | * [Sample source code](./#sample-source-code) 28 | * [Subscribe for Changes](./#subscribe-for-changes) 29 | * [Executing Contract on TVM](./#executing-contract-on-tvm) 30 | * [Interacting with Core SDK](./#interacting-with-core-sdk) 31 | 32 | ## Useful links 33 | 34 | * [Full API reference](https://tonlabs.github.io/ever-appkit-js/) 35 | * [Appkit samples](https://github.com/tonlabs/sdk-samples/tree/master/appkit-examples) 36 | * [SDK guides](https://docs.everos.dev/ever-sdk/quick\_start) - to get a deeper understanding dive into our sdk guides where you can find extensive explanations and descriptions of each step of DApp development on Everscale. 37 | 38 | ## Before You Start 39 | 40 | We strongly recommend installing [EverDev](https://docs.everos.dev/everdev/) utility before you start playing with AppKit. This utility will help you manage your tools for Everscale development. 41 | 42 | ## Installation 43 | 44 | ```shell 45 | # Install core package 46 | npm i --save @eversdk/core 47 | 48 | # Install lib-node bridge if you write node js application 49 | npm i --save @eversdk/lib-node 50 | 51 | # Or install lib-web bridge if you write web/browser application 52 | npm i --save @eversdk/lib-web 53 | 54 | # Or install lib-react-native if you write react-native mobile application 55 | npm i --save @eversdk/lib-react-native 56 | 57 | # And finally install appkit itself 58 | npm i --save @eversdk/appkit 59 | ``` 60 | 61 | ## Setup Client Library 62 | 63 | You must initialize the core library before the first use. The best place to do it is in the initialization code of your application. 64 | 65 | ### NodeJs: 66 | 67 | ```javascript 68 | const { TonClient } = require("@eversdk/core"); 69 | const { libNode } = require("@eversdk/lib-node"); 70 | 71 | // Application initialization 72 | 73 | TonClient.useBinaryLibrary(libNode) 74 | ``` 75 | 76 | ### Web: 77 | 78 | ```javascript 79 | import { TonClient } from "@eversdk/core"; 80 | import { libWeb } from "@eversdk/lib-web"; 81 | 82 | // Application initialization 83 | 84 | TonClient.useBinaryLibrary(libWeb); 85 | ``` 86 | 87 | By default, the library loads wasm module from relative URL `/tonclient.wasm`. 88 | 89 | You can specify alternative URL if you want to place (or rename) wasm module. 90 | 91 | ```javascript 92 | import { TonClient } from "@eversdk/core"; 93 | import { libWeb, libWebSetup } from "@eversdk/lib-web"; 94 | 95 | // Application initialization. 96 | 97 | // You have to setup libWeb if the `tonclient.wasm` 98 | // isn't located at root of your web site. 99 | // Otherwise you havn't to call `libWebSetup`. 100 | libWebSetup({ 101 | binaryURL: "/assets/tonclient_1_2_3.wasm", 102 | }); 103 | 104 | TonClient.useBinaryLibrary(libWeb); 105 | ``` 106 | 107 | ### React Native: 108 | 109 | ```javascript 110 | import { TonClient } from "@eversdk/core"; 111 | import { libReactNative } from "@eversdk/lib-react-native"; 112 | 113 | // Application initialization 114 | 115 | TonClient.useBinaryLibrary(libReactNative); 116 | ``` 117 | 118 | ## Create Client Instance 119 | 120 | AppKit is built over [core JS library](https://github.com/tonlabs/ever-sdk-js/tree/master/packages/core). So you have to create an instance of `TonClient` to use it later with AppKit objects. 121 | 122 | ```javascript 123 | const client = new TonClient({ 124 | network: { endpoints: ["http://localhost"] } 125 | }); 126 | ``` 127 | 128 | In this sample we create a client instance configured to use local blockchain [Evernode SE](https://github.com/tonlabs/evernode-se) instance. 129 | 130 | If you want to work with Developer Network or Everscale main network, please use the [list of endpoints, listed here](https://docs.everos.dev/ever-sdk/reference/ever-os-api/networks). **Attention** You must specify all the endpoints as an array in `endpoints` parameter, because each endpoint does not guarantee its availability, but we guarantee that at least one endpoint is operational at the moment. 131 | 132 | ## A Few Words about the Code 133 | 134 | Below we use a code snippets to illustrate `AppKit` usage.\ 135 | In this code we omit an initialization part because it is the same.\ 136 | We suppose that we are using lib-node bridge (NodeJs) to write examples. Also, we use the library to deal with local [Evernode SE](https://github.com/tonlabs/evernode-se) instance. 137 | 138 | So the full code of each example can look like this: 139 | 140 | ```javascript 141 | const { TonClient } = require("@eversdk/core"); 142 | const { libNode } = require("@eversdk/lib-node"); 143 | const { Account } = require("@eversdk/appkit"); 144 | 145 | TonClient.useBinaryLibrary(libNode); 146 | 147 | (async () => { 148 | const endpoint = process.env.TON_NETWORK_ADDRESS || "http://localhost"; 149 | const client = new TonClient({ network: { endpoints: [endpoint] } }); 150 | try { 151 | await main(client); 152 | } catch (err) { 153 | console.error(err); 154 | } finally { 155 | client.close(); 156 | } 157 | })(); 158 | 159 | async function main(client) { 160 | // Snippet code is here 161 | } 162 | ``` 163 | 164 | ## Use Account Object 165 | 166 | At the moment the key point of `AppKit` is an Account object (class). Application uses an Account instance to deal with specific blockchain account using specific owner ( signer in terms of TonClient library). 167 | 168 | Each Account instance must use an ABI compliant contract. So we have to define the `Contract` object with an ABI and optionally tvc fields. This object must be provided to the Account constructor. 169 | 170 | In the example below we use predefined giver already included in AppKit and predeployed in Evernode SE. 171 | 172 | ```javascript 173 | // Define Contract object. 174 | const AccContract = { 175 | abi: { /* ABI declarations */ }, 176 | tvc: "... base64 encoded string ...", 177 | }; 178 | 179 | // Generate new keys pair for new account. 180 | const keys = await client.crypto.generate_random_sign_keys(); 181 | 182 | // Create owner (signer) instance for new account. 183 | const signer = signerKeys(keys); 184 | 185 | // Construct Account instance. 186 | // 187 | // Note that this account is not deployed in the blockchain yet. 188 | // We just create an object to deal with this account. 189 | const acc = new Account(AccContract, { signer, client }); 190 | 191 | // We can determine the future addres of the account 192 | // and print it to the user before deploying. 193 | console.log(`New account future address: ${await acc.getAddress()}`); 194 | 195 | // Deploy account to the blockchain. 196 | // Here we use TONOS SE giver to create a positive balance 197 | // before deploying. 198 | await acc.deploy({ useGiver: true }); 199 | 200 | // Send external inbound message to our new account 201 | // and receives result from external outboud message. 202 | const response = await acc.run("someFunction", { someParam: 1 }); 203 | 204 | // Print decoded response message 205 | console.log("Account has responded to someFunction with", response.decoded.output); 206 | 207 | // Print current balance. 208 | // Note that balance returned as a string in decimal representation. 209 | // This is because of a value measure is a nano. 210 | // So its value may not be representable using JS Number. 211 | console.log("Account balance now is", await acc.getBalance()); 212 | ``` 213 | 214 | In the example above we demonstrated typical basic usage of the Account object. 215 | 216 | ### Sample source code 217 | 218 | Find the sample that demonstrates AppKit usage source code here: [https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet](https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet) 219 | 220 | ## Subscribe for Changes 221 | 222 | Sometimes it is required to listen for events related to an account in realtime. 223 | 224 | It is easy: just call one of the `subscribe` methods of an account instance. 225 | 226 | For example, if we need to track all changes in the account state on the blockchain we can use `subscribeAccount`: 227 | 228 | ```ts 229 | const hello = new Account(Hello, { signer }); 230 | await hello.deploy(); 231 | 232 | await hello.subscribeAccount("balance", (acc) => { 233 | // This callback triggers every time the account data 234 | // is changed on the blockchain 235 | console.log("Account has updated. Current balance is ", parseInt(acc.balance)); 236 | }); 237 | 238 | await hello.subscribeMessages("boc", async (msg) => { 239 | // This callback triggers every time the message related to this account 240 | // is appeared on the blockchain. 241 | // Releated messages include inbound and outbound messages. 242 | console.log("Message is appeared ", msg); 243 | }); 244 | 245 | // ...... do something with hello account ........... 246 | 247 | // In addition to other cleanup stuff the `free` method 248 | // unsubscribes all active subscriptions for this account instance. 249 | await hello.free(); 250 | ``` 251 | 252 | ## Executing Contract on TVM 253 | 254 | There are some situations where running the contract on the blockchain is not acceptable: 255 | 256 | * Writing a tests for developing contract. 257 | * Emulating execution for an existing account to detect failure reason or to calculate estimated fees. 258 | * Getting information from an existing account by running its get methods. 259 | 260 | In these cases we can play with an account on the TVM included in EVER SDK client library: 261 | 262 | ```ts 263 | const hello = new Account(Hello, { signer }); 264 | 265 | // We don't deploy contract on real network. 266 | // We just emulate it. After this call the hello instance 267 | // will have an account boc that can be used in consequent 268 | // calls. 269 | await hello.deployLocal(); 270 | 271 | // We execute contract locally. 272 | // But exactly the same way as it executes on the real blockchain. 273 | const result = await hello.runLocal("touch", {}); 274 | console.log('Touch output', result); 275 | ``` 276 | 277 | We can call get method on accounts in the blockchain: 278 | 279 | ```ts 280 | const acc = new Account(MyAccount, { address: someAddress }); 281 | 282 | // Contracts code and data will be downloaded from the blockchain 283 | // and used to execute on the local TVM. 284 | // Without any fees. 285 | const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid; 286 | console.log('Last bid is', lastBid); 287 | 288 | // As laways we need to cleanup resources associated with insdtance. 289 | await acc.free(); 290 | ``` 291 | 292 | There are some situations where running the contract on the blockchain is not acceptable: 293 | 294 | * Writing a tests for developing contract. 295 | * Emulating execution for an existing account to detect failure reason or to calculate estimated fees. 296 | * Getting information from an existing account by running its get methods. 297 | 298 | In these cases we can play with an account on the TVM included in EVER SDK client library: 299 | 300 | ```ts 301 | const hello = new Account(Hello, { signer }); 302 | 303 | // We don't deploy contract on real network. 304 | // We just emulate it. After this call the hello instance 305 | // will have an account boc that can be used in consequent 306 | // calls. 307 | await hello.deployLocal(); 308 | 309 | // We execute contract locally. 310 | // But exactly the same way as it executes on the real blockchain. 311 | const result = await hello.runLocal("touch", {}); 312 | console.log('Touch output', result); 313 | ``` 314 | 315 | We can call get method on accounts in the blockchain: 316 | 317 | ```ts 318 | const acc = new Account(MyAccount, { address: someAddress }); 319 | 320 | // Contracts code and data will be downloaded from the blockchain 321 | // and used to execute on the local TVM. 322 | // Without any fees. 323 | const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid; 324 | console.log('Last bid is', lastBid); 325 | 326 | // As laways we need to cleanup resources associated with insdtance. 327 | await acc.free(); 328 | ``` 329 | 330 | ## Interacting with Core SDK 331 | 332 | AppKit is a convenient library built over the EVER SDK core library. Of course the AppKit doesn't cover a lot of tasks the core SDK do. 333 | 334 | So you have to easily interact with low level SDK functions. It is really easy. 335 | 336 | Each `Account` instance has a reference to the EVER SDK client instance. So you can use this reference. 337 | 338 | ```ts 339 | async function test(wallet: Account) { 340 | const rnd = (await wallet.client.crypto.generate_random_bytes({ 341 | length: 100 342 | })).bytes; 343 | } 344 | ``` 345 | 346 | Each account instance has an `abi` field with ABI this account belongs to. 347 | 348 | ```ts 349 | async function test(wallet: Account) { 350 | const decoded = (await wallet.client.abi.decode_message_body({ 351 | abi: wallet.abi, 352 | body: someMessageBody, 353 | is_internal: false, 354 | })).value; 355 | } 356 | ``` 357 | -------------------------------------------------------------------------------- /__tests__/basic.ts: -------------------------------------------------------------------------------- 1 | import { 2 | signerKeys, 3 | TonClient, 4 | } from "@eversdk/core"; 5 | import { 6 | loadContract, 7 | init, 8 | done, 9 | } from "./utils"; 10 | import { 11 | Account, 12 | AccountType, 13 | } from "../src"; 14 | 15 | beforeAll(init); 16 | afterAll(done); 17 | const helloContract = () => loadContract("Hello"); 18 | 19 | test("Account Basic Usage", async () => { 20 | const client = TonClient.default; 21 | const startTimeInSeconds = Math.floor(Date.now() / 1000); 22 | 23 | const acc = new Account(helloContract(), { 24 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 25 | client, 26 | }); 27 | 28 | const address = await acc.getAddress(); 29 | expect(address.substr(0, 2)).toEqual("0:"); 30 | 31 | await acc.deploy({useGiver: true}); 32 | expect(Number.parseInt((await acc.getAccount()).balance)).toBeGreaterThan(500_000_000); 33 | 34 | let response = await acc.run("touch", {}); 35 | expect(response.transaction.id).toHaveLength(64); 36 | 37 | response = await acc.runLocal("sayHello", {}); 38 | const timestampInSeconds = Number(response.decoded?.output.value0); 39 | expect(timestampInSeconds).toBeGreaterThanOrEqual(startTimeInSeconds); 40 | }); 41 | 42 | test("Calc Fees", async () => { 43 | const client = TonClient.default; 44 | const account = new Account(helloContract(), { 45 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 46 | client, 47 | useCachedState: true, 48 | }); 49 | 50 | const deployFees = await account.calcDeployFees(); 51 | expect(deployFees.total_account_fees).toBeGreaterThan(13_300_000); 52 | 53 | await account.deployLocal(); 54 | 55 | const runFees = await account.calcRunFees("touch", {}); 56 | expect(runFees.total_account_fees).toBeGreaterThan(5_550_000); 57 | }); 58 | 59 | test("Uninit State", async () => { 60 | const client = TonClient.default; 61 | const account = new Account(helloContract(), { 62 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 63 | client, 64 | }); 65 | expect((await account.getAccount()).acc_type).toEqual(AccountType.nonExist); 66 | const giver = await Account.getGiverForClient(client); 67 | await giver.sendTo(await account.getAddress(), 200_000_000); 68 | 69 | account.refresh(); 70 | expect((await account.getAccount()).acc_type).toEqual(AccountType.uninit); 71 | }); 72 | 73 | test("Local run without `useCachedState`", async () => { 74 | const client = TonClient.default; 75 | const account = new Account(helloContract(), { 76 | signer: signerKeys(await client.crypto.generate_random_sign_keys()), 77 | client, 78 | }); 79 | await account.deployLocal(); 80 | await expect(account.calcRunFees("touch", {})).rejects.toHaveProperty( 81 | 'message', 82 | expect.stringMatching(/Account does not exists on the blockchain/) 83 | ) 84 | }); 85 | -------------------------------------------------------------------------------- /__tests__/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.base.json", 3 | "compilerOptions": { 4 | "rootDir": "../", 5 | "outDir": "./dist", 6 | "types": ["node", "jest"] 7 | }, 8 | "include": [ 9 | "../**/*" 10 | ], 11 | "exclude": [ 12 | "**/dist" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.abi.json: -------------------------------------------------------------------------------- 1 | { 2 | "ABI version": 2, 3 | "header": ["time", "expire"], 4 | "functions": [ 5 | { 6 | "name": "constructor", 7 | "inputs": [ 8 | ], 9 | "outputs": [ 10 | ] 11 | }, 12 | { 13 | "name": "touch", 14 | "inputs": [ 15 | ], 16 | "outputs": [ 17 | ] 18 | }, 19 | { 20 | "name": "sayHello", 21 | "inputs": [ 22 | ], 23 | "outputs": [ 24 | {"name":"value0","type":"uint32"} 25 | ] 26 | }, 27 | { 28 | "name": "sendAllMoney", 29 | "inputs": [ 30 | {"name":"dest_addr","type":"address"} 31 | ], 32 | "outputs": [ 33 | ] 34 | } 35 | ], 36 | "data": [ 37 | ], 38 | "events": [ 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.sol: -------------------------------------------------------------------------------- 1 | pragma solidity >=0.5.0; 2 | pragma AbiHeader time; 3 | pragma AbiHeader expire; 4 | 5 | contract HelloTON { 6 | uint32 timestamp; 7 | 8 | // Modifier that allows public function to accept all external calls. 9 | modifier alwaysAccept { 10 | tvm.accept(); 11 | _; 12 | } 13 | modifier onlyOwner { 14 | require(msg.pubkey() == tvm.pubkey(), 100); 15 | tvm.accept(); 16 | _; 17 | } 18 | 19 | constructor() public { 20 | tvm.accept(); 21 | timestamp = uint32(now); 22 | } 23 | //Function setting set value to state variable timestamp 24 | function touch() public alwaysAccept { 25 | timestamp = uint32(now); 26 | } 27 | //Function returns value of state variable timestamp 28 | function sayHello() public view returns (uint32) { 29 | return timestamp; 30 | } 31 | //Due to the modifier onlyOwner function sendAllMoney can be called only by the owner of the contract. 32 | //Function sendAllMoney send all contract's money to dest_addr. 33 | function sendAllMoney(address dest_addr) public onlyOwner { 34 | selfdestruct(dest_addr); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /__tests__/utils/Hello.tvc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/__tests__/utils/Hello.tvc -------------------------------------------------------------------------------- /__tests__/utils/index.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as path from "path"; 3 | import {TonClient} from "@eversdk/core"; 4 | import {libNode} from "@eversdk/lib-node"; 5 | import {ContractPackage} from "../../src"; 6 | 7 | export function init() { 8 | jest.setTimeout(100000); 9 | TonClient.useBinaryLibrary(libNode); 10 | TonClient.defaultConfig = {network: {endpoints: [process.env.TON_NETWORK_ADDRESS ?? "http://localhost"]}}; 11 | } 12 | 13 | export function done() { 14 | TonClient.default.close(); 15 | } 16 | 17 | export function loadContract(name: string): ContractPackage { 18 | function load(suffix: string) { 19 | return fs.readFileSync( 20 | path.resolve(__dirname, `${name}${suffix}`), 21 | ); 22 | } 23 | 24 | return { 25 | abi: JSON.parse(load(".abi.json").toString()), 26 | tvc: load(".tvc").toString("base64"), 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | ["@babel/preset-env", { targets: { node: "current" } }], 4 | "@babel/preset-typescript", 5 | ], 6 | }; 7 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- 1 | TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false. -------------------------------------------------------------------------------- /docs/assets/highlight.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --light-hl-0: #008000; 3 | --dark-hl-0: #6A9955; 4 | --light-hl-1: #000000; 5 | --dark-hl-1: #D4D4D4; 6 | --light-hl-2: #0000FF; 7 | --dark-hl-2: #569CD6; 8 | --light-hl-3: #0070C1; 9 | --dark-hl-3: #4FC1FF; 10 | --light-hl-4: #795E26; 11 | --dark-hl-4: #DCDCAA; 12 | --light-hl-5: #A31515; 13 | --dark-hl-5: #CE9178; 14 | --light-hl-6: #001080; 15 | --dark-hl-6: #9CDCFE; 16 | --light-hl-7: #AF00DB; 17 | --dark-hl-7: #C586C0; 18 | --light-hl-8: #000000FF; 19 | --dark-hl-8: #D4D4D4; 20 | --light-hl-9: #098658; 21 | --dark-hl-9: #B5CEA8; 22 | --light-hl-10: #267F99; 23 | --dark-hl-10: #4EC9B0; 24 | --light-code-background: #F5F5F5; 25 | --dark-code-background: #1E1E1E; 26 | } 27 | 28 | @media (prefers-color-scheme: light) { :root { 29 | --hl-0: var(--light-hl-0); 30 | --hl-1: var(--light-hl-1); 31 | --hl-2: var(--light-hl-2); 32 | --hl-3: var(--light-hl-3); 33 | --hl-4: var(--light-hl-4); 34 | --hl-5: var(--light-hl-5); 35 | --hl-6: var(--light-hl-6); 36 | --hl-7: var(--light-hl-7); 37 | --hl-8: var(--light-hl-8); 38 | --hl-9: var(--light-hl-9); 39 | --hl-10: var(--light-hl-10); 40 | --code-background: var(--light-code-background); 41 | } } 42 | 43 | @media (prefers-color-scheme: dark) { :root { 44 | --hl-0: var(--dark-hl-0); 45 | --hl-1: var(--dark-hl-1); 46 | --hl-2: var(--dark-hl-2); 47 | --hl-3: var(--dark-hl-3); 48 | --hl-4: var(--dark-hl-4); 49 | --hl-5: var(--dark-hl-5); 50 | --hl-6: var(--dark-hl-6); 51 | --hl-7: var(--dark-hl-7); 52 | --hl-8: var(--dark-hl-8); 53 | --hl-9: var(--dark-hl-9); 54 | --hl-10: var(--dark-hl-10); 55 | --code-background: var(--dark-code-background); 56 | } } 57 | 58 | body.light { 59 | --hl-0: var(--light-hl-0); 60 | --hl-1: var(--light-hl-1); 61 | --hl-2: var(--light-hl-2); 62 | --hl-3: var(--light-hl-3); 63 | --hl-4: var(--light-hl-4); 64 | --hl-5: var(--light-hl-5); 65 | --hl-6: var(--light-hl-6); 66 | --hl-7: var(--light-hl-7); 67 | --hl-8: var(--light-hl-8); 68 | --hl-9: var(--light-hl-9); 69 | --hl-10: var(--light-hl-10); 70 | --code-background: var(--light-code-background); 71 | } 72 | 73 | body.dark { 74 | --hl-0: var(--dark-hl-0); 75 | --hl-1: var(--dark-hl-1); 76 | --hl-2: var(--dark-hl-2); 77 | --hl-3: var(--dark-hl-3); 78 | --hl-4: var(--dark-hl-4); 79 | --hl-5: var(--dark-hl-5); 80 | --hl-6: var(--dark-hl-6); 81 | --hl-7: var(--dark-hl-7); 82 | --hl-8: var(--dark-hl-8); 83 | --hl-9: var(--dark-hl-9); 84 | --hl-10: var(--dark-hl-10); 85 | --code-background: var(--dark-code-background); 86 | } 87 | 88 | .hl-0 { color: var(--hl-0); } 89 | .hl-1 { color: var(--hl-1); } 90 | .hl-2 { color: var(--hl-2); } 91 | .hl-3 { color: var(--hl-3); } 92 | .hl-4 { color: var(--hl-4); } 93 | .hl-5 { color: var(--hl-5); } 94 | .hl-6 { color: var(--hl-6); } 95 | .hl-7 { color: var(--hl-7); } 96 | .hl-8 { color: var(--hl-8); } 97 | .hl-9 { color: var(--hl-9); } 98 | .hl-10 { color: var(--hl-10); } 99 | pre, code { background: var(--code-background); } 100 | -------------------------------------------------------------------------------- /docs/assets/icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/icons.png -------------------------------------------------------------------------------- /docs/assets/icons@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/icons@2x.png -------------------------------------------------------------------------------- /docs/assets/search.js: -------------------------------------------------------------------------------- 1 | window.searchData = JSON.parse("{\"kinds\":{\"8\":\"Enumeration\",\"16\":\"Enumeration member\",\"32\":\"Variable\",\"128\":\"Class\",\"256\":\"Interface\",\"512\":\"Constructor\",\"1024\":\"Property\",\"2048\":\"Method\",\"65536\":\"Type literal\",\"4194304\":\"Type alias\"},\"rows\":[{\"id\":0,\"kind\":4194304,\"name\":\"AccountOptions\",\"url\":\"modules.html#AccountOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":1,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountOptions\"},{\"id\":2,\"kind\":1024,\"name\":\"initData\",\"url\":\"modules.html#AccountOptions.__type.initData\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":3,\"kind\":1024,\"name\":\"signer\",\"url\":\"modules.html#AccountOptions.__type.signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":4,\"kind\":1024,\"name\":\"address\",\"url\":\"modules.html#AccountOptions.__type.address\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":5,\"kind\":1024,\"name\":\"client\",\"url\":\"modules.html#AccountOptions.__type.client\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":6,\"kind\":1024,\"name\":\"useCachedState\",\"url\":\"modules.html#AccountOptions.__type.useCachedState\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountOptions.__type\"},{\"id\":7,\"kind\":4194304,\"name\":\"AccountRunOptions\",\"url\":\"modules.html#AccountRunOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":8,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountRunOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountRunOptions\"},{\"id\":9,\"kind\":1024,\"name\":\"signer\",\"url\":\"modules.html#AccountRunOptions.__type.signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountRunOptions.__type\"},{\"id\":10,\"kind\":4194304,\"name\":\"AccountRunLocalOptions\",\"url\":\"modules.html#AccountRunLocalOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":11,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountRunLocalOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountRunLocalOptions\"},{\"id\":12,\"kind\":1024,\"name\":\"performAllChecks\",\"url\":\"modules.html#AccountRunLocalOptions.__type.performAllChecks\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountRunLocalOptions.__type\"},{\"id\":13,\"kind\":256,\"name\":\"AccountGiver\",\"url\":\"interfaces/AccountGiver.html\",\"classes\":\"tsd-kind-interface\"},{\"id\":14,\"kind\":1024,\"name\":\"address\",\"url\":\"interfaces/AccountGiver.html#address\",\"classes\":\"tsd-kind-property tsd-parent-kind-interface\",\"parent\":\"AccountGiver\"},{\"id\":15,\"kind\":2048,\"name\":\"sendTo\",\"url\":\"interfaces/AccountGiver.html#sendTo\",\"classes\":\"tsd-kind-method tsd-parent-kind-interface\",\"parent\":\"AccountGiver\"},{\"id\":16,\"kind\":4194304,\"name\":\"AccountDeployOptions\",\"url\":\"modules.html#AccountDeployOptions\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":17,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#AccountDeployOptions.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"AccountDeployOptions\"},{\"id\":18,\"kind\":1024,\"name\":\"initFunctionName\",\"url\":\"modules.html#AccountDeployOptions.__type.initFunctionName\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":19,\"kind\":1024,\"name\":\"initInput\",\"url\":\"modules.html#AccountDeployOptions.__type.initInput\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":20,\"kind\":1024,\"name\":\"useGiver\",\"url\":\"modules.html#AccountDeployOptions.__type.useGiver\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"AccountDeployOptions.__type\"},{\"id\":21,\"kind\":4194304,\"name\":\"ContractPackage\",\"url\":\"modules.html#ContractPackage\",\"classes\":\"tsd-kind-type-alias\"},{\"id\":22,\"kind\":65536,\"name\":\"__type\",\"url\":\"modules.html#ContractPackage.__type\",\"classes\":\"tsd-kind-type-literal tsd-parent-kind-type-alias\",\"parent\":\"ContractPackage\"},{\"id\":23,\"kind\":1024,\"name\":\"abi\",\"url\":\"modules.html#ContractPackage.__type.abi\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContractPackage.__type\"},{\"id\":24,\"kind\":1024,\"name\":\"tvc\",\"url\":\"modules.html#ContractPackage.__type.tvc\",\"classes\":\"tsd-kind-property tsd-parent-kind-type-literal\",\"parent\":\"ContractPackage.__type\"},{\"id\":25,\"kind\":128,\"name\":\"AccountError\",\"url\":\"classes/AccountError.html\",\"classes\":\"tsd-kind-class\"},{\"id\":26,\"kind\":2048,\"name\":\"missingTVC\",\"url\":\"classes/AccountError.html#missingTVC\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"AccountError\"},{\"id\":27,\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/AccountError.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class tsd-is-inherited\",\"parent\":\"AccountError\"},{\"id\":28,\"kind\":8,\"name\":\"AccountType\",\"url\":\"enums/AccountType.html\",\"classes\":\"tsd-kind-enum\"},{\"id\":29,\"kind\":16,\"name\":\"uninit\",\"url\":\"enums/AccountType.html#uninit\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":30,\"kind\":16,\"name\":\"active\",\"url\":\"enums/AccountType.html#active\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":31,\"kind\":16,\"name\":\"frozen\",\"url\":\"enums/AccountType.html#frozen\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":32,\"kind\":16,\"name\":\"nonExist\",\"url\":\"enums/AccountType.html#nonExist\",\"classes\":\"tsd-kind-enum-member tsd-parent-kind-enum\",\"parent\":\"AccountType\"},{\"id\":33,\"kind\":128,\"name\":\"Account\",\"url\":\"classes/Account.html\",\"classes\":\"tsd-kind-class\"},{\"id\":34,\"kind\":1024,\"name\":\"giversByClient\",\"url\":\"classes/Account.html#giversByClient\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private tsd-is-static\",\"parent\":\"Account\"},{\"id\":35,\"kind\":2048,\"name\":\"findGiverForClient\",\"url\":\"classes/Account.html#findGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":36,\"kind\":2048,\"name\":\"setGiverForClient\",\"url\":\"classes/Account.html#setGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":37,\"kind\":2048,\"name\":\"createGiver\",\"url\":\"classes/Account.html#createGiver\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-private tsd-is-static\",\"parent\":\"Account\"},{\"id\":38,\"kind\":2048,\"name\":\"getGiverForClient\",\"url\":\"classes/Account.html#getGiverForClient\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-static\",\"parent\":\"Account\"},{\"id\":39,\"kind\":512,\"name\":\"constructor\",\"url\":\"classes/Account.html#constructor\",\"classes\":\"tsd-kind-constructor tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":40,\"kind\":1024,\"name\":\"contract\",\"url\":\"classes/Account.html#contract\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":41,\"kind\":1024,\"name\":\"client\",\"url\":\"classes/Account.html#client\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":42,\"kind\":1024,\"name\":\"abi\",\"url\":\"classes/Account.html#abi\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":43,\"kind\":1024,\"name\":\"signer\",\"url\":\"classes/Account.html#signer\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":44,\"kind\":1024,\"name\":\"initData\",\"url\":\"classes/Account.html#initData\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":45,\"kind\":1024,\"name\":\"useCachedState\",\"url\":\"classes/Account.html#useCachedState\",\"classes\":\"tsd-kind-property tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":46,\"kind\":1024,\"name\":\"address\",\"url\":\"classes/Account.html#address\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":47,\"kind\":1024,\"name\":\"syncLastTransLt\",\"url\":\"classes/Account.html#syncLastTransLt\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":48,\"kind\":1024,\"name\":\"cachedBoc\",\"url\":\"classes/Account.html#cachedBoc\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":49,\"kind\":1024,\"name\":\"subscriptions\",\"url\":\"classes/Account.html#subscriptions\",\"classes\":\"tsd-kind-property tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":50,\"kind\":2048,\"name\":\"getAddress\",\"url\":\"classes/Account.html#getAddress\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":51,\"kind\":2048,\"name\":\"getParamsOfDeployMessage\",\"url\":\"classes/Account.html#getParamsOfDeployMessage\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":52,\"kind\":2048,\"name\":\"calcDeployFees\",\"url\":\"classes/Account.html#calcDeployFees\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":53,\"kind\":2048,\"name\":\"deploy\",\"url\":\"classes/Account.html#deploy\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":54,\"kind\":2048,\"name\":\"deployLocal\",\"url\":\"classes/Account.html#deployLocal\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":55,\"kind\":2048,\"name\":\"calcRunFees\",\"url\":\"classes/Account.html#calcRunFees\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":56,\"kind\":2048,\"name\":\"run\",\"url\":\"classes/Account.html#run\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":57,\"kind\":2048,\"name\":\"runLocal\",\"url\":\"classes/Account.html#runLocal\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":58,\"kind\":2048,\"name\":\"needSyncWithTransaction\",\"url\":\"classes/Account.html#needSyncWithTransaction\",\"classes\":\"tsd-kind-method tsd-parent-kind-class tsd-is-private\",\"parent\":\"Account\"},{\"id\":59,\"kind\":2048,\"name\":\"boc\",\"url\":\"classes/Account.html#boc\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":60,\"kind\":2048,\"name\":\"refresh\",\"url\":\"classes/Account.html#refresh\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":61,\"kind\":2048,\"name\":\"getAccount\",\"url\":\"classes/Account.html#getAccount\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":62,\"kind\":2048,\"name\":\"subscribeAccount\",\"url\":\"classes/Account.html#subscribeAccount\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":63,\"kind\":2048,\"name\":\"subscribeTransactions\",\"url\":\"classes/Account.html#subscribeTransactions\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":64,\"kind\":2048,\"name\":\"subscribeMessages\",\"url\":\"classes/Account.html#subscribeMessages\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":65,\"kind\":2048,\"name\":\"decodeMessage\",\"url\":\"classes/Account.html#decodeMessage\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":66,\"kind\":2048,\"name\":\"decodeMessageBody\",\"url\":\"classes/Account.html#decodeMessageBody\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":67,\"kind\":2048,\"name\":\"getBalance\",\"url\":\"classes/Account.html#getBalance\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":68,\"kind\":2048,\"name\":\"subscribe\",\"url\":\"classes/Account.html#subscribe\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":69,\"kind\":2048,\"name\":\"free\",\"url\":\"classes/Account.html#free\",\"classes\":\"tsd-kind-method tsd-parent-kind-class\",\"parent\":\"Account\"},{\"id\":70,\"kind\":32,\"name\":\"DefaultGiverContract\",\"url\":\"modules.html#DefaultGiverContract\",\"classes\":\"tsd-kind-variable\"}],\"index\":{\"version\":\"2.3.9\",\"fields\":[\"name\",\"parent\"],\"fieldVectors\":[[\"name/0\",[0,33.604]],[\"parent/0\",[]],[\"name/1\",[1,25.719]],[\"parent/1\",[0,3.149]],[\"name/2\",[2,33.604]],[\"parent/2\",[3,2.41]],[\"name/3\",[4,30.239]],[\"parent/3\",[3,2.41]],[\"name/4\",[5,30.239]],[\"parent/4\",[3,2.41]],[\"name/5\",[6,33.604]],[\"parent/5\",[3,2.41]],[\"name/6\",[7,33.604]],[\"parent/6\",[3,2.41]],[\"name/7\",[8,33.604]],[\"parent/7\",[]],[\"name/8\",[1,25.719]],[\"parent/8\",[8,3.149]],[\"name/9\",[4,30.239]],[\"parent/9\",[9,3.628]],[\"name/10\",[10,33.604]],[\"parent/10\",[]],[\"name/11\",[1,25.719]],[\"parent/11\",[10,3.149]],[\"name/12\",[11,38.712]],[\"parent/12\",[12,3.628]],[\"name/13\",[13,30.239]],[\"parent/13\",[]],[\"name/14\",[5,30.239]],[\"parent/14\",[13,2.834]],[\"name/15\",[14,38.712]],[\"parent/15\",[13,2.834]],[\"name/16\",[15,33.604]],[\"parent/16\",[]],[\"name/17\",[1,25.719]],[\"parent/17\",[15,3.149]],[\"name/18\",[16,38.712]],[\"parent/18\",[17,2.834]],[\"name/19\",[18,38.712]],[\"parent/19\",[17,2.834]],[\"name/20\",[19,38.712]],[\"parent/20\",[17,2.834]],[\"name/21\",[20,33.604]],[\"parent/21\",[]],[\"name/22\",[1,25.719]],[\"parent/22\",[20,3.149]],[\"name/23\",[21,33.604]],[\"parent/23\",[22,3.149]],[\"name/24\",[23,38.712]],[\"parent/24\",[22,3.149]],[\"name/25\",[24,30.239]],[\"parent/25\",[]],[\"name/26\",[25,38.712]],[\"parent/26\",[24,2.834]],[\"name/27\",[26,33.604]],[\"parent/27\",[24,2.834]],[\"name/28\",[27,25.719]],[\"parent/28\",[]],[\"name/29\",[28,38.712]],[\"parent/29\",[27,2.41]],[\"name/30\",[29,38.712]],[\"parent/30\",[27,2.41]],[\"name/31\",[30,38.712]],[\"parent/31\",[27,2.41]],[\"name/32\",[31,38.712]],[\"parent/32\",[27,2.41]],[\"name/33\",[32,6.523]],[\"parent/33\",[]],[\"name/34\",[33,38.712]],[\"parent/34\",[32,0.611]],[\"name/35\",[34,38.712]],[\"parent/35\",[32,0.611]],[\"name/36\",[35,38.712]],[\"parent/36\",[32,0.611]],[\"name/37\",[36,38.712]],[\"parent/37\",[32,0.611]],[\"name/38\",[37,38.712]],[\"parent/38\",[32,0.611]],[\"name/39\",[26,33.604]],[\"parent/39\",[32,0.611]],[\"name/40\",[38,38.712]],[\"parent/40\",[32,0.611]],[\"name/41\",[6,33.604]],[\"parent/41\",[32,0.611]],[\"name/42\",[21,33.604]],[\"parent/42\",[32,0.611]],[\"name/43\",[4,30.239]],[\"parent/43\",[32,0.611]],[\"name/44\",[2,33.604]],[\"parent/44\",[32,0.611]],[\"name/45\",[7,33.604]],[\"parent/45\",[32,0.611]],[\"name/46\",[5,30.239]],[\"parent/46\",[32,0.611]],[\"name/47\",[39,38.712]],[\"parent/47\",[32,0.611]],[\"name/48\",[40,38.712]],[\"parent/48\",[32,0.611]],[\"name/49\",[41,38.712]],[\"parent/49\",[32,0.611]],[\"name/50\",[42,38.712]],[\"parent/50\",[32,0.611]],[\"name/51\",[43,38.712]],[\"parent/51\",[32,0.611]],[\"name/52\",[44,38.712]],[\"parent/52\",[32,0.611]],[\"name/53\",[45,38.712]],[\"parent/53\",[32,0.611]],[\"name/54\",[46,38.712]],[\"parent/54\",[32,0.611]],[\"name/55\",[47,38.712]],[\"parent/55\",[32,0.611]],[\"name/56\",[48,38.712]],[\"parent/56\",[32,0.611]],[\"name/57\",[49,38.712]],[\"parent/57\",[32,0.611]],[\"name/58\",[50,38.712]],[\"parent/58\",[32,0.611]],[\"name/59\",[51,38.712]],[\"parent/59\",[32,0.611]],[\"name/60\",[52,38.712]],[\"parent/60\",[32,0.611]],[\"name/61\",[53,38.712]],[\"parent/61\",[32,0.611]],[\"name/62\",[54,38.712]],[\"parent/62\",[32,0.611]],[\"name/63\",[55,38.712]],[\"parent/63\",[32,0.611]],[\"name/64\",[56,38.712]],[\"parent/64\",[32,0.611]],[\"name/65\",[57,38.712]],[\"parent/65\",[32,0.611]],[\"name/66\",[58,38.712]],[\"parent/66\",[32,0.611]],[\"name/67\",[59,38.712]],[\"parent/67\",[32,0.611]],[\"name/68\",[60,38.712]],[\"parent/68\",[32,0.611]],[\"name/69\",[61,38.712]],[\"parent/69\",[32,0.611]],[\"name/70\",[62,38.712]],[\"parent/70\",[]]],\"invertedIndex\":[[\"__type\",{\"_index\":1,\"name\":{\"1\":{},\"8\":{},\"11\":{},\"17\":{},\"22\":{}},\"parent\":{}}],[\"abi\",{\"_index\":21,\"name\":{\"23\":{},\"42\":{}},\"parent\":{}}],[\"account\",{\"_index\":32,\"name\":{\"33\":{}},\"parent\":{\"34\":{},\"35\":{},\"36\":{},\"37\":{},\"38\":{},\"39\":{},\"40\":{},\"41\":{},\"42\":{},\"43\":{},\"44\":{},\"45\":{},\"46\":{},\"47\":{},\"48\":{},\"49\":{},\"50\":{},\"51\":{},\"52\":{},\"53\":{},\"54\":{},\"55\":{},\"56\":{},\"57\":{},\"58\":{},\"59\":{},\"60\":{},\"61\":{},\"62\":{},\"63\":{},\"64\":{},\"65\":{},\"66\":{},\"67\":{},\"68\":{},\"69\":{}}}],[\"accountdeployoptions\",{\"_index\":15,\"name\":{\"16\":{}},\"parent\":{\"17\":{}}}],[\"accountdeployoptions.__type\",{\"_index\":17,\"name\":{},\"parent\":{\"18\":{},\"19\":{},\"20\":{}}}],[\"accounterror\",{\"_index\":24,\"name\":{\"25\":{}},\"parent\":{\"26\":{},\"27\":{}}}],[\"accountgiver\",{\"_index\":13,\"name\":{\"13\":{}},\"parent\":{\"14\":{},\"15\":{}}}],[\"accountoptions\",{\"_index\":0,\"name\":{\"0\":{}},\"parent\":{\"1\":{}}}],[\"accountoptions.__type\",{\"_index\":3,\"name\":{},\"parent\":{\"2\":{},\"3\":{},\"4\":{},\"5\":{},\"6\":{}}}],[\"accountrunlocaloptions\",{\"_index\":10,\"name\":{\"10\":{}},\"parent\":{\"11\":{}}}],[\"accountrunlocaloptions.__type\",{\"_index\":12,\"name\":{},\"parent\":{\"12\":{}}}],[\"accountrunoptions\",{\"_index\":8,\"name\":{\"7\":{}},\"parent\":{\"8\":{}}}],[\"accountrunoptions.__type\",{\"_index\":9,\"name\":{},\"parent\":{\"9\":{}}}],[\"accounttype\",{\"_index\":27,\"name\":{\"28\":{}},\"parent\":{\"29\":{},\"30\":{},\"31\":{},\"32\":{}}}],[\"active\",{\"_index\":29,\"name\":{\"30\":{}},\"parent\":{}}],[\"address\",{\"_index\":5,\"name\":{\"4\":{},\"14\":{},\"46\":{}},\"parent\":{}}],[\"boc\",{\"_index\":51,\"name\":{\"59\":{}},\"parent\":{}}],[\"cachedboc\",{\"_index\":40,\"name\":{\"48\":{}},\"parent\":{}}],[\"calcdeployfees\",{\"_index\":44,\"name\":{\"52\":{}},\"parent\":{}}],[\"calcrunfees\",{\"_index\":47,\"name\":{\"55\":{}},\"parent\":{}}],[\"client\",{\"_index\":6,\"name\":{\"5\":{},\"41\":{}},\"parent\":{}}],[\"constructor\",{\"_index\":26,\"name\":{\"27\":{},\"39\":{}},\"parent\":{}}],[\"contract\",{\"_index\":38,\"name\":{\"40\":{}},\"parent\":{}}],[\"contractpackage\",{\"_index\":20,\"name\":{\"21\":{}},\"parent\":{\"22\":{}}}],[\"contractpackage.__type\",{\"_index\":22,\"name\":{},\"parent\":{\"23\":{},\"24\":{}}}],[\"creategiver\",{\"_index\":36,\"name\":{\"37\":{}},\"parent\":{}}],[\"decodemessage\",{\"_index\":57,\"name\":{\"65\":{}},\"parent\":{}}],[\"decodemessagebody\",{\"_index\":58,\"name\":{\"66\":{}},\"parent\":{}}],[\"defaultgivercontract\",{\"_index\":62,\"name\":{\"70\":{}},\"parent\":{}}],[\"deploy\",{\"_index\":45,\"name\":{\"53\":{}},\"parent\":{}}],[\"deploylocal\",{\"_index\":46,\"name\":{\"54\":{}},\"parent\":{}}],[\"findgiverforclient\",{\"_index\":34,\"name\":{\"35\":{}},\"parent\":{}}],[\"free\",{\"_index\":61,\"name\":{\"69\":{}},\"parent\":{}}],[\"frozen\",{\"_index\":30,\"name\":{\"31\":{}},\"parent\":{}}],[\"getaccount\",{\"_index\":53,\"name\":{\"61\":{}},\"parent\":{}}],[\"getaddress\",{\"_index\":42,\"name\":{\"50\":{}},\"parent\":{}}],[\"getbalance\",{\"_index\":59,\"name\":{\"67\":{}},\"parent\":{}}],[\"getgiverforclient\",{\"_index\":37,\"name\":{\"38\":{}},\"parent\":{}}],[\"getparamsofdeploymessage\",{\"_index\":43,\"name\":{\"51\":{}},\"parent\":{}}],[\"giversbyclient\",{\"_index\":33,\"name\":{\"34\":{}},\"parent\":{}}],[\"initdata\",{\"_index\":2,\"name\":{\"2\":{},\"44\":{}},\"parent\":{}}],[\"initfunctionname\",{\"_index\":16,\"name\":{\"18\":{}},\"parent\":{}}],[\"initinput\",{\"_index\":18,\"name\":{\"19\":{}},\"parent\":{}}],[\"missingtvc\",{\"_index\":25,\"name\":{\"26\":{}},\"parent\":{}}],[\"needsyncwithtransaction\",{\"_index\":50,\"name\":{\"58\":{}},\"parent\":{}}],[\"nonexist\",{\"_index\":31,\"name\":{\"32\":{}},\"parent\":{}}],[\"performallchecks\",{\"_index\":11,\"name\":{\"12\":{}},\"parent\":{}}],[\"refresh\",{\"_index\":52,\"name\":{\"60\":{}},\"parent\":{}}],[\"run\",{\"_index\":48,\"name\":{\"56\":{}},\"parent\":{}}],[\"runlocal\",{\"_index\":49,\"name\":{\"57\":{}},\"parent\":{}}],[\"sendto\",{\"_index\":14,\"name\":{\"15\":{}},\"parent\":{}}],[\"setgiverforclient\",{\"_index\":35,\"name\":{\"36\":{}},\"parent\":{}}],[\"signer\",{\"_index\":4,\"name\":{\"3\":{},\"9\":{},\"43\":{}},\"parent\":{}}],[\"subscribe\",{\"_index\":60,\"name\":{\"68\":{}},\"parent\":{}}],[\"subscribeaccount\",{\"_index\":54,\"name\":{\"62\":{}},\"parent\":{}}],[\"subscribemessages\",{\"_index\":56,\"name\":{\"64\":{}},\"parent\":{}}],[\"subscribetransactions\",{\"_index\":55,\"name\":{\"63\":{}},\"parent\":{}}],[\"subscriptions\",{\"_index\":41,\"name\":{\"49\":{}},\"parent\":{}}],[\"synclasttranslt\",{\"_index\":39,\"name\":{\"47\":{}},\"parent\":{}}],[\"tvc\",{\"_index\":23,\"name\":{\"24\":{}},\"parent\":{}}],[\"uninit\",{\"_index\":28,\"name\":{\"29\":{}},\"parent\":{}}],[\"usecachedstate\",{\"_index\":7,\"name\":{\"6\":{},\"45\":{}},\"parent\":{}}],[\"usegiver\",{\"_index\":19,\"name\":{\"20\":{}},\"parent\":{}}]],\"pipeline\":[]}}"); -------------------------------------------------------------------------------- /docs/assets/widgets.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/widgets.png -------------------------------------------------------------------------------- /docs/assets/widgets@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/everx-labs/ever-appkit-js/b93ee8a917c5cc249b860d2b79ea75b6008d379b/docs/assets/widgets@2x.png -------------------------------------------------------------------------------- /docs/classes/AccountError.html: -------------------------------------------------------------------------------- 1 |
Generated using TypeDoc
Generated using TypeDoc
This library is a part of Free TON SDK for JavaScript.
6 |AppKit is built over the @eversdk/core package and purposed to simplify writing applications on Free TON.
7 |Full API reference: https://tonlabs.github.io/appkit-js/
8 |If this package helped you, please give it a star:)
9 |Have a question? Get quick help in our channel:
10 | 11 | 12 | 13 |We strongly recommend installing TONDEV utility before you start playing with TON AppKit. This utility will help you manage your tools for Free TON development.
49 | 50 | 51 |# Install core package
npm i --save @eversdk/core
# Install lib-node bridge if you write node js application
npm i --save @eversdk/lib-node
# Or install lib-web bridge if you write web/browser application
npm i --save @eversdk/lib-web
# Or install lib-react-native if you write react-native mobile application
npm i --save @eversdk/lib-react-native
# And finally install appkit itself
npm i --save @eversdk/appkit
54 |
55 |
56 |
57 | You must initialize the core library before the first use. The best place to do it is in the initialization code of your application.
60 | 61 | 62 |const { TonClient } = require("@eversdk/core");
const { libNode } = require("@eversdk/lib-node");
// Application initialization
TonClient.useBinaryLibrary(libNode)
65 |
66 |
67 |
68 | import { TonClient } from "@eversdk/core";
import { libWeb } from "@eversdk/lib-web";
// Application initialization
TonClient.useBinaryLibrary(libWeb);
71 |
72 | By default, the library loads wasm module from relative URL /tonclient.wasm
.
You can specify alternative URL if you want to place (or rename) wasm module.
74 |import { TonClient } from "@eversdk/core";
import { libWeb, libWebSetup } from "@eversdk/lib-web";
// Application initialization.
// You have to setup libWeb if the `tonclient.wasm`
// isn't located at root of your web site.
// Otherwise you havn't to call `libWebSetup`.
libWebSetup({
binaryURL: "/assets/tonclient_1_2_3.wasm",
});
TonClient.useBinaryLibrary(libWeb);
75 |
76 |
77 |
78 | import { TonClient } from "@eversdk/core";
import { libReactNative } from "@eversdk/lib-react-native";
// Application initialization
TonClient.useBinaryLibrary(libReactNative);
81 |
82 |
83 |
84 | TON AppKit is built over core JS library. So you have to create an instance of TonClient
to use it later with TON AppKit objects.
const client = new TonClient({
network: { endpoints: ["http://localhost"] }
});
88 |
89 | In this sample we create a client instance configured to use local blockchain TON OS SE instance.
90 |If you want to work with Developer Network or Free TON network, please use the list of endpoints, listed here. Attention You must specify all the endpoints as an array in endpoints
parameter, because each endpoint does not guarantee its availability, but we guarantee that at least one endpoint is operational at the moment.
Below we use a code snippets to illustrate AppKit
usage.
In this code we omit an initialization part because it is the same.
We suppose that we are using lib-node bridge (NodeJs) to write examples. Also, we use the library to deal with local TON OS SE instance.
So the full code of each example can look like this:
97 |const { TonClient } = require("@eversdk/core");
const { libNode } = require("@eversdk/lib-node");
const { Account } = require("@eversdk/appkit");
TonClient.useBinaryLibrary(libNode);
(async () => {
const endpoint = process.env.TON_NETWORK_ADDRESS || "http://localhost";
const client = new TonClient({ network: { endpoints: [endpoint] } });
try {
await main(client);
} catch (err) {
console.error(err);
} finally {
client.close();
}
})();
async function main(client) {
// Snippet code is here
}
98 |
99 |
100 |
101 | At the moment the key point of AppKit
is an Account object (class). Application uses an Account instance to deal with specific blockchain account using specific owner ( signer in terms of TonClient library).
Each Account instance must use an ABI compliant contract. So we have to define the Contract
object with an ABI and optionally tvc fields. This object must be provided to the Account constructor.
In the example below we use predefined giver already included in AppKit and predeployed in TONOS SE.
106 |// Define Contract object.
const AccContract = {
abi: { /* ABI declarations */ },
tvc: "... base64 encoded string ...",
};
// Generate new keys pair for new account.
const keys = await client.crypto.generate_random_sign_keys();
// Create owner (signer) instance for new account.
const signer = signerKeys(keys);
// Construct Account instance.
//
// Note that this account is not deployed in the blockchain yet.
// We just create an object to deal with this account.
const acc = new Account(AccContract, { signer, client });
// We can determine the future addres of the account
// and print it to the user before deploying.
console.log(`New account future address: ${await acc.getAddress()}`);
// Deploy account to the blockchain.
// Here we use TONOS SE giver to create a positive balance
// before deploying.
await acc.deploy({ useGiver: true });
// Send external inbound message to our new account
// and receives result from external outboud message.
const response = await acc.run("someFunction", { someParam: 1 });
// Print decoded response message
console.log("Account has responded to someFunction with", response.decoded.output);
// Print current balance.
// Note that balance returned as a string in decimal representation.
// This is because of a value measure is a nano.
// So its value may not be representable using JS Number.
console.log("Account balance now is", await acc.getBalance());
107 |
108 | In the example above we demonstrated typical basic usage of the Account object.
109 | 110 | 111 |Find the sample that demonstrates AppKit usage source code here https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet
114 | 115 | 116 |Sometimes it is required to listen for events related to an account in realtime.
119 |It is easy: just call one of the subscribe
methods of an account instance.
For example, if we need to track all changes in the account state on the blockchain we can use subscribeAccount
:
const hello = new Account(Hello, { signer });
await hello.deploy();
await hello.subscribeAccount("balance", (acc) => {
// This callback triggers every time the account data
// is changed on the blockchain
console.log("Account has updated. Current balance is ", parseInt(acc.balance));
});
await hello.subscribeMessages("boc", async (msg) => {
// This callback triggers every time the message related to this account
// is appeared on the blockchain.
// Releated messages include inbound and outbound messages.
console.log("Message is appeared ", msg);
});
// ...... do something with hello account ...........
// In addition to other cleanup stuff the `free` method
// unsubscribes all active subscriptions for this account instance.
await hello.free();
122 |
123 |
124 |
125 | There are some situations where running the contract on the blockchain is not acceptable:
128 |In these cases we can play with an account on the TVM included in TON SDK client library:
134 |const hello = new Account(Hello, { signer });
// We don't deploy contract on real network.
// We just emulate it. After this call the hello instance
// will have an account boc that can be used in consequent
// calls.
await hello.deployLocal();
// We execute contract locally.
// But exactly the same way as it executes on the real blockchain.
const result = await hello.runLocal("touch", {});
console.log('Touch output', result);
135 |
136 | We can call get method on accounts in the blockchain:
137 |const acc = new Account(MyAccount, { address: someAddress });
// Contracts code and data will be downloaded from the blockchain
// and used to execute on the local TVM.
// Without any fees.
const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid;
console.log('Last bid is', lastBid);
// As laways we need to cleanup resources associated with insdtance.
await acc.free();
138 |
139 | There are some situations where running the contract on the blockchain is not acceptable:
140 |In these cases we can play with an account on the TVM included in TON SDK client library:
146 |const hello = new Account(Hello, { signer });
// We don't deploy contract on real network.
// We just emulate it. After this call the hello instance
// will have an account boc that can be used in consequent
// calls.
await hello.deployLocal();
// We execute contract locally.
// But exactly the same way as it executes on the real blockchain.
const result = await hello.runLocal("touch", {});
console.log('Touch output', result);
147 |
148 | We can call get method on accounts in the blockchain:
149 |const acc = new Account(MyAccount, { address: someAddress });
// Contracts code and data will be downloaded from the blockchain
// and used to execute on the local TVM.
// Without any fees.
const lastBid = (await acc.runLocal("getLastBid", {})).decoded.output.lastBid;
console.log('Last bid is', lastBid);
// As laways we need to cleanup resources associated with insdtance.
await acc.free();
150 |
151 |
152 |
153 | AppKit is a convenient library built over the TON-SDK core library. Of course the AppKit doesn't cover a lot of tasks the core SDK do.
156 |So you have to easily interact with low level SDK functions. It is really easy.
157 |Each Account
instance has a reference to the TON SDK client instance. So you can use this reference.
async function test(wallet: Account) {
const rnd = (await wallet.client.crypto.generate_random_bytes({
length: 100
})).bytes;
}
159 |
160 | Each account instance has an abi
field with ABI this account belongs to.
async function test(wallet: Account) {
const decoded = (await wallet.client.abi.decode_message_body({
abi: wallet.abi,
body: someMessageBody,
is_internal: false,
})).value;
}
162 |
163 | Generated using TypeDoc
Generated using TypeDoc
Deploy options
3 |Function name that will be run on deploy. Special values:
5 |undefined
(omitted): library will use constructor
as a function name.null
: library will not produce message body (no init function invocation).Parameters of init function.
11 | Note: library ignores this parameter if initFunctionName
is null
.
Giver to be used to send amount of value to deploying address 14 | before deploying.
15 |If true
then Account.getDefaultGiver() will be used.
16 | If omitted then application must prepay address
17 | using own logic.
Options for an account instance
20 |If not specified will be calculated on contracts init state.
22 |If not specified the Account.getDefaultClient() will be used.
24 |Initial data
26 |Default is signerNone
If true, appkit aggressively caches account state.
30 | Useful for running runLocal
and runLocal
functions in tests.
Run Local options
33 |If true
then performs all checks and calculations as node do.
35 | If false
then simplified execution is used.
Run options
38 |Is not specified then this.signer
40 |Smart Contract Package
42 |This object contains information about smart contract class.
43 |ABI of smart contract
45 |Compiled artifact of the smart contract. 47 | This field contains BOC with code and initial data (init state). 48 | If it is missing, then application can't deploy account of this contracts.
49 |Generated using TypeDoc
Current type of the account.
3 |