What is a Value / token bundle in Plutus?
newtype Value = Value { getValue :: Map.Map CurrencySymbol (Map.Map TokenName Integer) }
deriving stock (Generic)
deriving anyclass (ToJSON, FromJSON, Hashable, NFData)
deriving newtype (Serialise, PlutusTx.IsData)
deriving Pretty via (PrettyShow Value)
Each native token, including Ada, is identified by 2 things:
CurrencySymbol
- newtype wrapper aroundByteString
TokenName
- newtype wrapper aroundByteString
This is also known as an AssetClass
.
assetClass :: CurrencySymbol -> TokenName -> AssetClass
assetClass s t = AssetClass (s, t)
A Value
shows how many units exist for a given asset class.
For ada symbol and token these are empty bytestrings.
We have smart constructors for value maps: lovelaceValueOf
.