cargo.pollTx

After enabling Cargo you can use the PollTx instance on the enabled Cargo instance. You can use the methods of the PollTx class to watch pending transactions and notify you when they are complete. Here is the source on GitHub.

Using PollTx

Here is an example of how you might use PollTx in an application

async function purchaseAnItem(resaleItemId, price) {
// After making a call that submit a transaction,
// PollTx will immediately start watching the transaction
// for completion. You can listen for completed transactions
// by using the events below.
const tx = await cargo.api.purchaseResaleToken(resaleItemId, price);
}
// Somewhere else in your application you can add event listeners
// to the PollTx instance that will tell you when the list of pending
// transactions has been updated and when a transaction is complete
cargo.pollTx.on('pending', (newTx, pendingTxArray) => {
// newTx is the new pending transaction
// pendingTxArray a list of all transactions that are still pending
console.log(pendingTxArray);
});
cargo.pollTx.on('completed', (tx, pendingTxArray) => {
// tx is the completed transaction hash
console.log(tx);
// pendingTxArray is the updated list of pending
// transactions.
})