Manual block confirmation for arbitrum streams

Hi guys, I have a question.

Based on this documentation for Arbitrum I will receive a stream request from Moralis with confirmed = true when will be 100 block confirmations.

Sometimes it can takes up to even 10 minutes (it happened to me).
In that case for Arbitrum I would like to build a custom block confirmation.

Do you have an idea how to make it properly?
I tried something like:

import { Types as StreamsTypes } from '@moralisweb3/streams';
import { JsonRpcProvider } from 'ethers';
import { uniqBy } from 'lodash';

const checkTxConfirmation = async (input: StreamsTypes.IWebhook, jsonRpcUrl: string): Promise<boolean> => {
  if (!input.confirmed) {
    const provider = new JsonRpcProvider(jsonRpcUrl);

    const results = await Promise.all(
      uniqBy(input.logs || [], 'transactionHash').map(async (log: any) => {
        const tx = await provider.getTransaction(log.transactionHash);
        const receipt = await tx?.wait(10);

        return receipt?.status === 1;

    return !results.find((confirmation) => !confirmation);
  return input.confirmed;

But I’m not sure whether is a good direction.
Can you advice?

Hi @mits87

Can you please confirm if you are still seeing the same issue? In general, it should not take 10 minutes.

For block confirmations, you just have to wait for a certain number of blocks and check if the transaction hash still exists at that block. So I think your approach is correct

Now I don’t have specific logs anymore but I experienced that few times that I received unconfirmed webhook event and after 5 / 7 / 10 min I’ve got confirmed event.

It happened few times and for some chains like Arbitrum I can’t wait so much time for block confirmation (100 confirmations regarding documentation).

So I would like to have my own control over that (let’s say for me it’s fine if I get 20 confirmations instead 100).

Any idea?

you can use a delay in seconds, for example you can wait 30 seconds and then check the transaction hash with a RPC node to see if it was confirmed and at what block number