Closed W123-T closed 10 months ago
The code snippet you provided appears to be correct and should send the transaction and then retrieve the transaction status using the myAppExplorerService.getTransaction()
method which you have created by yourself.
However, it is recommended to use tonConnectUI.sendTransaction()
from @tonconnect/ui-react
or @tonconnect/ui
instead of connector.sendTransaction()
. This is because UI packages have built-in handlers for displaying modal windows and notifications. The usage is almost the same as the example you provided, but instead of calling connector.sendTransaction()
, you would call tonConnectUI.sendTransaction()
.
Additionally, please make sure that the wallet is indeed connected through TON Connect at the time of sending the transaction. Also, verify that the validUntil
parameter is not expired; otherwise, it may cause an error.
Thank you, but where does this myAppExplorerService come from,How should I implement it,I used @ tonconnect/ui repeat, and when using sendTransaction, it was in a loading state. The window prompted me to 'Confirm the transaction in Tonkeeper' It will only take a moment , This is my demo code: /xxxx/
const Content: React.FC<IContentProps> = ({ }) => {
const [tonConnectUI] = useTonConnectUI();
const myTransaction = {
validUntil: Math.floor(Date.now() / 1000) + 10000,
messages: [
{
address: "EQBBJBB3HagsujBqVfqeDUPJ0kXjgTPLWPFFffuNXNiJL0aA",
amount: "20000000",
// stateInit: "base64bocblahblahblah==" // just for instance. Replace with your transaction initState or remove
},
]
}
return (
<div>
<button onClick={() => {
tonConnectUI.sendTransaction(myTransaction);
myAppExplorerService.getTransaction();
}}>
Send transaction
</button>
</div>
);
}
/xxxx/
Hello friends, myAppExplorerService.getTransaction()
how to wait and show the success message to the user?
Hi, please open this issue again i also still confused how to get transaction detail by boc @thekiba
Hello, the readme example is using this myAppExplorerService.getTransaction(). Is there a sample code ?
The current method i know is getting the convert the bloc and get msg hash then use find transaction by msg hash method
const bocCell = tonweb.boc.Cell.oneFromBoc(tonweb.utils.base64ToBytes(blocString)); const YOUR_MSG_HASH= tonweb.utils.bytesToBase64(await bocCell.hash()); console.log("Msg Hash:", hash);
https://github.com/ton-connect/sdk/issues/106#issuecomment-2116506961 yes , is there a resolution for get hash by boc?