I have an Smart Contract which submits events when a function is executed, and the associated transaction is mined.

It works perfectly from NodeJS with a websocket network provider (wss://), but Metamask does not support web socket URLs when adding a blockchain network.

Without a web socket connection I cannot listen to Blockchain events. How could users listen to Blockchain events, from their own Metamask connection?

The only alternative I see, is to get the event data from the receipt (I'm using ethers). Is this a valid/safe approach?

await w3.provider.send('eth_requestAccounts', []);
let signer = w3.provider.getSigner();
let scWithSigner = w3.my_contract.connect(signer);

let rawTX = await scWithSigner.myFunction(true, {value: 1});
const receipt = await rawTX.wait(1);


1 Answer 1


from their own Metamask connection

They cannot. MetaMask connection is solely designed to be used only for MetaMask's internal functions. It includes arbitrary RPC limitations that make using this connection for Dapps difficult.

Plese use your own nodes as Dapp developer. Because Ethereum users are not running their own nodes, as a Dapp developer you need to provide a node for them. You can find some providers at ethereumnodes.com.

  • But if your make you RPC URL available on your frontend, anyone could use it for their own requests. There is no way to restrict the origin, as any connected wallet could be a potential user. solana.stackexchange.com/questions/1055/… Commented Jan 18 at 11:34
  • This is correct. However this is the price to pay if you want to develop Dapps. Otherwise you need to ask users to bring their own nodes and no one is going to do that. Commented Jan 18 at 11:59
  • Also note that MetaMask has the same issue and their RPC is tailored to limit abuse. The problem is not limited to blockchain RPC, but is the same across all free RPC services. Commented Jan 18 at 11:59
  • 1
    If you really want to be strict about it, you can proxy all your RPC requests and ask users to authenticate first to your centralised backend, where you can do user filtering, but again no one is going to use your service if you do that. Commented Jan 18 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.