import { Address, toNano, WalletContractV5R1, TonClient } from "@ton/ton";
import { mnemonicToPrivateKey } from "@ton/crypto";
import { AssetsSDK, createApi } from "@ton-community/assets-sdk";
const NETWORK = "testnet";
// a list of 24 space-separated words
const MNEMONIC = "foo bar baz ...";
const JETTON_WALLET_ADDR = Address.parse("<JETTON_WALLET_ADDR>");
async function main() {
// create an RPC client that will send network requests
const client = new TonClient({
endpoint: "https://toncenter.com/api/v2/jsonRPC",
});
// extract private and public keys from the mnemonic
const keyPair = await mnemonicToPrivateKey(MNEMONIC.split(" "));
// create a client for TON wallet
const wallet = WalletContractV5R1.create({
workchain: 0,
// public key is required to deploy a new wallet
// if it wasn't deployed yet
publicKey: keyPair.publicKey,
});
const provider = client.provider(wallet.address);
// sender is an object used by assets-sdk to send messages
// private key is used to sign messages sent to a wallet
const sender = wallet.sender(provider, keyPair.secretKey);
// create an assets-sdk client
const api = await createApi(NETWORK);
const sdk = AssetsSDK.create({
api,
sender,
});
// create a client for interacting with given jetton wallet
const jetton = sdk.openJettonWallet(JETTON_WALLET_ADDR);
// burn 1200000 jettons
await jetton.sendBurn(sender, 1200000n);
}
void main();