Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

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

TypeDescription

object

Returns the transaction receipt, retaining the original fields returned by the node, with the following processing applied: status is a number (1 indicates success, 0 indicates failure), blockNumber is a number, and fields such as gasUsed and effectiveGasPrice are decimal strings; events is an array of decoded events, where each element contains the address, event, args, and logIndex fields; when the transaction execution fails, revertReason is the reason for the failure. If the transaction is still not on-chain after the timeout, a null value is returned, and the specific error message can be obtained through GetLastError().

Arguments

NameTypeRequiredDescription

k

string

Yes

Function of the exchange.IO() function. When set to waitReceipt, the function is used to wait for a transaction receipt.

txHash

string

Yes

Transaction hash (a 32-byte hexadecimal string starting with 0x), i.e., the value returned by exchange.IO("api", ...) when sending a transaction.

options

object

No

Optional settings {timeout, confirmations, interval}: timeout is the maximum wait (milliseconds, 120000 by default, between 1000 and 600000), confirmations is the number of confirmations required (1 by default), and interval is the polling interval (milliseconds, 1500 by default, between 200 and 60000).

See Also

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.