plutus-wallet-api-0.1.0.0: Wallet API

Safe HaskellNone
LanguageHaskell2010

Ledger.Scripts

Contents

Description

Functions for working with scripts on the ledger.

Synopsis

Scripts

newtype Script Source #

A script on the chain. This is an opaque type as far as the chain is concerned.

Note: the program inside the Script should have normalized types.

Constructors

Script 

Fields

Instances
Eq Script Source # 
Instance details

Defined in Ledger.Scripts

Ord Script Source # 
Instance details

Defined in Ledger.Scripts

Serialise Script Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: Script -> Encoding

decode :: Decoder s Script

encodeList :: [Script] -> Encoding

decodeList :: Decoder s [Script]

FromJSON Script Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser Script

parseJSONList :: Value -> Parser [Script]

ToJSON Script Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: Script -> Value

toEncoding :: Script -> Encoding

toJSONList :: [Script] -> Value

toEncodingList :: [Script] -> Encoding

Eq Script Source # 
Instance details

Defined in Ledger.Scripts

Methods

(==) :: Script -> Script -> Bool

Ord Script Source # 
Instance details

Defined in Ledger.Scripts

scriptSize :: Script -> Integer Source #

The size of a Script. No particular interpretation is given to this, other than that it is proportional to the serialized size of the script.

fromCompiledCode :: CompiledCode a -> Script Source #

Turn a CompiledCode (usually produced by compile) into a Script for use with this package.

compileScript :: Q (TExp a) -> Q (TExp Script) Source #

Compile a quoted Haskell expression to a Script.

lifted :: Lift a => a -> Script Source #

Lift a Haskell value into the corresponding Script. This allows you to create Scripts at runtime, whereas compileScript allows you to do so at compile time.

applyScript :: Script -> Script -> Script Source #

Given two Scripts, compute the Script that consists of applying the first to the second.

data Checking Source #

Constructors

Typecheck 
DontCheck 

data ScriptError Source #

Instances
Eq ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Show ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Generic ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep ScriptError :: Type -> Type Source #

NFData ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Methods

rnf :: ScriptError -> () Source #

FromJSON ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser ScriptError

parseJSONList :: Value -> Parser [ScriptError]

ToJSON ScriptError Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: ScriptError -> Value

toEncoding :: ScriptError -> Encoding

toJSONList :: [ScriptError] -> Value

toEncodingList :: [ScriptError] -> Encoding

type Rep ScriptError Source # 
Instance details

Defined in Ledger.Scripts

type Rep ScriptError = D1 (MetaData "ScriptError" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" False) (C1 (MetaCons "TypecheckError" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)) :+: C1 (MetaCons "EvaluationError" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [String])))

evaluateScript :: forall m. MonadError ScriptError m => Checking -> Script -> m [String] Source #

Evaluate a script, returning the trace log.

runScript :: MonadError ScriptError m => Checking -> ValidationData -> DataScripts -> ValidatorScript -> DataScript -> RedeemerScript -> m [String] Source #

Evaluate a validator script with the given arguments, returning the log and a boolean indicating whether evaluation was successful.

Script wrappers

newtype ValidatorScript Source #

ValidatorScript is a wrapper around Scripts which are used as validators in transaction outputs.

Constructors

ValidatorScript 

Fields

Instances
Eq ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Ord ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Show ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Generic ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep ValidatorScript :: Type -> Type Source #

Serialise ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: ValidatorScript -> Encoding

decode :: Decoder s ValidatorScript

encodeList :: [ValidatorScript] -> Encoding

decodeList :: Decoder s [ValidatorScript]

FromJSON ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser ValidatorScript

parseJSONList :: Value -> Parser [ValidatorScript]

ToJSON ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: ValidatorScript -> Value

toEncoding :: ValidatorScript -> Encoding

toJSONList :: [ValidatorScript] -> Value

toEncodingList :: [ValidatorScript] -> Encoding

Eq ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

Ord ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

ByteArrayAccess ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

type Rep ValidatorScript Source # 
Instance details

Defined in Ledger.Scripts

type Rep ValidatorScript = D1 (MetaData "ValidatorScript" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "ValidatorScript" PrefixI True) (S1 (MetaSel (Just "getValidator") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Script)))

newtype RedeemerScript Source #

RedeemerScript is a wrapper around Scripts that are used as redeemer scripts in transaction inputs.

Constructors

RedeemerScript 

Fields

Instances
Eq RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Ord RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Show RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Generic RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep RedeemerScript :: Type -> Type Source #

