Hydra - Layer 2 Scaling for Cardano
Build fast, low-cost applications with Hydra Head protocol. Process thousands of transactions per second while maintaining Cardano's security guarantees.
Overview
Hydra is a Layer 2 scaling solution for Cardano that enables near-instant, low-cost transactions between participants. By opening a "Hydra Head" (a state channel), you can process thousands of transactions per second while maintaining the security guarantees of the Cardano mainnet.
When to use Hydra
- High-frequency transactions: Gaming, micropayments, or real-time applications requiring sub-second finality
- Cost-sensitive applications: Reduce transaction fees by batching settlements on Layer 1
- Private transactions: Keep transaction details off-chain until final settlement
- Interactive applications: Multi-party protocols requiring rapid state updates
Key benefits
| Feature | Description |
|---|---|
| Speed | Near-instant transaction confirmation within the Head |
| Low cost | Minimal fees inside the Head; only pay L1 fees for open/close |
| Security | Funds are always secured by Cardano's consensus |
| Isomorphic | Use the same transaction format as Layer 1 |
Quick start
Install the Mesh Hydra package and connect to a running Hydra node:
import { HydraProvider, HydraInstance } from "@meshsdk/hydra";
import { BlockfrostProvider } from "@meshsdk/core";
// Initialize the blockchain provider for L1 operations
const blockfrost = new BlockfrostProvider("<YOUR_BLOCKFROST_KEY>");
// Connect to your Hydra node
const hydraProvider = new HydraProvider({
httpUrl: "http://localhost:4001",
});
// Create a Hydra instance for head operations
const hydraInstance = new HydraInstance({
provider: hydraProvider,
fetcher: blockfrost,
submitter: blockfrost,
});
// Connect and initialize the head
await hydraProvider.connect();
await hydraProvider.init();Documentation
Hydra Instance
The HydraInstance is a class interface for interacting with a Hydra head after initialization.
Hydra Provider (beta)
Layer 2 scaling solution for Cardano that increases transaction throughput and ensures cost efficiency while maintaining security.
End-to-end Hydra Tutorial
Open a layer 2 state channel between two participants, build transactions, and close the Hydra head
How Hydra works
- Initialize: Participants agree to open a Hydra Head
- Commit: Each participant commits funds from Layer 1 to the Head
- Transact: Process unlimited transactions instantly within the Head
- Close: Submit the final state back to Layer 1
- Fanout: Distribute funds according to the final Head state
Related resources
- Hydra Instance API - Detailed API reference for HydraInstance
- End-to-end Tutorial - Complete walkthrough from setup to settlement
- Hydra Protocol Documentation - Official Hydra protocol specifications
- Cardano Providers - Configure blockchain providers for L1 operations