plutus-tx-1.0.0.0: Libraries for Plutus Tx and its prelude
Safe Haskell None
Language Haskell2010

PlutusTx.Builtins

Description

Primitive names and functions for working with Plutus Core builtins.

Synopsis

Bytestring builtins

data BuiltinByteString Source #

An opaque type representing Plutus Core ByteStrings.

Instances

Instances details
Eq BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Data BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> BuiltinByteString -> c BuiltinByteString Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c BuiltinByteString Source #

toConstr :: BuiltinByteString -> Constr Source #

dataTypeOf :: BuiltinByteString -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c BuiltinByteString ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c BuiltinByteString ) Source #

gmapT :: ( forall b. Data b => b -> b) -> BuiltinByteString -> BuiltinByteString Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinByteString -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinByteString -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> BuiltinByteString -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> BuiltinByteString -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> BuiltinByteString -> m BuiltinByteString Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinByteString -> m BuiltinByteString Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinByteString -> m BuiltinByteString Source #

Ord BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

IsString BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Class

Semigroup BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Monoid BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Hashable BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

NFData BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

ByteArray BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

ByteArrayAccess BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Pretty BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Serialise BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinByteString Source #
Instance details

Defined in PlutusTx.Eq

Ord BuiltinByteString Source #
Instance details

Defined in PlutusTx.Ord

Semigroup BuiltinByteString Source #
Instance details

Defined in PlutusTx.Semigroup

Monoid BuiltinByteString Source #
Instance details

Defined in PlutusTx.Monoid

UnsafeFromData BuiltinByteString Source #
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinByteString Source #
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinByteString Source #
Instance details

Defined in PlutusTx.IsData.Class

Includes uni ByteString => Lift uni BuiltinByteString Source #
Instance details

Defined in PlutusTx.Lift.Instances

ToBuiltin ByteString BuiltinByteString Source #
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinByteString ByteString Source #
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni ByteString => Typeable uni BuiltinByteString Source #
Instance details

Defined in PlutusTx.Lift.Instances

sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString Source #

Returns the substring of a ByteString from index start of length n .

indexByteString :: BuiltinByteString -> Integer -> Integer Source #

Returns the byte of a ByteString at index.

lessThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool Source #

Check if one ByteString is less than another.

lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool Source #

Check if one ByteString is less than or equal to another.

greaterThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool Source #

Check if one ByteString is greater than another.

verifyEd25519Signature Source #

Arguments

:: BuiltinByteString

Public Key (32 bytes)

-> BuiltinByteString

Message (arbirtary length)

-> BuiltinByteString

Signature (64 bytes)

-> Bool

Ed25519 signature verification. Verify that the signature is a signature of the message by the public key. This will fail if key or the signature are not of the expected length.

verifyEcdsaSecp256k1Signature Source #

Arguments

:: BuiltinByteString

Verification key (64 bytes)

-> BuiltinByteString

Message hash (32 bytes)

-> BuiltinByteString

Signature (64 bytes)

-> Bool

Given an ECDSA SECP256k1 verification key, an ECDSA SECP256k1 signature, and an ECDSA SECP256k1 message hash (all as BuiltinByteString s), verify the hash with that key and signature.

Important note

The verification key, the signature, and the message hash must all be of appropriate form and length. This function will error if any of these are not the case.

verifySchnorrSecp256k1Signature Source #

Arguments

:: BuiltinByteString

Verification key (64 bytes)

-> BuiltinByteString

Message

-> BuiltinByteString

Signature (64 bytes)

-> Bool

Given a Schnorr SECP256k1 verification key, a Schnorr SECP256k1 signature, and a message (all as BuiltinByteString s), verify the message with that key and signature.

Important note

The verification key and signature must all be of appropriate form and length. This function will error if this is not the case.

Integer builtins

data Integer Source #

Arbitrary precision integers. In contrast with fixed-size integral types such as Int , the Integer type represents the entire infinite range of integers.

For more information about this type's representation, see the comments in its implementation.

Instances

Instances details
Enum Integer

Since: base-2.1

Instance details

Defined in GHC.Enum

