Is there a way to filter ethereum json-rpc methods to only allow read calls, not writing? ie, filter out sendTransaction, sendRawTransaction, create, etc

  • One option would be to write some middleware that sits in front of your node. Commented Mar 7, 2022 at 17:07

1 Answer 1


If you want to do it inside the node, you will need to override some of frontiers RPC handlers. For example, you can see the EthApi implementation here:https://github.com/paritytech/frontier/blob/master/client/rpc/src/eth.rs. You could proceed in either of two ways:

  1. Copy this code and change some methods eg sendRawTransaction to behave as you like.
  2. Write your own struct that wraps the one I linked. For methods you want to enable, you can call into the wrapped original. And for methods you want to block, you can just return immediately with no action or error.
  • Thanks @JoshOrndorff. I think that the correct way to achieve what I want is to use a middleware as you suggested, because I only want some nodes to be read-only. In this case it's infeasible to use different implementations for each type of node. Maybe in the future we could have cli options to directly filter the methods.
    – afm
    Commented Mar 7, 2022 at 20:43

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.