0

I try to set an initial state of the emulator like so:

test :: IO ()
test = runEmulatorTraceIO' def emCfg myTrace
  where
    dist = Map.fromList [ (senderWallet, Ada.lovelaceValueOf 100_000_000)
                        , (receiverWallet, Ada.lovelaceValueOf 100_000_000)
                        ]
  
    emCfg :: EmulatorConfig
    emCfg = EmulatorConfig (Left dist) def

myTrace :: EmulatorTrace ()
myTrace = do
  void $ Emulator.payToWallet (senderWallet) (receiverWallet) $ Ada.lovelaceValueOf 5_000_000
  void $ Emulator.waitNSlots 1

It works perfectly. However when I set a custom currency ff with:

    dist = Map.fromList [ (senderWallet, Ada.lovelaceValueOf 100_000_000
                           <> Value.singleton "ff" "TokenName" 100_000_000)
                        , (receiverWallet, Ada.lovelaceValueOf 100_000_000)
                        ]

The script compiles but after running test I get this error:

*** Exception: Cannot build the initial state: Tag "toCardanoPolicyId" (Tag "1 bytes" DeserialisationError) CallStack (from HasCallStack):
error, called at src/Wallet/Emulator/Stream.hs:171:12 in plutus-contract-1.0.0.0-68585fe6251fbab3f7ee7ae8755133e693587e4f6afa588ae8db3b056e79dcc0:Wallet.Emulator.Stream

This is plutus-apps v.1.0.0. This code works with some other tags.

How do I fix this? Is this a bug?

1 Answer 1

3

ff is not a valid PolicyId (aka CurrencySymbol). It must be 28 bytes.

For examples, see this answer on this similar Github issue https://github.com/input-output-hk/plutus-apps/issues/732#issuecomment-1265261105

1
  • Thanks. That solves it. "ff" seems to be ok with earlier version of plutus. Not anymore.
    – Adam
    Commented Dec 22, 2022 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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