Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
How can I wait for transaction to confirm using TonWeb?

I'm writing a simple DApp on TON blockchain and using the tonweb JavaScript library to interact with it.

I need to first send a transaction, and then after it confirms on chain, perform some other code in JavaScript.


await ton.send('ton_sendTransaction', [{
        to: 'some address',
        value: '1000'
// wait for tx to confirm on chain

I don't know how to wait for a transaction's confirmation.

Posted one year ago
Edited one year ago
Daniil Sedov
219 × 6 Administrator
Votes Newest


You can save transaction hash before sending it and then query Toncenter API method getTransactionByInMessageHash to check if transaction with such hash was confirmed or not


// Sleep function:
const sleep = ms => new Promise(r => setTimeout(r, ms))

// `msg` is a Cell containing your external message
// Convert message Cell to BOC String
const boc = await msg.toBoc(false)

// Calculate it's hash
const hash = tonweb.utils.bytesToBase64(await msg.hash())

// Send message and run a loop until transaction with that hash confirms
await tonweb.sendBoc(boc)
var txs = []
while (txs.length == 0) {
    await sleep(1200) // some delay between API calls
    const resp = await fetch('https://toncenter.com/api/index/getTransactionByInMessageHash?&include_msg_body=false&msg_hash=' + encodeURIComponent(hash))
    txs = await resp.json()

Posted one year ago
Edited one year ago
Daniil Sedov
219 × 6 Administrator

What if several transactions will be processed by the account between calls to the getTransactions()? You will probably match an incorrect transaction. You need to implement a more strict transaction matching for this to work reliably.

Slava Fomin   one year ago Report

@<1485966303708581888|Slava Fomin> Yes you're right. I mentioned in the answer that it's just a simple approach. I'll update the answer now with more explanations

Daniil Sedov   one year ago Report
1 Answer
one year ago
one year ago