Skip to content
/ ton Public template
forked from ton-org/ton

Most popular TON Typescript Library

License

Notifications You must be signed in to change notification settings

Shepherd36/ton

This branch is 3 commits ahead of, 87 commits behind ton-org/ton:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

3454d64 · Jul 24, 2024
Jul 24, 2024
Feb 28, 2023
Jun 11, 2024
Feb 28, 2023
Feb 28, 2023
May 31, 2024
Feb 22, 2023
Jul 14, 2023
May 30, 2024
Sep 3, 2021
Sep 3, 2021
May 31, 2024
Dec 27, 2022
Feb 26, 2024

Repository files navigation

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
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

About

Most popular TON Typescript Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages

  • TypeScript 99.2%
  • JavaScript 0.8%