-
I am calling a view function inside of a gas-calling function (in this case my simple storage function), however, the execution cost does not seem to go up. Anyone else experiencing this or know why this would be the case? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
My experience with |
Beta Was this translation helpful? Give feedback.
-
@Quent-eth view or pure function when called alone don't spend gas, however if a gas calling function calls them, then it will cost gas, like in this tutorial, I called the retrieve() function inside the store() function function retrieve() public view returns(uint256) {
return favoriteNumber;
} function store(uint256 _favoriteNumber) public virtual {
favoriteNumber = _favoriteNumber;
retrieve();
} There comes a difference of gas costs depending whether the store function is called with or without the retrieve() function. In my case the transaction cost was 43,746 without calling the view function and 43,886 with calling the view function. |
Beta Was this translation helpful? Give feedback.
-
This is a good question Thats kinda BS if that's the situation... |
Beta Was this translation helpful? Give feedback.
@Quent-eth view or pure function when called alone don't spend gas, however if a gas calling function calls them, then it will cost gas, like in this tutorial, I called the retrieve() function inside the store() function
There comes a difference of gas costs depending whether the store function is called with or without the retrieve() function.
In my case the transaction cost was 43,746 without calling the view function and 43,886 with calling the view function.