All Projects → tonlabs → ton-client-js

tonlabs / ton-client-js

Licence: Apache-2.0 license
Everscale Javascript SDK

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
rust
11053 projects
java
68154 projects - #9 most used programming language
C++
36643 projects - #6 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to ton-client-js

TON-SDK
Core Everscale Client library - develop decentralized applications on Everscale blockchain. 14 programming languages supported.
Stars: ✭ 110 (+83.33%)
Mutual labels:  free, ton, freeton, everscale
tonos-se
Local Node for Everscale DApp development and testing
Stars: ✭ 29 (-51.67%)
Mutual labels:  free, freeton, everscale
everdev
Everscale Development Environment - Set up all the core Developer tools and work with Everscale blockchain from a single interface
Stars: ✭ 55 (-8.33%)
Mutual labels:  free, freeton, everscale
starter-kit-gsn
An OpenZeppelin starter kit focused on GSN.
Stars: ✭ 39 (-35%)
Mutual labels:  dapp, web3
nft-swap-sdk
Ethereum's missing p2p NFT and token swap library for web3 developers. Written in TypeScript. Powered by 0x.
Stars: ✭ 200 (+233.33%)
Mutual labels:  dapp, web3
circles-myxogastria
Webapp and mobile client for Circles
Stars: ✭ 32 (-46.67%)
Mutual labels:  dapp, web3
dxvote
Governance Dapp of DXdao
Stars: ✭ 28 (-53.33%)
Mutual labels:  dapp, web3
create-react-native-dapp
Your next Ethereum application starts here. ⚛️ 💪 🦄
Stars: ✭ 410 (+583.33%)
Mutual labels:  dapp, web3
SkyGallery
Create galleries by uploading images and videos. Powered by Sia Skynet.
Stars: ✭ 23 (-61.67%)
Mutual labels:  dapp, web3
dtube
Decentralized video sharing & social media platform on Ethereum blockchain.
Stars: ✭ 70 (+16.67%)
Mutual labels:  dapp, web3
vue-web3
🐙 Web3 blockchain bindings for Vue.js (inspired by Vuefire and Drizzle)
Stars: ✭ 63 (+5%)
Mutual labels:  dapp, web3
airswap-web
AirSwap Web App
Stars: ✭ 94 (+56.67%)
Mutual labels:  dapp, web3
erebos
JavaScript client and CLI for Swarm
Stars: ✭ 47 (-21.67%)
Mutual labels:  dapp, web3
nextjs-dapp-starter-ts
A fullstack monorepo template to develop ethereum dapps
Stars: ✭ 228 (+280%)
Mutual labels:  dapp, web3
trystero
🤝 Serverless WebRTC matchmaking for painless P2P — Make any site multiplayer in a few lines — Use BitTorrent, IPFS, or Firebase
Stars: ✭ 512 (+753.33%)
Mutual labels:  dapp, web3
zksync-dapp-checkout
zkCheckout — trustable permissionless DeFi payment gateway. Brand new zkSync dApp w/t all L2 perks: fast&cheap transfers / simple&quick withdrawal
Stars: ✭ 37 (-38.33%)
Mutual labels:  dapp, web3
colonyDapp
Colony dApp client
Stars: ✭ 52 (-13.33%)
Mutual labels:  dapp, web3
NFT-Dapp-Boilerplate
A highly scalable NFT and DEFI boilerplate with pre added web3 and different wallets with a focus on performance and best practices
Stars: ✭ 51 (-15%)
Mutual labels:  dapp, web3
foodprint
Algorand dApp for blockchain-enabled food transparency and traceability in local food supply chains. For use by smallholder farmers, food co-operatives and consumers.
Stars: ✭ 43 (-28.33%)
Mutual labels:  dapp, web3
Frame
System-wide Web3 for macOS, Windows and Linux
Stars: ✭ 225 (+275%)
Mutual labels:  dapp, web3

JavaScript Everscale SDK

Client Library built on the GraphQL API

for Web, Node.js and React Native platforms

Have a question? Get quick help in our channel:

Chat on Telegram

Table of Content

Useful links

  • Quick Start

  • Types and Methods (API Reference)

  • AppKit - JS package built on top of @eversdk/core package which purpose is to simplify writing applications on EverScale. It helps to implement most common use-cases with less coding.

  • SDK guides - get a deeper understanding by diving into our guides where you can find extensive explanations of each step of DApp development on EverScale.

  • SDK Samples - a good place to get to practice with SDK examples asap:)

Library distribution

This SDK is distributed via npm packages:

You can find their source code in this repository.

Installation

Prerequisites

  • Node.js 14 LTS

Package probably works OK on other Node.js versions, but we use 14 version in our testing pipelines so we quarantee its stable work only on 14 version.

Install core package

npm i --save @eversdk/core

