Helios API/ API Reference/

Functions

bytesToHex

bytesToHex(bytes): string

Converts a list of uint8 bytes into its hexadecimal string representation.

Parameters

NameType
bytesnumber[]

Returns

string

Example

bytesToHex([0, 255, 52]) == "00ff34"

bytesToText

bytesToText(bytes): string

Decodes a list of uint8 bytes into a string using UTF-8 encoding.

Parameters

NameType
bytesnumber[]

Returns

string

Example

bytesToText([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]) == "hello world"

deserializeUplc

deserializeUplc(json): UplcProgram

Parses a plutus core program. Returns a UplcProgram instance.

Parameters

NameTypeDescription
jsonstring | { cborHex: string }a raw JSON string or a parsed JSON object

Returns

UplcProgram

deserializeUplcBytes

deserializeUplcBytes(bytes, properties?): UplcProgram

Deserializes a flat encoded UplcProgram.

Parameters

NameType
bytesnumber[]
properties?ProgramProperties

Returns

UplcProgram

extractScriptPurposeAndName

extractScriptPurposeAndName(rawSrc): null | [ScriptPurpose, string]

Quickly extract the script purpose header of a script source, by parsing only the minimally necessary characters.

Parameters

NameType
rawSrcstring

Returns

null | [ScriptPurpose, string]

Returns null if the script header is missing or syntactically incorrect. The first string returned is the script purpose, the second value returned is the script name.

hexToBytes

hexToBytes(hex): number[]

Converts a hexadecimal string into a list of bytes.

Parameters

NameType
hexstring

Returns

number[]

Example

hexToBytes("00ff34") == [0, 255, 52]

highlight

highlight(src): Uint8Array

Returns Uint8Array with the same length as the number of chars in the script. Each resulting byte respresents a different syntax category. This approach should be faster than a RegExp based a approach.

Parameters

NameType
srcstring

Returns

Uint8Array

hl

hl(a, ...b): string

Template string tag function that doesn't do anything and just returns the template string as a string. Can be used as a marker of Helios sources so that syntax highlighting can work inside JS/TS files.

Parameters

NameType
astring[]
...bany[]

Returns

string

Example

hl`hello ${"world"}!` == "hello world!"

textToBytes

textToBytes(str): number[]

Encodes a string into a list of uint8 bytes using UTF-8 encoding.

Parameters

NameType
strstring

Returns

number[]

Example

textToBytes("hello world") == [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]