a view function like this
function bar() public view returns (uint) {
variableInStorage.x=1;
return (variableInStorage.x);
}
it doesn't compile, but if I do something like
function bar() public view returns (uint) {
mystruct memory a = variableInStorage;
a.x=1;
return (a.x);
}
`
function foo() public{
bar();
}
If I make a call to that function it doesn't give me error, and it returns value 1, but if I then check the value of a.x it is not updated
If instead I make a function foo that calls internally bar and then I check the value of a.x, it is updated
So does view functions allow to modify state if called internally firing a transaction?
no, and you will pay the view function's gas fees
Обсуждают сегодня