A user provides me with his wallet pub key as BultinByteString (or Haskell string, fine either way). From that, I need to get the PubKeyHash, but I am not sure how to hash it or if I need to hash it at all.

Then, I need to use it in the PubKeyHash in Ledger.Constraints.MustBeSignedBy in my state machine. Kinda like that:

Constraints.mustBeSignedBy "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3"


Constraints.mustBeSignedBy PubKeyHash { getPubKeyHash = "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3" }

The problem is when I put some PubKeyHash in the constraint (like above), the compiler spits out 5000 long error starting with:

GHC Core to PLC plugin: E042:Error: Unsupported feature: Use of fromString on type other than builtin strings or bytestrings: Plutus.V1.Ledger.Crypto.PubKeyHash
Context: Compiling expr: Data.String.fromString
                           @ Plutus.V1.Ledger.Crypto.PubKeyHash

Can the string be translated into the PubKeyHash? Can it be somehow fixed? Is it me, or is it a Plutus bug?


Tried new code:

Constraints.mustBeSignedBy $ pubKeyHash (PubKey {
                            getPubKey = LedgerBytes { 
                                    getLedgerBytes = "35dedd2982a03cf39e7dce03c839994ffdec2ec6b04f1cf2d40e61a3" 

Got new error:

 GHC Core to PLC plugin: E042:Error: Unsupported feature: Type constructor: GHC.Prim.Char#
Context: Compiling type: GHC.Prim.Char#
Context: Compiling data constructor type: GHC.Types.C#
Context: Compiling type: GHC.Types.Char
Context: Compiling type: GHC.Base.String
Context: Compiling type: GHC.Base.String
                         -> Plutus.V1.Ledger.Bytes.LedgerBytes
Context: Compiling definition of: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
Context: Compiling expr: Plutus.V1.Ledger.Bytes.$fIsStringLedgerBytes_$cfromString
  • Did you add OverloadedStrings pragma?
    – kindofdev
    Feb 25 at 18:10
  • Yes, I do have that pragma at the beginning of my file. No other issues with strings occurred in my state machine contract. Feb 25 at 18:32

1 Answer 1


It's an issue with Plutus core. Even though PubKeyHash is part of IsString type class, we can't use OverloadedStrings mechanism in on-chain code for certain types. Basically, the problem is this:

Unfortunately, due to the technical reasons plutus plugin doesn't support OverloadedStrings with newtypes.

Please, check this issue.


Same thing apply for PubKeyHash and LedgerBytes.

A solution might be to have a parameterized validator script with PubKeyHash. This way, you can build PubkeyHash offchain using OverloadedStrings and pass it to the validator.

  • Thank you! Parameterized validator script with PubKeyHash works like a charm. Indeed a fascinating issue. Feb 25 at 21:00
  • 1
    @MartinDrozdík You’re welcome. glad to help!
    – kindofdev
    Feb 25 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.