sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Call transaction fail when add liquidity pool with my personal jetton

Open dev1line opened this issue 1 year ago • 3 comments

I created my jetton: EQBNRUUeRiG1sg4rgQEC0d1DnLvVlWjvOkGMfesO9ENbGIZX and add liquid with tx init my pool: EQBkpaQJdlKeYvy9wIV1IMGczdy548KLftfy34hYg5MZYEdj It 's fail because 0xffff exit code. Please check it and tell me your reason. Maybe a bug !

dev1line avatar May 17 '24 03:05 dev1line

The same this question !

cmccamnguyen avatar May 17 '24 04:05 cmccamnguyen

Same error with me

Rakeshpradhan1999 avatar Sep 15 '24 17:09 Rakeshpradhan1999

"use client";
import {
  SendTransactionRequest,
  useTonAddress,
  useTonConnectUI,
} from "@tonconnect/ui-react";
import React from "react";

import { Address, beginCell, toNano, TonClient4 } from "@ton/ton";
import {
  Asset,
  Factory,
  JettonRoot,
  MAINNET_FACTORY_ADDR,
  PoolType,
  VaultJetton,
} from "@dedust/sdk";
import { Button } from "@nextui-org/react";
const Page = () => {
  const walletAddress = useTonAddress();
  const [tonconnect] = useTonConnectUI();
  const transferJettons = async () => {
    try {
      const wallet = Address.parse(walletAddress);

      const JETTON_WALLET = Address.parse(
        "EQD2MOAd3BagoN3l02Sio6O8MQuRmOc5QRLy_x1XpeaKt8cO"
      );
      const TOKEN_ADDRESS = Address.parse(
        "EQDUjm5A8og_JbEGn2dMCilcy-0DcKQho6KOsOc11bgXlQRg"
      );
      const tonClient = new TonClient4({
        endpoint: "https://mainnet-v4.tonhubapi.com",
      });

      const factory = tonClient.open(
        Factory.createFromAddress(MAINNET_FACTORY_ADDR)
      );
      const jettonRoot = tonClient.open(
        JettonRoot.createFromAddress(TOKEN_ADDRESS)
      );

      const vault = tonClient.open(
        await factory.getJettonVault(jettonRoot.address)
      );
      console.log(vault.address);
      const TON = Asset.native();
      const TOKEN = Asset.jetton(TOKEN_ADDRESS);
      const assets: [Asset, Asset] = [TON, TOKEN];
      const tonAmount = toNano("1"); // 1 TON
      const scaleAmount = toNano("10000"); // 10 SCALE
      const targetBalances: [bigint, bigint] = [tonAmount, scaleAmount];
      const transferTx = beginCell()
        .storeUint(0xf8a7ea5, 32)
        .storeUint(1, 64)
        .storeCoins(scaleAmount)
        .storeAddress(vault.address)
        .storeAddress(wallet)
        .storeBit(false)
        .storeCoins(toNano("0.4"))
        .storeBit(true) // forward_payload in this slice,
        .storeRef(
          VaultJetton.createDepositLiquidityPayload({
            poolType: PoolType.VOLATILE,
            assets,
            targetBalances,
          })
        )
        .endCell();
      const tx: SendTransactionRequest = {
        validUntil: Date.now() + 5 * 60 * 1000,
        messages: [
          {
            address: JETTON_WALLET.toString(),
            amount: toNano(0.5).toString(),
            stateInit: undefined,
            payload: transferTx.toBoc().toString("base64"),
          },
        ],
      };

      await tonconnect.sendTransaction(tx);

      // await waiter();
    } catch (error) {}
  };
  return (
    <div>
      <Button onClick={transferJettons}>Transfer Jettons</Button>
    </div>
  );
};

export default Page;

I did the token sending transaction from frontend without the SDK and it worked. You can try it.

Rakeshpradhan1999 avatar Sep 16 '24 04:09 Rakeshpradhan1999