plutus-contract-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Contract

Synopsis

Documentation

newtype Contract w (s :: Row *) e a Source #

Contract w s e a is a contract with schema s, producing a value of type a or an error e. See note [Contract Schema].

Constructors

Contract 

Fields

Instances

Instances details
IsContract Contract Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

toContract :: forall w (s :: Row Type) e a. Contract w s e a -> Contract w s e a Source #

MonadError e (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

throwError :: e -> Contract w s e a #

catchError :: Contract w s e a -> (e -> Contract w s e a) -> Contract w s e a

Bifunctor (Contract w s) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

bimap :: (a -> b) -> (c -> d) -> Contract w s a c -> Contract w s b d Source #

first :: (a -> b) -> Contract w s a c -> Contract w s b c Source #

second :: (b -> c) -> Contract w s a b -> Contract w s a c Source #

Monad (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

(>>=) :: Contract w s e a -> (a -> Contract w s e b) -> Contract w s e b Source #

(>>) :: Contract w s e a -> Contract w s e b -> Contract w s e b Source #

return :: a -> Contract w s e a Source #

Functor (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

fmap :: (a -> b) -> Contract w s e a -> Contract w s e b Source #

(<$) :: a -> Contract w s e b -> Contract w s e a Source #

Applicative (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

pure :: a -> Contract w s e a Source #

(<*>) :: Contract w s e (a -> b) -> Contract w s e a -> Contract w s e b Source #

liftA2 :: (a -> b -> c) -> Contract w s e a -> Contract w s e b -> Contract w s e c Source #

(*>) :: Contract w s e a -> Contract w s e b -> Contract w s e b Source #

(<*) :: Contract w s e a -> Contract w s e b -> Contract w s e a Source #

Applicative (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

pure :: a -> Contract w s e a

(<*>) :: Contract w s e (a -> b) -> Contract w s e a -> Contract w s e b

Functor (Contract w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

fmap :: (a -> b) -> Contract w s e a -> Contract w s e b

Semigroup a => Semigroup (Contract w s e a) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

(<>) :: Contract w s e a -> Contract w s e a -> Contract w s e a Source #

sconcat :: NonEmpty (Contract w s e a) -> Contract w s e a Source #

stimes :: Integral b => b -> Contract w s e a -> Contract w s e a Source #

data ContractError Source #

Constructors

WalletContractError WalletAPIError 
ChainIndexContractError Text ChainIndexResponse 
ConstraintResolutionContractError MkTxError 
ToCardanoConvertContractError ToCardanoError 
ResumableContractError MatchingError 
CCheckpointContractError CheckpointError 
EndpointDecodeContractError 

Fields

OtherContractError Text 

Instances

Instances details
Eq ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Show ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

IsString ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Generic ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Associated Types

type Rep ContractError :: Type -> Type Source #

FromJSON ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Methods

parseJSON :: Value -> Parser ContractError

parseJSONList :: Value -> Parser [ContractError]

ToJSON ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Methods

toJSON :: ContractError -> Value

toEncoding :: ContractError -> Encoding

toJSONList :: [ContractError] -> Value

toEncodingList :: [ContractError] -> Encoding

Pretty ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Methods

pretty :: ContractError -> Doc ann

prettyList :: [ContractError] -> Doc ann

AsCheckpointError ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

AsContractError ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

type Rep ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

type Rep ContractError = D1 ('MetaData "ContractError" "Plutus.Contract.Error" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) (((C1 ('MetaCons "WalletContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 WalletAPIError)) :+: C1 ('MetaCons "ChainIndexContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainIndexResponse))) :+: (C1 ('MetaCons "ConstraintResolutionContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MkTxError)) :+: C1 ('MetaCons "ToCardanoConvertContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ToCardanoError)))) :+: ((C1 ('MetaCons "ResumableContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MatchingError)) :+: C1 ('MetaCons "CCheckpointContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CheckpointError))) :+: (C1 ('MetaCons "EndpointDecodeContractError" 'PrefixI 'True) (S1 ('MetaSel ('Just "eeEndpointDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 EndpointDescription) :*: (S1 ('MetaSel ('Just "eeEndpointValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (EndpointValue Value)) :*: S1 ('MetaSel ('Just "eeErrorMessage") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: C1 ('MetaCons "OtherContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))

class AsContractError r where Source #

Minimal complete definition

_ContractError

Instances

Instances details
AsContractError Text Source #

This lets people use Text as their error type.

Instance details

Defined in Plutus.Contract.Error

AsContractError ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

AsContractError SMContractError Source # 
Instance details

Defined in Plutus.Contract.StateMachine

class IsContract c where Source #

Class of types that can be trivially converted to a Contract. For use with functions where it is convenient to accept both Contract and Promise types.

Methods

toContract :: c w s e a -> Contract w s e a Source #

Instances

Instances details
IsContract Promise Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

toContract :: forall w (s :: Row Type) e a. Promise w s e a -> Contract w s e a Source #

IsContract Contract Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

toContract :: forall w (s :: Row Type) e a. Contract w s e a -> Contract w s e a Source #

(>>) :: Monad m => m a -> m b -> m b infixl 1 Source #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

'as >> bs' can be understood as the do expression

do as
   bs

throwError :: MonadError e m => e -> m a #

handleError :: forall w s e e' a. (e -> Contract w s e' a) -> Contract w s e a -> Contract w s e' a Source #

Handle errors, potentially throwing new errors.

mapError :: forall w s e e' a. (e -> e') -> Contract w s e a -> Contract w s e' a Source #

Transform any exceptions thrown by the Contract using the given function.

runError :: forall w s e e0 a. Contract w s e a -> Contract w s e0 (Either e a) Source #

Turn a contract with error type e and return type a into one with any error type (ie. throwing no errors) that returns 'Either e a'

Select

data Promise w (s :: Row *) e a Source #

A wrapper indicating that this contract starts with a waiting action. For use with select.

Instances

Instances details
IsContract Promise Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

toContract :: forall w (s :: Row Type) e a. Promise w s e a -> Contract w s e a Source #

Bifunctor (Promise w s) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

bimap :: (a -> b) -> (c -> d) -> Promise w s a c -> Promise w s b d Source #

first :: (a -> b) -> Promise w s a c -> Promise w s b c Source #

second :: (b -> c) -> Promise w s a b -> Promise w s a c Source #

Functor (Promise w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

fmap :: (a -> b) -> Promise w s e a -> Promise w s e b Source #

(<$) :: a -> Promise w s e b -> Promise w s e a Source #

Apply (Promise w s e) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

(<.>) :: Promise w s e (a -> b) -> Promise w s e a -> Promise w s e b

(.>) :: Promise w s e a -> Promise w s e b -> Promise w s e b

(<.) :: Promise w s e a -> Promise w s e b -> Promise w s e a

liftF2 :: (a -> b -> c) -> Promise w s e a -> Promise w s e b -> Promise w s e c

Semigroup a => Semigroup (Promise w s e a) Source # 
Instance details

Defined in Plutus.Contract.Types

Methods

(<>) :: Promise w s e a -> Promise w s e a -> Promise w s e a Source #

sconcat :: NonEmpty (Promise w s e a) -> Promise w s e a Source #

stimes :: Integral b => b -> Promise w s e a -> Promise w s e a Source #

awaitPromise :: Promise w s e a -> Contract w s e a Source #

promiseMap :: (Contract w1 s1 e1 a1 -> Contract w2 s2 e2 a2) -> Promise w1 s1 e1 a1 -> Promise w2 s2 e2 a2 Source #

Lift a mapping function for Contract to a mapping function for Promise.

promiseBind :: Promise w s e a -> (a -> Contract w s e b) -> Promise w s e b Source #

Run more Contract code after the Promise.

both :: Promise w s e a -> Promise w s e b -> Promise w s e (a, b) Source #

Execute both contracts in any order

selectEither :: forall w s e a b. Promise w s e a -> Promise w s e b -> Promise w s e (Either a b) Source #

A variant of select for contracts with different return types.

select :: forall w s e a. Promise w s e a -> Promise w s e a -> Promise w s e a Source #

select returns the contract that makes progress first, discarding the other one.

However, note that if multiples promises are chained together like P1 select P2 select P3 and all three can make progress at the same moment, then select will prioritize the promises starting from the right (first P3 then P2 then P1).

selectList :: [Promise w s e a] -> Contract w s e a Source #

selectList returns the contract that makes progress first, discarding the other ones.

However, if multiple contracts can make progress, selectList prioritizes the ones appearing first in the input list. Therefore, the order of the list of promises is important.

never :: Promise w s e a Source #

A Promise that is never fulfilled. This is the identity of select.

Dealing with time

awaitSlot :: forall w s e. AsContractError e => Slot -> Contract w s e Slot Source #

Wait until the slot

isSlot :: forall w s e. AsContractError e => Slot -> Promise w s e Slot Source #

Wait until the slot

currentSlot :: forall w s e. AsContractError e => Contract w s e Slot Source #

Deprecated: Use currentNodeClientSlot instead

Get the current slot number

currentPABSlot :: forall w s e. AsContractError e => Contract w s e Slot Source #

Deprecated: Use currentNodeClientSlot instead

Get the current slot number of PAB

currentNodeClientSlot :: forall w s e. AsContractError e => Contract w s e Slot Source #

Get the current slot number of the node client (the local or remote node) that the application is connected to.

currentChainIndexSlot :: forall w s e. AsContractError e => Contract w s e Slot Source #

Get the current node slot number querying slot number from plutus chain index to be aligned with slot at local running node

waitNSlots :: forall w s e. AsContractError e => Natural -> Contract w s e Slot Source #

Wait for a number of slots to pass

awaitTime :: forall w s e. AsContractError e => POSIXTime -> Contract w s e POSIXTime Source #

Wait until the slot where the given time falls into and return latest time we know has passed.

Example: if starting time is 0 and slot length is 3s, then `awaitTime 4` waits until slot 2 and returns the value `POSIXTime 5`.

isTime :: forall w s e. AsContractError e => POSIXTime -> Promise w s e POSIXTime Source #

Wait until the slot where the given time falls into and return latest time we know has passed.

currentTime :: forall w s e. AsContractError e => Contract w s e POSIXTime Source #

Deprecated: Use currentNodeClientTimeRange instead

Get the latest time of the current slot.

Example: if slot length is 3s and current slot is 2, then currentTime returns the value `POSIXTime 5`

currentNodeClientTimeRange :: forall w s e. AsContractError e => Contract w s e (POSIXTime, POSIXTime) Source #

Get the POSIXTime range of the current slot.

Example: if slot length is 3s and current slot is 2, then currentTimeRange returns the time interval [3, 5[.

waitNMilliSeconds :: forall w s e. AsContractError e => DiffMilliSeconds -> Contract w s e POSIXTime Source #

Wait for a number of milliseconds starting at the ending time of the current slot, and return the latest time we know has passed.

Example: if starting time is 0, slot length is 3000ms and current slot is 0, then `waitNMilliSeconds 0` returns the value `POSIXTime 2000` and `waitNMilliSeconds 1000` returns the value `POSIXTime 5`.

Endpoints

newtype EndpointDescription Source #

Instances

Instances details
Eq EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Ord EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Show EndpointDescription Source # 
Instance details

Defined in Wallet.Types

IsString EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Generic EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Associated Types

type Rep EndpointDescription :: Type -> Type Source #

FromJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Methods

parseJSON :: Value -> Parser EndpointDescription

parseJSONList :: Value -> Parser [EndpointDescription]

ToJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Pretty EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Methods

pretty :: EndpointDescription -> Doc ann

prettyList :: [EndpointDescription] -> Doc ann

Lift EndpointDescription Source # 
Instance details

Defined in Wallet.Types

type Rep EndpointDescription Source # 
Instance details

Defined in Wallet.Types

type Rep EndpointDescription = D1 ('MetaData "EndpointDescription" "Wallet.Types" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'True) (C1 ('MetaCons "EndpointDescription" 'PrefixI 'True) (S1 ('MetaSel ('Just "getEndpointDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))

endpoint :: forall l a w s e b. (HasEndpoint l a s, AsContractError e, FromJSON a) => (a -> Contract w s e b) -> Promise w s e b Source #

Expose an endpoint, return the data that was entered

handleEndpoint :: forall l a w s e1 e2 b. (HasEndpoint l a s, AsContractError e1, FromJSON a) => (Either e1 a -> Contract w s e2 b) -> Promise w s e2 b Source #

endpointWithMeta :: forall l a w s e meta b. (HasEndpoint l a s, AsContractError e, ToJSON meta, FromJSON a) => meta -> (a -> Contract w s e b) -> Promise w s e b Source #

Expose an endpoint with some metadata. Return the data that was entered.

Blockchain events

watchAddressUntilSlot :: forall w s e. AsContractError e => CardanoAddress -> Slot -> Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Wait until the target slot and get the unspent transaction outputs at an address.

watchAddressUntilTime :: forall w s e. AsContractError e => CardanoAddress -> POSIXTime -> Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Wait until the target time and get the unspent transaction outputs at an address.

fundsAtAddressGt :: forall w s e. AsContractError e => CardanoAddress -> Value -> Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Watch an address for changes, and return the outputs at that address when the total value at the address has surpassed the given value.

fundsAtAddressGeq :: forall w s e. AsContractError e => CardanoAddress -> Value -> Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Watch an address for changes, and return the outputs at that address when the total value at the address has reached or surpassed the given value.

awaitUtxoSpent :: forall w s e. AsContractError e => TxOutRef -> Contract w s e ChainIndexTx Source #

Wait until the UTXO has been spent, returning the transaction that spends it.

utxoIsSpent :: forall w s e. AsContractError e => TxOutRef -> Promise w s e ChainIndexTx Source #

Wait until the UTXO has been spent, returning the transaction that spends it.

awaitUtxoProduced :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e (NonEmpty ChainIndexTx) Source #

Wait until one or more unspent outputs are produced at an address.

utxoIsProduced :: forall w s e. AsContractError e => CardanoAddress -> Promise w s e (NonEmpty ChainIndexTx) Source #

Wait until one or more unspent outputs are produced at an address.

Chain index requests

datumFromHash :: forall w s e. AsContractError e => DatumHash -> Contract w s e (Maybe Datum) Source #

datumsAt :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e [Datum] Source #

Get the all datums at an address whether or not the corresponding utxo have been consumed or not.

findReferenceValidatorScripByHash :: forall w s e. AsContractError e => ValidatorHash -> CardanoAddress -> Contract w s e TxOutRef Source #

Find the reference to an utxo containing a reference script by its the script hash, amongst the utxos at a given address

validatorFromHash :: forall w s e. AsContractError e => ValidatorHash -> Contract w s e (Maybe (Versioned Validator)) Source #

mintingPolicyFromHash :: forall w s e. AsContractError e => MintingPolicyHash -> Contract w s e (Maybe (Versioned MintingPolicy)) Source #

stakeValidatorFromHash :: forall w s e. AsContractError e => StakeValidatorHash -> Contract w s e (Maybe (Versioned StakeValidator)) Source #

txOutFromRef :: forall w s e. AsContractError e => TxOutRef -> Contract w s e (Maybe DecoratedTxOut) Source #

unspentTxOutFromRef :: forall w s e. AsContractError e => TxOutRef -> Contract w s e (Maybe DecoratedTxOut) Source #

txFromTxId :: forall w s e. AsContractError e => TxId -> Contract w s e (Maybe ChainIndexTx) Source #

utxoRefMembership :: forall w s e. AsContractError e => TxOutRef -> Contract w s e IsUtxoResponse Source #

utxoRefsAt :: forall w s e. AsContractError e => PageQuery TxOutRef -> CardanoAddress -> Contract w s e UtxosResponse Source #

Get the unspent transaction output references at an address.

utxoRefsWithCurrency :: forall w s e. AsContractError e => PageQuery TxOutRef -> AssetClass -> Contract w s e UtxosResponse Source #

Get the unspent transaction output references with a specific currrency (AssetClass).

utxosAt :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Get the unspent transaction outputs at an address.

utxosTxOutTxFromTx :: AsContractError e => ChainIndexTx -> Contract w s e [(TxOutRef, (DecoratedTxOut, ChainIndexTx))] Source #

Get the unspent transaction outputs from a ChainIndexTx.

getTip :: forall w s e. AsContractError e => Contract w s e Tip Source #

Wallet's information

ownPaymentPubKeyHash :: forall w s e. AsContractError e => Contract w s e PaymentPubKeyHash Source #

Deprecated: Use ownFirstPaymentPubKeyHash, ownPaymentPubKeyHashes or ownAddresses instead

Get the hash of a public key belonging to the wallet that runs this contract. * Any funds paid to this public key hash will be treated as the wallet's own funds * The wallet is able to sign transactions with the private key of this public key, for example, if the public key is added to the requiredSignatures field of Tx. * There is a 1-n relationship between wallets and public keys (although in the mockchain n=1)

ownPaymentPubKeyHashes :: forall w s e. AsContractError e => Contract w s e [PaymentPubKeyHash] Source #

ownFirstPaymentPubKeyHash :: forall w s e. AsContractError e => Contract w s e PaymentPubKeyHash Source #

ownAddresses :: forall w s e. AsContractError e => Contract w s e (NonEmpty CardanoAddress) Source #

Get the addresses belonging to the wallet that runs this contract. * Any funds paid to one of these addresses will be treated as the wallet's own funds * The wallet is able to sign transactions with the private key of one of its public key, for example, if the public key is added to the requiredSignatures field of Tx. * There is a 1-n relationship between wallets and addresses (although in the mockchain n=1)

ownAddress :: forall w s e. AsContractError e => Contract w s e CardanoAddress Source #

Get the first address of the wallet that runs this contract.

ownUtxos :: forall w s e. AsContractError e => Contract w s e (Map TxOutRef DecoratedTxOut) Source #

Get all utxos belonging to the wallet that runs this contract.

Contract instance Id

data ContractInstanceId Source #

Unique ID for contract instance

Instances

Instances details
Eq ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Ord ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Show ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Generic ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Associated Types

type Rep ContractInstanceId :: Type -> Type Source #

FromJSON ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Methods

parseJSON :: Value -> Parser ContractInstanceId

parseJSONList :: Value -> Parser [ContractInstanceId]

FromJSONKey ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Methods

fromJSONKey :: FromJSONKeyFunction ContractInstanceId

fromJSONKeyList :: FromJSONKeyFunction [ContractInstanceId]

ToJSON ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

ToJSONKey ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Methods

toJSONKey :: ToJSONKeyFunction ContractInstanceId

toJSONKeyList :: ToJSONKeyFunction [ContractInstanceId]

Pretty ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Methods

pretty :: ContractInstanceId -> Doc ann

prettyList :: [ContractInstanceId] -> Doc ann

type Rep ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

type Rep ContractInstanceId = D1 ('MetaData "ContractInstanceId" "Wallet.Types" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'True) (C1 ('MetaCons "ContractInstanceId" 'PrefixI 'True) (S1 ('MetaSel ('Just "unContractInstanceId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UUID)))

ownInstanceId :: forall w s e. AsContractError e => Contract w s e ContractInstanceId Source #

Get the ContractInstanceId of this instance.

Notifications

tell :: w -> Contract w s e () Source #

Update the contract's accumulating state w

Transactions

data WalletAPIError Source #

An error thrown by wallet interactions.

Instances

Instances details
Eq WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Show WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Generic WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Associated Types

type Rep WalletAPIError :: Type -> Type Source #

FromJSON WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Methods

parseJSON :: Value -> Parser WalletAPIError

parseJSONList :: Value -> Parser [WalletAPIError]

ToJSON WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Methods

toJSON :: WalletAPIError -> Value

toEncoding :: WalletAPIError -> Encoding

toJSONList :: [WalletAPIError] -> Value

toEncodingList :: [WalletAPIError] -> Encoding

Pretty WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Methods

pretty :: WalletAPIError -> Doc ann

prettyList :: [WalletAPIError] -> Doc ann

type Rep WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

type Rep WalletAPIError = D1 ('MetaData "WalletAPIError" "Wallet.Emulator.Error" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) (((C1 ('MetaCons "InsufficientFunds" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "ChangeHasLessThanNAda" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Ada))) :+: (C1 ('MetaCons "NoPaymentPubKeyHashError" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "PaymentPrivateKeyNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash)))) :+: ((C1 ('MetaCons "ValidationError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationError)) :+: C1 ('MetaCons "ToCardanoError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ToCardanoError))) :+: (C1 ('MetaCons "PaymentMkTxError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MkTxError)) :+: (C1 ('MetaCons "RemoteClientFunctionNotYetSupported" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "OtherError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))))))

adjustUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e UnbalancedTx Source #

Adjust the unbalanced tx

submitTx :: forall w s e. AsContractError e => TxConstraints Void Void -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. The constraints do not refer to any typed script inputs or outputs.

submitTxConfirmed :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e () Source #

A version of submitTx that waits until the transaction has been confirmed on the ledger before returning.

submitTxConstraints :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => TypedValidator a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. Using the current outputs at the contract address and the contract's own public key to solve the constraints.

submitTxConstraintsSpending :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => TypedValidator a -> Map TxOutRef DecoratedTxOut -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints using the UTXO map to resolve any input constraints (see InputConstraint)

submitTxConstraintsWith :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. Using the given constraints.

submitUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx Source #

Send an unbalanced transaction to be balanced and signed. Returns the ID of the final transaction when the transaction was submitted. Throws an error if balancing or signing failed.

submitBalancedTx :: forall w s e. AsContractError e => CardanoTx -> Contract w s e CardanoTx Source #

Send an balanced transaction to be signed. Returns the ID of the final transaction when the transaction was submitted. Throws an error if signing failed.

balanceTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx Source #

Send an unbalanced transaction to be balanced. Returns the balanced transaction. Throws an error if balancing failed.

mkTxConstraints :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e UnbalancedTx Source #

Build a transaction that satisfies the constraints

yieldUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e () Source #

Take an UnbalancedTx then balance, sign and submit it to the blockchain without returning any results.

Tx confirmation

awaitTxConfirmed :: forall w s e. AsContractError e => TxId -> Contract w s e () Source #

Wait until a transaction is confirmed (added to the ledger). If the transaction is never added to the ledger then awaitTxConfirmed never returns

awaitTxStatusChange :: forall w s e. AsContractError e => TxId -> Contract w s e TxStatus Source #

Wait for the status of a transaction to change

isTxConfirmed :: forall w s e. AsContractError e => TxId -> Promise w s e () Source #

Wait until a transaction is confirmed (added to the ledger).

Tx output confirmation

awaitTxOutStatusChange :: forall w s e. AsContractError e => TxOutRef -> Contract w s e TxOutStatus Source #

Wait for the status of a transaction output to change.

Parameters

getParams :: forall w s e. AsContractError e => Contract w s e Params Source #

Get the configured parameter set.

Checkpoints

checkpoint :: forall w s e a. (AsCheckpointError e, FromJSON a, ToJSON a) => Contract w s e a -> Contract w s e a Source #

Write the current state of the contract to a checkpoint.

checkpointLoop :: forall w s e a b. (AsCheckpointError e, FromJSON a, ToJSON a, ToJSON b, FromJSON b) => (a -> Contract w s e (Either b a)) -> a -> Contract w s e b Source #

data CheckpointError Source #

Constructors

JSONDecodeError Text 

Instances

Instances details
Eq CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Ord CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Show CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Generic CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Associated Types

type Rep CheckpointError :: Type -> Type Source #

FromJSON CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Methods

parseJSON :: Value -> Parser CheckpointError

parseJSONList :: Value -> Parser [CheckpointError]

ToJSON CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Methods

toJSON :: CheckpointError -> Value

toEncoding :: CheckpointError -> Encoding

toJSONList :: [CheckpointError] -> Value

toEncodingList :: [CheckpointError] -> Encoding

Pretty CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Methods

pretty :: CheckpointError -> Doc ann

prettyList :: [CheckpointError] -> Doc ann

AsCheckpointError CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

type Rep CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

type Rep CheckpointError = D1 ('MetaData "CheckpointError" "Plutus.Contract.Checkpoint" "plutus-contract-1.2.0.0-FH8LC9wh7UV4Nmv68NHXrC" 'False) (C1 ('MetaCons "JSONDecodeError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Logging

Row-related things

class (r .! l) ≈ a => HasType (l :: Symbol) (a :: k) (r :: Row k) #

Instances

Instances details
(r .! l) ≈ a => HasType l (a :: k) (r :: Row k) 
Instance details

Defined in Data.Row.Internal

type ContractRow s = (AllUniqueLabels (Input s), AllUniqueLabels (Output s)) Source #

Constraints on the contract schema, ensuring that the labels of the schema are unique.

type family (l :: Row k) .\/ (r :: Row k) :: Row k where ... #

Equations

(x :: Row k) .\/ ('R ('[] :: [LT k]) :: Row k) = x 
('R ('[] :: [LT k]) :: Row k) .\/ (y :: Row k) = y 
('R l :: Row a) .\/ ('R r :: Row a) = 'R (MinJoinR l r) 

type Empty = 'R ('[] :: [LT a]) #