Table of Contents

Struct AsmToken

Namespace
NArk.Arkade.Program.Models
Assembly
NArk.Arkade.dll

One entry in an TapscriptSegment/ArkadeScriptSegment's Asm/Witness/Signers list — mirrors the ts-sdk's AsmToken/ WitnessRef/SignerRef unions (string | number | bigint | Uint8Array).

public readonly struct AsmToken : IEquatable<AsmToken>
Implements
Inherited Members

Remarks

A pure data holder with value semantics: it does not resolve $param placeholders, look up opcodes, or encode anything. Resolution happens later, once constructor args (and, for witness tokens, call args) are known. The implicit conversions let callers write asm/witness lists as bare literals (["HASH160", "$hash", 42]) instead of factory calls.

Properties

Bytes

Set when Kind is Bytes.

public byte[]? Bytes { get; }

Property Value

byte[]

IsParam

True when this is a \(param</code> placeholder (a <xref href="NArk.Arkade.Program.Models.AsmToken.Text" data-throw-if-not-resolved="false"></xref> token starting with <code>\)).

public bool IsParam { get; }

Property Value

bool

Kind

Which of Text/Number/Bytes is set.

public AsmTokenKind Kind { get; }

Property Value

AsmTokenKind

Number

Set when Kind is Number.

public BigInteger? Number { get; }

Property Value

BigInteger?

ParamName

The parameter name for a IsParam token (without the $ prefix).

public string ParamName { get; }

Property Value

string

Text

Set when Kind is Text.

public string? Text { get; }

Property Value

string

Methods

Equals(AsmToken)

Value equality: same Kind and payload. Text compares ordinally (opcode/param/ signer names are case-sensitive, matching how they resolve), bytes compare by content.

public bool Equals(AsmToken other)

Parameters

other AsmToken

Returns

bool

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

FromBytes(byte[])

Wrap raw bytes.

public static AsmToken FromBytes(byte[] bytes)

Parameters

bytes byte[]

Returns

AsmToken

FromNumber(BigInteger)

Wrap a numeric literal.

public static AsmToken FromNumber(BigInteger number)

Parameters

number BigInteger

Returns

AsmToken

FromText(string)

Wrap an opcode mnemonic, $param placeholder, or signer keyword.

public static AsmToken FromText(string text)

Parameters

text string

Returns

AsmToken

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Operators

operator ==(AsmToken, AsmToken)

Value equality — see Equals(AsmToken).

public static bool operator ==(AsmToken left, AsmToken right)

Parameters

left AsmToken
right AsmToken

Returns

bool

implicit operator AsmToken(byte[])

Implicitly wrap raw bytes — see FromBytes(byte[]).

public static implicit operator AsmToken(byte[] bytes)

Parameters

bytes byte[]

Returns

AsmToken

implicit operator AsmToken(long)

Implicitly wrap an integer literal (also covers int via widening) — see FromNumber(BigInteger).

public static implicit operator AsmToken(long number)

Parameters

number long

Returns

AsmToken

implicit operator AsmToken(BigInteger)

Implicitly wrap an arbitrary-precision integer — see FromNumber(BigInteger).

public static implicit operator AsmToken(BigInteger number)

Parameters

number BigInteger

Returns

AsmToken

implicit operator AsmToken(string)

Implicitly wrap an opcode mnemonic / $param / signer keyword — see FromText(string).

public static implicit operator AsmToken(string text)

Parameters

text string

Returns

AsmToken

operator !=(AsmToken, AsmToken)

Value inequality — see Equals(AsmToken).

public static bool operator !=(AsmToken left, AsmToken right)

Parameters

left AsmToken
right AsmToken

Returns

bool