DEV Community

Loading Blocks
Loading Blocks

Posted on

Function Visibility AND a changeable state modifier

Preface

In solidity, modifier controls access permission of function or state.

Visibility modifiers

  1. public variables automatically generate getters.
  2. private variables can be only accessed in the inner contract. 3.internal variables can be accessed in the inner contract and sub contract, external cannot call 4.external functions cannot be called internally with this

State Mutability Modifiers

  • view view functions can read but not modify state. call don't consume Gas,It can call other view or pure functions.
  • pure pure functions do not read or modify state. This function neither reads nor modifies the contract state.

Its output depends solely on the input parameters.

  • default modifier can modify state, external calls need transaction and consume Gas.

Solidity Function Modifiers Summary

Modifier External Call Inner Call Sub Contract Call Modify State Read State
public
external ❌ (this) ❌ (this)
internal
private
view
pure

Top comments (0)