exchange.IO("waitReceipt", ...)
Waits for a transaction to be included on-chain and reach the specified number of confirmations, returning the transaction receipt and the decoded event logs.
exchange.IO(k, txHash)
exchange.IO(k, txHash, options)Examples
After sending a transaction, wait for it to be included on-chain, then check the execution result and events.
javascript
function main() {
// After sending a transaction, you will get the transaction hash, for example:
// var txHash = exchange.IO("api", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "approve",
// spender, amount)
var txHash = "TX_HASH" // The transaction hash to wait for
// Wait up to 2 minutes until 2 confirmations are reached
var rec = exchange.IO("waitReceipt", txHash, { timeout: 120000, confirmations: 2 })
if (!rec) {
Log("Wait failed:", GetLastError())
return
}
if (rec.status !== 1) {
Log("Transaction execution failed:", rec.revertReason)
return
}
Log("Block:", rec.blockNumber, "gasUsed:", rec.gasUsed, "Gas price:", rec.effectiveGasPrice)
// events contains the decoded events; the token Transfer/Approval events do not require ABI
// registration
rec.events.forEach(function (e) {
Log(e.address, e.event, JSON.stringify(e.args))
})
}Returns
| Type | Description |
object | Returns the transaction receipt, retaining the original fields returned by the node, with the following processing applied: |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Function of the |
txHash | string | Yes | Transaction hash (a 32-byte hexadecimal string starting with |
options | object | No | Optional settings |
See Also
Web3 exchange.IO exchange.IO("logs") exchange.IO("speedUp") exchange.IO("cancelTx") exchange.IO("api")
Remarks
Events are decoded according to the ABI registered through exchange.IO("abi", ...); the token Transfer and Approval events are supported natively and do not require registration. Logs without a matching ABI will not appear in events; their raw data can be viewed in logs.
Currently only Ethereum (EVM) chains are supported; TRON is not supported yet.