Suppose I have a contract which performs an arbitrary mathematical calculation like:
function add2plus2() external view
return 2 + 2;
The function does not rely on any state information of the contract, and does not actually require any knowledge of what is happening on the Ethereum chain, the EVM or otherwise. It just performs a basic mathematical calculation.
I am aware that view functions do not modify stateful variables within a contract. However, they cost gas to perform.
Is there a way to define such a function that is performed client-side, without any interaction with the EVM - and hence be gasless? If so, how would such a function be defined?