Get Transaction Status

The getTxStatus method retrieves the current status of a transaction that was submitted asynchronously. When you submit a transaction using transfer, transferMulti, or submitRawTx with broadcast: true, you receive a ticketId that can be used to track the transaction's progress.

Usage

Basic Status Check

const ticketId = '5d4b9bfb-4dee-4f9b-bb0c-6b068572fae3'; // From transfer response
const status = await mnee.getTxStatus(ticketId); 
console.log('Transaction status:', status.status); console.log('Transaction ID:', status.tx_id);

Poll Until Complete

async function waitForTransaction(ticketId) {
  let status;
  let attempts = 0;
  const maxAttempts = 30; // 60 seconds with 2-second intervals
  
  while (attempts < maxAttempts) {
    status = await mnee.getTxStatus(ticketId);
    
    if (status.status === 'SUCCESS' || status.status === 'MINED') {
      console.log('Transaction confirmed:', status.tx_id);
      return status;
    }
    
    if (status.status === 'FAILED') {
      throw new Error(`Transaction failed: ${status.errors}`);
    }
    
    // Still broadcasting, wait and retry
    await new Promise(resolve => setTimeout(resolve, 2000));
    attempts++;
  }
  
  throw new Error('Transaction timeout after 60 seconds');
}

Parameters

  • ticketId: The ticket ID returned from a transfer or submitRawTx operation

Response

Returns a TransferStatus object:

Status Values

  • BROADCASTING: Transaction is being broadcast to the network

  • SUCCESS: Transaction successfully broadcast and accepted by the network

  • MINED: Transaction has been confirmed in a block

  • FAILED: Transaction failed (check errors field for details)

Common Use Cases

After Transfer

With Timeout and Retry

Batch Status Checking

Transaction Monitor

Error Handling

Important Notes

  • The tx_id field will be empty until the transaction reaches SUCCESS status

  • Tickets expire after a certain period - check status promptly after submission

  • Status changes are one-way: BROADCASTING → SUCCESS → MINED (or → FAILED)

  • Once a status reaches SUCCESS, MINED, or FAILED, it will not change

  • For real-time updates without polling, use webhook callbacks when submitting transactions

See Also

Last updated