For more up-to-date information, please refer to the TAC SDK GitHub repository.

The TAC-SDK provides two approaches for sending transactions:

  • Using TonConnect
  • Using a Raw Wallet via mnemonic

Using TonConnect

import { TonConnectUI } from "@tonconnect/ui";
import { TonConnectSender } from "tac-sdk";

// Initialize TonConnect
const tonConnect = new TonConnectUI({
  manifestUrl: config.tonconnectManifestUrl,
});

// Create sender
const sender = await SenderFactory.getSender({
  tonConnect,
});

Using a Raw Wallet via mnemonic

const walletVersion = "v4";

const mnemonic = process.env.TVM_MNEMONICS || ""; // 24 words mnemonic
const sender = await SenderFactory.getSender({
  version: walletVersion,
  mnemonic,
});

Sending Cross-Chain Transactions

  1. Prepare EVM Proxy Message
const abi = new ethers.AbiCoder();
const encodedParameters = abi.encode(
  ["uint256", "uint256", "address[]", "address"],
  [tokenAAmount, tokenBAmount, [EVMtokenAAddress, EVMtokenBAddress], proxyDapp]
);
const evmProxyMsg: EvmProxyMsg = {
  evmTargetAddress: DappProxyAddress,
  methodName: "addLiquidity(uint256,uint256,address[],address)",
  encodedParameters,
};
  1. Prepare Jetton Transfer Data
const assets: AssetBridgingData[] = [
  {
    address: TVMtokenAAddress,
    amount: tokenAAmount,
  },
  {
    address: TVMtokenBAddress,
    amount: tokenBAmount,
  },
];
  1. Send Transaction
const result = await tacSdk.sendCrossChainTransaction(
  evmProxyMsg,
  sender,
  assets
);

Complete Example

import { TacSdk } from "tac-sdk";
import { TonConnectUI } from "@tonconnect/ui";
import { ethers } from "ethers";

// Create EVM payload for DappProxy
const abi = new ethers.AbiCoder();
const encodedParameters = abi.encode(
  ["uint256", "uint256", "address[]", "address"],
  [tokenAAmount, tokenBAmount, [EVMtokenAAddress, EVMtokenBAddress], proxyDapp]
);
const evmProxyMsg: EvmProxyMsg = {
  evmTargetAddress: DappProxyAddress,
  methodName: "addLiquidity(uint256,uint256,address[],address)",
  encodedParameters,
};

// Create jetton transfer messages corresponding to EVM tokens, e.g., two tokens for adding liquidity to a pool
const assets: AssetBridgingData[] = [
  {
    address: TVMtokenAAddress,
    amount: tokenAAmount,
  },
  {
    address: TVMtokenBAddress,
    amount: tokenBAmount,
  },
];

const tacSdk = new TacSdk({
  network: Network.Testnet,
  delay: 3,
});
await tacSdk.init();

//Send transaction via tonConnect or mnemonic
const tonConnectUI = new TonConnectUI({
  manifestUrl: config.tonconnectManifestUrl as string,
});
const sender = await SenderFactory.getSender({
  tonConnect: tonConnectUI,
});

return await tacSdk.sendCrossChainTransaction(evmProxyMsg, sender, assets);