Skip to main content

Vote & Propose

With a registered DRep (or a committee hot credential or a pool key), what remains is using it: casting votes on live actions, and submitting actions of your own. The seven action types and their thresholds are on the concept page; this page is the code.

Vote on an action

Registered DReps (and CC members and SPOs, for their action types) cast Yes / No / Abstain votes against a specific governance action, identified by the transaction that created it and its index.

import { DRep, GovernanceAction, TransactionHash, VotingProcedures } from "@evolution-sdk/evolution"

declare const drep: DRep.DRep
const voter = new VotingProcedures.DRepVoter({ drep })

declare const govActionTxHash: TransactionHash.TransactionHash
const govActionId = new GovernanceAction.GovActionId({
transactionId: govActionTxHash,
govActionIndex: 0n,
})

const procedure = new VotingProcedures.VotingProcedure({
vote: VotingProcedures.yes(), // or .no() / .abstain()
anchor: null,
})

const votingProcedures = VotingProcedures.singleVote(voter, govActionId, procedure)

const tx = await client.newTx().vote({ votingProcedures }).build()
const signed = await tx.sign()
await signed.submit()

The voter can be a DRep, a Constitutional Committee hot credential, or an SPO pool key hash. DRep and CC voters may be script-controlled; the builder detects this and requires a redeemer.

Submit a proposal

Anyone can submit any of the seven action types on-chain with a deposit (govActionDeposit, refunded to your reward account after the vote).

import { Anchor, GovernanceAction, RewardAccount } from "@evolution-sdk/evolution"

declare const governanceAction: GovernanceAction.GovernanceAction
declare const rewardAccount: RewardAccount.RewardAccount
declare const anchor: Anchor.Anchor

const tx = await client
.newTx()
.propose({ governanceAction, rewardAccount, anchor })
.build()

const signed = await tx.sign()
await signed.submit()

Chain multiple .propose(...) calls to submit several actions in one transaction. The deposit is deducted automatically during balancing.

Authoring each action type

Every action takes --governance-action-deposit, --deposit-return-stake-verification-key-file, --anchor-url, --anchor-data-hash, and --out-file. Types that share state (committee, constitution, hard fork, protocol parameters) also need --prev-governance-action-tx-id and --prev-governance-action-index once a prior action of that type was enacted; treasury withdrawals and info actions never do.

  • Treasury withdrawal (create-treasury-withdrawal): adds --funds-receiving-stake-verification-key-file, --transfer <lovelace>, and --constitution-script-hash.
  • Protocol-parameter update (create-protocol-parameters-update): the parameter flags being changed, plus --constitution-script-hash.
  • Constitution / guardrails (create-constitution): --constitution-url, --constitution-hash, and --constitution-script-hash.
  • Update committee (governance action update-committee): --add-cc-cold-verification-key-hash <hash> paired with --epoch <expiry>, --remove-cc-cold-verification-key-hash <hash>, and --threshold <fraction>.
  • No confidence (create-no-confidence): the common flags plus the previous committee-action reference.
  • Hard fork (create-hard-fork): initiates a protocol upgrade.
  • Info (create-info): common flags only, with no on-chain effect.

Next steps

  • Governance operations: committee credential management, governance-state queries, and the CIP-95 wallet API