plutus-contract-0.1.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 Source #

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

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 Source #

(<*>) :: Contract w s e (a -> b) -> Contract w s e a -> Contract w s e b 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 #

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 #

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 #

ToJSON ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

FromJSON ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

Pretty ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

AsCheckpointError ContractError Source # 
Instance details

Defined in Plutus.Contract.Error

AsAssertionError 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-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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 "EmulatorAssertionContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AssertionError)) :+: C1 ('MetaCons "ConstraintResolutionContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MkTxError)))) :+: ((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 Source #

Is used within a monadic computation to begin exception processing.

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 Source #

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

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

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

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 #

Get the current slot number

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 #

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`

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 #

ToJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

FromJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

ToSchema EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Pretty EndpointDescription Source # 
Instance details

Defined in Wallet.Types

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-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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 => Address -> Slot -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

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

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

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

fundsAtAddressGt :: forall w s e. AsContractError e => Address -> Value -> Contract w s e (Map TxOutRef ChainIndexTxOut) 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 => Address -> Value -> Contract w s e (Map TxOutRef ChainIndexTxOut) 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 => Address -> 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 => Address -> Promise w s e (NonEmpty ChainIndexTx) Source #

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

Chain index requests

utxoRefsAt :: forall w s e. AsContractError e => PageQuery TxOutRef -> Address -> 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 => Address -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Get the unspent transaction outputs at an address.

utxosTxOutTxFromTx :: AsContractError e => ChainIndexTx -> Contract w s e [(TxOutRef, (ChainIndexTxOut, 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 own public key

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

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)

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 #

ToJSON ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

ToJSONKey ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

FromJSON ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

FromJSONKey ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

ToSchema ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

Pretty ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

type Rep ContractInstanceId Source # 
Instance details

Defined in Wallet.Types

type Rep ContractInstanceId = D1 ('MetaData "ContractInstanceId" "Wallet.Types" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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 #

ToJSON WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

FromJSON WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

Pretty WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

type Rep WalletAPIError Source # 
Instance details

Defined in Wallet.Emulator.Error

type Rep WalletAPIError = D1 ('MetaData "WalletAPIError" "Wallet.Emulator.Error" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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 "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)))))

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 ChainIndexTxOut -> 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.

Creating transactions

collectFromScriptFilter :: forall i o. (TxOutRef -> ChainIndexTxOut -> Bool) -> Map TxOutRef ChainIndexTxOut -> i -> TxConstraints i o Source #

Given the pay to script address of the Validator, collect from it all the outputs that match a predicate, using the RedeemerValue.

collectFromScript :: forall i o. Map TxOutRef ChainIndexTxOut -> i -> TxConstraints i o Source #

A version of collectFromScript that selects all outputs at the address

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.

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 #

ToJSON CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

FromJSON CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

Pretty CheckpointError Source # 
Instance details

Defined in Plutus.Contract.Checkpoint

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-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" '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) Source #

Alias for (r .! l) ≈ a. It is a class rather than an alias, so that it can be partially applied.

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 ... infixl 6 Source #

The minimum join of the two rows.

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]) Source #

Type level version of empty