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.
From the official documentation:
The first four bytes of the call data for a function call specifies the function to be called. It is the first (left, high-order in big-endian) four bytes of the Keccak-256 (SHA-3) hash of the signature of the function. The signature is defined as the canonical expression of the basic prototype without data location ...
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-...
Gas , refers to the amount of gas remaining after the execution of the STATICCALL function while gasCost is the cost of static call. The former is available for other calls in the transaction and refunded if not used .
The cost of STATICCALL is 700 gas.
To verify, at step 323 , you have a STATICCALL
But at the next step 324, ...