Atomicity is a fundamental property of blockchain transactions that guarantees a transaction is processed as a single, indivisible unit. Either all operations within the transaction are executed successfully, or none of them are.
Why Atomicity Matters
In financial systems, partial execution of transactions would be catastrophic. If you swap Token A for Token B, atomicity ensures you can't lose Token A without receiving Token B. The transaction either completes both sides or reverts entirely.
Atomicity in Smart Contracts
Smart contracts on platforms like Ethereum enforce atomicity — if any step in a multi-step transaction fails, the entire transaction reverts and all state changes are undone. This is crucial for DeFi protocols where transactions often involve multiple token transfers and contract interactions in a single call.
Practical Example
When using a DEX to swap ETH for USDC, atomicity guarantees that the ETH leaves your wallet and USDC arrives in the same transaction. If the swap fails for any reason (insufficient liquidity, slippage too high), you keep your original ETH.