Solidity·Solidity essentials

Functions and visibility

Functions declare visibility and can read or write state.

Intermediate 10 min read Lesson 2 of 150 Challenge included
What you will be able to do
  • Use external/public for callers.
  • Use view for reads.
  • Use pure for no state access.

In plain English

Functions declare visibility and can read or write state.

  • Use external/public for callers.
  • Use view for reads.
  • Use pure for no state access.
Math.solSOLIDITY
pragma solidity ^0.8.24;

contract Math {
    function add(uint256 a, uint256 b) public pure returns (uint256) {
        return a + b;
    }
}
Your turn

Explain it back

Easy

Answer from memory: Which mutability means no state is read or written?

TEXT · starter
Your answer…
Check your understanding before moving on.
Knowledge checkQuestion 1

Which mutability means no state is read or written?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: Events
Lesson 2 of 150 · 0% of course