Safe Haskell | None |
---|---|
Language | Haskell2010 |
Plutus.Contracts.Vesting
Synopsis
- data VestingParams = VestingParams {
- vestingTranche1 :: VestingTranche
- vestingTranche2 :: VestingTranche
- vestingOwner :: PaymentPubKeyHash
- type VestingSchema = Endpoint "vest funds" () .\/ Endpoint "retrieve funds" Value
- data VestingTranche = VestingTranche {
- vestingTrancheDate :: POSIXTime
- vestingTrancheAmount :: Value
- data VestingError
- = VContractError ContractError
- | InsufficientFundsError Value Value Value
- class AsVestingError r where
- _VestingError :: Prism' r VestingError
- _VContractError :: Prism' r ContractError
- _InsufficientFundsError :: Prism' r (Value, Value, Value)
- totalAmount :: VestingParams -> Value
- vestingContract :: VestingParams -> Contract () VestingSchema VestingError ()
- validate :: VestingParams -> () -> () -> ScriptContext -> Bool
- vestingScript :: VestingParams -> Validator
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.
Constructors
VestingParams | |
Fields
|
Instances
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
Generic VestingTranche Source # | |
Defined in Plutus.Contracts.Vesting Methods from :: VestingTranche -> Rep VestingTranche x Source # to :: Rep VestingTranche x -> VestingTranche Source # | |
Lift DefaultUni VestingTranche Source # | |
Defined in Plutus.Contracts.Vesting Methods lift :: VestingTranche -> RTCompile DefaultUni fun (Term TyName Name DefaultUni fun ()) | |
Typeable DefaultUni VestingTranche Source # | |
Defined in Plutus.Contracts.Vesting Methods typeRep :: Proxy VestingTranche -> RTCompile DefaultUni fun (Type TyName DefaultUni ()) | |
type Rep VestingTranche Source # | |
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
class AsVestingError r where Source #
Minimal complete definition
Methods
_VestingError :: Prism' r VestingError Source #
_VContractError :: Prism' r ContractError Source #
_InsufficientFundsError :: Prism' r (Value, Value, Value) Source #
Instances
AsVestingError VestingError Source # | |
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
vestingContract :: VestingParams -> Contract () VestingSchema VestingError () Source #
validate :: VestingParams -> () -> () -> ScriptContext -> Bool Source #
vestingScript :: VestingParams -> Validator Source #