In this track: Write and read Solidity
advanced · 4 MIN READ

Functions and visibility

Call reachability and business authorization are separate layers.

LET’S PICTURE IT

A door can be publicly reachable while a guard still checks which operation a visitor may request.

SEE IT FOR YOURSELF
A valid counter call, step by stepStep 1 / 4
A valid counter call, step by stepFunction requestincrement()No argumentsBefore executionstored count0A local teaching example with a defined starting stateIncoming callCheck function dispatchCheck coded conditionsRules passConditions passContinue executionA failed check can revert insteadCalculation0 + 1Result: 1Storage writecount = 1Persists if call succeedsCalculating a local value and storing it are separate stepsPersistent statecount1Later readGetter reports 1No new incrementState, logs and browser display have different roles

This example begins with count zero and a request to call increment(). No real contract is deployed.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

Read the visibility category

Solidity functions can be public, external, internal or private, each with language-defined reachability. Public and external functions can form part of the callable contract interface.

Reachability is not a role check

An external function does not automatically restrict callers to trusted websites. An owner-only condition requires actual code that checks permission. Naming it private in a comment changes nothing.

Private does not encrypt blockchain state

A private variable restricts source-level access from other contracts or derived code under language rules. It does not make the raw state cryptographically hidden from observers of a public chain.

Use a narrow teaching example

The helper below is internal and reached through an external wrapper. That demonstrates call structure without claiming it is an access-control policy. Read the permission-check lesson for authorization.

Read the example

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract LearningExample {
    function twice(uint256 x) internal pure returns (uint256) {
        return x * 2;
    }

    function quote(uint256 x) external pure returns (uint256) {
        return twice(x);
    }
}

The wrapper makes the internal calculation reachable through a public interface.

QUICK CHECK · NO PRESSURE

Does a private Solidity state variable automatically become secret to public-chain observers?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.