Install bridge package (depends on target JS platform)

The bridge package will download precompiled binaries from TON Labs cloud storage. If you want to rebuild binary from sources see [build binaries](#build binaries) section.

NodeJs

npm i --save @eversdk/lib-node

Web

npm i --save @eversdk/lib-web

Important! Each time you run npm install the new version of the eversdk.wasm and index.js is downloaded. So you have to always update the eversdk.wasm inside your web package before publishing (starting local web server, creating web bundle etc.). If you use Webpack the best way is to use CopyPlugin.

React Native

npm i --save @eversdk/lib-react-native

Setup library

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

You need to attach the chosen binary module to the TonClient class.

NodeJs:

const {TonClient} = require("@eversdk/core");
const {libNode} = require("@eversdk/lib-node");

// Application initialization

TonClient.useBinaryLibrary(libNode)

Web:

import {TonClient} from "@eversdk/core";
import {libWeb} from "@eversdk/lib-web";

// Application initialization

TonClient.useBinaryLibrary(libWeb);

By default the library loads wasm module from relative URL /eversdk.wasm.

You can specify alternative URL if you want to place (or rename) wasm module.

import {TonClient} from "@eversdk/core";
import {libWeb, libWebSetup} from "@eversdk/lib-web";

// Setup alternative URL for WASM module.
libWebSetup({
    binaryURL: "/assets/eversdk_1_30_1.wasm",
});

TonClient.useBinaryLibrary(libWeb);

By default, lib web starts a separate worker that will utilize core (wasm).

So main thread never freezes – it is fine for UI. But in some cases (e.g. when worker already exists in application or extension) separate worker is a bad approach.

In this case application can suppress separate worker with:

import {TonClient} from "@eversdk/core";
import {libWeb, libWebSetup} from "@eversdk/lib-web";

// Disable separate worker
libWebSetup({
    disableSeparateWorker: true,
});

TonClient.useBinaryLibrary(libWeb);

React Native (iOS/Android):

import {TonClient} from "@eversdk/core";
import {libReactNative} from "@eversdk/lib-react-native";

// Application initialization

TonClient.useBinaryLibrary(libReactNative);

React Native (Web):

If you use React Native in Web, work the same way as described in Web section (see above).

Use library

All library functions are incorporated into TonClient class. Each client module is represented as a property of the TonClient object.

To start use library you must create an instance of the TonClient class:

const client = new TonClient();
const keys = await client.crypto.generate_random_sign_keys();

You can pass a configuration object in TonClient constructor:

const client = new TonClient({
    network: { 
        endpoints: ['net.ton.dev']
    } 
});

In the end, close client to close all the sockets related to it:

 client.close();

You can find reference guide to TonClient here: TON-SDK API Documentation

Build bridge binaries

You can build binaries from sources.

If you install a bridge package from the npmjs you can build it with the following commands (e.g. for nodejs):

cd node_modules/@eversdk/lib-node/build
cargo run

Build binaries

If you checkout this repository you can build binaries for all bridges.

cd packages/lib-node/build
cargo run
cd ../../../lib-web/build
cargo run
cd ../../../lib-react-native/android/build
cargo run
cd ../../ios/build
cargo run

Also the archives will be created to be published on the TON Labs cloud storage. Archives will be placed into the following folders:

  • packages/lib-node/publish
  • packages/lib-web/publish
  • packages/lib-react-native/ios/publish
  • packages/lib-react-native/android/publish

Run tests

This suite has test packages:

  • tests – common test package containing all unit tests for a library.
  • tests-node – tests runner on node js.
  • tests-web – tests runner on web browser.
  • tests-react-native – tests runner on react native platform.

Preparation to run tests

cd packages/core
npm i
npx tsc
cd packages/tests
npm i
npx tsc

Run tests on node js

cd packages/tests-node
npm i
node run

Run tests on web browser

cd packages/tests-web
npm i
node run

Run tests on react native platform

cd packages/tests-react-native
npm i
node run ios
node run android

To control where your tests will run use this environments

TON_USE_SE=true TON_NETWORK_ADDRESS=http://localhost node run

Download precompiled binaries

Instead of building library yourself, you can download the latest precompiled binaries from TON Labs SDK Binaries Store.

Binary Target Major Download links
Node.js AddOn Win32 1 eversdk.node
  macOS x86_64 1 eversdk.node
  macOS aarch64 1 eversdk.node
  Linux 1 eversdk.node
React Native Module Android x86_64 1 libeversdk.so
  Android i686 1 libeversdk.so
  Android armv7 1 libeversdk.so
  Android aarch64 1 libeversdk.so
  iOS 1 libeversdk.a
WASM Module Browser 1 eversdk.wasm, index.js

Downloaded archive is gzipped file


Copyright 2018-2020 TON Labs LTD.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].