I wrote a simple calculator program in solidity. I recieved error given as
"Gas requirement of function calculator.add is infinite: If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage)"
Can anyone point out where it went wrong? Thanks in advance
here's my code
`// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.13;
contract calculator{
int result;
function add(int a,int b) public {
result = a+b;
}
function sub(int a,int b) public {
result = a-b;
}
function mul(int a,int b) public {
result = a*b;
}
function div(int a,int b) public {
require(b!=0,"B should not be 0!");
result = a/b;
}
function getResult()public view returns (int) {
return result;
}
}`
When there is a runtime error, EVM can't estimate the gas expense. You should look for runtime errors.