1

When converting my UnbalancedTx to an ExportTx using the export function, I get this error:

Left (Tag \"toCardanoPolicyId\" (Tag \"1 bytes\" DeserialisationError))

What is very strange is that when I submit the unbalanced transaction with submitUnbalancedTx in the emulator it works and the transaction gets executed. So it should be fine. I feel like this is a bug but I could also be missing something. Before digging deeper, I wanted to post this issue to see if someone can help me. Does anybody see what could be the reason for this issue ?

The error comes probably from function toCardanoMintValue on line 531 here: https://github.com/input-output-hk/plutus-apps/blob/main/plutus-ledger/src/Ledger/Tx/CardanoAPI.hs

The contract that I have looks like this:

buyTokensTx :: forall w s. TokenPool -> BuyTokensParams -> Contract w s Text (Either ToCardanoError ExportTx)
buyTokensTx pool param = do
  m <- findTokenPool pool
  case m of
    Nothing -> do
      logInfo @String $ "no token pool found with nft: " <> show (nft pool)
      return (Left $ TxBodyError "Error: cannot find token pool")
    Just (oref, o, state) -> do
      logInfo @String $ "found token pool with nft: " <> show (nft pool)
      let lookups = ...
      let txc = ...
      case Constraints.mkTx @TokenPool lookups txc of
        Right ut -> do
          let unbalTx = Constraints.adjustUnbalancedTx ut
          return (export def myNetworkId unbalTx)
        Left err -> return (Left $ TxBodyError $ "UnbalancedTx error:" <> show err)

1 Answer 1

0

I finally found the issue and I think I might not be the only one to fall into this trap.

What happened is that I defined an asset class that I used as a placeholder for a stable coin in my smart contracts. I chose the following values that I saw in one tutorial:

stableCoinSymbol :: CurrencySymbol
stableCoinSymbol = "ff"

stableCoinTokenName :: TokenName
stableCoinTokenName = "USDT"

I then used this stable coin in the UTxOs of my transactions. Interestingly this works fine in the emulator, but throws a serialisation error (of course) because ff is not a valid CurrencySymbol.

So changing ff to a random valid one (e.g. 8d803516132f6fb8ddfcf168065886bf44ecc9e0023b570963b4bac8) fixed the issue.

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.