user255: Is there a way to programmatically get all the TokenNames belonging to a CurrencySymbol with Plutus?

user1071: Yes. Using ghci in Plutus repo I'll show you how. I will use fully qualified functions for clarity, and don't forget to :set -XOverloadedStrings.
Plutus observes all tokens in an output using txOutValue of TxOut. To define our own Value we can do (taken from PPP Lecture#5):
> let v = Plutus.V1.Ledger.Value.singleton "a8ff" "ABC" 7 <> Plutus.V1.Ledger.Ada.lovelaceValueOf 42 <> Plutus.V1.Ledger.Value.singleton "a8ff" "XYZ" 100
> v
Value (Map [(,Map [("",42)]),(a8ff,Map [("ABC",7),("XYZ",100)])])

To filter by CurrencySymbol we can do:
> PlutusTx.AssocMap.keys $ Data.Maybe.fromJust $ PlutusTx.AssocMap.lookup "a8ff" (Plutus.V1.Ledger.Value.getValue v)
["ABC","XYZ"]

This gives you TokenNames for CurrencySymbol a8ff. Ada's CurrencySymbol of "" has been filtered out.

255: <p>Is there a way to programmatically get all the <code>TokenName</code>s belonging to a <code>CurrencySymbol</code> with Plutus?</p>
 1071: <p>Yes. Using ghci in Plutus repo I'll show you how. I will use fully qualified functions for clarity, and don't forget to <code>:set -XOverloadedStrings</code>.</p>
<p>Plutus observes all tokens in an output using txOutValue of <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Api.html#t:TxOut" rel="nofollow noreferrer">TxOut</a>. To define our own <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Api.html#t:Value" rel="nofollow noreferrer">Value</a> we can do (taken from <a href="https://youtu.be/SsaVjSsPPcg?t=491" rel="nofollow noreferrer">PPP Lecture#5</a>):</p>
<pre><code>&gt; let v = Plutus.V1.Ledger.Value.singleton &quot;a8ff&quot; &quot;ABC&quot; 7 &lt;&gt; Plutus.V1.Ledger.Ada.lovelaceValueOf 42 &lt;&gt; Plutus.V1.Ledger.Value.singleton &quot;a8ff&quot; &quot;XYZ&quot; 100
&gt; v
Value (Map [(,Map [(&quot;&quot;,42)]),(a8ff,Map [(&quot;ABC&quot;,7),(&quot;XYZ&quot;,100)])])
</code></pre>
<p>To filter by <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-ledger-api/html/Plutus-V1-Ledger-Value.html#v:currencySymbol" rel="nofollow noreferrer">CurrencySymbol</a> we can do:</p>
<pre><code>&gt; PlutusTx.AssocMap.keys $ Data.Maybe.fromJust $ PlutusTx.AssocMap.lookup &quot;a8ff&quot; (Plutus.V1.Ledger.Value.getValue v)
[&quot;ABC&quot;,&quot;XYZ&quot;]
</code></pre>
<p>This gives you <code>TokenName</code>s for <code>CurrencySymbol</code> a8ff. Ada's <code>CurrencySymbol</code> of <code>&quot;&quot;</code> has been filtered out.</p>
