In this track: Smart contract security foundations
advanced · 4 MIN READ

Access control mistakes

Sensitive actions need the correct on-chain authority checks.

LET’S PICTURE IT

An office must check who may edit the master records, not just hide the edit button.

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.

List privileged actions

Identify upgrades, minting, withdrawals, role changes and parameter setters. Review every reachable path to each effect rather than only functions labeled admin.

Check the correct identity

Immediate caller, signed authorizer and transaction originator are different concepts. Select the authority required by the protocol and validate it consistently.

Review role transitions

Granting, revoking and transferring authority can be as sensitive as the final privileged action. Consider accidental renunciation and incomplete ownership transfers.

Test unauthorized callers

Include unrelated accounts, former owners and contracts acting as intermediaries. Verify that failure leaves state unchanged.

Reason about the scenario

privileged effect → identify every entry path
entry path → enforce intended authority
role changes → review with the same care

Pseudocode or a simplified scenario for local reasoning. This is not a production contract or a completed security review.

QUICK CHECK · NO PRESSURE

Is hiding an admin button enough to restrict an external function?

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.