ton
TypeScript icon, indicating that this package has built-in type declarations

13.9.0Β β€’Β PublicΒ β€’Β Published

TON JS Client

🚨 Repository Deprecated and Moved! 🚨

This repository has been deprecated and is no longer actively maintained. We have moved our project to a new repository, which you can find here: ton-org/ton. The new NPM package is available here: @ton/ton

Please make sure to update your bookmarks and star the new repository to stay up-to-date with the latest developments and updates. This repository will be archived and eventually removed.

Thank you for your continued support!


Version npm

Cross-platform client for TON blockchain.

Features

  • πŸš€ Create new wallets
  • 🍰 Get balance
  • ✈️ Transfers

Install

yarn add ton ton-crypto ton-core buffer

Browser polyfill

// Add before using library
require("buffer");

Usage

To use this library you need HTTP API endpoint, you can use one of the public endpoints:

import { TonClient, WalletContractV4, internal } from "ton";
import { mnemonicNew, mnemonicToPrivateKey } from "ton-crypto";

// Create Client
const client = new TonClient({
  endpoint: 'https://toncenter.com/api/v2/jsonRPC',
});

// Generate new key
let mnemonics = await mnemonicNew();
let keyPair = await mnemonicToPrivateKey(mnemonics);

// Create wallet contract
let workchain = 0; // Usually you need a workchain 0
let wallet = WalletContractV4.create({ workchain, publicKey: keyPair.publicKey });
let contract = client.open(wallet);

// Get balance
let balance: bigint = await contract.getBalance();

// Create a transfer
let seqno: number = await contract.getSeqno();
let transfer = await contract.createTransfer({
  seqno,
  secretKey: keyPair.secretKey,
  messages: [internal({
    value: '1.5',
    to: 'EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N',
    body: 'Hello world',
  })]
});

Docs

Documentation

Acknowledgements

This library is developed by the Whales Corp. and maintained by Dan Volkov.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i ton

Weekly Downloads

2,602

Version

13.9.0

License

MIT

Unpacked Size

320 kB

Total Files

91

Last publish

Collaborators

  • mrmld
  • tonwhales