Eq Integer
Instance details

Defined in GHC.Integer.Type

Integral Integer

Since: base-2.0.1

Instance details

Defined in GHC.Real

Data Integer

Since: base-4.0.0.0

Instance details

Defined in Data.Data

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Integer -> c Integer Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Integer Source #

toConstr :: Integer -> Constr Source #

dataTypeOf :: Integer -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Integer ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Integer ) Source #

gmapT :: ( forall b. Data b => b -> b) -> Integer -> Integer Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Integer -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Integer -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> Integer -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> Integer -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Integer -> m Integer Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Integer -> m Integer Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Integer -> m Integer Source #

Num Integer

Since: base-2.1

Instance details

Defined in GHC.Num

Ord Integer
Instance details

Defined in GHC.Integer.Type

Read Integer

Since: base-2.1

Instance details

Defined in GHC.Read

Real Integer

Since: base-2.0.1

Instance details

Defined in GHC.Real

Show Integer

Since: base-2.1

Instance details

Defined in GHC.Show

Ix Integer

Since: base-2.1

Instance details

Defined in GHC.Ix

Hashable Integer
Instance details

Defined in Data.Hashable.Class

ToJSON Integer
Instance details

Defined in Data.Aeson.Types.ToJSON

ToJSONKey Integer
Instance details

Defined in Data.Aeson.Types.ToJSON

FromJSON Integer

This instance includes a bounds check to prevent maliciously large inputs to fill up the memory of the target system. You can newtype Scientific and provide your own instance using withScientific if you want to allow larger inputs.

Instance details

Defined in Data.Aeson.Types.FromJSON

FromJSONKey Integer
Instance details

Defined in Data.Aeson.Types.FromJSON

Subtractive Integer
Instance details

Defined in Basement.Numerical.Subtractive

NFData Integer
Instance details

Defined in Control.DeepSeq

ExMemoryUsage Integer
Instance details

Defined in PlutusCore.Evaluation.Machine.ExMemory

