Governance Transactions
Transactions for participating in Cardano's on-chain governance
In CIP-1694, Cardano's on-chain governance system was proposed to allow the community to vote on proposals and protocol updates. This system is designed to be decentralized and transparent, allowing the community to have a say in the future of the network.
In the code snippet, you will find txBuilder
, which is an instance of MeshTxBuilder
, a powerful low-level APIs that allows you to build transactions. Learn how to initialize MeshTxBuilder.
This page list the governance transactions that can be created using the Mesh SDK.
Vote Delegation
Any wallet can delegate its voting power to another DRep. This is done by creating a vote delegation certificate and submitting it to the blockchain.
First we need to get the wallet information. This includes the UTXOs, the reward address, and the change address.
Next we need to select the UTXOs to use to pay for the transaction. We will select the UTXOs that have at least 5 ADA. Though the fee is less than 1 ADA.
We can now start building the transaction. We will add the selected UTXOs as inputs to the transaction. We will also add the vote delegation certificate to the transaction. The vote delegation certificate requires the DRep ID of the DRep to delegate to and the reward address of the delegator. Note that we would need to have at least 5 ADA for the certificate delegation, in the selectUtxosFrom
we will configure 10 ADA as threshold buffer.
Finally we can build, sign the transaction and submit it to the blockchain.
The transaction will be submitted to the blockchain and the DRep will be registered. The deposit will be taken from the DRep owner and the DRep will be added to the list of registered DReps.
Delegate your voting power to another DRep
Connect wallet to run this demo
DRep Registration
In Voltaire, stake credentials can delegate their stake to Decentralized Representatives (DReps) for voting, in addition to the current delegation to stake pools for block production. This DRep delegation will work similarly to the current stake delegation process, using on-chain certificates. Registering as a DRep will also follow the same process as stake registration.
However, registered DReps need to vote regularly to remain active. If a DRep does not vote for a set number of epochs (defined by the new protocol parameter, drepActivity), they are considered inactive and will not count towards the active voting stake. To become active again, DReps need to vote on governance actions or submit a DRep update certificate within the drepActivity period.
A DRep registration certificates include:
- a DRep ID
- a deposit
- an optional anchor
An anchor is a pair of:
- a URL to a JSON payload of metadata
- a hash of the contents of the metadata URL
First we need to get the DRep ID of the DRep we want to register. We can do this by calling getDRep
method on the wallet. This will return the DRep object which contains the DRep ID.
Next we need to get the hash of the anchor. We can do this by calling the getMeshJsonHash
function. This function fetches the anchor from the given URL and returns the hash of the anchor.
We can now build the transaction by adding the DRep registration certificate to the transaction. We also need to add the change address and the selected UTxOs to the transaction. Note that the deposit for registering a DRep is 500 ADA, we would set 505 ADA as UTxO selection threshold.
Finally we can sign the transaction and submit it to the blockchain.
The transaction will be submitted to the blockchain and the DRep will be registered. The deposit will be taken from the DRep owner and the DRep will be added to the list of registered DReps.
Register a DRep certificate and pay the deposit
Connect wallet to run this demo
DRep Update
Updating a DRep is similar to registering.
We build the transaction by adding the DRep update certificate to the transaction, providing the change address and the UTxOs needed for the transaction's fees.
This transaction is an example of a successful DRep update for DRep ID.
Update DRep metadata
Connect wallet to run this demo
DRep Retirement
A DRep is retired right away when the blockchain accepts a retirement certificate. The deposit is refunded immediately as part of the transaction that submits the retirement certificate, just like how deposits are returned when a stake credential is unregistered.
First we need to get the DRep ID of the DRep we want to retire. We can do this by calling getDRep
method on the wallet. This will return the DRep object which contains the DRep ID.
We then need to initialize the transaction builder by creating a new instance of MeshTxBuilder
. We need to pass the blockchain provider to the constructor.
We can now build the transaction by adding the UTxOs as inputs to the transaction and adding the DRep deregistration certificate to the transaction.
Finally we can sign the transaction and submit it to the blockchain.
The transaction will be submitted to the blockchain and the DRep will be retired. The deposit will be refunded to the DRep owner.
Retire a DRep certificate amd return the deposit
Connect wallet to run this demo
Vote
Each vote transaction consists of the following:
- a governance action ID
- a role - constitutional committee member, DRep, or SPO
- a governance credential witness for the role
- an optional anchor (as defined above) for information that is relevant to the vote
- a 'Yes'/'No'/'Abstain' vote
First, we get the DRep ID from the wallet, the DRep ID voting for this governance action.
Then we get the utxos and the change address from the wallet.
We then create the vote transaction using the vote()
function.
The vote()
takes 3 parameters:
- voter — The voter, can be a Constitutional Commitee, a DRep or a StakePool
- govActionId — The transaction hash and transaction id of the governance action
- votingProcedure — The voting kind (Yes, No, Abstain) with an optional anchor
Check the full documentation or the source code for more details.
Finally, we sign the transaction and submit it to the blockchain.
You can check here a successful vote transaction for this governance action.
Here is another example of a vote transaction:
And another example of a vote transaction with a Plutus script and a redeemer:
Vote on a governance action
Connect wallet to run this demo