Safe Haskell | None |
---|---|
Language | Haskell2010 |
A basic governance contract in Plutus.
Synopsis
- contract :: AsGovError e => Params -> Contract () Schema e ()
- proposalContract :: AsGovError e => Params -> Address -> Proposal -> Contract () EmptySchema e ()
- data Params = Params {
- baseTokenName :: TokenName
- initialHolders :: [Address]
- requiredVotes :: Integer
- data Proposal = Proposal {
- newLaw :: Law
- tokenName :: TokenName
- votingDeadline :: POSIXTime
- type Schema = Endpoint "new-law" Law .\/ Endpoint "add-vote" (Address, TokenName, Bool)
- mkTokenName :: TokenName -> Integer -> TokenName
- typedValidator :: Params -> TypedValidator GovernanceMachine
- mkValidator :: Params -> ValidatorType GovernanceMachine
- data GovState = GovState {}
- newtype Law = Law {
- unLaw :: BuiltinByteString
- data Voting = Voting {}
- votingValue :: MintingPolicyHash -> TokenName -> Value
- data GovError
- covIdx :: CoverageIndex
- covIdx' :: CoverageIndex
- getLaw :: GovState -> BuiltinByteString
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 -> Address -> Proposal -> Contract () EmptySchema e () Source #
The contract for proposing changes to a law.
The governace contract parameters.
Params | |
|
Instances
Lift DefaultUni Params Source # | |
Defined in Plutus.Contracts.Governance | |
Typeable DefaultUni Params Source # | |
Defined in Plutus.Contracts.Governance |
The parameters for the proposal contract.
Proposal | |
|
Instances
type Schema = Endpoint "new-law" Law .\/ Endpoint "add-vote" (Address, TokenName, Bool) Source #
The endpoints of governance contracts are
new-law
to create a new law and distribute voting tokensadd-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 #
Instances
Instances
Eq Law Source # | |
Show Law Source # | |
Generic Law Source # | |
FromJSON Law Source # | |
Defined in Plutus.Contracts.Governance parseJSON :: Value -> Parser Law parseJSONList :: Value -> Parser [Law] | |
ToJSON Law Source # | |
Defined in Plutus.Contracts.Governance | |
ToData Law Source # | |
Defined in Plutus.Contracts.Governance toBuiltinData :: Law -> BuiltinData | |
FromData Law Source # | |
Defined in Plutus.Contracts.Governance fromBuiltinData :: BuiltinData -> Maybe Law | |
UnsafeFromData Law Source # | |
Defined in Plutus.Contracts.Governance unsafeFromBuiltinData :: BuiltinData -> Law | |
Lift DefaultUni Law Source # | |
Defined in Plutus.Contracts.Governance | |
Typeable DefaultUni Law Source # | |
Defined in Plutus.Contracts.Governance | |
type Rep Law Source # | |
Defined in Plutus.Contracts.Governance |
Instances
votingValue :: MintingPolicyHash -> TokenName -> Value Source #