# Class BSV::Transaction::UnlockingScriptTemplate <a id="class-BSV-Transaction-UnlockingScriptTemplate"></a>

**Inherits:** `Object`

Abstract base class for unlocking script templates.

Templates provide deferred signing — an input can hold a template that
generates the unlocking script at sign time, when the full transaction is
available for sighash computation. Subclass and implement {#sign} and
{#estimated_length}.

- **@abstract** Subclass and override {#sign} and {#estimated_length}.
- **@see** `P2PKH`

## Public Instance Methods
### `estimated_length(_tx, _input_index)` <a id="method-i-estimated_length"></a> <a id="estimated_length-instance_method"></a>
Estimate the unlocking script length in bytes (for fee estimation).
- **@param** `_tx` [Transaction::Tx] the transaction
- **@param** `_input_index` [Integer] the input index
- **@raise** [NotImplementedError] if not overridden by a subclass
- **@return** [Integer] estimated script length in bytes

### `sign(_tx, _input_index)` <a id="method-i-sign"></a> <a id="sign-instance_method"></a>
Generate the unlocking script for a transaction input.
- **@param** `_tx` [Transaction::Tx] the transaction being signed
- **@param** `_input_index` [Integer] the input index to sign
- **@raise** [NotImplementedError] if not overridden by a subclass
- **@return** [Script::Script] the generated unlocking script
