Helios API/ API Reference/ Classes/

Value

Represents a collection of tokens.

Hierarchy

Index

Constructors

constructor

new Value(props?, assets?)

Parameters

NameType
props?ValueProps
assets?null | Assets | AssetsProps

Overrides

HeliosData.constructor

Accessors

assets

get assets(): Assets

Gets the Assets contained in the Value.

Returns

Assets

lovelace

get lovelace(): bigint

Gets the lovelace quantity contained in the Value.

Returns

bigint

Methods

_toUplcData

_toUplcData(isInScriptContext?): MapData

Used when building script context

Parameters

NameType
isInScriptContext?boolean

Returns

MapData

add

add(other): Value

Adds two Value instances together. Returns a new Value instance.

Parameters

NameType
otherValue

Returns

Value

assertAllPositive

assertAllPositive(): Value

Throws an error if any of the Value entries is negative.

Used when building transactions because transactions can't contain negative values.

Returns

Value

  • returns this

dump

dump(): any

Returns

any

eq

eq(other): boolean

Checks if two Value instances are equal (Assets need to be in the same order).

Parameters

NameType
otherValue

Returns

boolean

ge

ge(other): boolean

Checks if a Value instance is strictly greater or equal to another Value instance. Returns false if any asset is missing.

Parameters

NameType
otherValue

Returns

boolean

gt

gt(other): boolean

Checks if a Value instance is strictly greater than another Value instance. Returns false if any asset is missing.

Parameters

NameType
otherValue

Returns

boolean

mul

mul(scalar): Value

Multiplies a Value by a whole number.

Parameters

NameType
scalarHInt | HIntProps

Returns

Value

setLovelace

setLovelace(lovelace): void

Mutates the quantity of lovelace in a Value.

Parameters

NameType
lovelaceHInt | HIntProps

Returns

void

sub

sub(other): Value

Substracts one Value instance from another. Returns a new Value instance.

Parameters

NameType
otherValue

Returns

Value

toCbor

toCbor(): number[]

Returns

number[]

Inherited from

HeliosData.toCbor

toCborHex

toCborHex(): string

Returns

string

Inherited from

HeliosData.toCborHex

toSchemaJson

toSchemaJson(): string

Returns

string

Inherited from

HeliosData.toSchemaJson

asset

Static asset(mph, tokenName, qty): Value

Parameters

Returns

Value

cleanConstructorArgs

Static cleanConstructorArgs(props, maybeAssets): [HInt | HIntProps, Assets | AssetsProps]

Parameters

NameType
propsValueProps
maybeAssetsnull | Assets | AssetsProps

Returns

[HInt | HIntProps, Assets | AssetsProps]

fromCbor

Static fromCbor(bytes): Value

Parameters

NameType
bytesnumber[]

Returns

Value

fromProps

Static fromProps(props): Value

Parameters

NameType
propsValue | ValueProps

Returns

Value

fromUplcCbor

Static fromUplcCbor(bytes): Value

Parameters

NameType
bytesstring | number[]

Returns

Value

fromUplcData

Static fromUplcData(data): Value

Converts a UplcData instance into a Value. Throws an error if it isn't in the right format.

Parameters

NameType
dataUplcData

Returns

Value

sum

Static sum(values): Value

Parameters

NameType
valuesValue[]

Returns

Value