.wait(timeout?, interval?)
Feature
Keep polling the blockchain network for a transaction's status until it is confirmed or a timeout occurs, using default or user-specified timeout and interval values. Note: If the node initially reverts the transaction, the wait function is not executed. (EC_TRANSACTION_REVERTED occur). interval must less than timeout.
Parameters
number
| undefined
timeout, // if not given, the default value is 10000 [ms] number
| undefined
interval // if not given, the default value is 1000 [ms]
Return Value
object
SuccessResponse || ErrorResponse
example
// Note: an asynchronous request.
const sendOperation = async () => {
const info = await mitum.operation.send(sign.toHintedObject());
const receipt = await info.wait();
console.log(receipt);
};
sendOperation();
// output (If the transaction is processed successfully)
operation in_state is true
{
status: 200,
method: 'get',
url: 'http://127.0.0.1:24321/block/operation/DejBgQfuRGtwXspaUzC5YNv4ZT7i7zVy1TAxtjNyXEqJ',
request_body: undefined,
data: {
_hint: 'mitum-currency-operation-value-v0.0.1',
hash: 'DejBgQfuRGtwXspaUzC5YNv4ZT7i7zVy1TAxtjNyXEqJ',
operation: {
hash: '1zf2TiK5idBp2fP3zyPXkpRFDddF7oAyCyQMfJWv82B',
fact: [Object],
signs: [Array],
_hint: 'mitum-currency-transfer-operation-v0.0.1'
},
height: 752899,
confirmed_at: '2024-04-05T04:51:17.46Z',
reason: '',
in_state: true,
index: 0
}
}
// output (If the transaction fails and is not processed)
operation in_state is false. reason: check enough balance; insufficient balance of sender, 0xe1842cCaAf7Df28467ECFdFbD3bdB7de84dEDC3Dfca; 10 !> 21
{
status: 200,
method: 'get',
url: 'http://127.0.0.1:24321/block/operation/7CopNsoAMU9WGneAmAA4fWauNvKHiD5ZGhGBwYJZf4cm',
request_body: undefined,
data: {
_hint: 'mitum-currency-operation-value-v0.0.1',
hash: '7CopNsoAMU9WGneAmAA4fWauNvKHiD5ZGhGBwYJZf4cm',
operation: {
hash: 'DgH2p8QMJasvZZ5hnrWiAgZgKR21UDdnzi5YjUp9mi2f',
fact: [Object],
signs: [Array],
_hint: 'mitum-currency-transfer-operation-v0.0.1'
},
height: 752937,
confirmed_at: '2024-04-05T04:54:12.457Z',
reason: 'check enough balance; insufficient balance of sender, 0xe1842cCaAf7Df28467ECFdFbD3bdB7de84dEDC3Dfca; 10 !> 21',
in_state: false,
index: 0
}
}
Last updated