import { Asset, PlutusScript, NativeScript, UTxO, IFetcher, ISubmitter, Protocol, AccountInfo, IFetcherOptions, TransactionInfo, AssetMetadata, BlockInfo, GovernanceProposalInfo } from '@meshsdk/common'; import { RawAxiosRequestHeaders } from 'axios'; type hydraTransaction = { type: "Tx ConwayEra" | "Unwitnessed Tx ConwayEra" | "Witnessed Tx ConwayEra"; description: string; cborHex: string; txId?: string; }; type HydraAssets = { lovelace: number; } & { [policyId: string]: { [assetNameHex: string]: number; }; }; declare function hydraAssets(assets: Asset[]): HydraAssets; declare namespace hydraAssets { var toAssets: (assetsObj: HydraAssets) => Asset[]; } type hydraScriptInfo = { scriptInstance: PlutusScript | NativeScript | undefined; scriptType: "PlutusScriptV1" | "PlutusScriptV2" | "PlutusScriptV3" | "SimpleScript" | "Unknown"; scriptLanguage: "PlutusScriptLanguage PlutusScriptV1" | "PlutusScriptLanguage PlutusScriptV2" | "PlutusScriptLanguage PlutusScriptV3" | "NativeScriptLanguage SimpleScript" | null; }; type hydraReferenceScript = { script: { cborHex: string; description: string; type: "SimpleScript" | "PlutusScriptV1" | "PlutusScriptV2" | "PlutusScriptV3" | null; }; scriptLanguage: string; } | null; declare function hydraReferenceScript(scriptRef: string | null): Promise; type HydraUTxOs = { [txRef: string]: hydraUTxO; }; declare function hydraUTxOs(utxos: UTxO[]): Promise; type hydraUTxO = { address: string; datum: string | null; inlineDatum: object | null; inlineDatumRaw: string | null; inlineDatumhash: string | null; referenceScript: hydraReferenceScript | null; value: HydraAssets; }; declare function hydraUTxO(utxo: UTxO): Promise; declare namespace hydraUTxO { var toUTxO: (hydraUTxO: hydraUTxO, txId: string) => UTxO; } interface HydraBaseEvent { tag: string; seq: number; timestamp: string; } interface NetworkConnected extends HydraBaseEvent { tag: "NetworkConnected"; } interface NetworkDisconnected extends HydraBaseEvent { tag: "NetworkDisconnected"; } interface NetworkVersionMismatch extends HydraBaseEvent { tag: "NetworkVersionMismatch"; ourVersion: number; theirVersion: number | null; } interface NetworkClusterIDMismatch extends HydraBaseEvent { tag: "NetworkClusterIDMismatch"; clusterPeers: string; misconfiguredPeers: string; } interface PeerConnected extends HydraBaseEvent { tag: "PeerConnected"; peer: { hostname: string; port: number; }; } interface PeerDisconnected extends HydraBaseEvent { tag: "PeerDisconnected"; peer: { hostname: string; port: number; }; } interface EventLogRotated extends HydraBaseEvent { tag: "EventLogRotated"; } type SnapshotSignatures = { multiSignature: string[]; }; type InitialSnapshot = { headId: string; tag: "InitialSnapshot"; initialUTxO: UTxO[]; }; interface NoSeenSnapshot { tag: "NoSeenSnapshot"; } interface LastSeenSnapshot { tag: "LastSeenSnapshot"; lastSeen: number; } interface RequestedSnapshot { tag: "RequestedSnapshot"; lastSeen: number; requested: number; } interface SeenSnapshot { tag: "SeenSnapshot"; snapshot: Snapshot; signatories: Record; } type ConfirmedSnapshot = { tag: "ConfirmedSnapshot"; snapshot: { headId: string; version: number; number: number; confirmed: hydraTransaction[]; utxo: UTxO[]; utxoToCommit?: UTxO[] | null; utxoToDecommit?: UTxO[] | null; }; signatures: SnapshotSignatures; }; type Snapshot = { headId: string; version: number; number: number; confirmed: hydraTransaction[]; utxo: HydraUTxOs; utxoToCommit?: HydraUTxOs; utxoToDecommit?: HydraUTxOs; }; type SnapshotSideLoaded = { tag: "SnapshotSideLoaded"; headId: string; snapshotNumber: number; seq: number; timestamp: string; }; interface SnapshotConfirmed extends HydraBaseEvent { tag: "SnapshotConfirmed"; headId: string; snapshot: Snapshot; } type seenSnapshot = NoSeenSnapshot | LastSeenSnapshot | RequestedSnapshot | SeenSnapshot; type snapshotSideLoad = InitialSnapshot | ConfirmedSnapshot; interface HydraHeadParameters { contestationPeriod: number; parties: HydraParty; } type HydraParty = { vkey: string; }[]; interface InitTx { tag: "InitTx"; participants: string[]; headParameters: HydraHeadParameters; } interface AbortTx { tag: "AbortTx"; utxo: HydraUTxOs; headSeed: string; } interface CollectComTx { tag: "CollectComTx"; utxo: HydraUTxOs; headId: string; headParameters: HydraHeadParameters; } interface RecoverTx { tag: "RecoverTx"; headId: string; recoverTxId: string; recoverUTxO: HydraUTxOs; deadline: number; } interface IncrementTx { tag: "IncrementTx"; headId: string; headParameters: HydraHeadParameters; incrementingSnapshot: InitialSnapshot | ConfirmedSnapshot; depositTxId: string; } interface DecrementTx { tag: "DecrementTx"; headId: string; headParameters: HydraHeadParameters; decrementingSnapshot: InitialSnapshot | ConfirmedSnapshot; } interface CloseTx { tag: "CloseTx"; headId: string; headParameters: HydraHeadParameters; closingSnapshot: InitialSnapshot | ConfirmedSnapshot; openVersion: number; } interface ContestTx { tag: "ContestTx"; headId: string; headParameters: HydraHeadParameters; openVersion: number; contestingSnapshot: InitialSnapshot | ConfirmedSnapshot; } interface FanoutTx { tag: "FanoutTx"; utxo: HydraUTxOs; utxoToCommit: HydraUTxOs; utxoToDecommit: HydraUTxOs; headSeed: string; contestationDeadline: string; } type PostChainTx = InitTx | AbortTx | CollectComTx | RecoverTx | IncrementTx | DecrementTx | CloseTx | ContestTx | FanoutTx; type ScriptFailedInWallet = { tag: "ScriptFailedInWallet"; redeemerPtr: string; failureReason: string; failingTx: hydraTransaction; }; type InternalWalletError = { tag: "InternalWalletError"; failingTx: hydraTransaction; reason: string; headUTxO: HydraUTxOs; }; type NotEnoughFuel = { tag: "NotEnoughFuel"; failingTx: hydraTransaction; }; type NoFuelUTXOFound = { tag: "NoFuelUTXOFound"; failingTx: hydraTransaction; }; type CannotFindOwnInitial = { tag: "CannotFindOwnInitial"; knownUTxO: HydraUTxOs; }; type UnsupportedLegacyOutput = { tag: "UnsupportedLegacyOutput"; byronAddress: string; }; type NoSeedInput = { tag: "NoSeedInput"; }; type InvalidStateToPost = { tag: "InvalidStateToPost"; chainState: any; txTried: PostChainTx; }; type FailedToPostTx = { tag: "FailedToPostTx"; failureReason: string; failingTx: hydraTransaction; }; type CommittedTooMuchADAForMainnet = { tag: "CommittedTooMuchADAForMainnet"; userCommittedLovelace: number; mainnetLimitLovelace: number; }; type FailedToDraftTxNotInitializing = { tag: "FailedToDraftTxNotInitializing"; }; type InvalidSeed = { tag: "InvalidSeed"; headSeed: string; }; type InvalidHeadId = { tag: "InvalidHeadId"; headId: string; }; type FailedToConstructAbortTx = { tag: "FailedToConstructAbortTx"; }; type FailedToConstructCloseTx = { tag: "FailedToConstructCloseTx"; }; type FailedToConstructContestTx = { tag: "FailedToConstructContestTx"; }; type FailedToConstructCollectTx = { tag: "FailedToConstructCollectTx"; }; type FailedToConstructDepositTx = { tag: "FailedToConstructDepositTx"; failureReason: string; }; type FailedToConstructRecoverTx = { tag: "FailedToConstructRecoverTx"; failureReason: string; }; type FailedToConstructIncrementTx = { tag: "FailedToConstructIncrementTx"; failureReason: string; }; type FailedToConstructDecrementTx = { tag: "FailedToConstructDecrementTx"; failureReason: string; }; type FailedToConstructFanoutTx = { tag: "FailedToConstructFanoutTx"; }; type TransactionSubmitted = { tag: "TransactionSubmitted"; }; type PostTxOnChainFailed = { tag: "PostTxOnChainFailed"; postChainTx: PostChainTx; postTxError: ScriptFailedInWallet | InternalWalletError | NotEnoughFuel | NoFuelUTXOFound | CannotFindOwnInitial | UnsupportedLegacyOutput | NoSeedInput | InvalidStateToPost | FailedToPostTx | CommittedTooMuchADAForMainnet | FailedToDraftTxNotInitializing | InvalidSeed | InvalidHeadId | FailedToConstructAbortTx | FailedToConstructCloseTx | FailedToConstructContestTx | FailedToConstructCollectTx | FailedToConstructDepositTx | FailedToConstructRecoverTx | FailedToConstructIncrementTx | FailedToConstructDecrementTx | FailedToConstructFanoutTx; }; /** * HydraProvider is a tool for administrating & interacting with Hydra Heads. * * Usage: * ``` * import { HydraProvider } from "@meshsdk/hydra"; * * const hydraProvider = new HydraProvider({httpUrl:'http://123.45.67.890:4001'}); */ declare class HydraProvider implements IFetcher, ISubmitter { private _connection; private readonly _eventEmitter; private readonly _axiosInstance; private _messageCallback; private _messageQueue; private _disconnectTimeout; private _isDisconnecting; private _currentStatus; private _connectionState; private _connectingPromise; constructor({ httpUrl, history, address, wsUrl, }: { httpUrl: string; history?: boolean; address?: string; wsUrl?: string; }); /** * Connects to the Hydra Head socket only. */ connect(): Promise; /** * Connects (if needed) and waits until Hydra confirms readiness via "Greetings". * * - Idempotent * - No dangling handlers * - Accurate state tracking */ isConnected(timeoutMs?: number): Promise; /** * Disconnects from the Hydra Head. * * @param timeout Optional timeout in milliseconds (defaults to 5 minutes) to wait for the disconnect operation to complete. * If set to 0, disconnects immediately (reactive to clicks/events). * If not provided, the default disconnect timeout will be used. * Useful for customizing how long to wait before disconnecting. * @throws {Error} If timeout is less than 0 or between 1 and 59,999 ms */ disconnect(timeout?: number): Promise; /** * Commands sent to the Hydra node. * * Accepts one of the following commands: * - Init: init() * - Abort: abort() * - NewTx: newTx() * - Decommit: decommit() * - Close: close() * - Contest: contest() * - Fanout: fanout() */ /** * Initializes a new Head. This command is a no-op when a Head is already open and the server will output an CommandFailed message should this happen. */ /** * Initialize the head when status is Idle. */ init(): Promise; /** * Aborts a head before it is opened. This can only be done before all participants have committed. Once opened, the head can't be aborted anymore but it can be closed using: `Close`. */ abort(): Promise; /** * Submit a transaction through the Hydra head. * The transaction must be well-formed and valid; otherwise, it will not be broadcast. * * @param transaction The transaction object to submit. Should have the following structure: * - type: The type of the transaction * - description (optional) * - cborHex: * @returns txhash * @example * ```tsx * await hydraProvider.newTx({ * type: "Tx ConwayEra", * description: "", * cborHex: unsignedTx, * }); * ``` */ newTx(transaction: hydraTransaction): Promise; /** * Attempt to recover a deposit transaction in the Hydra head by its transaction ID. * @param txHash - The deposit txId or txHash of the deposit transaction to recover. * * @example * ```ts * await hydraProvider.recover(txId); * ``` */ recover(txHash: string): Promise; /** * Request to decommit a UTxO from a Head making UTxOavailable on the layer 1. * * @param transaction The transaction object to decommit. Should have the following structure: * - type: The type of the transaction. Allowed values: "Tx ConwayEra", "Unwitnessed Tx ConwayEra", "Witnessed Tx ConwayEra". * - description: (Optional) A human-readable description of the transaction. * - cborHex: The base16-encoded CBOR representation of the transaction. * * @example * ```tsx * await hydraProvider.decommit({ * type: "Tx ConwayEra", * description: "", * cborHex: unsignedTx, * }); * ``` */ decommit(transaction: hydraTransaction): Promise; /** * Decommits a UTxO from the Hydra Head incrementally, making it available on layer 1. * * @param transaction The transaction object to decommit. * @returns Promise resolving to the transaction hash or result. */ incrementalDecommit(transaction: hydraTransaction): Promise; /** * Terminate a head with the latest known snapshot. This effectively moves the head from the Open state to the Close state where the contestation phase begin. As a result of closing a head, no more transactions can be submitted via NewTx. */ close(): Promise; /** * Challenge the latest snapshot announced as a result of a head closure from another participant. Note that this necessarily contest with the latest snapshot known of your local Hydra node. Participants can only contest once. */ contest(): Promise; /** * Finalize a head after the contestation period passed. * This will distribute the final (as closed and maybe contested) head state back on the layer 1. */ fanout(): Promise; /** * FETCHERS and SUBMITTERS */ /** * Fetches the UTXOs available in the current Hydra Head snapshot. * @param address - The address to filter UTXOs by (returns only UTXOs with this address if provided) * @param asset - Optional asset unit to filter UTXOs (returns only UTXOs containing this asset if provided) * @returns - Array of UTxOs matching the address and asset if provided */ fetchAddressUTxOs(address: string, asset?: string): Promise; /** * Fetch the latest protocol parameters. * @returns - Protocol parameters */ fetchProtocolParameters(): Promise; /** * Get UTxOs for a given hash. * @param hash * @param index * @returns - Array of UTxOs */ fetchUTxOs(hash?: string, index?: number): Promise; /** * Fetches the addresses and quantities for a given Cardano asset. * * @param asset - The asset unit in Cardano format, defined as a concatenation of the policy ID and asset name in hex * * @returns the address and quantity for each UTxO holding the specified asset. */ fetchAssetAddresses(asset: string): Promise<{ address: string; quantity: string; }[]>; /** * Fetches the list of assets for a given policy ID. * @param policyId The policy ID to fetch assets for * @returns The list of assets in the policyId collection */ fetchCollectionAssets(policyId: string): Promise<{ assets: Asset[]; }>; /** * Submit a transaction to the Hydra node. Note, unlike other providers,this returns a transaction hash (txId). * @param cborHex - The transaction in CBOR hex format usually the unsigned transaction * @returns The transaction hash (txId) */ submitTx(cborHex: string): Promise; /** * Submit a transaction to the Cardano L1 network. * @param transaction - The transaction to submit * @returns The transaction cborHex */ submitL1Tx(transaction: hydraTransaction): Promise; /** * Obtain a list of pending deposit transaction ID's. */ getPendingCommits(): Promise; /** * Get the latest snapshot signed by the Hydra node. * This returns snapshot information. * * @returns {Promise} The latest seen snapshot information. * @throws {Error} If the latest snapshot cannot be retrieved or parsed. */ getLatestSeenSnapshot(): Promise; /** * This is used to get the snapshop from a healthy node ready to * sideload into a stuck or unhealthy node * @returns */ getSideloadedSnapshot(): Promise; /** * sync or sideLoadSnapshot to the hydra unhealthy node * */ syncSideloadSnapshot(snapshot: snapshotSideLoad): Promise; /** * OPERATIONS */ /** * Draft a commit transaction, which can be completed and later submitted to the L1 network. */ buildCommit(payload: unknown, headers?: RawAxiosRequestHeaders): Promise; /** * * gets last seen snapshot in the head */ subscribeSeenSnapshot(): Promise; /** * A set of unspent transaction outputs. * @returns - Array of UTxOs */ subscribeSnapshotUtxo(): Promise; /** * Provide decommit transaction that needs to be applicable to the Hydra's local ledger state. Specified transaction outputs will be available on layer 1 after decommit is successfully processed. */ publishDecommit(payload: unknown, headers?: RawAxiosRequestHeaders): Promise; /** * Cardano transaction to be submitted to the L1 network. Accepts transactions encoded as Base16 CBOR string, TextEnvelope type or JSON. */ publishCardanoTransaction(payload: unknown, headers?: RawAxiosRequestHeaders): Promise; /** * Get protocol parameters. * @returns - Protocol parameters */ subscribeProtocolParameters(): Promise; /** * Registers a callback to receive messages from the Hydra Head. * When called, the callback will immediately be invoked for all messages that have already been received * (queued in the message queue), and subsequently for each new incoming message. * * @param callback - The function to call with each ServerOutput or ClientMessage received. * * @example * ```ts * hydraProvider.onMessage((message) => { * console.log("Received Hydra message:", message); * }); * ``` */ onMessage(callback: (data: ServerOutput | ClientMessage) => void): void; /** * Subscribe to status changes of the Hydra Head. * The callback will be called whenever the status changes. * * @param callback Function to call when status changes, receives the new hydraStatus * @returns The current status * * @example * ```ts * hydraProvider.onStatusChange((status) => { * console.log(`Hydra Head status changed to: ${status}`); * }); * ``` */ onStatusChange(callback: (status: hydraStatus) => void): hydraStatus; /** * Get the current status of the Hydra Head. * * @returns The current hydraStatus * * @example * ```ts * const currentStatus = hydraProvider.getStatus(); * console.log(`Current status: ${currentStatus}`); * ``` */ getStatus(): hydraStatus; /** * Useful utility functions. */ /** * A generic method to fetch data from a URL. * @param url - The URL to fetch data from * @returns - The data fetched from the URL */ get(url: string): Promise; /** * A generic method to post data to a URL. * @param url - The URL to post data to * @param payload - The data to post * @returns - The response from the URL */ post(url: string, payload: unknown, headers: RawAxiosRequestHeaders): Promise; /** * NOT SUPPORTED FETCHERS */ /** * Note: Not supported in Hydra L2. */ fetchAccountInfo(address?: string): Promise; /** * Not supported in Hydra L2. */ fetchAddressTxs(address?: string, option?: IFetcherOptions): Promise; /** * Not supported in Hydra L2. */ fetchAssetMetadata(asset?: string): Promise; /** * Note: Not supported in Hydra L2. */ fetchBlockInfo(hash?: string): Promise; /** * Not supported in Hydra L2. */ fetchGovernanceProposal(txHash?: string, certIndex?: number): Promise; /** * Not supported in Hydra L2. */ fetchTxInfo(hash: string): Promise; } type hydraStatus = (typeof status)[number]; declare function getHydraStatus(value: { headStatus?: string; tag?: string; }): hydraStatus | null; declare const status: readonly ["IDLE", "INITIALIZING", "OPEN", "CLOSED", "FANOUT_POSSIBLE", "FINAL"]; type ClientInput = { tag: "Init"; } | { tag: "Abort"; } | { tag: "NewTx"; transaction: hydraTransaction; } | { tag: "Recover"; recoverTxId: string; } | { tag: "Decommit"; transaction: hydraTransaction; } | { tag: "Close"; } | { tag: "Contest"; } | { tag: "Fanout"; } | { tag: "SideLoadSnapshot"; snapshot: InitialSnapshot | ConfirmedSnapshot; }; declare const clientInput: { init: ClientInput; abort: ClientInput; newTx: (transaction: hydraTransaction) => ClientInput; recover: (txhash: string) => ClientInput; decommit: (transaction: hydraTransaction) => ClientInput; close: ClientInput; contest: ClientInput; fanout: ClientInput; sideLoadSnapshot: (snapshot: InitialSnapshot | ConfirmedSnapshot) => ClientInput; }; type CommandFailed = { tag: "CommandFailed"; clientInput: ClientInput; }; type InvalidInput = { tag: "InvalidInput"; reason: string; input: string; }; type IgnoredHeadInitializing = { tag: "IgnoredHeadInitializing"; headId: string; contestationPeriod: number; parties: HydraParty; participants: string[]; seq: number; timestamp: string; }; type ClientMessage = PostTxOnChainFailed | CommandFailed; type CommitApproved = { tag: "CommitApproved"; headId: string; utxoToCommit: HydraUTxOs; seq: number; timestamp: string; }; type CommitRecorded = { tag: "CommitRecorded"; headId: string; utxoToCommit: HydraUTxOs; pendingDeposit: string; deadline: string; seq: number; timestamp: string; }; type CommitFinalized = { tag: "CommitFinalized"; headId: string; depositTxId: string; seq: number; timestamp: string; }; type CommitRecovered = { tag: "CommitRecovered"; headId: string; recoveredUTxO: HydraUTxOs; recoveredTxId: string; seq: number; timestamp: string; }; type Committed = { tag: "Committed"; parties: HydraParty[]; utxo: HydraUTxOs; seq: number; timestamp: string; }; type DecommitTxInvalid = { tag: "DecommitTxInvalid"; localUTxO: HydraUTxOs; validationError: { reason: string; [key: string]: unknown; }; }; type DecommitAlreadyInFlight = { tag: "DecommitAlreadyInFlight"; otherDecommitTxId: string; }; type DecommitInvalid = { tag: "DecommitInvalid"; headId: string; decommitTx: hydraTransaction; decommitInvalidReason: DecommitTxInvalid | DecommitAlreadyInFlight; }; type DecommitRequested = { tag: "DecommitRequested"; headId: string; decommitTx: hydraTransaction; utxoToDecommit: HydraUTxOs; seq: number; timestamp: string; }; type DecommitApproved = { tag: "DecommitApproved"; headId: string; seq: number; timestamp: string; }; type DecommitFinalized = { tag: "DecommitFinalized"; headId: string; seq: number; timestamp: string; }; interface DepositActivated { tag: "DepositActivated"; headId: string; depositTxId: string; deadline: string; chainTime: string; seq: number; timestamp: string; } interface DepositExpired { tag: "DepositExpired"; headId: string; depositTxId: string; deadline: string; chainTime: string; seq: number; timestamp: string; } interface Greetings { tag: "Greetings"; me: { vkey: string; }; headStatus: "Idle" | "Initializing" | "Open" | "Closed" | "FanoutPossible" | "Final"; hydraHeadId: string; snapshotUtxo: HydraUTxOs; timestamp?: string; hydraNodeVersion: string; } interface HeadIsInitializing extends HydraBaseEvent { tag: "HeadIsInitializing"; headId: string; parties: HydraParty[]; } interface HeadIsOpen extends HydraBaseEvent { tag: "HeadIsOpen"; headId: string; utxo: HydraUTxOs; } interface HeadIsClosed extends HydraBaseEvent { tag: "HeadIsClosed"; headId: string; snapshotNumber: number; contestationDeadline: string; } interface HeadIsContested extends HydraBaseEvent { tag: "HeadIsContested"; headId: string; snapshotNumber: number; contestationDeadline: string; } interface ReadyToFanout extends HydraBaseEvent { tag: "ReadyToFanout"; headId: string; } interface HeadIsAborted extends HydraBaseEvent { tag: "HeadIsAborted"; headId: string; utxo: HydraUTxOs; } interface HeadIsFinalized extends HydraBaseEvent { tag: "HeadIsFinalized"; headId: string; utxo: HydraUTxOs; } interface TxValid extends HydraBaseEvent { tag: "TxValid"; headId: string; transactionId: string; } interface TxInvalid extends HydraBaseEvent { tag: "TxInvalid"; headId: string; utxo: HydraUTxOs; transaction: hydraTransaction; validationError: { reason: string; }; } type ServerOutput = Greetings | NetworkConnected | NetworkDisconnected | NetworkVersionMismatch | NetworkClusterIDMismatch | PeerConnected | PeerDisconnected | HeadIsInitializing | Committed | HeadIsOpen | HeadIsClosed | HeadIsContested | ReadyToFanout | HeadIsAborted | HeadIsFinalized | TxValid | TxInvalid | SnapshotConfirmed | InvalidInput | IgnoredHeadInitializing | DecommitInvalid | DecommitRequested | DecommitApproved | DecommitFinalized | CommitRecorded | DepositActivated | DepositExpired | CommitApproved | CommitFinalized | CommitRecovered | SnapshotSideLoaded | EventLogRotated; type ConnectionState = "IDLE" | "CONNECTING" | "CONNECTED" | "FAILED" | "DISCONNECTED"; /** * HydraInstance is a tool for interacting with a Hydra head. * @constructor * @param provider - The Hydra provider instance for interacting with the Hydra head. * @param fetcher - The fetcher instance for fetching UTxOs and other data. * @param submitter - The submitter instance for submitting transactions. * * @example * * ```tsx * const provider = new HydraProvider({ * httpUrl: "", * }); * * const instance = new HydraInstance({ * provider: provider, * fetcher: blockchainProvider, * submitter: blockchainProvider, * }); * ``` */ declare class HydraInstance { provider: HydraProvider; fetcher: IFetcher; submitter: ISubmitter; constructor({ provider, fetcher, submitter, }: { provider: HydraProvider; fetcher: IFetcher; submitter: ISubmitter; }); private _commitToHydra; /** * If you don't want to commit any funds and only want to receive on layer 2, * you can request an empty commit transaction to open the head: * @example * ```tsx * const commit = await hydraInstance.commitEmpty(); * const submitTx = await wallet.submitTx(commit); * console.log("submitTx", submitTx); * ``` * * @returns The transaction CBOR hex ready to be submitted. */ commitEmpty(): Promise; /** * To commit funds to the head, choose which UTxO you would like to make available on layer 2. * The function returns the transaction CBOR hex ready to be partially signed. * @param txHash * @param txIndex * @returns commitTransactionHex */ commitFunds(txHash: string, outputIndex: number): Promise; /** * Allows Commit UTxOs as ScriptUTxOs in a Cardano transaction blueprint to the Hydra head. * * https://hydra.family/head-protocol/docs/how-to/commit-blueprint * @param txHash - The transaction hash of the UTxO to be committed as a blueprint. * @param outputIndex - The output index of the UTxO to be committed. * @param hydraTransaction - The Cardano transaction in text envelope format, containing: * - type: The type of the transaction (e.g., "Unwitnessed Tx ConwayEra"). * - description: (Optional) A human-readable description of the transaction. * - cborHex: The CBOR-encoded unsigned transaction. * @returns The function returns the transaction CBOR hex ready to be partially signed. * @example * ```tsx * const commitTx = await instance.commitBlueprint(txHash, outputIndex, { * type: "Tx ConwayEra", * cborHex: unsignedTx, * description: "Commit Blueprint", * }); * ``` */ commitBlueprint(txHash: string, outputIndex: number, transaction: hydraTransaction): Promise; /** * Commit multiple UTxOs in a Cardano transaction blueprint to the Hydra head. * * @param utxos - Array of UTxO to commit, each with txHash and outputIndex * @param transaction - The Cardano transaction in text envelope format, containing: * - type: The type of the transaction (e.g., "Unwitnessed Tx ConwayEra"). * - description: (Optional) A human-readable description of the transaction. * - cborHex: The CBOR-encoded unsigned transaction. * @returns The function returns the transaction CBOR hex ready to be partially signed. * @example * ```tsx * const commitTx = await instance.commitBlueprintUTxOs([ * { txHash: "abc123...", outputIndex: 0 }, * { txHash: "def456...", outputIndex: 1 }, * ], { * type: "Tx ConwayEra", * cborHex: unsignedTx, * description: "Commit Multiple Blueprint", * }); * ``` */ commitBlueprintUTxOs(txIn: { txHash: string; outputIndex: number; }[], transaction: hydraTransaction): Promise; /** * Increment commit funds to the head, choose which UTxO you would like to make available on layer 2. * The function returns the transaction CBOR hex ready to be partially signed. * @param txHash * @param txIndex * @returns commitTransactionHex */ incrementalCommitFunds(txHash: string, outputIndex: number): Promise; /** * Increment a Cardano transaction blueprint to the Hydra head. * * This method allows you to increase a commit in the Cardano text envelope format * (i.e., a JSON object containing a 'type' and a 'cborHex' field) as a blueprint UTxO * to the Hydra head. This is useful for advanced use cases such as reference scripts, * inline datums, or other on-chain features that require a transaction context. * * * https://hydra.family/head-protocol/docs/how-to/commit-blueprint * * @param txHash - The transaction hash of the UTxO to be committed as a blueprint. * @param outputIndex - The output index of the UTxO to be committed. * @param hydraTransaction - The Cardano transaction in text envelope format, containing: * - type: The type of the transaction (e.g., "Unwitnessed Tx ConwayEra"). * - description: (Optional) A human-readable description of the transaction. * - cborHex: The CBOR-encoded unsigned transaction. * @returns A promise that resolves to the CBOR hex ready to be partially signed. */ incrementalBlueprintCommit(txHash: string, outputIndex: number, transaction: hydraTransaction): Promise; } export { type ClientInput, type ClientMessage, type ConnectionState, type HydraAssets, HydraInstance, HydraProvider, type HydraUTxOs, type ServerOutput, clientInput, getHydraStatus, hydraAssets, hydraReferenceScript, type hydraScriptInfo, type hydraStatus, type hydraTransaction, hydraUTxO, hydraUTxOs };