Table of Contents

Class ArkProgramContract

Namespace
NArk.Arkade.Contracts
Assembly
NArk.Arkade.dll

An ArkContract whose spending paths come from a compiled ArkadeProgram rather than a hardcoded script shape. Compiles once at construction; GetScriptBuilders() hands the compiled leaves to the base class, which assembles them into a taproot tree exactly like every other contract (GetTaprootSpendInfo()).

public sealed class ArkProgramContract : ArkContract
Inheritance
ArkProgramContract
Inherited Members

Constructors

ArkProgramContract(OutputDescriptor, ArkadeProgram, IReadOnlyDictionary<string, AsmToken>, OutputDescriptor?, ECXOnlyPubKey?)

Compiles an Arkade program into a spendable contract.

public ArkProgramContract(OutputDescriptor server, ArkadeProgram program, IReadOnlyDictionary<string, AsmToken> args, OutputDescriptor? user = null, ECXOnlyPubKey? emulatorKey = null)

Parameters

server OutputDescriptor

Output descriptor for the Arkade server's key, bound as $server.

program ArkadeProgram

The parsed program artifact to compile.

args IReadOnlyDictionary<string, AsmToken>

Values for the program's declared params, by name.

user OutputDescriptor

Optional descriptor for the wallet's own key, bound as $user when the program declares it.

emulatorKey ECXOnlyPubKey

Optional emulator signer key; required for functions carrying an ArkadeScript, since the emulator's per-script tweaked key becomes a required signer on that leaf.

Fields

ContractType

The contract type discriminator used in Type and persistence.

public const string ContractType = "ArkadeProgram"

Field Value

string

Properties

Args

Args this program was compiled against.

public IReadOnlyDictionary<string, AsmToken> Args { get; }

Property Value

IReadOnlyDictionary<string, AsmToken>

CompiledFunctions

All compiled spending paths, in declaration order.

public IReadOnlyList<CompiledArkadeFunction> CompiledFunctions { get; }

Property Value

IReadOnlyList<CompiledArkadeFunction>

DefaultScope

The layer this contract type's funds live on by default (on-chain vs off-chain). Abstract so every contract type makes an explicit, compile-time scope decision. Used as the fallback when ToEntity(string, OutputDescriptor?, DateTimeOffset?, ContractActivityState, ContractScope?) is called without a scope override.

public override ContractScope DefaultScope { get; }

Property Value

ContractScope

Type

Contract type discriminator string (e.g. "vtxo", "boarding").

public override string Type { get; }

Property Value

string

User

Output descriptor for the wallet's own key, bound as the $user param when the program declares it.

public OutputDescriptor? User { get; }

Property Value

OutputDescriptor

Methods

FunctionByName(string)

The compiled spending path with the given function name, if any.

public CompiledArkadeFunction? FunctionByName(string name)

Parameters

name string

The function name as declared in the program artifact.

Returns

CompiledArkadeFunction

The compiled function, or null when the program declares no such function.

GetContractData()

Returns the key-value map of contract parameters used for serialization.

protected override Dictionary<string, string> GetContractData()

Returns

Dictionary<string, string>

GetScriptBuilders()

Returns the script builders for each tapscript leaf in the tree.

protected override IEnumerable<ScriptBuilder> GetScriptBuilders()

Returns

IEnumerable<ScriptBuilder>

Parse(Dictionary<string, string>, Network)

Rebuilds a contract from persisted GetContractData() output.

public static ArkProgramContract Parse(Dictionary<string, string> contractData, Network network)

Parameters

contractData Dictionary<string, string>

The persisted key/value data produced by GetContractData.

network Network

The network to parse descriptors and keys against.

Returns

ArkProgramContract

The rebuilt contract, compiled against the persisted program and args.