Policy Units
Represents the policy_id + asset_name in HEX format
Unit: Understanding Policy IDs and Asset Names
Overview
In Cardano, "unit" typically refers to the policy ID plus the asset name in a single hex string that identifies a native token or NFT. Because you can have thousands of different tokens, each must be uniquely identified by a combination of:
Policy ID (28 bytes, 56 hex characters).
Asset Name (up to 32 bytes, variable hex length).
For CIP-25 or CIP-68 NFTs, you might see unit
used in your minted assets or outputs. Similarly, when listing assets in an output, you specify:
For example, if your policyId
is:
and your asset name (in hex) is:
the Unit becomes:
Why Do Policy IDs and Asset Names Matter?
Token Gating and Access Control
Imagine you run a membership site or event. You want to grant access only to users who hold a specific NFT (like a “hotel keycard”).
To validate their NFT, you check the policy ID (the “hotel”) and the asset name (the “room”). If a user’s wallet has the exact combination, they get in.
Verification
If someone claims they hold a certain collectible or token, you can confirm by comparing their token’s Unit to the official “Unit” you expect.
This prevents duplicates or fakes.
Metadata and Searching
Explorers like preprod.cexplorer.io allow you to search by policy ID or asset name, letting you track how many tokens are minted, who holds them, and more.
Minting and Burning
To mint or burn tokens, the blockchain needs to know exactly which asset under which policy you’re referring to.
The policy ID and asset name form that unique identifier.
How to Extract the Policy ID and Asset Name from a Unit
If you have the full unit string (policyId + assetName
in hex), you can slice it into two parts:
Tip: Some asset names contain non-ASCII characters, so you might see garbled text if you convert from hex incorrectly or if it’s truly a binary representation. Always check the token’s known format.
Where to Find Your Policy ID and Asset Name
1. From a Blockchain Explorer
Go to an explorer like Preprod CExplorer (for testnet) or CExplorer.io (for mainnet).
Paste the asset name or policy ID in the search bar (e.g., “AnvilTest1208”).
On the asset’s detail page, you’ll typically see:
Encoded Asset Name (hex)
Policy ID (hex string)
Once you have both, concatenate them to get the unit.
2. From a Wallet (e.g., Eternl)
Open your wallet interface.
Locate the NFT or token in question.
The wallet interface usually displays both:
Policy ID
Asset Name (in either plain text or hex)
Some wallets (like Eternl) also display the unit or a direct link to an explorer page.
TBD: Add practical example.
Additional Tips and Best Practices
Hex vs. ASCII
Always confirm whether your asset name is stored in hex or ASCII.
If you do comparisons in your code, stay consistent—comparing hex to ASCII won’t match.
Policy Expiration
Some policies allow minting indefinitely; others have an expiration. Check the policy’s script if you plan to handle or mint new tokens under it.
Handling Special Characters
Asset names may include emojis or non-English text. The hex representation ensures compatibility, but the plain text might look odd.
Batching
For dApps dealing with numerous tokens, consider how you’ll fetch all these units efficiently (paging, caching, etc.).
Don’t Overlook Testnets
If you’re new to token gating or minted assets, test your approach on Preprod or Preview first. Real ADA isn’t at risk there.
Summary
Unit = policyId + assetName
(in hex).Why It Matters: It’s the unique identifier for any Cardano-native asset, crucial for gating, verification, minting, and more.
Where to Get Them: Use explorers, your wallet, or direct blockchain APIs.
Hotel Keycard Analogy: The policy ID is the “hotel,” and the asset name is the “room.” Checking them together ensures you grant access to the right person holding the right token.
With a solid grasp of Units, Policy IDs, and Asset Names, you can confidently build sophisticated Cardano applications—whether that’s token-gated dApps, NFT marketplaces, or membership sites—knowing exactly which assets users hold and how to verify them securely.
Next Steps
Learn about Utilities Functions to simplify asset handling (e.g., unitToName()
, nameToUnit()
, etc.). Jump into Transaction for guidance on how to send assets, sign transactions, or mint new tokens with Anvil. Explore advanced NFT & FT documentation to create, distribute, and manage your custom assets.
Last updated
Was this helpful?