Serialise RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: RedeemerScript -> Encoding

decode :: Decoder s RedeemerScript

encodeList :: [RedeemerScript] -> Encoding

decodeList :: Decoder s [RedeemerScript]

FromJSON RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser RedeemerScript

parseJSONList :: Value -> Parser [RedeemerScript]

ToJSON RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: RedeemerScript -> Value

toEncoding :: RedeemerScript -> Encoding

toJSONList :: [RedeemerScript] -> Value

toEncodingList :: [RedeemerScript] -> Encoding

Eq RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

Ord RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

ByteArrayAccess RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

type Rep RedeemerScript Source # 
Instance details

Defined in Ledger.Scripts

type Rep RedeemerScript = D1 (MetaData "RedeemerScript" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "RedeemerScript" PrefixI True) (S1 (MetaSel (Just "getRedeemer") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Script)))

newtype DataScript Source #

DataScript is a wrapper around Scripts which are used as data scripts in transaction outputs.

Constructors

DataScript 
Instances
Eq DataScript Source # 
Instance details

Defined in Ledger.Scripts

Ord DataScript Source # 
Instance details

Defined in Ledger.Scripts

Show DataScript Source # 
Instance details

Defined in Ledger.Scripts

Generic DataScript Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep DataScript :: Type -> Type Source #

Serialise DataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: DataScript -> Encoding

decode :: Decoder s DataScript

encodeList :: [DataScript] -> Encoding

decodeList :: Decoder s [DataScript]

FromJSON DataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser DataScript

parseJSONList :: Value -> Parser [DataScript]

ToJSON DataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: DataScript -> Value

toEncoding :: DataScript -> Encoding

toJSONList :: [DataScript] -> Value

toEncodingList :: [DataScript] -> Encoding

Eq DataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

(==) :: DataScript -> DataScript -> Bool

Ord DataScript Source # 
Instance details

Defined in Ledger.Scripts

ByteArrayAccess DataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

length :: DataScript -> Int

withByteArray :: DataScript -> (Ptr p -> IO a) -> IO a

copyByteArrayToPtr :: DataScript -> Ptr p -> IO ()

type Rep DataScript Source # 
Instance details

Defined in Ledger.Scripts

type Rep DataScript = D1 (MetaData "DataScript" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "DataScript" PrefixI True) (S1 (MetaSel (Just "getDataScript") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Script)))

newtype ValidationData Source #

Information about the state of the blockchain and about the transaction that is currently being validated, represented as a value in a Script.

Constructors

ValidationData Script 
Instances
Show ValidationData Source # 
Instance details

Defined in Ledger.Scripts

Generic ValidationData Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep ValidationData :: Type -> Type Source #

FromJSON ValidationData Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser ValidationData

parseJSONList :: Value -> Parser [ValidationData]

ToJSON ValidationData Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: ValidationData -> Value

toEncoding :: ValidationData -> Encoding

toJSONList :: [ValidationData] -> Value

toEncodingList :: [ValidationData] -> Encoding

type Rep ValidationData Source # 
Instance details

Defined in Ledger.Scripts

type Rep ValidationData = D1 (MetaData "ValidationData" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "ValidationData" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Script)))

Hashes

newtype DataScriptHash Source #

Script runtime representation of a Digest SHA256.

Instances
Eq DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Ord DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Show DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

IsString DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Generic DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep DataScriptHash :: Type -> Type Source #

Serialise DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: DataScriptHash -> Encoding

decode :: Decoder s DataScriptHash

encodeList :: [DataScriptHash] -> Encoding

decodeList :: Decoder s [DataScriptHash]

Hashable DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

FromJSON DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser DataScriptHash

parseJSONList :: Value -> Parser [DataScriptHash]

FromJSONKey DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

fromJSONKey :: FromJSONKeyFunction DataScriptHash

fromJSONKeyList :: FromJSONKeyFunction [DataScriptHash]

ToJSON DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: DataScriptHash -> Value

toEncoding :: DataScriptHash -> Encoding

toJSONList :: [DataScriptHash] -> Value

toEncodingList :: [DataScriptHash] -> Encoding

ToJSONKey DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSONKey :: ToJSONKeyFunction DataScriptHash

toJSONKeyList :: ToJSONKeyFunction [DataScriptHash]

Lift DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

lift :: DataScriptHash -> RTCompile (Term TyName Name ())

Eq DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Ord DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Typeable DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

typeRep :: Proxy DataScriptHash -> RTCompile (Type TyName ())

