Solidity: The pure getter and view functions

Solidity provides two particular types of getter functions: view and pure.

The view functions

view allows the state to be read but does not allow the state to be modified:

uint public a = 1;function viewFunction(uint b) public view returns (uint) {
return a + b;

Let’s compile and deploy the contract. Then call the viewFunction() function:

The result is 3 = 1 + 2.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Bruno Delb

Bruno Delb

Blockchains, DevOps, Agile Coaching, development, testing, Cloud, Management 3.0, ITIL. It defines me.