@duckcoin/ton
v15.3.1-duck0.0.3
Published
[](https://www.npmjs.com/package/@duckcoin/ton)
Downloads
273
Maintainers
Readme
TON JS Client
Cross-platform client for TON blockchain.
Features
- 🚀 Create new wallets
- 🍰 Get balance
- ✈️ Transfers
Planned
- 🌎 DNS (including custom)
Install
yarn add @duckcoin/ton @ton/crypto @ton/core bufferTest
If you experience issues with tests failing with 500 errors - consider using different API or if it's not feasible - you can replace those with warnings by calling yarn test with IGNORE_500=true as an environment variable
Same with adding extension to the wallet, variable IGNORE_EXTENSION_ERR=true
Disclaimer 🐛🐞
That's a temporary solution. We plan to resolve those with splitting suites into unit and e2e correspondingly and negotiating with API providers in order to find out and solve the root cause
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:
- Mainnet: https://toncenter.com/api/v2/jsonRPC
- Testnet: https://testnet.toncenter.com/api/v2/jsonRPC
import { TonClient, WalletContractV4, internal } from "@duckcoin/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: 'EQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAM9c',
body: 'Hello world',
})]
});
Docs
Acknowledgements
This repository is currently maintained by Duck 🦆
This library was initially developed by the Whales Corp. and maintained by Dan Volkov
Integrations
Currently used by DuckSeek and DuckWallet
License
MIT
