3 Built-in modifiers in Solidity

  • view - No need to pay gas fee to call functions with view modifier because it does not change state of the blockchain
  • pure - No need to pay gas fee so it’s free to call. It neither reads or writes to the blockchain. It’s used as functions where input has identical output.
  • payable - Need to pay gas fee (variable). It’s often used in token sale contracts where money is sent by users to each other.
function getMyName() public view returns(string memory) {
    return myName;
}