A flash loan lets you borrow with no collateral, on the condition that you repay within the SAME transaction. ERC-3156 standardizes flash loans; flash MINTING is the token-native form: the token mints you any amount out of thin air, you use it within one call, and it is burned (plus a fee) before the transaction ends. Nothing backs it but the atomicity of the EVM.
1// ERC-3156 lender interface (the token itself):2function maxFlashLoan(address token) external view returns (uint256);3function flashFee(address token, uint256 amount) external view returns (uint256);4function flashLoan(5IERC3156FlashBorrower receiver,6address token,7uint256 amount,8bytes calldata data9) external returns (bool);1011// The borrower must implement and return the magic value:12// keccak256("ERC3156FlashBorrower.onFlashLoan")
Why is lending unbacked, uncollateralized tokens safe? Atomicity. If the borrower does not return amount + fee (and approve it for the burn) by the end of onFlashLoan, the entire transaction reverts — un-minting everything as if it never happened. Legitimate uses include arbitrage, collateral swaps, and self-liquidation. During the call, the token's effective supply can briefly exceed its normal supply.
Systemic risk: flash loans let anyone temporarily command enormous capital, which supercharges attacks on systems that read instantaneous state — spot-price oracles and naive vote-counting. This is exactly why governance uses getPastVotes (see ERC20Votes) and protocols use time-weighted (TWAP) oracles instead of spot prices.
1function onFlashLoan(address initiator, address token,2uint256 amount, uint256 fee, bytes calldata data)3external returns (bytes32)4{5// ... do arbitrage / swap with 'amount' ...6IERC20(token).approve(msg.sender, amount + fee); // enable repayment7return keccak256("ERC3156FlashBorrower.onFlashLoan");8}
Connect your wallet to mark this lesson as complete
Earn 25 EFFORT tokens