Like Bitcoin, Cardano uses UTxO, but only in the extended EUTxO version (Extended Unspent Transaction Output). The UTxO is a registration and verification model, an alternative to Ethereum accounts and other blockchains. The UTxO is the transaction recording model, where every transaction has its inputs and outputs.
Let us look at the practical example. Tanya wants to send 5 tokens from her wallet to the PapaJohn's pizzeria wallet to pay for the order. Also, she needs to send 10 tokens to the wallet of Margo, her nail artist. Finally, she wants to send 15 tokens to Mark's wallet, her boyfriend. In this case, a transaction is a record of inputs and outputs information about money flow. At the input, Tanya's wallet uses one or more unspent outputs from previous transactions, where the total number of tokens is 30 or more.
This transaction has four outputs:
- 5 tokens (for PapaJohn's wallet);
- 10 tokens (for Margo's wallet);
- 15 tokens (for Mark's wallet);
- The unspent sum from the input (for Tanya's wallet), if the total amount of more than 30 tokens was recorded in the input.
These outputs can also be inputs for the next transaction.
In short, UTxO is a sum left from previous transactions. So, it can be used as input for future transactions. If it is still not clear, here is a video. After watching it, you will have no more questions about UTxO.
In Cardano, UTxO upgraded new features. In addition to sender address and transfer amount, EUTxOs contain Datum not carried by traditional UTxOs. It is additional data or state required for the Program operation. Data can be random and change on different EUTxO. At the same time, the data structure remains the same for a particular script.
We may need Datum for transaction validation because the transaction contains only the blockchain information with the incoming EUTxOs. For example, we want to exchange one token within a transaction. But, we need to get the exchange rate from an external source. This source sends its EUTxO to the transaction, which contains the exchange rate in Datum.
Also, wallets have an additional wallet backend structure. It allows them to process payments and facilitate off-chain code involved in on-chain code execution. Outputs are locked by validator scripts, and inputs are unlocked with redeemer scripts.
Before the Gauguin era, Cardano's UTxO model was criticized for the concurrency issue. Different algorithm units can perform simultaneously with the same smart contract. For example, an account-based blockchain allows multiple users to operate on one smart contract at once. DApp runs quickly and efficiently. So, in the case of shared state, concurrency can lead to deadlock or resource contention issues.
EUTxO can be used once and fully, so it is easier to validate the transaction. Unfortunately, when two or more parties try to use the same EUTxO, the system can not verify the transaction. In the case of smart contracts, many users interact with its protocol, so they will have to send a transaction several times. It will continue until the platform can include it in the block and process it. As a rule, it takes 1 to 20 seconds to start a new block.
The UTxO model is less vulnerable and centralized than the one account based on Ethereum. It is significant for decentralized DeFi platforms. So, developers pay much attention to the concurrency issue and try to solve it. For example, they build and control many UTxOs with different NFTs, which contain the same data. Moreover, developers store all transactions of the same UTxO into one block and process them together.
We can solve the concurrency issue through a centralized coordinator. However, the Plutus platform does not have a global state or "Cardano virtual machine" that will evaluate the system and connect all the Plutus smart contracts. It is not the only possible solution. IOHK offered to reach the maximum level of the concurrency. Developers should write codes to limit any conflicts. For example, it is necessary to avoid shared states and random dependencies.
The system needs to shift from concurrency to parallelism. Cardax also suggested a solution. They released the Streaming Merge algorithm, which delivers user actions into a single time-based stream and processes it through the converter. Cardax released the algorithm in a shared library, and everyone can access it.