Cardano Governance: Delegate to DRep, Vote
Scalus TxBuilder provides comprehensive support for Cardano’s Conway era governance features. ADA holders can participate in on-chain governance by delegating voting power to Delegated Representatives (DReps) or by becoming DReps themselves.
Governance operations are part of the Conway era upgrade. These features enable decentralized decision-making for the Cardano protocol.
Delegating Voting Power to DReps
Delegate your voting power to a Delegated Representative (DRep) to participate in Cardano governance decisions.
val drep = DRep.KeyHash(drepKeyHash)
val tx = TxBuilder(env)
.delegateVoteToDRep(stakeAddress, drep)
.complete(provider, sponsorAddress)
.build()DRep Types
Scalus supports multiple DRep delegation options:
DRep.KeyHash(keyHash) // Specific DRep
DRep.ScriptHash(scriptHash) // Script-based DRep
DRep.Abstain // Abstain from voting
DRep.NoConfidence // Vote no confidenceScript-based DReps enable programmatic voting aligned with community policies or institutional strategies, allowing automated governance participation.
Registering Stake Keys and Delegating to DRep
Combine stake registration and DRep delegation in a single transaction:
val drep = DRep.KeyHash(drepKeyHash)
val deposit = Coin.ada(2)
val tx = TxBuilder(env)
.registerAndDelegateVoteToDRep(stakeAddress, drep, deposit)
.complete(provider, sponsorAddress)
.build()This requires the standard 2 ADA stake registration deposit, which is refundable upon deregistration.
Delegating to Stake Pool and DRep
Delegate both your staking power (to a stake pool) and voting power (to a DRep) simultaneously:
val poolId = PoolKeyHash.fromHex("pool1...")
val drep = DRep.KeyHash(drepKeyHash)
val tx = TxBuilder(env)
.delegateToPoolAndDRep(stakeAddress, poolId, drep)
.complete(provider, sponsorAddress)
.build()Post-Chang Era: Delegating to a DRep is required to withdraw staking rewards. See Staking Operations for more details.
Registering and Delegating to Both
Register your stake key and delegate to both a stake pool and DRep in one efficient transaction:
val poolId = PoolKeyHash.fromHex("pool1...")
val drep = DRep.KeyHash(drepKeyHash)
val deposit = Coin.ada(2)
val tx = TxBuilder(env)
.registerAndDelegateToPoolAndDRep(stakeAddress, poolId, drep, deposit)
.complete(provider, sponsorAddress)
.build()Combining operations saves transaction fees and simplifies the user experience.
Becoming a Delegated Representative (DRep)
Registering as a DRep
To become a DRep and accept voting delegation, you need to register with a stake address:
val drepCredential = Credential.KeyHash(yourKeyHash)
val deposit = Coin.ada(500)
val anchor = Some(Anchor(
url = "https://example.com/drep-metadata.json",
dataHash = metadataHash
))
val tx = TxBuilder(env)
.registerDRep(drepCredential, deposit, anchor)
.complete(provider, sponsorAddress)
.build()DRep registration requires a 500 ADA deposit, which is significantly higher than the stake registration deposit. This deposit is refundable upon deregistration.
The anchor parameter is optional but recommended. It should point to metadata describing your governance positions, credentials, and voting philosophy.
Updating DRep Metadata
Update your DRep metadata to reflect changes in your governance positions or credentials:
val newAnchor = Some(Anchor(
url = "https://example.com/updated-metadata.json",
dataHash = newMetadataHash
))
val tx = TxBuilder(env)
.updateDRep(drepCredential, newAnchor)
.complete(provider, sponsorAddress)
.build()Unregistering as DRep
Unregister your DRep credential and reclaim your 500 ADA deposit:
val tx = TxBuilder(env)
.unregisterDRep(drepCredential, Coin.ada(500))
.complete(provider, sponsorAddress)
.build()