I'm trying to send a specific number of transactions per day to a smart contract. Because of low CPU stake I easily get CPU error. My goal is to catch this error and handle it in order to keep trying sending transactions until CPU allows it.
try {
const res = await api.transact(objTrans, {blocksBehind: 3,expireSeconds: 30})
//do something
} catch (error) {
console.log('\nCaught exception: ' + e);
if (error instanceof RpcError) {
console.log(JSON.stringify(error.json, null, 2));
//send another transaction
}
}
This is what i'm trying to achieve, i tried this but the program just shuts whenever an error occurs.