An atomic transaction is a blockchain operation where all steps succeed together or none of them execute at all — there is no partial state. The term comes from the classical database concept of atomicity (the “A” in ACID properties), but in blockchain contexts it has a specific and powerful meaning: everything in a single Ethereum transaction either completes and is written to state, or the entire transaction reverts as if it never happened. This property is what makes flash loans possible (borrow millions with zero collateral, use them, and repay in one transaction — or the whole thing reverts), what makes complex multi-protocol DeFi interactions safe to compose, and what makes arbitrage bots risk-free (the arb either works and profits, or it doesn’t and costs only gas).
The Core Property
In a standard Ethereum transaction, you can call multiple smart contracts in sequence — depositing into a lending protocol, then using borrowed funds in a DEX, then repaying the loan. The EVM tracks all state changes throughout:
- If every call succeeds → all changes are committed to the blockchain
- If any call reverts (fails) → the EVM unwinds all changes back to the state before the transaction began
Neither the user nor any external party ever sees the intermediate state. From the perspective of the blockchain, the transaction either happened (all steps, atomically) or it didn’t happen at all.
Why This Matters in DeFi
1. Flash Loans
2. Arbitrage Without Risk
3. Composability
4. Liquidation Safety
How Atomicity Is Enforced
The EVM uses a stack-based revert mechanism:
- Transaction begins; EVM starts tracking a “snapshot” of current state
- Each CALL opcode to an external contract is logged
- If any called contract executes
REVERT, it bubbles up: the calling contract’s state changes are also reverted - If the top-level call reverts (or runs out of gas), the entire state is rolled back
Gas: Even on a reverted transaction, the gas consumed up to the revert point is still charged — the miner/validator did the work of processing the transaction.
Atomicity Within a Block vs. Across Blocks
Within one transaction: Fully atomic. No partial state.
Across transactions within one block: Not atomic by default. Transactions in the same block are ordered sequentially (by MEV builders). Two separate transactions can interact, but there’s no cross-transaction atomicity guarantee. This is why:
- Flash loans must be single-transaction
- MEV bots must execute in one transaction
- Cross-protocol strategies needing atomicity use “smart contract wallets” or aggregators that bundle all steps
Across multiple blocks: No atomicity. This is why multi-block strategies (e.g., long-term yield farming) carry intermediate-state risk — at any point between blocks, prices can change, positions can be liquidated, and protocols can be exploited.
Practical Examples
Successful Atomic Flash Loan Arbitrage
Transaction begins:
- Borrow 10,000,000 USDC from Aave (flash loan) ✓
- Buy ETH on Uniswap with 10,000,000 USDC (ETH cheaper here) ✓
- Sell ETH on Curve (ETH more expensive here) ✓
- Repay 10,000,000 USDC + 0.05% flash loan fee ✓
- Pocket $15,000 profit ✓
Transaction committed — all state changes written.
“`
Failed Atomic Flash Loan (Price Moved)
Transaction begins:
- Borrow 10,000,000 USDC from Aave (flash loan) ✓
- Buy ETH on Uniswap ✓
- Sell ETH on Curve — price moved; would net a loss ✗ REVERT
- [never reached]
Transaction reverted — state returns to pre-transaction. Only gas is charged.
“`
Atomicity and MEV
Atomicity is central to MEV (maximal extractable value). Searchers bundle multiple steps into one atomic transaction — ensuring that if any step in a complex MEV strategy fails (sandwich attack, liquidation, arbitrage), the entire thing reverts with no loss other than gas. This is what makes MEV bots economically rational: failure is cheap (just gas), success is profitable.