I'm using the bundler repo, and during a code review, I'm having trouble understanding why the revert is used in the constructor. The intention seems to be to trigger an error, but using revert in constructors is not common. Normally, constructors set up the contract or perform initialization. This might be for a specific reason not clear in the code.BundlerHelper.sol constructors

1 Answer 1


Using revert in the constructor is a hack to run some EVM code without deploying it.

Let's consider you want to do an eth_call for getUserOpHashes (the view function call that doesn't cost money), however, that involves you deploying the contract on the chain which costs ETH (after that you can call view function for basically free). So instead what you can do is to use eth_call for deploying a contract that reverts along with some useful data and in the eth_call's response you get the revert data which you can parse.

Just to add a note here: view functions are considered free but it is misleading. The computation resource is spent by the node that is executing the eth_call, in the sense that it could do something else but the CPU was doing this job. Providers like Alchemy or Infura have a flat rate for this kind of request. So if you do this constructor revert eth_call (which is more costly for node) vs deploy the contract by paying gas and then make the eth_call (which is relatively cheaper) you are charged by Alchemy or Infura, so people are motivated to do this practice.

  • Okay, this appears to intentionally revert the tx in order to obtain the user's operation hash, without deploying the contract. Thank you for your response. Aug 28, 2023 at 4:39

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.