Everscale JS Application Kit

This library is a part of Everscale SDK for JavaScript.

AppKit is built over the @eversdk/core package and purposed to simplify writing applications on Everscale.

Full API reference: https://tonlabs.github.io/ever-appkit-js/

If this package helped you, please give it a star:)

Have a question? Get quick help in our channel:

Chat on Telegram

Table of Contents

Before You Start

We strongly recommend installing EverDev utility before you start playing with AppKit. This utility will help you manage your tools for Everscale development.

Installation

Setup Client Library

You must initialize the core library before the first use. The best place to do it is in the initialization code of your application.

NodeJs:

Web:

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.

React Native:

Create Client Instance

AppKit is built over core JS library. So you have to create an instance of TonClient to use it later with AppKit objects.

In this sample we create a client instance configured to use local blockchain Evernode SE instance.

If you want to work with Developer Network or Everscale main 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.

A Few Words about the Code

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 Evernode SE instance.

So the full code of each example can look like this:

Use Account Object

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 Evernode SE.

In the example above we demonstrated typical basic usage of the Account object.

Sample source code

Find the sample that demonstrates AppKit usage source code here: https://github.com/tonlabs/sdk-samples/tree/master/demo/hello-wallet

Subscribe for Changes

Sometimes it is required to listen for events related to an account in realtime.

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:

Executing Contract on TVM

There are some situations where running the contract on the blockchain is not acceptable:

  • Writing a tests for developing contract.

  • Emulating execution for an existing account to detect failure reason or to calculate estimated fees.

  • Getting information from an existing account by running its get methods.

In these cases we can play with an account on the TVM included in EVER SDK client library:

We can call get method on accounts in the blockchain:

There are some situations where running the contract on the blockchain is not acceptable:

  • Writing a tests for developing contract.

  • Emulating execution for an existing account to detect failure reason or to calculate estimated fees.

  • Getting information from an existing account by running its get methods.

In these cases we can play with an account on the TVM included in EVER SDK client library:

We can call get method on accounts in the blockchain:

Interacting with Core SDK

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.

So you have to easily interact with low level SDK functions. It is really easy.

Each Account instance has a reference to the EVER SDK client instance. So you can use this reference.

Each account instance has an abi field with ABI this account belongs to.

Last updated