Plutus Explained: How native tokens are defined

Welcome to the Plutus Explained series of blog posts where I seek to explain the Plutus programming language, in an accessible manner. This post accompanies the Plutus Pioneer week 5 video. (2-5 minute mark)

First of all each UTxO has both an Address and a Value (i.e. quantity). In EUTxO, each UTxO also has a Data too, though we won’t be referencing that here.

A native token in Cardano is known as an asset class. An asset class is defined by two things: currency symbol, and token name, both of which are essentially of byte string data type.

Ada is measured in Lovelace, so lovelace would be the asset class.

The currency symbol is a hash of the minting policy script, and points to a UTxO on the blockchain. Each time we wish to create or burn a native token, the policy script is looked up.

Except in the case of Lovelace – for this, by design, there is no policy script so its not possible to mint or burn any.

  • Use getValue function to work out the quantity of the asset class.
  • Use flattenValue to extract the currency symbol, token name and value into a triplet
  • Using singleton with a currency symbol, token name, and quantity we can construct a native token

Published by ReddSpark

Follow me on Twitter: https://twitter.com/Redd_Spark or YouTube https://www.youtube.com/@ReddSpark

One thought on “Plutus Explained: How native tokens are defined

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: