Class ArkadeScript
Encode/decode + ASM helpers for ArkadeScript — the Bitcoin-Script superset
the emulator executes. Mirrors the ts-sdk's ArkadeScript coder
(and its toASM / fromASM helpers) so that the same script
bytes round-trip across the .NET, TypeScript, and Go SDKs.
public static class ArkadeScript
- Inheritance
-
ArkadeScript
- Inherited Members
Remarks
Encoding is a thin pass-through over NBitcoin's NBitcoin.Script /
NBitcoin.Op primitives — NBitcoin already treats any byte outside the
push range (0x01–0x4e) as an opaque single-byte opcode, so all 41
Arkade extension opcodes survive the trip without a custom serializer.
ASM formatting and parsing route through ArkadeOpcodeRegistry
so Arkade extension opcodes get their canonical OP_INSPECTOUTPUTVALUE-
style names instead of NBitcoin's OP_UNKNOWN placeholder.
Methods
AsmToBytes(string)
Encode an ASM string straight to bytes — convenience over FromAsm(string) + Encode(IEnumerable<Op>).
public static byte[] AsmToBytes(string asm)
Parameters
asmstring
Returns
- byte[]
BytesToAsm(byte[])
Decode bytes straight to ASM — convenience over Decode(byte[]) + ToAsm(IEnumerable<Op>).
public static string BytesToAsm(byte[] script)
Parameters
scriptbyte[]
Returns
Decode(byte[])
Decode an ArkadeScript byte stream into an op list. Equivalent to the
ts-sdk's ArkadeScript.decode(...). Bytes outside the data-push
range are surfaced as NBitcoin.Ops with NBitcoin.Op.Code
holding the raw byte; use GetOpcodeName(byte)
to resolve the mnemonic.
public static IReadOnlyList<Op> Decode(byte[] script)
Parameters
scriptbyte[]
Returns
- IReadOnlyList<Op>
Encode(IEnumerable<Op>)
Encode an op stream into the canonical ArkadeScript byte representation.
Equivalent to the ts-sdk's ArkadeScript.encode(...).
public static byte[] Encode(IEnumerable<Op> ops)
Parameters
opsIEnumerable<Op>
Returns
- byte[]
FromAsm(string)
Parse a Bitcoin-style ASM string back into an op list — the inverse of
ToAsm(IEnumerable<Op>). Tokens are: OP_* opcode mnemonics
(with or without the prefix), OP_0..OP_16 small-integer
shortcuts, or even-length hex strings interpreted as data pushes.
Small integers must carry the OP_ prefix: a bare "11" is a
one-byte data push, not OP_11, since the two are otherwise
indistinguishable in the hex rendering ToAsm(IEnumerable<Op>) emits.
public static IReadOnlyList<Op> FromAsm(string asm)
Parameters
asmstring
Returns
- IReadOnlyList<Op>
Exceptions
- FormatException
A token cannot be resolved as either an opcode or a hex push.
ToAsm(IEnumerable<Op>)
Format an op stream as Bitcoin-style ASM (e.g.
"OP_DUP OP_HASH160 deadbeef OP_INSPECTOUTPUTVALUE"). Data pushes
are lowercase hex; NBitcoin.OpcodeType.OP_0 through
NBitcoin.OpcodeType.OP_16 render as their OP_N mnemonics
to match the ts-sdk's output.
public static string ToAsm(IEnumerable<Op> ops)
Parameters
opsIEnumerable<Op>