BSV.Tokens.Script.StasBuilder (bsv_sdk v1.4.0)

Copy Markdown View Source

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).

Summary

Functions

Build a STAS v2 locking script (legacy).

Functions

build_stas_locking_script(arg1, arg2, splittable)

@spec build_stas_locking_script(<<_::160>>, <<_::160>>, 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(arg1, arg2, opts \\ [])

@spec build_stas_v3_locking_script(<<_::160>>, <<_::160>>, 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: [])