Helios API/ API Reference/ Classes/
Value
Represents a collection of tokens.
Hierarchy
-
↳
Value
Index
Constructors
constructor
• new Value(props?
, assets?
)
Parameters
Name | Type |
---|---|
props? | ValueProps |
assets? | null | Assets | AssetsProps |
Overrides
Accessors
assets
• get
assets(): Assets
Gets the Assets
contained in the Value
.
Returns
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
Name | Type |
---|---|
isInScriptContext? | boolean |
Returns
add
▸ add(other
): Value
Adds two Value
instances together. Returns a new Value
instance.
Parameters
Name | Type |
---|---|
other | Value |
Returns
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
- 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
Name | Type |
---|---|
other | Value |
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
Name | Type |
---|---|
other | Value |
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
Name | Type |
---|---|
other | Value |
Returns
boolean
mul
▸ mul(scalar
): Value
Multiplies a Value
by a whole number.
Parameters
Returns
setLovelace
▸ setLovelace(lovelace
): void
Mutates the quantity of lovelace in a Value
.
Parameters
Returns
void
sub
▸ sub(other
): Value
Substracts one Value
instance from another. Returns a new Value
instance.
Parameters
Name | Type |
---|---|
other | Value |
Returns
toCbor
▸ toCbor(): number
[]
Returns
number
[]
Inherited from
toCborHex
▸ toCborHex(): string
Returns
string
Inherited from
toSchemaJson
▸ toSchemaJson(): string
Returns
string
Inherited from
asset
▸ Static
asset(mph
, tokenName
, qty
): Value
Parameters
Name | Type |
---|---|
mph | HashProps | MintingPolicyHash |
tokenName | ByteArray | ByteArrayProps |
qty | HInt | HIntProps |
Returns
cleanConstructorArgs
▸ Static
cleanConstructorArgs(props
, maybeAssets
): [HInt
| HIntProps
, Assets
| AssetsProps
]
Parameters
Name | Type |
---|---|
props | ValueProps |
maybeAssets | null | Assets | AssetsProps |
Returns
[HInt
| HIntProps
, Assets
| AssetsProps
]
fromCbor
▸ Static
fromCbor(bytes
): Value
Parameters
Name | Type |
---|---|
bytes | number [] |
Returns
fromProps
▸ Static
fromProps(props
): Value
Parameters
Name | Type |
---|---|
props | Value | ValueProps |
Returns
fromUplcCbor
▸ Static
fromUplcCbor(bytes
): Value
Parameters
Name | Type |
---|---|
bytes | string | number [] |
Returns
fromUplcData
▸ Static
fromUplcData(data
): Value
Converts a UplcData
instance into a Value
. Throws an error if it isn't in the right format.
Parameters
Name | Type |
---|---|
data | UplcData |
Returns
sum
▸ Static
sum(values
): Value
Parameters
Name | Type |
---|---|
values | Value [] |