Contract Structure
Contract structure
State and local variables
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.0 <0.9.0;
contract SimpleStorage {
uint public storedData; // State variable
// ...
function updateStoredData(uint newData) public {
uint formattedData = newData * 2; // formattedData is local variable
storedData = formattedData;
}
function getFormattedData() public view returns (uint) {
return formattedData; // failed can't compile because formattedData is local scope to the other function
}
function getStoredData() public view returns (uint) {
return storedData; // can compile because global variable
}
}Functions
Function modifiers
Events
Errors
Struct types
Enum types
Last updated