Class ArkProgramContractTransformer
Materializes an ArkProgramContract VTXO into a spendable ArkCoin,
mirroring HashLockedContractTransformer/DelegateContractTransformer: picks a
compiled function and resolves its witness at coin-materialization time (SpendingService
then spends any ArkCoin uniformly). Two entry points: the
IContractTransformer Transform(string, ArkContract, ArkVtxo) auto-selects
the single fully-args-bound path, and the explicit
Transform(string, ArkProgramContract, ArkVtxo, string, IReadOnlyDictionary<string, AsmToken>?)
overload spends a named path with call-time witness values (preimage, signature, …).
public class ArkProgramContractTransformer : IContractTransformer
- Inheritance
-
ArkProgramContractTransformer
- Implements
- Inherited Members
Remarks
Auto-select scope: a program is auto-transformable only if it has exactly one function whose
resolved signers include the wallet's own key (the $user param) and whose witness (see Witness/
Witness) resolves fully from the program's constructor
args — i.e. no unbound call-time inputs. Programs with several wallet-spendable
paths (claim vs. refund), or a path needing call-time values, use the explicit overload to
select the path and supply its callArgs.
A function may combine a Asm condition (an on-chain gate such as
a hashlock) with an ScriptSegment covenant. Its two witnesses are
carried separately: the tapscript witness satisfies the on-chain condition via
ArkCoin.SpendingConditionWitness, while the arkade-script witness travels to the emulator
on ArkadeScriptWitness (assembled into
the emulator packet by ArkadePsbtExtensions.BuildEmulatorPackets). This mirrors the ts-sdk,
which likewise splits the on-chain ConditionWitness from the emulator packet's witness.
Constructors
ArkProgramContractTransformer(IWalletProvider, ILogger<ArkProgramContractTransformer>?)
Materializes an ArkProgramContract VTXO into a spendable ArkCoin,
mirroring HashLockedContractTransformer/DelegateContractTransformer: picks a
compiled function and resolves its witness at coin-materialization time (SpendingService
then spends any ArkCoin uniformly). Two entry points: the
IContractTransformer Transform(string, ArkContract, ArkVtxo) auto-selects
the single fully-args-bound path, and the explicit
Transform(string, ArkProgramContract, ArkVtxo, string, IReadOnlyDictionary<string, AsmToken>?)
overload spends a named path with call-time witness values (preimage, signature, …).
public ArkProgramContractTransformer(IWalletProvider walletProvider, ILogger<ArkProgramContractTransformer>? logger = null)
Parameters
walletProviderIWalletProviderloggerILogger<ArkProgramContractTransformer>
Remarks
Auto-select scope: a program is auto-transformable only if it has exactly one function whose
resolved signers include the wallet's own key (the $user param) and whose witness (see Witness/
Witness) resolves fully from the program's constructor
args — i.e. no unbound call-time inputs. Programs with several wallet-spendable
paths (claim vs. refund), or a path needing call-time values, use the explicit overload to
select the path and supply its callArgs.
A function may combine a Asm condition (an on-chain gate such as
a hashlock) with an ScriptSegment covenant. Its two witnesses are
carried separately: the tapscript witness satisfies the on-chain condition via
ArkCoin.SpendingConditionWitness, while the arkade-script witness travels to the emulator
on ArkadeScriptWitness (assembled into
the emulator packet by ArkadePsbtExtensions.BuildEmulatorPackets). This mirrors the ts-sdk,
which likewise splits the on-chain ConditionWitness from the emulator packet's witness.
Methods
CanTransform(string, ArkContract, ArkVtxo)
Returns true if this transformer can handle the given contract/VTXO pair.
public Task<bool> CanTransform(string walletIdentifier, ArkContract contract, ArkVtxo vtxo)
Parameters
walletIdentifierstringcontractArkContractvtxoArkVtxo
Returns
Transform(string, ArkContract, ArkVtxo)
Transforms the contract/VTXO pair into a spendable coin with signing metadata.
public Task<ArkCoin> Transform(string walletIdentifier, ArkContract contract, ArkVtxo vtxo)
Parameters
walletIdentifierstringcontractArkContractvtxoArkVtxo
Returns
Transform(string, ArkProgramContract, ArkVtxo, string, IReadOnlyDictionary<string, AsmToken>?)
Materializes a specific spending path (functionName) into a spendable
ArkCoin, supplying its call-time witness values via callArgs.
Use this when the program exposes several wallet-spendable paths (e.g. claim vs. refund) or a
witness not fully determined by the program's constructor args — the parameterless
Transform(string, ArkContract, ArkVtxo) only handles the single, fully-args-bound path.
public Task<ArkCoin> Transform(string walletIdentifier, ArkProgramContract contract, ArkVtxo vtxo, string functionName, IReadOnlyDictionary<string, AsmToken>? callArgs = null)
Parameters
walletIdentifierstringcontractArkProgramContractvtxoArkVtxofunctionNamestringName of the program function (spending path) to spend through.
callArgsIReadOnlyDictionary<string, AsmToken>Values for the function's declared
inputs, keyed by input name. Each is a Bytes token (e.g. an HTLC preimage, a counterparty signature, a pubkey or a hash) or a Number token (an int) — matching the input's declared ArkadeProgramInputType.
Returns
Exceptions
- ArgumentException
No function named
functionNameexists.- InvalidOperationException
The function carries both a covenant and a tapscript condition (unrepresentable with the single witness field), or a required call argument is missing from
callArgs.