Skip to content

How to catch exception or receive the result of transaction #14

Discussion options

You must be logged in to vote

@nhannh-senspark hi,

We can modify the buy method written at:
https://github.com/ton-community/flappy-bird/blob/ff2287d668e1d41c76c02201f80c7aa7f1181789/workspaces/client/src/ui.ts#L96

try {
    await this.gameFi.buyWithJetton({
        amount: BigInt(price),
        forwardAmount: BigInt(1),
        forwardPayload: (window as any).Telegram.WebApp.initDataUnsafe.user.id + ':' + itemId
    });

    // Here we know transaction was sent. But it doesn't mean it received
    // Receiving mechanism is implemented on the backend side, in `processTxsForever` function
} catch (error) {
    console.error('Failed to buy an item.', error);
}
  1. We added await to buyWithJetton call. In the next line we …

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@nhannh-senspark
Comment options

@barinbritva
Comment options

Answer selected by nhannh-senspark
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants