Since I just started to write Plutus code, I want to make some tests of Plutus.

For example, I'd like to know what exactly my redeemer :: BuiltinData value is. However I can't convert BuiltinData to BuiltinString which means I can't use trace :: BuiltinString -> a -> a to log it.

Is it possible to convert BuiltinData to BuiltinString or there is different approach to log redeemer?


Since BuiltinData derives Show:

newtype BuiltinData = BuiltinData PLC.Data
    deriving newtype (Show, Eq, Ord)

and there's the function:

stringToBuiltinString :: String -> BuiltinString found here in PlutusTx/Builtins/Class.hs

Assuming your "variable name" is dummyBuiltinData, you can convert BuiltinData to BuiltinString using:

stringToBuiltinString $ show dummyBuiltinData


As noted by kolam, show isn't INLINABLE and isn't applicable on-chain. Here is a version that should work:

decodeUtf8 $ unsafeDataAsB dummyBuiltinData

both decodeUtf8 and unsafeDataAsB can be found in module PlutusTx.Builtins.Internal

  • That won't work as show is not an inlinable function and thus cannot be used in the validation (on-chain) part of Plutus. Those functions you mentioned are meant to be used in the off-chain part of Plutus.
    – kolam
    Aug 24 at 14:14

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.