Documentation
Deep Dives
Interact with Validators
Advanced
Reference Scripts

Reference Scripts

Reference scripts point to an already on-chain script rather than including it entirely. Without reference scripts, the full script code must be included in each transaction. This reduces transaction size and base fee (execution costs remain the same).

// Deploy a script as a reference script
const deployScriptTx = await lucid
  .newTx()
  .pay.ToAddressWithData(
    scriptAddress,
    { kind: "inline", value: datum },
    { lovelace: 5_000_000n },
    script // The script to be stored as a reference
  )
  .complete();