Articles → BLOCKCHAIN → Pure And The View In Solidity

Pure And The View In Solidity






Pure Function





View Function





Example


// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

contract PureViewDemo {

    uint8 public state_var = 50; 
    
    function viewDemo() public view returns (uint) {
        return state_var;  
    }

    function pureDemo(uint a, uint b) public pure returns (uint) {
        return a + b;
    } 

}





Output


Picture showing the output of pure and view function in solidity



Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, October 16, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250