Package Exports
- @ton/ton
- @ton/ton/dist/index.js
- @ton/ton/dist/wallets/WalletContractV3R1
- @ton/ton/dist/wallets/WalletContractV3R1.js
- @ton/ton/dist/wallets/WalletContractV3R2
- @ton/ton/dist/wallets/WalletContractV3R2.js
- @ton/ton/dist/wallets/WalletContractV4
- @ton/ton/dist/wallets/WalletContractV4.js
- @ton/ton/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ton/ton) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
TON JS Client
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
Acknowledgements
This library is developed by the Whales Corp. and maintained by Dan Volkov.
License
MIT