Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype Contract w (s :: Row *) e a = Contract {
- unContract :: Eff (ContractEffs w e) a
- data ContractError
- = WalletContractError WalletAPIError
- | ChainIndexContractError Text ChainIndexResponse
- | ConstraintResolutionContractError MkTxError
- | ToCardanoConvertContractError ToCardanoError
- | ResumableContractError MatchingError
- | CCheckpointContractError CheckpointError
- | EndpointDecodeContractError {
- eeEndpointDescription :: EndpointDescription
- eeEndpointValue :: EndpointValue Value
- eeErrorMessage :: Text
- | OtherContractError Text
- class AsContractError r where
- _ContractError :: Prism' r ContractError
- _WalletContractError :: Prism' r WalletAPIError
- _ChainIndexContractError :: Prism' r (Text, ChainIndexResponse)
- _ConstraintResolutionContractError :: Prism' r MkTxError
- _ToCardanoConvertContractError :: Prism' r ToCardanoError
- _ResumableContractError :: Prism' r MatchingError
- _CCheckpointContractError :: Prism' r CheckpointError
- _EndpointDecodeContractError :: Prism' r (EndpointDescription, EndpointValue Value, Text)
- _OtherContractError :: Prism' r Text
- class IsContract c where
- toContract :: c w s e a -> Contract w s e a
- (>>) :: Monad m => m a -> m b -> m b
- 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
- mapError :: forall w s e e' a. (e -> e') -> Contract w s e a -> Contract w s e' a
- runError :: forall w s e e0 a. Contract w s e a -> Contract w s e0 (Either e a)
- data Promise w (s :: Row *) e a
- awaitPromise :: Promise w s e a -> Contract w s e a
- promiseMap :: (Contract w1 s1 e1 a1 -> Contract w2 s2 e2 a2) -> Promise w1 s1 e1 a1 -> Promise w2 s2 e2 a2
- promiseBind :: Promise w s e a -> (a -> Contract w s e b) -> Promise w s e b
- both :: Promise w s e a -> Promise w s e b -> Promise w s e (a, b)
- selectEither :: forall w s e a b. Promise w s e a -> Promise w s e b -> Promise w s e (Either a b)
- select :: forall w s e a. Promise w s e a -> Promise w s e a -> Promise w s e a
- selectList :: [Promise w s e a] -> Contract w s e a
- never :: Promise w s e a
- awaitSlot :: forall w s e. AsContractError e => Slot -> Contract w s e Slot
- isSlot :: forall w s e. AsContractError e => Slot -> Promise w s e Slot
- currentSlot :: forall w s e. AsContractError e => Contract w s e Slot
- currentPABSlot :: forall w s e. AsContractError e => Contract w s e Slot
- currentNodeClientSlot :: forall w s e. AsContractError e => Contract w s e Slot
- currentChainIndexSlot :: forall w s e. AsContractError e => Contract w s e Slot
- waitNSlots :: forall w s e. AsContractError e => Natural -> Contract w s e Slot
- awaitTime :: forall w s e. AsContractError e => POSIXTime -> Contract w s e POSIXTime
- isTime :: forall w s e. AsContractError e => POSIXTime -> Promise w s e POSIXTime
- currentTime :: forall w s e. AsContractError e => Contract w s e POSIXTime
- currentNodeClientTimeRange :: forall w s e. AsContractError e => Contract w s e (POSIXTime, POSIXTime)
- waitNMilliSeconds :: forall w s e. AsContractError e => DiffMilliSeconds -> Contract w s e POSIXTime
- type HasEndpoint l a s = (HasType l (EndpointValue a) (Input s), HasType l ActiveEndpoint (Output s), KnownSymbol l, ContractRow s)
- newtype EndpointDescription = EndpointDescription {}
- type Endpoint l a = l .== (EndpointValue a, ActiveEndpoint)
- 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
- 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
- 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
- type EmptySchema = Empty
- watchAddressUntilSlot :: forall w s e. AsContractError e => CardanoAddress -> Slot -> Contract w s e (Map TxOutRef DecoratedTxOut)
- watchAddressUntilTime :: forall w s e. AsContractError e => CardanoAddress -> POSIXTime -> Contract w s e (Map TxOutRef DecoratedTxOut)
- fundsAtAddressGt :: forall w s e. AsContractError e => CardanoAddress -> Value -> Contract w s e (Map TxOutRef DecoratedTxOut)
- fundsAtAddressGeq :: forall w s e. AsContractError e => CardanoAddress -> Value -> Contract w s e (Map TxOutRef DecoratedTxOut)
- awaitUtxoSpent :: forall w s e. AsContractError e => TxOutRef -> Contract w s e ChainIndexTx
- utxoIsSpent :: forall w s e. AsContractError e => TxOutRef -> Promise w s e ChainIndexTx
- awaitUtxoProduced :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e (NonEmpty ChainIndexTx)
- utxoIsProduced :: forall w s e. AsContractError e => CardanoAddress -> Promise w s e (NonEmpty ChainIndexTx)
- datumFromHash :: forall w s e. AsContractError e => DatumHash -> Contract w s e (Maybe Datum)
- datumsAt :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e [Datum]
- findReferenceValidatorScripByHash :: forall w s e. AsContractError e => ValidatorHash -> CardanoAddress -> Contract w s e TxOutRef
- validatorFromHash :: forall w s e. AsContractError e => ValidatorHash -> Contract w s e (Maybe (Versioned Validator))
- mintingPolicyFromHash :: forall w s e. AsContractError e => MintingPolicyHash -> Contract w s e (Maybe (Versioned MintingPolicy))
- stakeValidatorFromHash :: forall w s e. AsContractError e => StakeValidatorHash -> Contract w s e (Maybe (Versioned StakeValidator))
- txOutFromRef :: forall w s e. AsContractError e => TxOutRef -> Contract w s e (Maybe DecoratedTxOut)
- unspentTxOutFromRef :: forall w s e. AsContractError e => TxOutRef -> Contract w s e (Maybe DecoratedTxOut)
- txFromTxId :: forall w s e. AsContractError e => TxId -> Contract w s e (Maybe ChainIndexTx)
- utxoRefMembership :: forall w s e. AsContractError e => TxOutRef -> Contract w s e IsUtxoResponse
- utxoRefsAt :: forall w s e. AsContractError e => PageQuery TxOutRef -> CardanoAddress -> Contract w s e UtxosResponse
- utxoRefsWithCurrency :: forall w s e. AsContractError e => PageQuery TxOutRef -> AssetClass -> Contract w s e UtxosResponse
- utxosAt :: forall w s e. AsContractError e => CardanoAddress -> Contract w s e (Map TxOutRef DecoratedTxOut)
- utxosTxOutTxFromTx :: AsContractError e => ChainIndexTx -> Contract w s e [(TxOutRef, (DecoratedTxOut, ChainIndexTx))]
- getTip :: forall w s e. AsContractError e => Contract w s e Tip
- ownPaymentPubKeyHash :: forall w s e. AsContractError e => Contract w s e PaymentPubKeyHash
- ownPaymentPubKeyHashes :: forall w s e. AsContractError e => Contract w s e [PaymentPubKeyHash]
- ownFirstPaymentPubKeyHash :: forall w s e. AsContractError e => Contract w s e PaymentPubKeyHash
- ownAddresses :: forall w s e. AsContractError e => Contract w s e (NonEmpty CardanoAddress)
- ownAddress :: forall w s e. AsContractError e => Contract w s e CardanoAddress
- ownUtxos :: forall w s e. AsContractError e => Contract w s e (Map TxOutRef DecoratedTxOut)
- data ContractInstanceId
- ownInstanceId :: forall w s e. AsContractError e => Contract w s e ContractInstanceId
- tell :: w -> Contract w s e ()
- data WalletAPIError
- adjustUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e UnbalancedTx
- submitTx :: forall w s e. AsContractError e => TxConstraints Void Void -> Contract w s e CardanoTx
- submitTxConfirmed :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e ()
- 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
- 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
- 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
- submitUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx
- submitBalancedTx :: forall w s e. AsContractError e => CardanoTx -> Contract w s e CardanoTx
- balanceTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx
- 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
- yieldUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e ()
- awaitTxConfirmed :: forall w s e. AsContractError e => TxId -> Contract w s e ()
- awaitTxStatusChange :: forall w s e. AsContractError e => TxId -> Contract w s e TxStatus
- isTxConfirmed :: forall w s e. AsContractError e => TxId -> Promise w s e ()
- awaitTxOutStatusChange :: forall w s e. AsContractError e => TxOutRef -> Contract w s e TxOutStatus
- getParams :: forall w s e. AsContractError e => Contract w s e Params
- checkpoint :: forall w s e a. (AsCheckpointError e, FromJSON a, ToJSON a) => Contract w s e a -> Contract w s e a
- 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
- class AsCheckpointError r where
- _CheckpointError :: Prism' r CheckpointError
- data CheckpointError = JSONDecodeError Text
- module Plutus.Contract.Logging
- class (r .! l) ≈ a => HasType (l :: Symbol) (a :: k) (r :: Row k)
- type ContractRow s = (AllUniqueLabels (Input s), AllUniqueLabels (Output s))
- type family (l :: Row k) .\/ (r :: Row k) :: Row k where ...
- type Empty = 'R ('[] :: [LT a])
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].
Contract | |
|
Instances
IsContract Contract Source # | |
Defined in Plutus.Contract.Types | |
MonadError e (Contract w s e) Source # | |
Defined in Plutus.Contract.Types 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 # | |
Monad (Contract w s e) Source # | |
Functor (Contract w s e) Source # | |
Applicative (Contract w s e) Source # | |
Defined in Plutus.Contract.Types 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 # | |
Functor (Contract w s e) Source # | |
Defined in Plutus.Contract.Types | |
Semigroup a => Semigroup (Contract w s e a) Source # | |
data ContractError Source #
WalletContractError WalletAPIError | |
ChainIndexContractError Text ChainIndexResponse | |
ConstraintResolutionContractError MkTxError | |
ToCardanoConvertContractError ToCardanoError | |
ResumableContractError MatchingError | |
CCheckpointContractError CheckpointError | |
EndpointDecodeContractError | |
| |
OtherContractError Text |
Instances
class AsContractError r where Source #
_ContractError :: Prism' r ContractError Source #
_WalletContractError :: Prism' r WalletAPIError Source #
_ChainIndexContractError :: Prism' r (Text, ChainIndexResponse) Source #
_ConstraintResolutionContractError :: Prism' r MkTxError Source #
_ToCardanoConvertContractError :: Prism' r ToCardanoError Source #
_ResumableContractError :: Prism' r MatchingError Source #
_CCheckpointContractError :: Prism' r CheckpointError Source #
_EndpointDecodeContractError :: Prism' r (EndpointDescription, EndpointValue Value, Text) Source #
_OtherContractError :: Prism' r Text Source #
Instances
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.
toContract :: c w s e a -> Contract w s e a Source #
Instances
IsContract Promise Source # | |
Defined in Plutus.Contract.Types | |
IsContract Contract Source # | |
Defined in Plutus.Contract.Types |
(>>) :: 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
' can be understood as the >>
bsdo
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
.
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 #
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
and all three can make progress at the same
moment, then select
P2 select
P3select
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.
Dealing with time
awaitSlot :: forall w s e. AsContractError e => Slot -> Contract 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
type HasEndpoint l a s = (HasType l (EndpointValue a) (Input s), HasType l ActiveEndpoint (Output s), KnownSymbol l, ContractRow s) Source #
newtype EndpointDescription Source #
Instances
type Endpoint l a = l .== (EndpointValue a, ActiveEndpoint) Source #
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.
type EmptySchema = Empty Source #
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
ownInstanceId :: forall w s e. AsContractError e => Contract w s e ContractInstanceId Source #
Get the ContractInstanceId
of this instance.
Notifications
Transactions
data WalletAPIError Source #
An error thrown by wallet interactions.
Instances
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 #
class AsCheckpointError r where Source #
_CheckpointError :: Prism' r CheckpointError Source #
Instances
AsCheckpointError CheckpointError Source # | |
Defined in Plutus.Contract.Checkpoint _CheckpointError :: Prism' CheckpointError CheckpointError Source # _JSONDecodeError :: Prism' CheckpointError Text Source # | |
AsCheckpointError ContractError Source # | |
Defined in Plutus.Contract.Error _CheckpointError :: Prism' ContractError CheckpointError Source # _JSONDecodeError :: Prism' ContractError Text Source # |
data CheckpointError Source #
JSONDecodeError Text |
Instances
Logging
module Plutus.Contract.Logging
Row-related things
class (r .! l) ≈ a => HasType (l :: Symbol) (a :: k) (r :: Row k) #
Instances
(r .! l) ≈ a => HasType l (a :: k) (r :: Row k) | |
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.