Function Declarations

Function Visibility

  • public - can be called both within the contract and externally

  • external - can only be called from external contracts/EOAs

  • private - can only be called from this contract

  • internal - can only be called from this contract and other contracts that inherit it

Private is a subset of internal and external is a subset of public.

State Mutability

  • view: reads but does not modify the state

  • pure: does not read or modify the state

  • virtual for functions and modifiers: Allows the function’s or modifier’s behaviour to be changed in derived contracts.

  • override: States that this function, modifier or public state variable changes the behaviour of a function or modifier in a base contract.

Last updated