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
EDIT:
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.hsInternal