Function types
Last updated
Last updated
public -> all can access
external -> only externally calls; cannot be accessed internally
internal -> only this contract and contracts deriving from it can access
private -> can only be accessed from within this contract
View functions do not modify the state, thus only being used for viewing the state. Therefore only can return data:
List of conditions for a statement to be considered as “modifying the state”:
State variables being written to.
Events being emitted.
Other contracts being created.
selfdestruct
being used.
ETH being sent via calls.
Calling functions that are not marked view or pure.
Low-level calls being used.
Inline assembly containing certain opcodes being used
A View function can call on other View or Pure functions. Cannot call a writing f() -> else it would no longer be a read-only interaction.
pure function is one that does not interact with the blockchain in any way, including reading state of variables. It is self-encapsulated.
A pure f() can ONLY call another pure f() -> anything else it would violate the rule and interact w/ SC.
a writing f() can call any.