Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Extension alias for Value.multiply.
Extension alias for Value.plus.
Extension alias for Value.minus.
Flattens the Value into a list of policy id, token name, and amount triples.
Flattens the Value into a list of policy id, token name, and amount triples.
Converts the nested map structure into a flat list representation where each element contains the policy id, token name, and corresponding amount.
Attributes
- Returns
-
A flattened list of tuples containing (policyId, tokenName, amount)
- Example
-
val value = Value.fromList( List.Cons( (Value.adaPolicyId, List.Cons((Value.adaTokenName, BigInt(1000000)), List.Nil)), List.Cons( (ByteString.fromString("ff"), List.Cons((ByteString.fromString("TOKEN"), BigInt(100)), List.Nil)), List.Nil ) ) ) value.flatten === List.Cons( (Value.adaPolicyId, Value.adaTokenName, BigInt(1000000)), List.Cons( (ByteString.fromString("ff"), ByteString.fromString("TOKEN"), BigInt(100)), List.Nil ) )
Returns the amount of Lovelace in this Value.
Returns the amount of Lovelace in this Value.
If the Value contains no Lovelace, it returns zero.
Attributes
- Returns
-
The amount of Lovelace in this
Value - Example
-
val value = Value.lovelace(BigInt(1000000)) value.getLovelace === BigInt(1000000) val emptyValue = Value.zero emptyValue.getLovelace === BigInt(0)
Checks if this Value is non-zero and positive, meaning it contains at least one token or currency symbol with a non-zero positive amount and all amounts are positive.
Checks if this Value is non-zero and positive, meaning it contains at least one token or currency symbol with a non-zero positive amount and all amounts are positive.
Attributes
- Returns
-
trueif theValueis non-empty and has all positive amounts,falseotherwise
Checks if this Value is zero, meaning it contains no tokens or currency symbols.
Checks if this Value is zero, meaning it contains no tokens or currency symbols.
Attributes
- Returns
-
trueif theValueis empty,falseotherwise - Example
-
val value = Value.zero value.isZero === true val nonZeroValue = Value.lovelace(BigInt(1000000)) nonZeroValue.isZero === false
Checks if this Value is non-zero, meaning it contains at least one token or currency symbol with a non-zero amount.
Checks if this Value is non-zero, meaning it contains at least one token or currency symbol with a non-zero amount.
Attributes
- Returns
-
trueif theValueis non-empty,falseotherwise - Example
-
val value = Value.zero value.nonZero === false val nonZeroValue = Value.lovelace(BigInt(1000000)) nonZeroValue.nonZero === true
A list of all policy ids in that scalus.cardano.onchain.plutus.v1.Value with non-zero tokens.
A list of all policy ids in that scalus.cardano.onchain.plutus.v1.Value with non-zero tokens.
Attributes
- Returns
-
A list of sorted scalus.cardano.onchain.plutus.v1.PolicyId
- Example
-
val value = Value.fromList( List.Cons( (Value.adaPolicyId, List.Cons((Value.adaTokenName, BigInt(1000000)), List.Nil)), List.Cons( (ByteString.fromString("ff"), List.Cons((ByteString.fromString("TOKEN"), BigInt(100)), List.Nil)), List.Nil ) ) ) value.policyIds === List.Cons( Value.adaPolicyId, List.Cons( ByteString.fromString("ff"), List.Nil ) )
Gets the amount of a specific token in a policy id from a Value.
Gets the amount of a specific token in a policy id from a Value.
Returns the token amount for the given policy id and token name pair. If either the policy id or token name is not found, returns zero.
Value parameters
- cs
-
The policy id to look up
- tn
-
The token name to look up within that policy id
Attributes
- Returns
-
The amount of the specified token, or zero if not found
- Example
-
val value = Value.fromList( List.Cons( (Value.adaPolicyId, List.Cons((Value.adaTokenName, BigInt(1000000)), List.Nil)), List.Cons( (ByteString.fromString("ff"), List.Cons((ByteString.fromString("TOKEN"), BigInt(100)), List.Nil)), List.Nil ) ) ) value.quantityOf(Value.adaPolicyId, Value.adaTokenName) === BigInt(1000000) value.quantityOf(ByteString.fromString("ff"), ByteString.fromString("TOKEN")) === BigInt(100) value.quantityOf(ByteString.fromString("missing"), ByteString.fromString("TOKEN")) === BigInt(0)
Extension alias for Value.debugToString.
Returns a string representation of the object.
Returns a string representation of the object.
The default representation is platform dependent.
Attributes
- Returns
-
a string representation of the object.
- Definition Classes
-
Any
Get all tokens associated with a given policy.
Get all tokens associated with a given policy.
Returns the token SortedMap for the given policy id. If the policy id is not found, returns an empty SortedMap.
Value parameters
- cs
-
The policy id to look up
Attributes
- Returns
-
The
SortedMapof the specified token, or an emptySortedMapif not found - Example
-
val value = Value.fromList( List.Cons( (Value.adaPolicyId, List.Cons((Value.adaTokenName, BigInt(1000000)), List.Nil)), List.Cons( (utf8"ff", List.Cons((utf8"TOKEN", BigInt(100)), List.Nil)), List.Nil ) ) ) value.quantityOf(Value.adaPolicyId) === SortedMap.singleton(Value.adaTokenName, BigInt(1000000)) value.quantityOf(utf8"ff") === SortedMap.singleton(utf8"TOKEN", BigInt(100)) value.quantityOf(utf8"missing") === SortedMap.empty
Extension alias for Value.negate.
Returns a new Value with all ADA/Lovelace tokens removed.
Returns a new Value with all ADA/Lovelace tokens removed.
This method creates a copy of the value with the ADA policy id removed, effectively removing all Lovelace tokens while preserving other tokens.
Attributes
- Returns
-
A new
Valuewithout any Lovelace tokens - Example
-
val value = Value.fromList( List.Cons( (Value.adaPolicyId, List.Cons((Value.adaTokenName, BigInt(1000000)), List.Nil)), List.Cons( (ByteString.fromString("ff"), List.Cons((ByteString.fromString("TOKEN"), BigInt(100)), List.Nil)), List.Nil ) ) ) val withoutAda = Value.fromList( List.Cons( (ByteString.fromString("ff"), List.Cons((ByteString.fromString("TOKEN"), BigInt(100)), List.Nil)), List.Nil ) ) value.withoutLovelace === withoutAda
Inherited methods
Attributes
- Inherited from:
- Product
Attributes
- Inherited from:
- Product
Converts this Value to a scalus.cardano.ledger.Value
Converts this Value to a scalus.cardano.ledger.Value
Attributes
- Throws
-
IllegalArgumentException
if AssetName exceeds 32 bytes (thrown by AssetName constructor)
- Inherited from:
- ValueOffchainOps (hidden)