2

This question already has an answer here:

stateMutability: a string with one of the following values: pure (specified to not read blockchain state), view (specified to not modify the blockchain state), nonpayable and payable (same as payable above).

constant: true if function is specified to never modify blockchain state; payable: true if function accepts ether, defaults to false.

marked as duplicate by Achala Dissanayake, Richard Horrocks, flygoing, Roman Frolov, Nicolas Massart Feb 25 '18 at 17:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Within the original design some use cases were not possible to express. For example a pure function doesn't have an equivalent. – Ismael Feb 23 '18 at 14:13
2

constant has been deprecated in favour of pure and view - see here

pure is used for functions where state isn't even read (e.g. safeMath type functions) whereas view is used for functions which don't change state but do read from it.

in terms of the ABI, constant was retained for backward compatibility:

Remarks:

JSON ABI has a new field statemutability introduced with a string value as above

JSON ABI keeps constant/payable for backwards compatibility for a while

Source: Axic's comment on 15 Aug 2017 here

  • I guess the OP is not interested in the difference between pure/view/constants etc. He is asking why the abi contains stateMutability term since view/constant are already defined in the function signature. – Prashant Prabhakar Singh Feb 23 '18 at 12:06
  • The answer is clear. constant and payable was retained for backward compatibility. Thank you! – Anderson Feb 24 '18 at 9:44

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