kepadatan

// an example of a simple smart contract
pragma solidity 0.8.11;

contract MyContract {
  // Set Global public variables (make getters with "public")
  uint8 public storedNumber;
  
  // We create function to change number by anyone. Must not be same number
  // If it is, it will fail with message "They are the same number"
  function changeNumber(uint8 newNumber) public {
    require(storedNumber != newNumber, "They are the same number")
   	storedNumber = newNumber 
  }
  
  // This is how to return a public variable. This is already set with public
  // however for non public variables, this is how we create them
  function getCurrentNumber() public pure returns(uint8) {
    return storedNumber;
  }
}
John Appleseed