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

Plutus.Contracts.Vesting

Synopsis

Documentation

data VestingParams Source #

A vesting scheme consisting of two tranches. Each tranche defines a date (POSIX time) after which an additional amount can be spent.

Instances

Instances details
Generic VestingParams Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Associated Types

type Rep VestingParams :: Type -> Type Source #

Lift DefaultUni VestingParams Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

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

Typeable DefaultUni VestingParams Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

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

type Rep VestingParams Source # 
Instance details

Defined in Plutus.Contracts.Vesting

type Rep VestingParams = D1 ('MetaData "VestingParams" "Plutus.Contracts.Vesting" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "VestingParams" 'PrefixI 'True) (S1 ('MetaSel ('Just "vestingTranche1") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VestingTranche) :*: (S1 ('MetaSel ('Just "vestingTranche2") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 VestingTranche) :*: S1 ('MetaSel ('Just "vestingOwner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash))))

type VestingSchema = Endpoint "vest funds" () .\/ Endpoint "retrieve funds" Value Source #

A simple vesting scheme. Money is locked by a contract and may only be retrieved after some time has passed.

This is our first example of a contract that covers multiple transactions, with a contract state that changes over time.

In our vesting scheme the money will be released in two _tranches_ (parts): A smaller part will be available after an initial number of time has passed, and the entire amount will be released at the end. The owner of the vesting scheme does not have to take out all the money at once: They can take out any amount up to the total that has been released so far. The remaining funds stay locked and can be retrieved later.

Let's start with the data types.

data VestingTranche Source #

Tranche of a vesting scheme.

Constructors

VestingTranche 

Fields

Instances

Instances details
Generic VestingTranche Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Associated Types

type Rep VestingTranche :: Type -> Type Source #

Lift DefaultUni VestingTranche Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

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

Typeable DefaultUni VestingTranche Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

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

type Rep VestingTranche Source # 
Instance details

Defined in Plutus.Contracts.Vesting

type Rep VestingTranche = D1 ('MetaData "VestingTranche" "Plutus.Contracts.Vesting" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "VestingTranche" 'PrefixI 'True) (S1 ('MetaSel ('Just "vestingTrancheDate") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "vestingTrancheAmount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))

data VestingError Source #

Constructors

VContractError ContractError 
InsufficientFundsError Value Value Value 

Instances

Instances details
Eq VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Show VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Generic VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Associated Types

type Rep VestingError :: Type -> Type Source #

FromJSON VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

parseJSON :: Value -> Parser VestingError

parseJSONList :: Value -> Parser [VestingError]

ToJSON VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

toJSON :: VestingError -> Value

toEncoding :: VestingError -> Encoding

toJSONList :: [VestingError] -> Value

toEncodingList :: [VestingError] -> Encoding

AsContractError VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

_ContractError :: Prism' VestingError ContractError

_WalletContractError :: Prism' VestingError WalletAPIError

_ChainIndexContractError :: Prism' VestingError (Text, ChainIndexResponse)

_ConstraintResolutionContractError :: Prism' VestingError MkTxError

_ToCardanoConvertContractError :: Prism' VestingError ToCardanoError

_ResumableContractError :: Prism' VestingError MatchingError

_CCheckpointContractError :: Prism' VestingError CheckpointError

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

_OtherContractError :: Prism' VestingError Text

AsVestingError VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

_VestingError :: Prism' VestingError VestingError Source #

_VContractError :: Prism' VestingError ContractError Source #

_InsufficientFundsError :: Prism' VestingError (Value, Value, Value) Source #

type Rep VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

type Rep VestingError = D1 ('MetaData "VestingError" "Plutus.Contracts.Vesting" "plutus-use-cases-1.2.0.0-BuYOLXrynPcLosE012cowc" 'False) (C1 ('MetaCons "VContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractError)) :+: C1 ('MetaCons "InsufficientFundsError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))))

class AsVestingError r where Source #

Minimal complete definition

_VestingError

Methods

_VestingError :: Prism' r VestingError Source #

_VContractError :: Prism' r ContractError Source #

_InsufficientFundsError :: Prism' r (Value, Value, Value) Source #

Instances

Instances details
AsVestingError VestingError Source # 
Instance details

Defined in Plutus.Contracts.Vesting

Methods

_VestingError :: Prism' VestingError VestingError Source #

_VContractError :: Prism' VestingError ContractError Source #

_InsufficientFundsError :: Prism' VestingError (Value, Value, Value) Source #

totalAmount :: VestingParams -> Value Source #

The total amount vested

validate :: VestingParams -> () -> () -> ScriptContext -> Bool Source #