Pretty Integer
>>> pretty (2^123 :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in Prettyprinter.Internal

UniformRange Integer
Instance details

Defined in System.Random.Internal

Serialise Integer

Since: serialise-0.2.0.0

Instance details

Defined in Codec.Serialise.Class

Pretty Integer
Instance details

Defined in Text.PrettyPrint.Annotated.WL

Pretty Rational
Instance details

Defined in Text.PrettyPrint.Annotated.WL

Eq Integer Source #
Instance details

Defined in PlutusTx.Eq

Ord Integer Source #
Instance details

Defined in PlutusTx.Ord

MultiplicativeMonoid Integer Source #
Instance details

Defined in PlutusTx.Numeric

MultiplicativeSemigroup Integer Source #
Instance details

Defined in PlutusTx.Numeric

AdditiveGroup Integer Source #
Instance details

Defined in PlutusTx.Numeric

AdditiveMonoid Integer Source #
Instance details

Defined in PlutusTx.Numeric

AdditiveSemigroup Integer Source #
Instance details

Defined in PlutusTx.Numeric

UnsafeFromData Integer Source #
Instance details

Defined in PlutusTx.IsData.Class

FromData Integer Source #
Instance details

Defined in PlutusTx.IsData.Class

ToData Integer Source #
Instance details

Defined in PlutusTx.IsData.Class

Enum Integer Source #
Instance details

Defined in PlutusTx.Enum

Lift Integer
Instance details

Defined in Language.Haskell.TH.Syntax

PrettyDefaultBy config Integer => PrettyBy config Integer
>>> prettyBy () (2^(123 :: Int) :: Integer)
10633823966279326983230456482242756608
Instance details

Defined in Text.PrettyBy.Internal

DefaultPrettyBy config Integer
Instance details

Defined in Text.PrettyBy.Internal

NonDefaultPrettyBy ConstConfig Integer
Instance details

Defined in PlutusCore.Pretty.PrettyConst

Includes uni Integer => Lift uni Integer Source #
Instance details

Defined in PlutusTx.Lift.Instances

ToBuiltin Integer BuiltinInteger Source #
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinInteger Integer Source #
Instance details

Defined in PlutusTx.Builtins.Class

Module Integer Rational Source #
Instance details

Defined in PlutusTx.Ratio

HasConstantIn DefaultUni term => MakeKnownIn DefaultUni term Integer
Instance details

Defined in PlutusCore.Default.Universe

HasConstantIn DefaultUni term => ReadKnownIn DefaultUni term Integer
Instance details

Defined in PlutusCore.Default.Universe

KnownNat n => Reifies (n :: Nat ) Integer
Instance details

Defined in Data.Reflection

KnownBuiltinTypeAst DefaultUni Integer => KnownTypeAst DefaultUni Integer
Instance details

Defined in PlutusCore.Default.Universe

Contains DefaultUni Integer
Instance details

Defined in PlutusCore.Default.Universe

Includes uni Integer => Typeable uni Integer Source #
Instance details

Defined in PlutusTx.Lift.Instances

type Difference Integer
Instance details

Defined in Basement.Numerical.Subtractive

type IntBaseType Integer
Instance details

Defined in Data.IntCast

type ToBinds Integer
Instance details

Defined in PlutusCore.Default.Universe

type ToBinds Integer = ToBinds (ElaborateBuiltin Integer )
type ToHoles Integer
Instance details

Defined in PlutusCore.Default.Universe

type ToHoles Integer = ToHoles (ElaborateBuiltin Integer )

greaterThanInteger :: Integer -> Integer -> Bool Source #

Check whether one Integer is greater than another.

greaterThanEqualsInteger :: Integer -> Integer -> Bool Source #

Check whether one Integer is greater than or equal to another.

lessThanInteger :: Integer -> Integer -> Bool Source #

Check whether one Integer is less than another.

lessThanEqualsInteger :: Integer -> Integer -> Bool Source #

Check whether one Integer is less than or equal to another.

Error

error :: () -> a Source #

Aborts evaluation with an error.

Data

data BuiltinData Source #

A type corresponding to the Plutus Core builtin equivalent of Data .

The point of this type is to be an opaque equivalent of Data , so as to ensure that it is only used in ways that the compiler can handle.

As such, you should use this type in your on-chain code, and in any data structures that you want to be representable on-chain.

For off-chain usage, there are conversion functions builtinDataToData and dataToBuiltinData , but note that these will not work on-chain.

Instances

Instances details
Eq BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Data BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> BuiltinData -> c BuiltinData Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c BuiltinData Source #

toConstr :: BuiltinData -> Constr Source #

dataTypeOf :: BuiltinData -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c BuiltinData ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c BuiltinData ) Source #

gmapT :: ( forall b. Data b => b -> b) -> BuiltinData -> BuiltinData Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinData -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinData -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> BuiltinData -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> BuiltinData -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinData -> m BuiltinData Source #

Ord BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

NFData BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Pretty BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Eq BuiltinData Source #
Instance details

Defined in PlutusTx.Eq

UnsafeFromData BuiltinData Source #
Instance details

Defined in PlutusTx.IsData.Class

FromData BuiltinData Source #
Instance details

Defined in PlutusTx.IsData.Class

ToData BuiltinData Source #
Instance details

Defined in PlutusTx.IsData.Class

Includes uni Data => Lift uni BuiltinData Source #
Instance details

Defined in PlutusTx.Lift.Instances

ToBuiltin BuiltinData BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinData BuiltinData Source #
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni Data => Typeable uni BuiltinData Source #
Instance details

Defined in PlutusTx.Lift.Instances

ToBuiltin [( BuiltinData , BuiltinData )] ( BuiltinList ( BuiltinPair BuiltinData BuiltinData )) Source #
Instance details

Defined in PlutusTx.Builtins.Class

ToBuiltin [ BuiltinData ] ( BuiltinList BuiltinData ) Source #
Instance details

Defined in PlutusTx.Builtins.Class

ToBuiltin ( BuiltinData , BuiltinData ) ( BuiltinPair BuiltinData BuiltinData ) Source #
Instance details

Defined in PlutusTx.Builtins.Class

