# `BSV.Tokens.Script.StasBuilder`
[🔗](https://github.com/Bittoku/bsv_sdk_elixir/blob/main/lib/bsv/tokens/script/stas_builder.ex#L1)

Builder for STAS locking scripts.

Supports both the legacy STAS v2 template (P2PKH-only, splittable flag) and
the new STAS v3 template (P2MPKH, 2nd variable field, flags, service fields).

The v3 template shares its core logic with STAS 3.0 — the difference is in the
trailing metadata (flags and service fields appended after redemption PKH).

# `build_stas_locking_script`

```elixir
@spec build_stas_locking_script(&lt;&lt;_::160&gt;&gt;, &lt;&lt;_::160&gt;&gt;, boolean()) ::
  {:ok, BSV.Script.t()} | {:error, term()}
```

Build a STAS v2 locking script (legacy).

Uses the v2 template with P2PKH-only ownership and a simple splittable flag.
No support for 2nd variable field, flags, or service fields.

## Parameters
- `owner_pkh` - 20-byte public key hash of the owner
- `redemption_pkh` - 20-byte public key hash for redemption
- `splittable` - whether the token can be split

# `build_stas_v3_locking_script`

```elixir
@spec build_stas_v3_locking_script(&lt;&lt;_::160&gt;&gt;, &lt;&lt;_::160&gt;&gt;, keyword()) ::
  {:ok, BSV.Script.t()} | {:error, term()}
```

Build a STAS v3 locking script.

Uses the new template with P2MPKH support, 2nd variable field, flags,
and service fields. This is the same core template used by STAS 3.0.

## Parameters
- `owner_pkh` - 20-byte owner public key hash or multisig script hash
- `redemption_pkh` - 20-byte redemption address/MPKH
- `opts` - Keyword list of options:
  - `:action_data` - `ActionData.t()` or `nil` (default: `nil`)
  - `:frozen` - whether the UTXO is frozen (default: `false`)
  - `:flags` - `ScriptFlags.t()` (default: no flags)
  - `:service_fields` - list of binary service fields (default: `[]`)
  - `:optional_data` - list of additional data binaries (default: `[]`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
