The Cardano network allows you to submit a transaction for which you pay an average of 0.17 ADA. This is the fee for the transaction to be verified by all Cardano nodes and stored forever in the blockchain. It can take several tens of seconds to get the transaction into a block, which is a very long time for a regular financial transaction. The Hydra Head protocol is the basis for creating a second layer for Cardano that will enable sub-one-second settlements, low-to-near-zero fees, and reduced space requirements on the blockchain. The biggest benefit will be a significant increase in scalability.
- The Hydra Head protocol will allow the creation of a parallel network that will process user transactions in an off-chain manner.
- The Hydra consensus is based on the agreement of all participants to the newly proposed state of the EUTXO distribution.
- Isomorphism allows using the same EUTXO, transaction format, Plutus scripts, and signatures as used by the Cardano network.
- The SundaeSwap team showed a demo with their DEX on Hydra.
Why do we need Hydra?
The Cardano network is capable of creating a new block every 20 seconds. However, space in the block is limited. If multiple participants wanted to use the network at the same time, the network could become congested. One solution that is being pushed across the blockchain industry is to allow communication between users on networks that run in parallel with the main chain.
The Hydra Head protocol will allow the creation of a parallel network that will process user transactions in an off-chain manner. This means that the Cardano network does not need to verify these transactions or store them on the blockchain.
In order to use Hydra, i.e. to open a channel with one or more users, a secure transfer of assets from Cardano to Hydra and back must be ensured. Plutus scripts are used for this purpose. Users can directly transfer EUTXOs with ADA or other native assets to Hydra. New EUTXOs will be created in Hydra, which will be returned to the Cardano blockchain when the Hydra Head is closed.
Hydra will provide fast and cheap off-chain transactions while using Cardano as a secure settlement layer. Participants must have a Hydra node running on their computer to use Hydra. From a user perspective, a wallet supporting Hydra takes care of this.
How the Head of Hydra is opened
In the beginning, several participants agree to open the Hydra Head together. They need to transfer funds from the Cardano blockchain to Hydra, for which they need to use an on-chain transaction. The funds are moved to the address of the script that locks them. Since everything happens on-chain, none of the participants can cheat and secure execution is ensured. It is said that participants commit funds. Cardano collets the committed funds and make them available in Hydra. If this phase is successful, channels will be opened between all participants.
Hydra will be in initial state 0. From now on, participants can send transactions to each other through channels. As funds are sent, the states change. When a user spends a EUTXO, a new EUTXO is created, just as happens in the Cardano network.
The network consensus in Hydra is essentially based on a proposal for a new state to which the other participants must agree. The states are called snapshots. They are a kind of state reflecting the distribution of EUTXOs among the participants. When a transaction is created to move EUTXO, a new state is created at the same time. Let's call it to state 1. The new state 1 will be valid if all participants accept it.
The last agreed state is used when closing the Hydra Head. Once any participant decides to close the Hydra Head, all participants have to leave it. Again, the on-chain transaction (the script that locked the EUTXOs when Hydra Head was opened) is used to insert the EUTXOs from Hydra into the Cardano blockchain.
Let's take an example. Alice, Bob, Carol, and Dave agree to open Hydra Head together. Each commits 100 ADA. In Hydra, they send ADAs to each other as needed. A week later, Alice decides to close Hydra Head. Alice will have 200 ADAs, Bob will have 100 ADAs, and Carol and Dave will each have 50 ADAs. Cardano protocol will ensure that the correct number of ADAs are returned to the ledger when the Hydra Head is closed. Only the starting and ending states of EUTXOs are recorded in the Cardano ledger. Cardano knows nothing about what transactions have taken place in the Hydra Head.
It can be said that Hydra behaves basically like an application, as it uses Plutus script which locks EUTXO and allows it to be used in another protocol. Hydra can help scale applications on Cardano. For example, the SundaeSwap team was able to run their DEX on Hydra. This was a proof of concept.
It is important to note that Hydra Head is not a network that all users of the Cardano network can join at any time. It is a solution for groups of users who interact with each other frequently. So they will at one time open the Head of Hydra between them. Thus, many Hydra Heads will be created in parallel and will be independent of each other.
Hydra Head will be the basis for future iterations. The team plans to enable communication between multiple Hydra Heads. Thus, networks composed of interconnected Hydra heads may emerge.
Isomorphic state channels
The term "isomorphic" refers to two systems or structures that are equivalent or similar in their form or structure, even though their content or meaning may be different. This can refer to network systems that can be mapped one-to-one with each other, or to functions that can be transformed into each other while preserving their behavior.
Hydra introduces the concept of isomorphic state channels. It is possible to reuse the same ledger representation of assets, transaction formats, Plutus scripts, signatures, etc. in Hydra. Instead of creating an entirely new network with its own assets and transaction formats, it is possible to naturally extend the existing Cardano network. This is the power of isomorphism.
Simply put, the only thing that changes in Hydra is the consensus among the participants. The team is trying to keep everything else as similar to the Cardano protocol as possible. You can imagine that the same transactions take place in Hydra as in the Cardano network, but instead of PoS consensus and staking mechanism, the participants confirm new states among themselves based on the sent transactions. If any of the participants disagree with the new state, they can close the Hydra head. The state last agreed to by all participants is used.
Proof-of-concept implementation for the Hydra node is available. The team works on production-ready solutions and assists third-party teams in using Hydra for their applications. The team maintains a public roadmap so you can check the current status.