Skip to main content

Value

export interface Value {
  add(other: Value): Value
  assertAllPositive(): Value
  assetClasses: AssetClass<unknown>[]
  assets: Assets
  copy(): Value
  dump(): any
  isEqual(other: Value): boolean
  isGreaterOrEqual(other: Value): boolean
  isGreaterThan(other: Value): boolean
  kind: "Value"
  lovelace: bigint
  multiply(scalar: IntLike): Value
  subtract(other: Value): Value
  toCbor(): number[]
  toUplcData(isInScriptContext?: boolean): MapData
}
Represents a collection of tokens.

Properties​

add​

add(other: Value): 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.

assetClasses​

assetClasses: AssetClass<unknown>[]

assets​

assets: Assets

copy​

copy(): Value
Deep copy

dump​

dump(): any

isEqual​

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

isGreaterOrEqual​

isGreaterOrEqual(other: Value): boolean
Checks if a Value instance is strictly greater or equal to another Value instance. Returns false if any asset is missing.

isGreaterThan​

isGreaterThan(other: Value): boolean
Checks if a Value instance is strictly greater than another Value instance. Returns false if any asset is missing.

kind​

kind: "Value"

lovelace​

lovelace: bigint

multiply​

multiply(scalar: IntLike): Value
Multiplies a Value by a whole number.

subtract​

subtract(other: Value): Value
Substracts one Value instance from another. Returns a new Value instance.

toCbor​

toCbor(): number[]

toUplcData​

toUplcData(isInScriptContext?: boolean): MapData
Used when building datums, redeerms, or script contexts.

isInScriptContext

If isInScriptContext is true, the first entry in the returned map is always the lovelace entry. If the Value doesn't contain any lovelace, a 0 lovelace entry is prepended.

Also, the tokens of any minting policy in Value.assets, are sorted in lexicographic order instead of shortest-first order.

These changes are required to ensure validator script evaluation in Helios is identical to script evaluation in the reference node (and thus the same execution budget is obtained).