STATICCALL functions equivalently to a CALL, except it takes only 6
arguments (the “value” argument is not included and taken to be zero),
and calls the child with the STATIC flag set to true for the execution
of the child. Once this call returns, the flag is reset to its value
before the call.
By definition of EIP-214 any state change within a static call will cause an error. So if you define your function as view or pure this will not be possible, as this indicates the calling contract that they should use staticcall.
BUT if you want to write a method and don't care about the view or pure you can do a little trick.
You create a method that will ...
From the ethers documentation we can see that contract.callStatic is an utility that interacts with the node itself. It works by asking the node to simulate the transaction, without the tx being actually sent to be mined.
A similar behaviour isn't available at a smart contract level as any state change is permanent if not reverted. A workaround could be re-...