chooseData :: forall a. BuiltinData -> a -> a -> a -> a -> a -> a Source #

Given five values for the five different constructors of BuiltinData , selects one depending on which corresponds to the actual constructor of the given value.

matchData :: BuiltinData -> ( Integer -> [ BuiltinData ] -> r) -> ([( BuiltinData , BuiltinData )] -> r) -> ([ BuiltinData ] -> r) -> ( Integer -> r) -> ( BuiltinByteString -> r) -> r Source #

Given a BuiltinData value and matching functions for the five constructors, applies the appropriate matcher to the arguments of the constructor and returns the result.

matchData' :: BuiltinData -> ( Integer -> BuiltinList BuiltinData -> r) -> ( BuiltinList ( BuiltinPair BuiltinData BuiltinData ) -> r) -> ( BuiltinList BuiltinData -> r) -> ( Integer -> r) -> ( BuiltinByteString -> r) -> r Source #

Given a BuiltinData value and matching functions for the five constructors, applies the appropriate matcher to the arguments of the constructor and returns the result.

mkConstr :: Integer -> [ BuiltinData ] -> BuiltinData Source #

Constructs a BuiltinData value with the Constr constructor.

mkMap :: [( BuiltinData , BuiltinData )] -> BuiltinData Source #

Constructs a BuiltinData value with the Map constructor.

mkList :: [ BuiltinData ] -> BuiltinData Source #

Constructs a BuiltinData value with the List constructor.

mkI :: Integer -> BuiltinData Source #

Constructs a BuiltinData value with the I constructor.

mkB :: BuiltinByteString -> BuiltinData Source #

Constructs a BuiltinData value with the B constructor.

unsafeDataAsConstr :: BuiltinData -> ( Integer , [ BuiltinData ]) Source #

Deconstructs a BuiltinData as a Constr , or fails if it is not one.

unsafeDataAsMap :: BuiltinData -> [( BuiltinData , BuiltinData )] Source #

Deconstructs a BuiltinData as a Map , or fails if it is not one.

unsafeDataAsList :: BuiltinData -> [ BuiltinData ] Source #

Deconstructs a BuiltinData as a List , or fails if it is not one.

unsafeDataAsI :: BuiltinData -> Integer Source #

Deconstructs a BuiltinData as an I , or fails if it is not one.

unsafeDataAsB :: BuiltinData -> BuiltinByteString Source #

Deconstructs a BuiltinData as a B , or fails if it is not one.

Strings

data BuiltinString Source #

Instances

Instances details
Eq BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Data BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> BuiltinString -> c BuiltinString Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c BuiltinString Source #

toConstr :: BuiltinString -> Constr Source #

dataTypeOf :: BuiltinString -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c BuiltinString ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c BuiltinString ) Source #

gmapT :: ( forall b. Data b => b -> b) -> BuiltinString -> BuiltinString Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinString -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> BuiltinString -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> BuiltinString -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> BuiltinString -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> BuiltinString -> m BuiltinString Source #

Ord BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

Show BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Internal

IsString BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Class

Eq BuiltinString Source #
Instance details

Defined in PlutusTx.Eq

Semigroup BuiltinString Source #
Instance details

Defined in PlutusTx.Semigroup

Monoid BuiltinString Source #
Instance details

Defined in PlutusTx.Monoid

Includes uni Text => Lift uni BuiltinString Source #
Instance details

Defined in PlutusTx.Lift.Instances

ToBuiltin Text BuiltinString Source #
Instance details

Defined in PlutusTx.Builtins.Class

FromBuiltin BuiltinString Text Source #
Instance details

Defined in PlutusTx.Builtins.Class

Includes uni Text => Typeable uni BuiltinString Source #
Instance details

Defined in PlutusTx.Lift.Instances

encodeUtf8 :: BuiltinString -> BuiltinByteString Source #

Convert a String into a ByteString.

Lists

matchList :: forall a r. BuiltinList a -> r -> (a -> BuiltinList a -> r) -> r Source #

Tracing

trace :: BuiltinString -> a -> a Source #

Emit the given string as a trace message before evaluating the argument.

Conversions