🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@ton/ton

Package Overview
Dependencies
Maintainers
6
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ton/ton

[![Version npm](https://img.shields.io/npm/v/ton.svg?logo=npm)](https://www.npmjs.com/package/ton)

latest
Source
npmnpm
Version
16.3.0
Version published
Weekly downloads
217K
2.9%
Maintainers
6
Weekly downloads
 
Created
Source

TON JS Client

Version npm

Cross-platform client for TON blockchain.

Features

  • 🚀 Create new wallets
  • 🍰 Get balance
  • ✈️ Transfers

Install

yarn add @ton/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/ton";
import { mnemonicNew, mnemonicToPrivateKey } from "@ton/crypto";

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

// Generate new key
const mnemonic = await mnemonicNew();
const keyPair = await mnemonicToPrivateKey(mnemonic);

// Create wallet contract
const wallet = WalletContractV4.create({
  workchain: 0, // basechain
  publicKey: keyPair.publicKey,
});
const contract = client.open(wallet);

// Get balance
const balance = await contract.getBalance();

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

Formatting

We use biome as our formatter. It's prettier compatible and fast

IDE Setup: VSCode, Zed

yarn run format

Testing

Debugging in tests

By default tests are running using multiple worker threads. It's faster, but undesirable during debugging. SINGLETHREADED env variable covers this case

SINGLETHREADED=1 yarn run test

Coverage report

We use test coverage to eliminate blind spots in our tests.

How to?

The goal is to make all functions runned at least once

  • Build a coverage report
yarn run coverage
  • Coverage report is build to the /coverage directory

  • Open /coverage/index.html to check the report

Acknowledgements

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

License

MIT

FAQs

Package last updated on 01 Jun 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts