Safe Haskell | None |
---|---|
Language | Haskell2010 |
Primitive names and functions for working with Plutus Core builtins.
Synopsis
- data BuiltinByteString
- appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString
- consByteString :: Integer -> BuiltinByteString -> BuiltinByteString
- sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString
- lengthOfByteString :: BuiltinByteString -> Integer
- indexByteString :: BuiltinByteString -> Integer -> Integer
- emptyByteString :: BuiltinByteString
- equalsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- lessThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- lessThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- greaterThanByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- greaterThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool
- sha2_256 :: BuiltinByteString -> BuiltinByteString
- sha3_256 :: BuiltinByteString -> BuiltinByteString
- blake2b_256 :: BuiltinByteString -> BuiltinByteString
- verifyEd25519Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifyEcdsaSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- verifySchnorrSecp256k1Signature :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString -> Bool
- decodeUtf8 :: BuiltinByteString -> BuiltinString
- data Integer
- addInteger :: Integer -> Integer -> Integer
- subtractInteger :: Integer -> Integer -> Integer
- multiplyInteger :: Integer -> Integer -> Integer
- divideInteger :: Integer -> Integer -> Integer
- modInteger :: Integer -> Integer -> Integer
- quotientInteger :: Integer -> Integer -> Integer
- remainderInteger :: Integer -> Integer -> Integer
- greaterThanInteger :: Integer -> Integer -> Bool
- greaterThanEqualsInteger :: Integer -> Integer -> Bool
- lessThanInteger :: Integer -> Integer -> Bool
- lessThanEqualsInteger :: Integer -> Integer -> Bool
- equalsInteger :: Integer -> Integer -> Bool
- error :: () -> a
- data BuiltinData
- chooseData :: forall a. BuiltinData -> a -> a -> a -> a -> a -> a
- matchData :: BuiltinData -> ( Integer -> [ BuiltinData ] -> r) -> ([( BuiltinData , BuiltinData )] -> r) -> ([ BuiltinData ] -> r) -> ( Integer -> r) -> ( BuiltinByteString -> r) -> r
- matchData' :: BuiltinData -> ( Integer -> BuiltinList BuiltinData -> r) -> ( BuiltinList ( BuiltinPair BuiltinData BuiltinData ) -> r) -> ( BuiltinList BuiltinData -> r) -> ( Integer -> r) -> ( BuiltinByteString -> r) -> r
- equalsData :: BuiltinData -> BuiltinData -> Bool
- serialiseData :: BuiltinData -> BuiltinByteString
- mkConstr :: Integer -> [ BuiltinData ] -> BuiltinData
- mkMap :: [( BuiltinData , BuiltinData )] -> BuiltinData
- mkList :: [ BuiltinData ] -> BuiltinData
- mkI :: Integer -> BuiltinData
- mkB :: BuiltinByteString -> BuiltinData
- unsafeDataAsConstr :: BuiltinData -> ( Integer , [ BuiltinData ])
- unsafeDataAsMap :: BuiltinData -> [( BuiltinData , BuiltinData )]
- unsafeDataAsList :: BuiltinData -> [ BuiltinData ]
- unsafeDataAsI :: BuiltinData -> Integer
- unsafeDataAsB :: BuiltinData -> BuiltinByteString
- builtinDataToData :: BuiltinData -> Data
- dataToBuiltinData :: Data -> BuiltinData
- data BuiltinString
- appendString :: BuiltinString -> BuiltinString -> BuiltinString
- emptyString :: BuiltinString
- equalsString :: BuiltinString -> BuiltinString -> Bool
- encodeUtf8 :: BuiltinString -> BuiltinByteString
- matchList :: forall a r. BuiltinList a -> r -> (a -> BuiltinList a -> r) -> r
- trace :: BuiltinString -> a -> a
- fromBuiltin :: FromBuiltin arep a => arep -> a
- toBuiltin :: ToBuiltin a arep => a -> arep
Bytestring builtins
data BuiltinByteString Source #
An opaque type representing Plutus Core ByteStrings.
Instances
appendByteString :: BuiltinByteString -> BuiltinByteString -> BuiltinByteString Source #
Concatenates two
ByteString
s.
consByteString :: Integer -> BuiltinByteString -> BuiltinByteString Source #
Adds a byte to the front of a
ByteString
.
sliceByteString :: Integer -> Integer -> BuiltinByteString -> BuiltinByteString Source #
Returns the substring of a
ByteString
from index
start
of length
n
.
lengthOfByteString :: BuiltinByteString -> Integer Source #
Returns the length of a
ByteString
.
indexByteString :: BuiltinByteString -> Integer -> Integer Source #
Returns the byte of a
ByteString
at index.
emptyByteString :: BuiltinByteString Source #
An empty
ByteString
.
equalsByteString :: BuiltinByteString -> BuiltinByteString -> Bool Source #
Check if two
ByteString
s are equal.
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.
greaterThanEqualsByteString :: BuiltinByteString -> BuiltinByteString -> Bool Source #
Check if one
ByteString
is greater than another.
sha2_256 :: BuiltinByteString -> BuiltinByteString Source #
The SHA2-256 hash of a
ByteString
sha3_256 :: BuiltinByteString -> BuiltinByteString Source #
The SHA3-256 hash of a
ByteString
blake2b_256 :: BuiltinByteString -> BuiltinByteString Source #
The BLAKE2B-256 hash of a
ByteString
verifyEd25519Signature Source #
:: 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 #
:: 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 #
:: 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.
decodeUtf8 :: BuiltinByteString -> BuiltinString Source #
Converts a ByteString to a String.
Integer builtins
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
remainderInteger :: Integer -> Integer -> Integer Source #
Take the remainder of dividing two
Integer
s.
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
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
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.
equalsData :: BuiltinData -> BuiltinData -> Bool Source #
Check if two
BuiltinData
s are equal.
serialiseData :: BuiltinData -> BuiltinByteString Source #
Convert a String into a ByteString.
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.
builtinDataToData :: BuiltinData -> Data Source #
Convert a
BuiltinData
into a
Data
. Only works off-chain.
dataToBuiltinData :: Data -> BuiltinData Source #
Convert a
Data
into a
BuiltinData
. Only works off-chain.
Strings
data BuiltinString Source #
Instances
appendString :: BuiltinString -> BuiltinString -> BuiltinString Source #
Append two
String
s.
emptyString :: BuiltinString Source #
An empty
String
.
equalsString :: BuiltinString -> BuiltinString -> Bool Source #
Check if two strings are equal
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
fromBuiltin :: FromBuiltin arep a => arep -> a Source #