Skip to content

Instantly share code, notes, and snippets.

@sench93
sench93 / Send TON coin using TonWeb js.md
Created May 19, 2023 13:34
💡 Smart Description: This code sends a specified amount of cryptocurrency to a specified address, with an optional message. If the "wait" parameter is true, it waits for the transaction to be confirmed and returns the transaction hash.

Async Ton Transfer Function.

Preview:
async function sendTon(mnemonic: string, nano: string, to: string, message: string = '', waitForResult: boolean): Promise<any> {

    const key = await mnemonicToKeyPair(mnemonic.split(" ")); //creates keyPair from mnemonic
    const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', {apiKey: 'API_KEY'})); //creates Tonweb  with your api key
    const WalletClass = tonweb.wallet.all["v4R2"]; //loads WalletClass
    const wallet = new WalletClass(tonweb.provider, {publicKey: key.publicKey}); //creates wallet from key public key
    const seqno = await wallet.methods.seqno().call() || 0; //waits for current seqno
@sench93
sench93 / Send TON coin using TonWeb js.md
Last active May 23, 2023 12:33
💡 Smart Description: This code sends a specified amount of cryptocurrency to a specified address, with an optional message. If the "wait" parameter is true, it waits for the transaction to be confirmed and returns the transaction hash.

Async Ton Transfer Function.

Preview:
import TonWeb from "tonweb";
import {generateMnemonic, mnemonicToKeyPair} from "tonweb-mnemonic"
const MNEMONIC_OF_EXISTING_WALLET = ""
const DESTINATION_ADDRESS = ""
const API_KEY = "";
async function createDeploySend(){