<p>The issue is not with the Plutus version but the compiler. You need to remove <code>!</code> from where <code>mpTokenName</code> is defined. This should be fixed in the near future.</p>

CC BY-SA 4.0
2022-09-27T00:48:06.710Z
Thanks James, greatly appreciated.  This will work for now but had to remove other ! references in custom datatypes I have used in my code to get it to work.   Let me know if there is a bug logged for this.
lley154
CC BY-SA 4.0
2022-09-27T08:45:37.220Z
My pleasure @lley154! This bug has been reopened with reference to this question: https://github.com/input-output-hk/plutus/issues/4193
james
CC BY-SA 4.0
2022-09-27T23:08:49.773Z
Great - thanks James.
lley154
CC BY-SA 4.0
2022-09-26T09:52:03.263Z
2022-09-26T09:52:03.263Z
james
<p>I get the following GHC error for code that I am trying to update to Plutus V2.   I can reproduce the error using the plutus-scripts below.   Is this a bug with Plutus V2 or can anyone explain how to resolve it.   I don’t have this issue with Plutus V1.
Thank you.</p>
<p>Steps to reproduce</p>
<pre><code>Git clone https://github.com/james-iohk/plutus-scripts.git
Git clone https://github.com/input-output-hk/plutus-apps.git
Go into plutus-apps directory and checkout 87b647b05902a7cef37340fda9acb175f962f354 
Type nix-shell --extra-experimental-features flakes
Cd ../plutus-scripts/src
Make the following changes 1,2,3,4 below

vi NFTMint.hs


     53 data NFTParams = NFTParams --  doesn't need more than the TxOutRef
     54     {  mpTokenName :: !PlutusV2.TokenName  -- &lt;&lt; 1. uncommented code here
     55     , mpAmount   :: !Integer
     56     , mpTxOutRef :: !PlutusV2.TxOutRef
     57     --, mpPubKeyHs  :: !Plutus.PubKeyHash
     58     } deriving Show
     59 
     60 PlutusTx.makeLift ''NFTParams
     61 PlutusTx.unstableMakeIsData ''NFTParams
     62 
     63 tn :: PlutusV2.TokenName  -- &lt;&lt; 2. added helper function definition
     64 tn = PlutusV2.TokenName &quot;test&quot; -- &lt;&lt; 3. and here function body
     65 
     66 redeemer :: NFTParams
     67 redeemer = NFTParams { mpTokenName = tn,  -- &lt;&lt; 4. added tn to param
     68                        mpAmount = 1,
     69                        mpTxOutRef = PlutusV2.TxOutRef {txOutRefId = &quot;82669eddc629c8ce5cc3cb908cec6de339281bb0a0ec111880ff0936132ac8b0&quot;, txOutRefIdx = 0}
     70                      }

