My goal is to detect a contract invocation as fast as humanly possible. To do this I am processing all the pending transactions I have access to (via provider.on("pending", async (tx) => {})
).
To detect the contract invocation I am looking for, I scan the data
field of the transaction for the method signature. However, I have seen that a contract can be invoked via a call to another contract which may in turn call the method of interest. In this case the data
will only contain the method signature of the buffer contract, I don't think I can get further from this approach.
Another approach is to listen to contract events via targetContract.on("targetMethod", (**parameters) => {})
, however this way I have only access to the method parameters, I would like to have access to the transaction hash (even better if its still pending). I understand accessing the pending transaction is not possible since for the event to be recorded, it has to have been already processed, right?
Is it possible to access the transaction hash this way? Is there any way to achieve my goal of detecting contract invocation even when done via proxy contract and placing a transaction that gets processed in the same block?
Thanks!