Hey! I want to check transaction status in Moralis.Cloud event listener.
Suggest i have a listener like this
Moralis.Cloud.afterSave('CreateEvents', async function (request) {
async function waitForConfirmation(request) {
if (request.object.get('confirmed')) {
return
}
const config = await Moralis.Config.get({ useMasterKey: true })
const JSON_RPC_PROVIDER = config.get('JSON_RPC_PROVIDER')
const provider = new Moralis.web3Library.providers.JsonRpcProvider(
process.env.JSON_RPC_PROVIDER
)
const tx = await provider.getTransaction(
request.object.get('transaction_hash')
)
await tx.wait()
}
await waitForConfirmation()
// do some logic after confirmation
// ....
}
There waitForConfirmation - is a function that should check transaction status. But unfortunately i cannot get provider instance like
const provider = new Moralis.web3Library.providers.JsonRpcProvider
in Moralis.Cloud.
I know that Moralis auto update status after confirnation. But i want to avoid a delay (1-2 min) and get status as soon as posible.
Any suggestions? Thanks!