status

How to Understand Transactions in Transaction

Published 6.10.2023

Cardano allows you to send multiple assets to multiple recipients in a single transaction. The somewhat inappropriate term ‘transactions in transaction’ is sometimes used for this feature. Let's explain how transactions in the network that uses the UTxO accounting model differ from transactions in the network that uses the account-based model. You will also learn why the TPS metric is not suitable for Cardano, but it is fine to use it for Ethereum.

The Impact of the Accounting Model on Transactions and Scalability

Cardano uses a UTxO (unspent transaction output) accounting model. UTxO represents a certain amount and type of asset.

Each transaction consumes some UTxOs from previous transactions (UTxOs are the input of the transaction) and creates new UTxOs that can be used as inputs for future transactions.

In the context of a transaction, we can talk about input UTxOs and output UTxOs, or just inputs and outputs. It is the same thing.

Cardano transactions change the owners of UTxOs. A UTxO has an address that indicates who owns it and can spend it. The transaction outputs (UTxOs) have new addresses that belong to the recipients of the transaction. Transaction transfers the ownership of the UTxOs from the sender to the receiver.

A transaction can have multiple inputs and multiple outputs, and each output can have a different value and type of asset. Each output can be sent to a different recipient.

The global state of Cardano (balances of users) does not work with accounts or wallets in the context of the ledger. It just uses the UTxO set, which is the collection of all unspent transaction outputs on the network. The UTxO set represents the current distribution of assets among the users of Cardano.

What are the benefits of the UTxO model for scalability?

The ability to send multiple assets to multiple recipients reduces the transaction size (and thus the fee), which is beneficial for scalability. This allows more transactions to fit into a block.

The verification process is simple and efficient, as the network only needs to check that the inputs of a transaction are valid UTxOs from previous transactions and that the sum of the values of the inputs is equal to or greater than the sum of the values of the outputs.

The network does not need to keep track of the balances of each account or execute any complex logic associated with smart contracts, as Ethereum does (we will talk more about this later). Cardano has no account awareness. Each UTxO can be verified independently of other UTxOs, as long as they are not spent by the same transaction. It is similar in the case of script validation. Validation of script always refers to a single UTxO.

The UTxO model enables parallel processing of transactions that do not share any inputs, which can improve scalability and throughput. However, this also requires a consensus protocol that can handle concurrent transactions and resolve conflicts.

It can be said that Cardano transactions are 'parallel' in the sense that they can serve multiple recipients with different assets in a single transaction. Multiple participants are served by the network within one validation. Validation with multiple participants is of course more demanding on computer resources. However, it is less demanding than if separate transactions were created for the same number of recipients.

Let's take a look at the account-based model that Ethereum uses. It is important to understand the shared global state and the way Ethereum works with user balances, i.e. with accounts.

The shared global state of Ethereum is the current state of all accounts (balances of users) and contracts on the network. Each Ethereum account has a balance of ETH and other tokens. The shared global state of Ethereum is necessary to lock during the processing of every single transaction because it requires (nearly always) executions of code.

Transactions are simply transfers of value from one account to another, so they just update the balances of users. For example, a transaction deducts 10 tokens from Alice's account and adds them to Bob's account.

ERC-20 tokens are defined by smart contracts that implement a standard interface for token transfers and balances. It is not possible to transfer ERC-20 tokens without using a smart contract.

There are two types of transactions in Ethereum: a value transfer transaction and a smart contract transaction. A value transfer transaction can only transfer ETH, not other tokens. It can only have one sender and one recipient. Ethereum can send multiple assets in a single transaction, but only if the transaction involves a smart contract execution. A smart contract can also implement logic that can transfer these tokens to different recipients. It is not very usual in Ethereum to send multiple assets to multiple recipients in comparison with Cardano.

So processing a transaction in Ethereum nearly always requires the network to execute the code associated with the transaction and update the state of each account accordingly.

The state of each account includes (besides other things) its balance and nonce. A nonce is a number that counts how many transactions an account has sent.

The shared global state of Ethereum needs to be locked during this process because each transaction depends on the state of the sender’s account, which may change due to other transactions.

For example, if Alice sends a transaction to Bob with a nonce of 1, and then sends another transaction to Carol with a nonce of 2, the network needs to ensure that the first transaction is processed before the second one, otherwise, it would result in an invalid state transition.

The impact of locking the shared global state during the processing of every single transaction is that it limits the scalability and throughput of the network.

Locking the shared global state means that transactions that share the same sender or recipient have to be processed in a sequential fashion, which can create bottlenecks and delays. For example, if Alice sends 10 transactions to different recipients in a short period of time, each transaction has to wait for its predecessor to be confirmed before it can be processed. This can increase the latency and cost of each transaction.

The difference between the UTxO model and the account-based model is that Cardano works with UTxOs that are independent of each other (which enables parallelization), while Ethereum works with balances of accounts that depend on each other (which forces sequential processing).

You probably already understand that the term 'transactions in transaction' essentially refers to the ability to send multiple assets to multiple recipients in a single transaction. In Ethereum terminology, we could say that one transaction adjusts multiple balances.

The design of accounting models has an impact not only on scalability but also on the measurement of network throughput.

On the Suitability of the TPS Metric for Blockchains

TPS (Transactions Per Second) is a measure of the number of transactions a network can process in one second. TPS can tell us how many people are using or can use the network at any given time. The TPS metric assumes that one transaction transfers value between one sender and one receiver. However, it has one catch. This assumption is not valid for the blockchain industry.

TPS is commonly used to assess the performance and scalability of computer systems, particularly those that process large amounts of financial transactions, such as payment systems, exchanges, and banks. TPS is suitable for mainstream financial systems as transactions usually take place between two participants with a bank account.

It is possible to use the TPS metric in the blockchain industry. But there is a catch. If we want to compare blockchains with different accounting models, this metric is inappropriate. For Ethereum, the TPS metric is more suitable than for Cardano.

Even though Ethereum can send multiple assets to multiple recipients in a single transaction, it is not very common. TPS thus corresponds to reality although it may be inaccurate.

In the Cardano network, we can see complex transactions that transfer multiple assets to multiple recipients in almost every block. The TPS metric is therefore inappropriate and does not provide accurate numbers.

In the last 24 hours, Cardano processed 18,759 simple transactions and 30,481 SC transactions. Also, non-SC transactions can transfer multiple assets to multiple recipients. However, this is more common with SC transactions (typically with DEX applications).

One of the recent Cardano blocks contained 32 transactions. The TPS metric comes out to 1.6. However, if we examine the block more closely, we will find that the recipient addresses were a total of 62. If we adjusted the TPS accordingly, we would have the number 3.1. There were a total of 189 UTxOs in the block.

With Ethereum, a similar block with 32 transactions would very likely only have 32 recipients, so 32 balances would be adjusted.

If analytics want to measure the network throughput of Cardano, they need to go more in-depth and look at the content of transactions. The right metric would be something like Requests-per-Second or Recipients-per-Second.

Conclusion

In a broader context, it is necessary to realize that the blockchain is not likely to fulfill the function of a transaction network such as PayPal. Blockchain, or rather smart contract platforms, can be more like a kind of main settlement layer for higher layers or a kind of base layer. Assets will be minted on a blockchain that will guard their monetary policy, but users will probably use them in other networks. The future is uncertain in this regard, but at the moment it seems that way.

Users use Cardano mainly through applications, as evidenced by the composition of transactions in the block. It makes sense to have more requests in transactions, as it saves space in the block and users save on fees.

Featured:

Related articles

Did you enjoy this article? Other great articles by the same author