ston-fi / sdk

SDK for building applications on STON.fi protocol
MIT License
103 stars 19 forks source link

[Question] How to parse the result of a routerV1 SwapTonToJetton transaction? #38

Closed 3ww3-latiao closed 1 week ago

3ww3-latiao commented 1 month ago

Here is my example:

const txParams = await router.getSwapTonToJettonTxParams({
    userWalletAddress: wallet.friendlyAddress,
    proxyTon,
    offerAmount,
    askJettonAddress: not,
    minAskAmount,
});
const res = await wallet.connecter.sendTransaction({
    validUntil: dayjs().add(10, 'm').unix(),
    messages: [
      {
        address: txParams.to.toString(),
        amount: txParams.value.toString(),
        payload: txParams.body?.toBoc().toString('base64'),
      },
    ],
});

I am swapping notcoin through proxyTon and sending the transaction using tonconnect. Everything seems fine, and the transaction is confirmed on the blockchain. However, I am having trouble parsing the BOC. I don't know the details of the response data, but I know that the op is 2281714092.

pavel-rakhmanov commented 2 weeks ago

The cell creation is made in the create*Body contracts method.

If, for some reason, you need to parse BOC you can take a look at the createJettonTransferMessage and create*Body functions and just read from the BOC value by values according to the way it was packed.

For reference, you can take a look at this code where we read data about the router from the BOC by knowing the order and type of values, stored in the BOC