</code></pre>
<p>This will generate the following error when running <code>cabal build</code> from the plutus-scripts directory.</p>
<pre><code>GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Addr#
Context: Compiling type: GHC.Prim.Addr#
Context: Compiling data constructor type: Data.ByteString.Internal.PS
Context: Compiling type: Data.ByteString.Internal.ByteString
Context: Compiling data constructor type: NFTMint.NFTParams
Context: Compiling type: NFTMint.NFTParams
Context: Compiling expr: \ (mp' [Occ=OnceL1] :: NFTMint.NFTParams) -&gt;
                           PlutusTx.Base.$
                             @ (PlutusTx.Builtins.Internal.BuiltinData
                                -&gt; Plutus.V2.Ledger.Contexts.ScriptContext -&gt; GHC.Types.Bool)
                             @ Plutus.Script.Utils.V1.Typed.Scripts.MonetaryPolicies.UntypedMintingPolicy
                             (Plutus.Script.Utils.V2.Typed.Scripts.MonetaryPolicies.mkUntypedMintingPolicy
                                @ PlutusTx.Builtins.Internal.BuiltinData
                                PlutusTx.IsData.Class.$fUnsafeFromDataBuiltinData)
                             (\ _ [Occ=Dead] (ctx :: Plutus.V2.Ledger.Contexts.ScriptContext) -&gt;
                                let {
                                  info :: Plutus.V2.Ledger.Contexts.TxInfo
                                  [LclId,
                                   Unf=Unf{Src=&lt;vanilla&gt;, TopLvl=False, Value=False, ConLike=False,
                                           WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 20 0}]
                                  info = Plutus.V2.Ledger.Contexts.scriptContextTxInfo ctx } in
                                PlutusTx.Bool.&amp;&amp;
                                  (PlutusTx.Trace.traceIfFalse
                                     (Data.String.fromString
                                        @ PlutusTx.Builtins.Internal.BuiltinString
                                        PlutusTx.Builtins.Class.$fIsStringBuiltinString
                                        (GHC.CString.unpackCString# &quot;UTxO not consumed&quot;#))
                                     (PlutusTx.Base.$
                                        @ [Plutus.V2.Ledger.Contexts.TxInInfo]
                                        @ GHC.Types.Bool
                                        (PlutusTx.Foldable.any
                                           @ []
                                           @ Plutus.V2.Ledger.Contexts.TxInInfo
                                           PlutusTx.Foldable.$fFoldable[]
                                           (\ (i [Occ=Once1] :: Plutus.V2.Ledger.Contexts.TxInInfo) -&gt;
                                              PlutusTx.Eq.==
                                                @ Plutus.V1.Ledger.Tx.TxOutRef
                                                Plutus.V1.Ledger.Tx.$fEqTxOutRef
                                                (Plutus.V2.Ledger.Contexts.txInInfoOutRef i)
                                                (NFTMint.mpTxOutRef mp')))
                                        (Plutus.V2.Ledger.Contexts.txInfoInputs info)))
                                  (PlutusTx.Trace.traceIfFalse
                                     (Data.String.fromString
                                        @ PlutusTx.Builtins.Internal.BuiltinString
                                        PlutusTx.Builtins.Class.$fIsStringBuiltinString
                                        (GHC.CString.unpackCString# &quot;wrong amount minted&quot;#))
                                     (join {
                                        fail_dCmD [Occ=Once2!T[1]] :: GHC.Prim.Void# -&gt; GHC.Types.Bool
                                        [LclId[JoinId(1)],
                                         Arity=1,
                                         Str=&lt;L,U&gt;,
                                         Unf=Unf{Src=&lt;vanilla&gt;, TopLvl=False, Value=True, ConLike=True,
                                                 WorkFree=True, Expandable=True,
                                                 Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
                                        fail_dCmD _ [Occ=Dead, OS=OneShot] = GHC.Types.False } in
                                      case Plutus.V1.Ledger.Value.flattenValue
                                             (Plutus.V2.Ledger.Contexts.txInfoMint info)
                                      of {
                                        [] -&gt; jump fail_dCmD GHC.Prim.void#;
                                        : ds_dCmB [Occ=Once1!] ds_dCmC [Occ=Once1!] -&gt;
                                          case ds_dCmB of
                                          { (cs [Occ=Once1], tn' [Occ=Once1], amt [Occ=Once1]) -&gt;
                                          case ds_dCmC of {
                                            [] -&gt;
                                              PlutusTx.Bool.&amp;&amp;
                                                (PlutusTx.Eq.==
                                                   @ Plutus.V1.Ledger.Value.CurrencySymbol
                                                   Plutus.V1.Ledger.Value.$fEqCurrencySymbol0
                                                   cs
                                                   (Plutus.V2.Ledger.Contexts.ownCurrencySymbol ctx))
                                                (PlutusTx.Bool.&amp;&amp;
                                                   (PlutusTx.Eq.==
                                                      @ Plutus.V1.Ledger.Value.TokenName
                                                      Plutus.V1.Ledger.Value.$fEqTokenName0
                                                      tn'
                                                      ((Data.String.fromString
                                                          @ PlutusTx.Builtins.Internal.BuiltinByteString
                                                          PlutusTx.Builtins.Class.$fIsStringBuiltinByteString
                                                          (GHC.Types.[] @ GHC.Types.Char))
                                                       `cast` (Sym (Plutus.V1.Ledger.Value.N:TokenName[0])
                                                               :: GHC.Types.Coercible
                                                                    PlutusTx.Builtins.Internal.BuiltinByteString
                                                                    Plutus.V1.Ledger.Value.TokenName)))
                                                   (PlutusTx.Eq.==
                                                      @ GHC.Integer.Type.Integer
                                                      PlutusTx.Eq.$fEqInteger
                                                      amt
                                                      1));
                                            : _ [Occ=Dead] _ [Occ=Dead] -&gt; jump fail_dCmD GHC.Prim.void#
                                          }
                                          }
                                      })))
Context: Compiling expr at &quot;plutus-script-0.1.0.0-inplace:NFTMint:(98,8)-(98,37)&quot;

</code></pre>

<plutus>
GHC error when adding TokenName to NFTMint params
# GHC error when adding TokenName to NFTMint params

(Asked by: username_0 on 2022-09-25)

I get the following GHC error for code that I am trying to update to Plutus V2.   I can reproduce the error using the plutus-scripts below.   Is this a bug with Plutus V2 or can anyone explain how to resolve it.   I don’t have this issue with Plutus V1.
Thank you.
Steps to reproduce
Git clone https://github.com/james-iohk/plutus-scripts.git
Git clone https://github.com/input-output-hk/plutus-apps.git
Go into plutus-apps directory and checkout 87b647b05902a7cef37340fda9acb175f962f354 
Type nix-shell --extra-experimental-features flakes
Cd ../plutus-scripts/src
Make the following changes 1,2,3,4 below

vi NFTMint.hs


     53 data NFTParams = NFTParams --  doesn't need more than the TxOutRef
     54     {  mpTokenName :: !PlutusV2.TokenName  -- << 1. uncommented code here
     55     , mpAmount   :: !Integer
     56     , mpTxOutRef :: !PlutusV2.TxOutRef
     57     --, mpPubKeyHs  :: !Plutus.PubKeyHash
     58     } deriving Show
     59 
     60 PlutusTx.makeLift ''NFTParams
     61 PlutusTx.unstableMakeIsData ''NFTParams
     62 
     63 tn :: PlutusV2.TokenName  -- << 2. added helper function definition
     64 tn = PlutusV2.TokenName "test" -- << 3. and here function body
     65 
     66 redeemer :: NFTParams
     67 redeemer = NFTParams { mpTokenName = tn,  -- << 4. added tn to param
     68                        mpAmount = 1,
     69                        mpTxOutRef = PlutusV2.TxOutRef {txOutRefId = "82669eddc629c8ce5cc3cb908cec6de339281bb0a0ec111880ff0936132ac8b0", txOutRefIdx = 0}
     70                      }


This will generate the following error when running cabal build from the plutus-scripts directory.
GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Addr#
Context: Compiling type: GHC.Prim.Addr#
Context: Compiling data constructor type: Data.ByteString.Internal.PS
Context: Compiling type: Data.ByteString.Internal.ByteString
Context: Compiling data constructor type: NFTMint.NFTParams
Context: Compiling type: NFTMint.NFTParams
Context: Compiling expr: \ (mp' [Occ=OnceL1] :: NFTMint.NFTParams) ->
                           PlutusTx.Base.$
                             @ (PlutusTx.Builtins.Internal.BuiltinData
                                -> Plutus.V2.Ledger.Contexts.ScriptContext -> GHC.Types.Bool)
                             @ Plutus.Script.Utils.V1.Typed.Scripts.MonetaryPolicies.UntypedMintingPolicy
                             (Plutus.Script.Utils.V2.Typed.Scripts.MonetaryPolicies.mkUntypedMintingPolicy
                                @ PlutusTx.Builtins.Internal.BuiltinData
                                PlutusTx.IsData.Class.$fUnsafeFromDataBuiltinData)
                             (\ _ [Occ=Dead] (ctx :: Plutus.V2.Ledger.Contexts.ScriptContext) ->
                                let {
                                  info :: Plutus.V2.Ledger.Contexts.TxInfo
                                  [LclId,
                                   Unf=Unf{Src=, TopLvl=False, Value=False, ConLike=False,
                                           WorkFree=False, Expandable=True, Guidance=IF_ARGS [] 20 0}]
                                  info = Plutus.V2.Ledger.Contexts.scriptContextTxInfo ctx } in
                                PlutusTx.Bool.&&
                                  (PlutusTx.Trace.traceIfFalse
                                     (Data.String.fromString
                                        @ PlutusTx.Builtins.Internal.BuiltinString
                                        PlutusTx.Builtins.Class.$fIsStringBuiltinString
                                        (GHC.CString.unpackCString# "UTxO not consumed"#))
                                     (PlutusTx.Base.$
                                        @ [Plutus.V2.Ledger.Contexts.TxInInfo]
                                        @ GHC.Types.Bool
                                        (PlutusTx.Foldable.any
                                           @ []
                                           @ Plutus.V2.Ledger.Contexts.TxInInfo
                                           PlutusTx.Foldable.$fFoldable[]
                                           (\ (i [Occ=Once1] :: Plutus.V2.Ledger.Contexts.TxInInfo) ->
                                              PlutusTx.Eq.==
                                                @ Plutus.V1.Ledger.Tx.TxOutRef
                                                Plutus.V1.Ledger.Tx.$fEqTxOutRef
                                                (Plutus.V2.Ledger.Contexts.txInInfoOutRef i)
                                                (NFTMint.mpTxOutRef mp')))
                                        (Plutus.V2.Ledger.Contexts.txInfoInputs info)))
                                  (PlutusTx.Trace.traceIfFalse
                                     (Data.String.fromString
                                        @ PlutusTx.Builtins.Internal.BuiltinString
                                        PlutusTx.Builtins.Class.$fIsStringBuiltinString
                                        (GHC.CString.unpackCString# "wrong amount minted"#))
                                     (join {
                                        fail_dCmD [Occ=Once2!T[1]] :: GHC.Prim.Void# -> GHC.Types.Bool
                                        [LclId[JoinId(1)],
                                         Arity=1,
                                         Str=,
                                         Unf=Unf{Src=, TopLvl=False, Value=True, ConLike=True,
                                                 WorkFree=True, Expandable=True,
                                                 Guidance=ALWAYS_IF(arity=1,unsat_ok=True,boring_ok=True)}]
                                        fail_dCmD _ [Occ=Dead, OS=OneShot] = GHC.Types.False } in
                                      case Plutus.V1.Ledger.Value.flattenValue
                                             (Plutus.V2.Ledger.Contexts.txInfoMint info)
                                      of {
                                        [] -> jump fail_dCmD GHC.Prim.void#;
                                        : ds_dCmB [Occ=Once1!] ds_dCmC [Occ=Once1!] ->
                                          case ds_dCmB of
                                          { (cs [Occ=Once1], tn' [Occ=Once1], amt [Occ=Once1]) ->
                                          case ds_dCmC of {
                                            [] ->
                                              PlutusTx.Bool.&&
                                                (PlutusTx.Eq.==
                                                   @ Plutus.V1.Ledger.Value.CurrencySymbol
                                                   Plutus.V1.Ledger.Value.$fEqCurrencySymbol0
                                                   cs
                                                   (Plutus.V2.Ledger.Contexts.ownCurrencySymbol ctx))
                                                (PlutusTx.Bool.&&
                                                   (PlutusTx.Eq.==
                                                      @ Plutus.V1.Ledger.Value.TokenName
                                                      Plutus.V1.Ledger.Value.$fEqTokenName0
                                                      tn'
                                                      ((Data.String.fromString
                                                          @ PlutusTx.Builtins.Internal.BuiltinByteString
                                                          PlutusTx.Builtins.Class.$fIsStringBuiltinByteString
                                                          (GHC.Types.[] @ GHC.Types.Char))
                                                       `cast` (Sym (Plutus.V1.Ledger.Value.N:TokenName[0])
                                                               :: GHC.Types.Coercible
                                                                    PlutusTx.Builtins.Internal.BuiltinByteString
                                                                    Plutus.V1.Ledger.Value.TokenName)))
                                                   (PlutusTx.Eq.==
                                                      @ GHC.Integer.Type.Integer
                                                      PlutusTx.Eq.$fEqInteger
                                                      amt
                                                      1));
                                            : _ [Occ=Dead] _ [Occ=Dead] -> jump fail_dCmD GHC.Prim.void#
                                          }
                                          }
                                      })))
Context: Compiling expr at "plutus-script-0.1.0.0-inplace:NFTMint:(98,8)-(98,37)"

**Tags:** plutus

---

## 1 answers

### Answer by username_1 on 2022-09-26. Score: 1 | Accepted answer

The issue is not with the Plutus version but the compiler. You need to remove `!` from where `mpTokenName` is defined. This should be fixed in the near future.

> **Comments:**
> **username_0**: Thanks James, greatly appreciated.  This will work for now but had to remove other ! references in custom datatypes I have used in my code to get it to work.   Let me know if there is a bug logged for this.  
> **username_1**: My pleasure @lley154! This bug has been reopened with reference to this question: https://github.com/input-output-hk/plutus/issues/4193  
> **username_0**: Great - thanks James.  

---

