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
This example begins with count zero and a request to call increment(). No real contract is deployed.
This example begins with count zero and a request to call increment(). No real contract is deployed.Execution follows the code’s input and permission rules. A website button is not the access-control mechanism.The function reads zero, calculates zero plus one, and writes one to persistent storage.The accepted state contains count one. Later reads can inspect it. Events are emitted only if the code implements them.
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?
Anyone can construct a direct call to a public interface.