Answers for "state variables in solidity"

0

state variables in solidity

state variables: simply put these are variables declared outside of any methods in a contract. They are permanently stored in a 'contract storage'.
example:
----
//declare solidity version


contract SolidityTest{
	uint sum; // =>[sum] this is called a 'STATE VARIABLE' declared outside of any methods
    
    function add(uint a, uint b){
		uint res = a + b // this 's LOCAL VARIABLE'
		sum = res;
	}
 function result() public view returns(uint){
 	return sum;  
 
 }
     
}
Posted by: Guest on April-07-2022

Browse Popular Code Answers by Language