Atomicity in blockchain: how the “all or nothing” principle works

What is atomicity in blockchain?
Atomicity in blockchain is a transaction execution principle under which all state changes specified by an operation are either applied in full or not applied at all. Atomicity in blockchain prevents partial transaction execution and helps preserve data integrity in a distributed system.
The principle of atomicity in blockchain states that if the modified state of the system is not confirmed, the system will be returned to its original state — in other words, "all or nothing".
The concept of atomicity emerged long before blockchain and is used, in particular, in database theory. Atomicity is the letter A in the ACID model (Atomicity, Consistency, Isolation, Durability), which describes the properties of reliable transactional systems. Blockchains use the same fundamental principle: an intermediate, partially modified state must not become the final result of a transaction.
Atomicity in blockchain is one of the key standards used by virtually all blockchain protocols, including Bitcoin, Ethereum, XRP, Solana, and many others.
The origin of the term "atomicity in blockchain" is associated with one of the key characteristics of decentralized systems — indivisibility or integrity.
In other words, atomicity in blockchain means that in any decentralized system, a transaction represents a single indivisible unit, even if it involves several different operations (for example, a transfer and an exchange).
Consensus mechanisms such as Proof-of-Work (PoW) or Proof-of-Stake (PoS) ensure atomicity in blockchain.
In addition, atomicity in blockchain is related to other key properties of decentralized systems:
- Finality — the inability to change an already confirmed state of the system;
- Composability — the ability of different protocols to interact correctly with one another and reverse related changes if one of the operations ends in an error;
- Correctness of execution — compliance of transaction execution with the protocol's operating rules.
At the same time, atomicity and finality describe different properties. Atomicity in blockchain answers the question of whether an operation will be completed in full or reverted, while finality determines how definitive a state already accepted by the network is. A transaction may execute atomically while still being included in a block that has not yet reached finality.
Composability is particularly important for DeFi, where a single transaction may sequentially use the functions of several protocols. For example, a smart contract may obtain a loan, exchange an asset on a decentralized exchange, and use the resulting tokens in another protocol — all within a single logical operation. Atomicity in blockchain makes it possible to avoid preserving an intermediate state if the entire sequence cannot be completed.
The importance of atomicity in blockchain
Atomicity plays an important role in blockchain transaction processing. Completing transactions with errors could disrupt the operation of the entire blockchain system.
This is particularly important because when a transaction is rejected, it is necessary not only to restore the previous state of the blockchain but also to restore the balances in the wallets of the participants involved in the operation.
For ordinary transactions, such as cryptocurrency transfers, this process is straightforward and standard. However, with complex transactions*, everything becomes significantly more complicated.
* Complex transaction — a transaction whose execution includes several interconnected operations or sequential changes to the blockchain state. Such operations may involve interaction with multiple smart contracts or protocols, for example, exchanging tokens, transferring assets, providing liquidity, or performing other actions within a single logical sequence.
Here is an example of when atomicity in blockchain is highly important for ensuring the security of decentralized systems:
- A user needs to exchange tokens in one protocol and transfer them to another;
- If an error occurs at one of the stages, the smart contract must revert not only the current change but also all previous changes in that transaction sequence.
In other words, if an error occurs while transferring tokens between protocols, the cryptocurrency exchange transaction also reverts. That is, the system will either execute all transactions in full or cancel the entire sequence at once — in accordance with the principle of atomicity in blockchain; no other outcome is possible.
Atomicity in blockchain plays a particularly important role in complex inter-network or cross-chain transactions* involving interaction between at least two different decentralized protocols.
* Cross-chain transaction — an operation involving coordinated changes to the state of two or more independent blockchain networks or the transfer of assets, data, or messages between them. Because different blockchains have their own consensus mechanisms and record their states independently, they cannot directly confirm events on one another. Therefore, special interoperability protocols perform cross-chain operations — for example, blockchain bridges, messaging systems, validators, oracles, or other event-confirmation mechanisms. When assets are transferred, the original tokens may be locked or burned on one network, after which their representation is issued on another network or the corresponding asset is unlocked.
This is because while a consensus mechanism is sufficient for operations within a single blockchain, cross-chain transactions require the development of separate coordination protocols.
Coordination protocols must manage the state of all interacting systems to ensure atomicity in blockchain. This means that if a cryptocurrency asset transfer from one blockchain to another fails, both systems must return to their original state.
If atomicity is not maintained during cross-chain transactions, attackers may exploit the vulnerability to steal assets. In other words, all actions involved in processing a cross-chain transaction must be coordinated, and a "disconnect" between the states of different blockchains must not be allowed.
For example, a similar error in a protocol led to the hack of the well-known Nomad Bridge, during which an attacker stole approximately $200 million worth of assets. The issue stemmed from incorrect proof verification in an updated version of the smart contract during transaction execution, meaning the principle of atomicity in blockchain was not maintained.
Why atomicity is needed in blockchain
One of the main purposes of atomicity in blockchain is to minimize counterparty risk. In practice, this means that operations are protected against partial execution, and in the event of malicious actions or accidental errors, the transaction will return to its original state, and the user's funds will remain safe.
Atomicity in blockchain also simplifies transactions and reduces the risk of errors that can occur when executing them as separate sequences. In addition, combining several transactions into one may reduce network fee costs.
At the same time, due to the censorship-resistance properties of decentralized systems, no party can block or modify a transaction either while it is being executed or after it has been completed.
However, blockchain atomicity also has limitations. Even if a transaction is reverted, the contract execution fee is still charged. Moreover, the greater the number of failed attempts, the higher the total fee expenses will become. Thus, atomicity in blockchain guarantees secure, complete execution, but not a successful transaction outcome.
For example, in Ethereum, if an error occurs during smart contract execution, state changes may be reverted; however, the network must still pay for the computational resources already spent processing the transaction. Therefore, the fee is charged not only for successfully changing the blockchain state, but also for the computational work that network nodes have already performed while processing the operation.
In addition, atomicity in blockchain has limitations when applied to transactions with complex logic, for example, when exchanging tokens involving burning* on one network and issuance on another. In such a case, an error at the second stage may make it impossible to revert the first operation in the sequence, which can lead to irreversible losses.
* Token burning — the irreversible removal of a certain number of tokens from circulation in such a way that they can no longer be used or transferred. Burning may be performed at the smart-contract level by reducing the total number of issued tokens or by sending assets to an address for which no accessible private key is known to exist.
Finally, atomicity in blockchain does not guarantee that the transaction itself is beneficial, safe, or consistent with the user's intentions. Atomicity in blockchain will not protect against sending funds to the wrong address, an error in smart contract code, price manipulation, or the use of a vulnerable protocol. If the contract rules contain an error, the blockchain may execute that erroneous logic perfectly correctly and atomically.
Therefore, the primary purpose of atomicity in blockchain is not to guarantee the success or economic security of every operation, but to prevent the emergence of a partially executed state where a transaction is intended to be treated as a single whole.
