Mesh LogoMesh

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

FeatureDescription
SpeedNear-instant transaction confirmation within the Head
Low costMinimal fees inside the Head; only pay L1 fees for open/close
SecurityFunds are always secured by Cardano's consensus
IsomorphicUse 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

How Hydra works

  1. Initialize: Participants agree to open a Hydra Head
  2. Commit: Each participant commits funds from Layer 1 to the Head
  3. Transact: Process unlimited transactions instantly within the Head
  4. Close: Submit the final state back to Layer 1
  5. Fanout: Distribute funds according to the final Head state

On this page