In this track: Smart contract security foundations
advanced · 4 MIN READ
Unsafe external call assumptions
Targets can fail, reenter or return unexpected data.
LET’S PICTURE IT
A public service counter can behave differently from the clerk you tested yesterday.
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 the trust boundary
An external address is another execution boundary. A familiar ABI or matching selector does not establish a cooperative implementation.
Handle several outcome shapes
The call can revert, return false under a schema, return malformed bytes or provide unexpectedly large output. Success handling and failure handling both need bounds.
Protect state during the handoff
The target may call back into reachable functions. Keep relevant invariants coherent and do not rely solely on the frontend’s intended order.
Test hostile dependencies
Local mocks should exercise the behaviors the protocol claims to tolerate. Document unsupported behaviors rather than silently assuming every token or oracle fits.
Reason about the scenario
dependency behavior matrix:
revert; false; malformed output; huge output; callback
For each, define expected application state and outcome.
Pseudocode or a simplified scenario for local reasoning. This is not a production contract or a completed security review.
QUICK CHECK · NO PRESSURE
Does a matching ABI establish a trustworthy target?
The interface does not establish behavior or authority.