ston-fi / sdk

SDK for building applications on STON.fi protocol

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jetton to TON swap not working

Jayke770 opened this issue · comments

I'm trying to swap Jetton for Ton, but the transaction failed with a 47 exit code.

const jettonAddress = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs";
  const WalletClass = tonweb.wallet.all["v3R2"];
  const wallet = new WalletClass(provider, {
    publicKey: keyPair.publicKey,
    wc: 0,
  });
  const walletAddress = (await wallet.getAddress()).toString(true, true, false);
  console.log(walletAddress);
  const swapTxParams = await router.buildSwapJettonToTonTxParams({
    userWalletAddress: walletAddress as any,
    offerJettonAddress: jettonAddress as any,
    proxyTonAddress: pTON.v1.address,
    offerAmount: 1 * 10 ** 9,
    minAskAmount:  0,
    queryId: 8888,
  });
  const seqno = (await wallet.methods.seqno().call()) || 0;
  const tx = await wallet.methods
    .transfer({
      amount: swapTxParams.gasAmount,
      secretKey: keyPair.secretKey,
      payload: swapTxParams.payload,
      toAddress: swapTxParams.to,
      seqno,
      sendMode: 3,
    })
    .send();
  console.log(tx);
Screenshot 2024-05-12 at 10 51 16 AM

From what I see, you are trying to execute a swap of USDT to TON.
47 is a contract exit code for balance_error unrelated to SDK work.

  1. make sure your wallet has 1 USDT to swap to TON
  2. please set the not-zero minAskAmount argument. Use at least "1" (1 nanoiton)