Mesh LogoMesh

Governance Transactions

Register as a DRep, delegate your vote, vote on actions and submit proposals with TxBuilder.

Overview

Governance uses certificates, votes and proposals, passed as parts to builder.build(). A DRep (delegated representative) votes on behalf of the stake delegated to it. Use this page to act as a DRep, vote or propose.

A certificate changes what the chain records, such as a DRep's registration or a vote delegation. Every certificate is in Certificates.

The DRep and proposal deposits are protocol parameters that Mesh's Protocol type does not carry, so the builder takes them from its deposits option, or from deposit on a part. Without them the build throws MISSING_PARAMETER (see Deposits).

Examples stop at build(): call built.sign() and built.submit() as in Transaction Basics. They use wallet and provider from there, and these names, which your application defines:

  • builder - a TxBuilder with the deposits of your network: new TxBuilder({ network: "preprod", provider, deposits: { drepDeposit: 500_000_000n, govActionDeposit: 100_000_000_000n } })
  • rewardAddress - your stake address (stake_test1... on a test network, stake1... on mainnet)
  • drepId - a DRep id (drep1...)
  • anchor - { url, dataHash }, where a metadata or rationale file is published. hashDrepAnchor(json) makes the hash.
  • actionTxHash - the transaction hash of a governance action
TaskPartSigned by
Register, update or retire a DRepcertificate.drepRegistration, drepUpdate, drepDeregistrationthe DRep key
Delegate your votecertificate.voteDelegationthe stake key
Authorise a hot key or resign from the committeecertificate.committeeHotAuth, committeeColdResignthe cold key
Vote on an actionvotethe voter's key
Submit a proposalproposal.info, proposal.treasuryWithdrawals and othersthe payer

Manage a DRep

  • Register: certificate.drepRegistration. anchor is optional.
  • Update: certificate.drepUpdate, with the anchor of the changed file. Leave anchor out to clear it.
  • Retire: certificate.drepDeregistration, which refunds the deposit.
  • Deposit: drepDeposit from the builder, or deposit and refund on the part. See Deposits.
  • Signing: the DRep key signs, and a browser wallet must be connected with the CIP-95 extension. See Who Signs.
import { certificate } from "@meshsdk/core";

const built = await builder.build(
  certificate.drepRegistration({ drep: drepId, anchor }),
  { payer: wallet },
);

Delegate Your Vote

A registered stake key delegates its voting power with certificate.voteDelegation. drep is a DRep id, "alwaysAbstain" or "alwaysNoConfidence". To delegate to a pool and a DRep together, use certificate.stakeAndVoteDelegation. The combined builders are in Delegation.

import { certificate } from "@meshsdk/core";

const built = await builder.build(
  certificate.voteDelegation({ stake: rewardAddress, drep: drepId }),
  { payer: wallet },
);

Vote on an Action

All votes of one voter go in one vote part. vote is "yes", "no" or "abstain", and anchor points to your rationale. A voter can also be { pool } or { committee }. A script DRep adds a witness.

import { vote } from "@meshsdk/core";

const built = await builder.build(
  vote({
    voter: { drep: drepId },
    votes: [
      { action: { txHash: actionTxHash, index: 0 }, vote: "yes", anchor },
    ],
  }),
  { payer: wallet },
);

Submit a Proposal

proposal.info is a governance action with no effect on the chain, used as a poll. The deposit is govActionDeposit, or deposit on the part. It is paid from the payer's UTxOs and goes back to rewardAccount when the action ends.

import { proposal } from "@meshsdk/core";

const built = await builder.build(
  proposal.info({ rewardAccount: rewardAddress, anchor }),
  { payer: wallet },
);

Propose Other Actions

Each action takes rewardAccount and anchor, plus its own fields:

  • treasuryWithdrawals - withdrawals, lovelace by receiving reward address
  • parameterChange - updates
  • hardForkInitiation - protocolVersion
  • updateCommittee - quorum, and add and remove for members
  • newConstitution - constitution
  • noConfidence - nothing more

parameterChange and treasuryWithdrawals run the constitution's guardrail script. Leave guardrail out and the build adds it: the guardrail your provider's fetchConstitution reports, or, when the provider cannot say, the one of mainnet, preprod and preview, the same script on all three. On another network it is added only when the provider reports it. The guardrail is a Plutus script, so the build also puts up collateral and evaluates it. A constitution that names a guardrail Mesh does not hold is UNRESOLVED: pass that script as guardrail. guardrail: null builds the proposal without one. Every action except info and treasuryWithdrawals takes previous: { txHash, index }, the action it follows.

import { proposal } from "@meshsdk/core";

const built = await builder.build(
  proposal.treasuryWithdrawals({
    rewardAccount: rewardAddress,
    anchor,
    withdrawals: { [rewardAddress]: 50_000_000_000n },
  }),
  { payer: wallet },
);

On this page