Is it possible to set eth_sendTransaction event listeners?

Hi everyone,

I’d like to build an extension that listens to eth_sendTransaction requests to the Coinbase Wallet to process the to address that the user is about to interact with. Would anything like this be possible at all? I checked the docs but I wasn’t able to find the answer.

Thank you in advance!

Hi @HumanChapter! Welcome to the forum! We appreciate your support in trying Coinbase APIs.

Regarding your query, Coinbase Wallet injects a “Provider” in the top level window. eth_sendTransaction requests are made using this Provider. Unfortunately, calling this method doesn’t emit any events that you can listen for. We hope this helps, and again welcome to the community!

3 Likes

Is this the same as window.ethereum? Or could you point me to some docs explaining how to access this “Provider”?

Many thanks!

Hello @HumanChapter! The provider will be made available at window.ethereum. You can refer to this documentation for details on the said provider: Coinbase Wallet Injected Ethereum Provider

3 Likes

Ah yes, got it, thank you heaps!

I assume by the same way Coinbase Wallet handles multiple injected providers (with MM and CBW), I could also overwrite the provider.request() function to intercept the parameters and grab the to address, then forward the call to the original function. Is there any flaw in this logic somewhere?

Hi @HumanChapter! Unfortunately, we can’t speak to or verify whether or not overriding methods to the provider will work, but it sounds like a reasonable approach to accomplish what you want, if possible.

3 Likes

Sounds good, thank you!