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

Plutus.Contracts.Crowdfunding

Description

Crowdfunding contract implemented using the [[Plutus]] interface. This is the fully parallel version that collects all contributions in a single transaction. This is, of course, limited by the maximum number of inputs a transaction can have.

Synopsis

Campaign parameters

data Campaign Source #

A crowdfunding campaign.

Constructors

Campaign 

Fields

Instances

Instances details
Show Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Generic Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Associated Types

type Rep Campaign :: Type -> Type Source #

ToJSON Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

FromJSON Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

ToSchema Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Lift DefaultUni Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Typeable DefaultUni Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

type Rep Campaign Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

type Rep Campaign = D1 ('MetaData "Campaign" "Plutus.Contracts.Crowdfunding" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'False) (C1 ('MetaCons "Campaign" 'PrefixI 'True) (S1 ('MetaSel ('Just "campaignDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime) :*: (S1 ('MetaSel ('Just "campaignCollectionDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime) :*: S1 ('MetaSel ('Just "campaignOwner") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PaymentPubKeyHash))))

type CrowdfundingSchema = Endpoint "schedule collection" () .\/ Endpoint "contribute" Contribution Source #

crowdfunding :: Campaign -> Contract () CrowdfundingSchema ContractError () Source #

The crowdfunding contract for the Campaign.

theCampaign :: POSIXTime -> Campaign Source #

A sample campaign

Functionality for campaign contributors

contribute :: Campaign -> Promise () CrowdfundingSchema ContractError () Source #

The "contribute" branch of the contract for a specific Campaign. Exposes an endpoint that allows the user to enter their public key and the contribution. Then waits until the campaign is over, and collects the refund if the funding was not collected.

newtype Contribution Source #

Constructors

Contribution 

Fields

Instances

Instances details
Eq Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Show Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Generic Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

Associated Types

type Rep Contribution :: Type -> Type Source #

ToJSON Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

FromJSON Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

ToSchema Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

ToArgument Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

type Rep Contribution Source # 
Instance details

Defined in Plutus.Contracts.Crowdfunding

type Rep Contribution = D1 ('MetaData "Contribution" "Plutus.Contracts.Crowdfunding" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'True) (C1 ('MetaCons "Contribution" 'PrefixI 'True) (S1 ('MetaSel ('Just "contribValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))

Functionality for campaign owners

scheduleCollection :: Campaign -> Promise () CrowdfundingSchema ContractError () Source #

The campaign owner's branch of the contract for a given Campaign. It watches the campaign address for contributions and collects them if the funding goal was reached in time.

campaignAddress :: Campaign -> ValidatorHash Source #

The address of a [[Campaign]]

Validator script

contributionScript :: Campaign -> Validator Source #

The validator script that determines whether the campaign owner can retrieve the funds or the contributors can claim a refund.

mkValidator :: Campaign -> PaymentPubKeyHash -> CampaignAction -> ScriptContext -> Bool Source #

The validator script is of type CrowdfundingValidator, and is additionally parameterized by a Campaign definition. This argument is provided by the Plutus client, using applyCode. As a result, the Campaign definition is part of the script address, and different campaigns have different addresses. The Campaign{..} syntax means that all fields of the Campaign value are in scope (for example campaignDeadline in l. 70).

mkCampaign :: POSIXTime -> POSIXTime -> Wallet -> Campaign Source #

Construct a Campaign value from the campaign parameters, using the wallet's public key.

data CampaignAction Source #

Action that can be taken by the participants in this contract. A value of CampaignAction is provided as the redeemer. The validator script then checks if the conditions for performing this action are met.

Constructors

Collect 
Refund 

collectionRange :: Campaign -> POSIXTimeRange Source #

The POSIXTimeRange during which the funds can be collected

refundRange :: Campaign -> POSIXTimeRange Source #

The POSIXTimeRange during which a refund may be claimed

Traces

startCampaign :: EmulatorTrace (ContractHandle () CrowdfundingSchema ContractError) Source #

Call the "schedule collection" endpoint and instruct the campaign owner's wallet (wallet 1) to start watching the campaign address.

makeContribution :: Wallet -> Value -> EmulatorTrace () Source #

Call the "contribute" endpoint, contributing the amount from the wallet

successfulCampaign :: EmulatorTrace () Source #

Run a successful campaign with contributions from wallets 2, 3 and 4.