0.0.66 • Published 1 month ago

tonweb v0.0.66

Weekly downloads
60
License
MIT
Repository
github
Last release
1 month ago

splash_js_sdk

TonWeb - JavaScript SDK for The Open Network

NPM

Install Web

npm install tonweb or yarn add tonweb

import TonWeb from "tonweb";

const tonweb = new TonWeb();

or

<script src="tonweb.js"></script>

const tonweb = new window.TonWeb();

Install NodeJS

npm install tonweb or yarn add tonweb

const TonWeb = require('tonweb');

const tonweb = new TonWeb();

Overview example

const tonweb = new TonWeb();

const wallet = tonweb.wallet.create({publicKey});

const address = await wallet.getAddress();

const nonBounceableAddress = address.toString(true, true, false);

const seqno = await wallet.methods.seqno().call();

await wallet.deploy(secretKey).send(); // deploy wallet to blockchain

const fee = await wallet.methods.transfer({
    secretKey,
    toAddress: 'EQDjVXa_oltdBP64Nc__p397xLCvGm2IcZ1ba7anSW0NAkeP',
    amount: TonWeb.utils.toNano(0.01), // 0.01 TON
    seqno: seqno,
    payload: 'Hello',
    sendMode: 3,
}).estimateFee();

const Cell = TonWeb.boc.Cell;
const cell = new Cell();
cell.bits.writeUint(0, 32);
cell.bits.writeAddress(address);
cell.bits.writeGrams(1);
console.log(cell.print()); // print cell data like Fift
const bocBytes = cell.toBoc();

const history = await tonweb.getTransactions(address);

const balance = await tonweb.getBalance(address);

tonweb.sendBoc(bocBytes);

API

By default, mainnet toncenter.com API is used. Please note that without the API key there will be a request rate limit.

You can start your own TON HTTP API instance as it is open source.

Use mainnet TonCenter API with high ratelimit API key:

const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey: 'YOUR_MAINNET_TONCENTER_API_KEY'}));

Use testnet TonCenter API with high ratelimit API key:

const tonweb = new TonWeb(new TonWeb.HttpProvider('https://testnet.toncenter.com/api/v2/jsonRPC', {apiKey: 'YOUR_TESTNET_TONCENTER_API_KEY'}));

Documentation

Each part is documented separately:

tonweb - root class and methods

tonweb-contract-wallet - interaction with wallet's smart contracts.

tonweb-contract - abstract interface to interact with TON smart contracts.

tonweb-boc - serializations of Cell and BitString

tonweb-utils - work with TON Addresses, coin values, byte arrays, hex, hash functions.

Also we use JSDoc in code

Roadmap

  1. Unit-tests

  2. Typescript

Build

npm install 

npm run build

Use as alternative to Fift for building binary messages to smart-contracts

npm install -g tonweb

export NODE_PATH=$(npm root --quiet -g)

Then create your_script.js

const TonWeb = require('tonweb');

const tonweb = new TonWeb();

. . .

run script

node your_script.js
0.0.65

1 month ago

0.0.66

1 month ago

0.0.64

2 months ago

0.0.63

2 months ago

0.0.62

9 months ago

0.0.60

1 year ago

0.0.59

1 year ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.50

2 years ago

0.0.49

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.33

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.22

3 years ago

0.0.21

3 years ago

0.0.20

3 years ago

0.0.19

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.14

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago