cardano/value

This module contains code that aids in various value manipulations and comparisons.

Functions

from_token(token: Token) -> Value

Creates a Value type from a token.

value.from_token(this_token)

from_tokens(tokens: Tokens) -> Value

Creates a Value type from a list of tokens.

value.from_tokens(redeemer.tokens)

multiply(val: Value, n: Int) -> Value

Multiply some value by n. This is just a linear scaling to the quantity of each token.

value.multiply(bundle_value, bundle_size)

contains(total: Value, target: Value) -> Bool

Prove that the target value is contained inside another assets. Each token inside the target must exist inside the total assets. The quantity of each token must be at least the target amount or greater.

value.contains(total_value, target_value)

compute_hash(target: Value) -> ByteArray

Compute the sha3_256 hash of a value by merklizing the policy id, asset name, and quantity. Empty values return the empty by string.

value.compute_hash(validating_value)

unique_token_name(
  txid: TransactionId,
  idx: Int,
  prefix: ByteArray,
  personal: ByteArray,
) -> AssetName

Calculate a unique token name from a TxId#Idx and prefix. Can be combined with the find module to create unique token names from the first input utxo inside the transaction.

value.unique_token_name(tx_id, tx_idx, cip68.prefix_333, personal_tag)

prove_nft(total: Value, pid: PolicyId) -> Bool

Proves that inside some value there is a policy id with a single token name that has a quantity of 1. This will show that a value contains an NFT or something that is nft-like. Should be useful to prove that something is holding a token inside a transaction when the token name is assumed to be unique.

value.prove_nft(this_value, pid)

prove_exact_nft(
  total_value: Value,
  nft_pid: PolicyId,
  nft_tkn: AssetName,
) -> Bool

Proves that inside some value there is a policy id with token name that has a quantity of 1. This will show that a value contains an NFT or something that is nft-like. Should be useful to prove that something is holding a token inside a transaction when the policy id and token name is known.

value.prove_exact_nft(that_value, pid, tkn)
Search Document