1

I'm trying to create a crowdsale contract based on OpenZeppeline. The complete code can be found here. However, in remix, it's throwing the following warning:

browser/crowdsale.sol:262:3: Warning: Function state mutability can be restricted to pure
  function finalization() internal {
  ^
Spanning multiple lines.

The code that's creating the problem here is:

function finalization() internal {}

Can anyone suggest what is wrong here and how I can rewrite this finalization code so that there is no warning?

2

There is actually nothing wrong with the code. Remix just realizes that function finalization does not modify nor access the contract storage. For such functions, it is recommended to use the pure modifier, so if you change the line to

function finalization() pure internal {}

the warning will disappear.

Note, however, that the people from OpenZeppelin put this function in for the sake of completeness, leaving it to the user of their code to override it. If you do this, it is most likely that you will access contract storage in the function, which will make the function no longer pure.

For more information on pure and view functions see here and the solidity documentation , section Functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.