dedust-io / sdk

DeDust Protocol 2.0 SDK
https://docs.dedust.io
Apache License 2.0
50 stars 10 forks source link

Swap - Send a message to a Vault (TON) - Sender instance #6

Closed devbashana closed 3 months ago

devbashana commented 3 months ago

Docs

Step 4. Send a message to a Vault (TON) The final step is to send a message with the appropriate amount of TON to Vault (TON).

TypeScript

import { toNano } from '@ton/core';

// ...

const amountIn = toNano('5'); // 5 TON

await tonVault.sendSwap(sender, {
  poolAddress: pool.address,
  amount: amountIn,
  gasAmount: toNano("0.25"),
});

I'm having a difficulty how to to create this sender instance. Can someone please help me?

MurkyMeow commented 3 months ago
    import { TonClient4, WalletContractV4 } from "@ton/ton";

    const tonClient = new TonClient4({
        endpoint: "https://mainnet-v4.tonhubapi.com",
    });

    const walletContract = tonClient.open(
        WalletContractV4.create({
            workchain: 0,
            publicKey,
        }),
    )

    const sender = walletContract.sender(privateKey)
devbashana commented 3 months ago

Thank you @MurkyMeow