Skip to main content
added 4 characters in body
Source Link
Aoaddeola
  • 757
  • 4
  • 14

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

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 PlutusTx/Builtins/Internal.hs

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

Wrong initial answer. Provided a working one
Source Link
Aoaddeola
  • 757
  • 4
  • 14

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 PlutusTx/Builtins/Internal.hs

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

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 PlutusTx/Builtins/Internal.hs

Source Link
Aoaddeola
  • 757
  • 4
  • 14

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