UI-REACT : Not able to burn jettons
Closed this issue · 0 comments
karanpokar commented
Describe the bug
I have created the telegram app to burn jettons. But some how it is failing on chain.
const prepareBurnTransaction = async (amountToBurn:string) => {
const burnMessage = beginCell()
.storeUint(0x595f07bc, 32) // 'burn' method selector
.storeCoins(toNano(amountToBurn)) // Amount to burn in nanotons
.endCell(); // Finalize the cell
console.log(burnMessage,burnMessage.toBoc().toString('base64'));
// Prepare the transaction object
const transaction: SendTransactionRequest = {
validUntil: Date.now() + 5 * 60 * 1000, // 5 minutes
messages: [
{
address: selectedCoin?.address, // Jetton wallet address
amount: toNano('0.05')?.toString(), // Transaction fee (e.g., 0.05 Toncoin for the burn)
payload: burnMessage.toBoc().toString('base64'), // Burn method payload
},
],
};
return transaction;
};
// Function to handle the burn transaction
const handleBurn = async (successFunction:any) => {
try {
const transaction = await prepareBurnTransaction(amount?.toString()); // Prepare transaction
console.log(transaction)
const response:any=await tonConnectUI.sendTransaction(transaction) // Send transaction via TonConnect
if (response.error) {
setLoading(false);
toast.error('Transaction Failed')
} else {
successFunction();
}
} catch (error) {
console.error('Error burning Jettons:', error);
alert('Failed to burn Jettons.');
}
};
Expected behavior
The app should be able to burn tokens onchain and should not fail.
Current behavior
Check this tx hash it fails on chain, https://tonscan.org/tx/cf156f99151014310e8a88b3908ed67fd09c1c26484d7753ee35e28d1355ff12
Steps to Reproduce
- Create a next app
- Add tonconnect ui
- Add the above code and try to burn the tokens
Environment
MacOS, Chrome
Additional context
No response