type Rep DataScriptHash Source # 
Instance details

Defined in Ledger.Scripts

type Rep DataScriptHash = D1 (MetaData "DataScriptHash" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "DataScriptHash" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

newtype RedeemerHash Source #

Script runtime representation of a Digest SHA256.

Constructors

RedeemerHash ByteString 
Instances
Eq RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Ord RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Show RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

IsString RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Generic RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep RedeemerHash :: Type -> Type Source #

Serialise RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: RedeemerHash -> Encoding

decode :: Decoder s RedeemerHash

encodeList :: [RedeemerHash] -> Encoding

decodeList :: Decoder s [RedeemerHash]

Hashable RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

FromJSON RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser RedeemerHash

parseJSONList :: Value -> Parser [RedeemerHash]

FromJSONKey RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

fromJSONKey :: FromJSONKeyFunction RedeemerHash

fromJSONKeyList :: FromJSONKeyFunction [RedeemerHash]

ToJSON RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: RedeemerHash -> Value

toEncoding :: RedeemerHash -> Encoding

toJSONList :: [RedeemerHash] -> Value

toEncodingList :: [RedeemerHash] -> Encoding

ToJSONKey RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSONKey :: ToJSONKeyFunction RedeemerHash

toJSONKeyList :: ToJSONKeyFunction [RedeemerHash]

Lift RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

lift :: RedeemerHash -> RTCompile (Term TyName Name ())

Eq RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Ord RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Typeable RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

typeRep :: Proxy RedeemerHash -> RTCompile (Type TyName ())

type Rep RedeemerHash Source # 
Instance details

Defined in Ledger.Scripts

type Rep RedeemerHash = D1 (MetaData "RedeemerHash" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "RedeemerHash" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

newtype ValidatorHash Source #

Script runtime representation of a Digest SHA256.

Instances
Eq ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Ord ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Show ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

IsString ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Generic ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Associated Types

type Rep ValidatorHash :: Type -> Type Source #

ToSchema ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Serialise ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

encode :: ValidatorHash -> Encoding

decode :: Decoder s ValidatorHash

encodeList :: [ValidatorHash] -> Encoding

decodeList :: Decoder s [ValidatorHash]

Hashable ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

FromJSON ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

parseJSON :: Value -> Parser ValidatorHash

parseJSONList :: Value -> Parser [ValidatorHash]

FromJSONKey ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

fromJSONKey :: FromJSONKeyFunction ValidatorHash

fromJSONKeyList :: FromJSONKeyFunction [ValidatorHash]

ToJSON ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSON :: ValidatorHash -> Value

toEncoding :: ValidatorHash -> Encoding

toJSONList :: [ValidatorHash] -> Value

toEncodingList :: [ValidatorHash] -> Encoding

ToJSONKey ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

toJSONKey :: ToJSONKeyFunction ValidatorHash

toJSONKeyList :: ToJSONKeyFunction [ValidatorHash]

Lift ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

lift :: ValidatorHash -> RTCompile (Term TyName Name ())

Eq ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Ord ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Typeable ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

Methods

typeRep :: Proxy ValidatorHash -> RTCompile (Type TyName ())

type Rep ValidatorHash Source # 
Instance details

Defined in Ledger.Scripts

type Rep ValidatorHash = D1 (MetaData "ValidatorHash" "Ledger.Scripts" "plutus-wallet-api-0.1.0.0-BdsTjp7uGUGANkPkvyfvD2-plutus-ledger" True) (C1 (MetaCons "ValidatorHash" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString)))

plcValidatorDigest :: Digest SHA256 -> ValidatorHash Source #

Compute the hash of a validator script.

plcValidatorHash :: ValidatorScript -> ValidatorHash Source #

Compute the hash of a validator script.

Data script evidence

data HashedDataScript a Source #

A data script of type a, along with its hash. The hash can be cross-referenced into a PendingTx to determine which output this data script comes from.

Constructors

HashedDataScript 

Fields

Instances
(Typeable a, Lift a) => Lift (HashedDataScript a) Source # 
Instance details

Defined in Ledger.Scripts

Methods

lift :: HashedDataScript a -> RTCompile (Term TyName Name ())

Typeable HashedDataScript Source # 
Instance details

Defined in Ledger.Scripts

Methods

typeRep :: Proxy HashedDataScript -> RTCompile (Type TyName ())

Example scripts

unitRedeemer :: RedeemerScript Source #

() as a redeemer.

unitData :: DataScript Source #

() as a data script.