0

I am building a transaction where I use the following function to make my datum and redeemer,

writeJSON :: PlutusTx.ToData a => FilePath -> a -> IO ()
writeJSON file = LBS.writeFile file . encode . scriptDataToJson ScriptDataJsonDetailedSchema . dataToScriptData . PlutusTx.toData

But when I build a transaction to consume an UTxO at the script address I get the following error,

Command failed: transaction build  Error: The following scripts have execution failures:
the script for transaction input 0 (in the order of the TxIds) failed with: 
The Plutus script evaluation failed: An error has occurred:  User error:
The provided Plutus code called 'error'.
Script debugging logs: PT5

I am very certain that my redemeer and datum are correct. My onchain code is the following

data MyDatum = MyDatum
    { pubKey :: Integer
    } deriving (Show, Generic, FromJSON, ToJSON, ToSchema)

data MyRedeemer = MyRedeemer
    { privKey :: Integer
    } deriving (Show, Generic, FromJSON, ToJSON, ToSchema)

data Params = Params
    { params_p :: Integer
    , params_g :: Integer
    , params_bits :: Integer
    } deriving (Generic, FromJSON, ToJSON, ToSchema)

unsafeParams :: Params
unsafeParams = Params p g 64
        where
                p = safePrime64
                g = (safePrime64 - 1) `PlutusTx.Prelude.divide` 2

PlutusTx.makeIsDataIndexed ''MyDatum [('MyDatum, 0)]
PlutusTx.makeLift ''MyDatum
PlutusTx.makeIsDataIndexed ''MyRedeemer [('MyRedeemer, 0)]
PlutusTx.makeLift ''MyRedeemer
PlutusTx.makeLift ''Params

{-# INLINABLE mkValidator #-}
mkValidator :: Params -> MyDatum -> MyRedeemer -> ScriptContext -> Bool
mkValidator (Params p g _) (MyDatum pub) (MyRedeemer priv) _ = pub == exponentiateMod g priv p

Where the the validator checks whether or not the redeemer is the exponent of the datum via modular exponentiation. Perhaps I incorrectly indexed my datum and redeemer with the makeIsdataIndexed function?

2
  • Your error means that the validator script returned an error. In the newer version of node, I think 1.33 or 1.34 you can see the exact error message which is thrown from the validator.
    – zarej
    Commented Apr 7, 2022 at 10:53
  • I am currently running 1.33, ill update to 1.34 and see what I get there. Thanks for the tip!
    – Fermat
    Commented Apr 7, 2022 at 12:19

1 Answer 1

0

PT5 alone means that the validator returned False. You can break down your script into multiple steps of computation and add some traceIfFalse calls along the way to see more context why it happend to be False overall.

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