14. Token usage in Hydra Scripts
Status
Accepted
Context
- The Hydra on-chain-verification scripts are used to validate Hydra protocol transactions and ensure they are lawful.
- At least these three properties need to be enforced:
- Authentication: ensure that only Head participants can, for example,
aborta Head - Contract continuity: ensure that a Head was
initialized before it can be opened by acollectComtx. - Completeness: ensure that all Head participants had chance to
commitfunds to a Head.
- Authentication: ensure that only Head participants can, for example,
- The Hydra Head paper introduces participation tokens (PT) and a state thread token (ST) for that matter.
- Such tokens (a.k.a native assets) are identified by the
CurrencySymbol, that is the hash of theirMintingPolicyScript(a.k.aPolicyIDin the ledger), and aByteString, the socalledTokenName(a.k.a asAssetNamein the ledger, see shelley-ma ledger spec) - There can be multiple Hydra Heads on a network and a
hydra-nodeneed to distinguish individual Head instances or even (later) keep track of multiple Heads. Concretely, this means that we need to infer a Head identifier (HeadId) from observing each of the Hydra protocol transactions.
Decision
- We solve both challenges by defining that ST and PTs shall use the same
MintingPolicyScriptand thus have sameCurrencySymbol - The
MintingPolicyScriptshall be parameterized byTxOutRefto yield a uniqueCurrencySymbolper Head (similar to theOneShotCurrencyexample) - ST and one PT per participant are minted in the
initTx - The
TokenNameof the ST can be any well-knownByteString, e.g."HydraHeadV1" - The
TokenNameof the PTs needs to be thePubKeyHashof the respective participant
Consequences
-
Heads can be identified by looking for the
STininit,collectCom,close,contestorfanouttransactions, or thePTincommittransactions. In both cases, theCurrencySymbol == HeadId -
Our scripts become simpler as we only need to check that ST/PT are paid forward, instead of needing to check datums
-
The datum produced by
committxs (and consumed bycollectCom) isJust SerializedTxOut, which is simpler than also keeping the participant which committed in the datum (compare to full life-cycle of 0.3.0). -
The
v_headscript validator does not need to be parameterized, which makes discovering new Heads (and also tracking them for metrics) easier as the address to watch for is common to all Heads (of the samev_headversion). -
The
v_headscript (path) for the abort life-cycle can be implemented already much safer by checking that all PTs are burned on theaborttransaction (counting inputs in abort life-cycle of 0.3.0). -
Updated diagrams for the full and abort on-chain life-cycles of a Hydra Head.
Follow-up questions
- What value does the
STactually add? We could always look for thePTto identify a Head and contract continuity would already be achieved by thePTs! - In discussions it turned out to be not clear where the Head's
CurrencySymbolis coming from, and consequently how to identify that anSTis indeed anST?

