Jetton to TON swap not working
Jayke770 opened this issue · comments
Jake Velasco commented
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);
Pavel Rakhmanov commented
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.
- make sure your wallet has 1 USDT to swap to TON
- please set the not-zero
minAskAmount
argument. Use at least "1" (1 nanoiton)