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

Flash loans as a mechanism

Atomic borrowing changes available temporary capital, not arithmetic truth.

LET’S PICTURE IT

A borrower can use resources during one all-or-nothing procedure if repayment conditions are met.

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.

Understand atomic repayment

A flash-loan protocol makes funds available during a transaction and checks repayment conditions before accepting the final execution. Failure typically reverts the enclosing workflow.

Separate mechanism from vulnerability

Temporary capital can support legitimate operations. A harmful result depends on a separate weakness such as unsafe price assumptions or inconsistent accounting.

Test without assuming small balances

A protocol should not rely on an adversary lacking enough temporary capital unless that assumption is explicitly justified. Model large local balances in tests.

Preserve the full fee and callback context

The provider defines fees, callback authentication and repayment details. A generic flash-loan description is not sufficient to implement any particular provider’s interface.

Reason about the scenario

borrow → callback actions → repayment check
all conditions pass → transaction can succeed
repayment fails → workflow reverts

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 flash loan itself make an incorrect price mathematically correct?

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.