plutus-use-cases-1.2.0.0: Collection of smart contracts to develop the plutus/wallet interface
Safe HaskellNone
LanguageHaskell2010

Plutus.Contracts.SimpleEscrow

Description

This simple escrow contract facilitiates and exchange of currencies.

Synopsis

Documentation

data EscrowParams Source #

Constructors

EscrowParams 

Fields

  • payee :: PaymentPubKeyHash

    The entity that needs to be paid the expecting Value.

  • paying :: Value

    Value to be paid out to the redeemer.

  • expecting :: Value

    Value to be received by the payee.

  • deadline :: POSIXTime

    Time after which the contract expires.

Instances

Instances details
Show EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Generic EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Associated Types

type Rep EscrowParams :: Type -> Type Source #

FromJSON EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

parseJSON :: Value -> Parser EscrowParams

parseJSONList :: Value -> Parser [EscrowParams]

ToJSON EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

toJSON :: EscrowParams -> Value

toEncoding :: EscrowParams -> Encoding

toJSONList :: [EscrowParams] -> Value

toEncodingList :: [EscrowParams] -> Encoding

ToData EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

toBuiltinData :: EscrowParams -> BuiltinData

FromData EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

fromBuiltinData :: BuiltinData -> Maybe EscrowParams

UnsafeFromData EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

unsafeFromBuiltinData :: BuiltinData -> EscrowParams

Lift DefaultUni EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

lift :: EscrowParams -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ())

Typeable DefaultUni EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

typeRep :: Proxy EscrowParams -> RTCompile DefaultUni fun (Type TyName DefaultUni ())

type Rep EscrowParams Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep EscrowParams = D1 ('MetaData "EscrowParams" "Plutus.Contracts.SimpleEscrow" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "EscrowParams" 'PrefixI 'True) ((S1 ('MetaSel ('Just "payee") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash) :*: S1 ('MetaSel ('Just "paying") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :*: (S1 ('MetaSel ('Just "expecting") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime))))

type EscrowSchema = (Endpoint "lock" EscrowParams .\/ Endpoint "refund" EscrowParams) .\/ Endpoint "redeem" EscrowParams Source #

data Action Source #

Constructors

Redeem 
Refund 

Instances

Instances details
ToData Action Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

toBuiltinData :: Action -> BuiltinData

FromData Action Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

fromBuiltinData :: BuiltinData -> Maybe Action

UnsafeFromData Action Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

unsafeFromBuiltinData :: BuiltinData -> Action

Lift DefaultUni Action Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

lift :: Action -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ())

Typeable DefaultUni Action Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

typeRep :: Proxy Action -> RTCompile DefaultUni fun (Type TyName DefaultUni ())

data RedeemFailReason Source #

Constructors

DeadlinePassed 

Instances

Instances details
Eq RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Show RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Generic RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Associated Types

type Rep RedeemFailReason :: Type -> Type Source #

FromJSON RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

parseJSON :: Value -> Parser RedeemFailReason

parseJSONList :: Value -> Parser [RedeemFailReason]

ToJSON RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep RedeemFailReason Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep RedeemFailReason = D1 ('MetaData "RedeemFailReason" "Plutus.Contracts.SimpleEscrow" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "DeadlinePassed" 'PrefixI 'False) (U1 :: Type -> Type))

data EscrowError Source #

Instances

Instances details
Show EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Generic EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Associated Types

type Rep EscrowError :: Type -> Type Source #

FromJSON EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

parseJSON :: Value -> Parser EscrowError

parseJSONList :: Value -> Parser [EscrowError]

ToJSON EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

toJSON :: EscrowError -> Value

toEncoding :: EscrowError -> Encoding

toJSONList :: [EscrowError] -> Value

toEncodingList :: [EscrowError] -> Encoding

AsContractError EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

_ContractError :: Prism' EscrowError ContractError

_WalletContractError :: Prism' EscrowError WalletAPIError

_ChainIndexContractError :: Prism' EscrowError (Text, ChainIndexResponse)

_ConstraintResolutionContractError :: Prism' EscrowError MkTxError

_ToCardanoConvertContractError :: Prism' EscrowError ToCardanoError

_ResumableContractError :: Prism' EscrowError MatchingError

_CCheckpointContractError :: Prism' EscrowError CheckpointError

_EndpointDecodeContractError :: Prism' EscrowError (EndpointDescription, EndpointValue Value, Text)

_OtherContractError :: Prism' EscrowError Text

AsEscrowError EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep EscrowError Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep EscrowError = D1 ('MetaData "EscrowError" "Plutus.Contracts.SimpleEscrow" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "RedeemFailed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RedeemFailReason)) :+: (C1 ('MetaCons "RefundFailed" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractError))))

class AsEscrowError r where Source #

Minimal complete definition

_EscrowError

Methods

_EscrowError :: Prism' r EscrowError Source #

_RedeemFailed :: Prism' r RedeemFailReason Source #

_RefundFailed :: Prism' r () Source #

_EContractError :: Prism' r ContractError Source #

newtype RefundSuccess Source #

Constructors

RefundSuccess TxId 

Instances

Instances details
Eq RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Show RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Generic RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Associated Types

type Rep RefundSuccess :: Type -> Type Source #

FromJSON RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

parseJSON :: Value -> Parser RefundSuccess

parseJSONList :: Value -> Parser [RefundSuccess]

ToJSON RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Methods

toJSON :: RefundSuccess -> Value

toEncoding :: RefundSuccess -> Encoding

toJSONList :: [RefundSuccess] -> Value

toEncodingList :: [RefundSuccess] -> Encoding

type Rep RefundSuccess Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type Rep RefundSuccess = Rep TxId

data Escrow Source #

Instances

Instances details
ValidatorTypes Escrow Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

Associated Types

type RedeemerType Escrow

type DatumType Escrow

type DatumType Escrow Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type DatumType Escrow = EscrowParams
type RedeemerType Escrow Source # 
Instance details

Defined in Plutus.Contracts.SimpleEscrow

type RedeemerType Escrow = Action

escrowAddress :: CardanoAddress Source #

escrowInstance :: TypedValidator Escrow Source #

validate :: EscrowParams -> Action -> ScriptContext -> Bool Source #

lockEp :: Promise () EscrowSchema EscrowError () Source #

Lock the paying Value in the output of this script, with the requirement that the transaction validates before the deadline.

redeemEp :: Promise () EscrowSchema EscrowError RedeemSuccess Source #

Attempts to redeem the Value locked into this script by paying in from the callers address to the payee.

refundEp :: Promise () EscrowSchema EscrowError RefundSuccess Source #

Refunds the locked amount back to the payee.