assist/values
This module contains code that aids in various value manipulations and comparisons.
Functions
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.
values.compute_hash(validating_value)
contains(total: Value, target: Value) -> Bool
Prove that the target value is contained inside another value. Each token inside the target must exist inside the total value. The quantity of each token must be at least the target amount or greater.
values.contains(total_value, target_value)
from_token(token: Token) -> Value
Creates a Value type from a token.
values.from_token(this_token)
from_tokens(tokens: Tokens) -> Value
Creates a Value type from a list of tokens.
values.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.
values.multiply(bundle_value, bundle_size)
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.
values.prove_exact_nft(that_value, pid, tkn)
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.
values.prove_nft(this_value, pid)
unique_token_name(txid: TxHash, idx: Int, prefix: 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.
values.unique_token_name(tx_id, tx_idx, cip68.prefix_333)