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

Plutus.Contracts.Governance

Description

A basic governance contract in Plutus.

Synopsis

Documentation

  • When the contract starts it produces a number of tokens that represent voting rights.
  • Holders of those tokens can propose changes to the state of the contract and vote on them.
  • After a certain period of time the voting ends and the proposal is rejected or accepted.

contract :: AsGovError e => Params -> Contract () Schema e () Source #

The main contract for creating a new law and for voting on proposals.

proposalContract :: AsGovError e => Params -> Proposal -> Contract () EmptySchema e () Source #

The contract for proposing changes to a law.

data Params Source #

The governace contract parameters.

Constructors

Params 

Fields

Instances

Instances details
Lift DefaultUni Params Source # 
Instance details

Defined in Plutus.Contracts.Governance

Typeable DefaultUni Params Source # 
Instance details

Defined in Plutus.Contracts.Governance

data Proposal Source #

The parameters for the proposal contract.

Constructors

Proposal 

Fields

Instances

Instances details
Show Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

Generic Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

Associated Types

type Rep Proposal :: Type -> Type Source #

ToJSON Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromJSON Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

UnsafeFromData Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromData Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

ToData Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

Lift DefaultUni Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

Typeable DefaultUni Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep Proposal Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep Proposal = D1 ('MetaData "Proposal" "Plutus.Contracts.Governance" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'False) (C1 ('MetaCons "Proposal" 'PrefixI 'True) (S1 ('MetaSel ('Just "newLaw") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString) :*: (S1 ('MetaSel ('Just "tokenName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TokenName) :*: S1 ('MetaSel ('Just "votingDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTime))))

type Schema = Endpoint "new-law" ByteString .\/ Endpoint "add-vote" (TokenName, Bool) Source #

The endpoints of governance contracts are

  • new-law to create a new law and distribute voting tokens
  • add-vote to vote on a proposal with the name of the voting token and a boolean to vote in favor or against.

mkTokenName :: TokenName -> Integer -> TokenName Source #

Generate a voting token name by tagging on a number after the base token name.

typedValidator :: Params -> TypedValidator GovernanceMachine Source #

mkValidator :: Params -> ValidatorType GovernanceMachine Source #

data GovState Source #

Instances

Instances details
Show GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

Generic GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

Associated Types

type Rep GovState :: Type -> Type Source #

ToJSON GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromJSON GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

UnsafeFromData GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromData GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

ToData GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

Lift DefaultUni GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

Typeable DefaultUni GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep GovState Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep GovState = D1 ('MetaData "GovState" "Plutus.Contracts.Governance" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'False) (C1 ('MetaCons "GovState" 'PrefixI 'True) (S1 ('MetaSel ('Just "law") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 BuiltinByteString) :*: (S1 ('MetaSel ('Just "mph") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MintingPolicyHash) :*: S1 ('MetaSel ('Just "voting") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Voting)))))

data Voting Source #

Constructors

Voting 

Instances

Instances details
Show Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

Generic Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

Associated Types

type Rep Voting :: Type -> Type Source #

ToJSON Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromJSON Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

UnsafeFromData Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromData Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

ToData Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

Lift DefaultUni Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

Typeable DefaultUni Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep Voting Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep Voting = D1 ('MetaData "Voting" "Plutus.Contracts.Governance" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'False) (C1 ('MetaCons "Voting" 'PrefixI 'True) (S1 ('MetaSel ('Just "proposal") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Proposal) :*: S1 ('MetaSel ('Just "votes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TokenName Bool))))

data GovError Source #

Instances

Instances details
Eq GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

Show GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

Generic GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

Associated Types

type Rep GovError :: Type -> Type Source #

ToJSON GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

FromJSON GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

AsContractError GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

AsSMContractError GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep GovError Source # 
Instance details

Defined in Plutus.Contracts.Governance

type Rep GovError = D1 ('MetaData "GovError" "Plutus.Contracts.Governance" "plutus-use-cases-0.1.0.0-sCb7ThsvWbFT6VPXrOzPF" 'False) (C1 ('MetaCons "GovContractError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractError)) :+: C1 ('MetaCons "GovStateMachineError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SMContractError)))