Stake Validator

Detailed guide on stake validators including overview, use cases, and example Anvil API interactions for managing stake rewards.

Overview

Stake validators (also called reward validators) control access to staking rewards associated with script-controlled stake addresses. They determine when and how accumulated rewards can be withdrawn, enabling programmatic control over staking operations.

circle-info

TERMINOLOGY NOTE

In official Cardano terminology, these are called Stake Validators with the script purpose Rewarding. However, the Anvil API uses purpose: "withdraw" in the transaction structure. This documentation uses the terms interchangeably.

Real-world Use Cases

  • DAO Treasury Management: Automated governance of reward withdrawals based on DAO votes

  • Delegated Staking Pools: Programmatically manage stake delegation and reward distribution

  • Reward Distribution Systems: Automate the fair distribution of staking rewards among multiple parties

  • Conditional Reward Access: Restrict reward withdrawals based on time, market conditions, or other parameters

Required Fields for Reward Withdrawals

circle-info

For stake validators, you need two key components in your transaction:

  1. scriptInteractions: Specifies the validator hash, purpose ("withdraw" in Anvil API), and redeemer

  2. withdrawals: An array specifying which stake address to withdraw rewards from

The validator hash must match the script that controls the stake address you're withdrawing from.

{
  "scriptInteractions": [{ ... }],
  "withdrawals": ["stake_script_address_here"]
}

Note: The stake address must be registered and have delegated ADA to accumulate rewards before withdrawal can occur.

circle-exclamation

Stake Validator API Interaction Example

Use the below examples to build transactions that interact with withdraw validators.

If you are unfamiliar with the Anvil API transaction builder, review the Transaction Overview guide first.

1. Registering a Script-Controlled Stake Address

2. Withdrawing Rewards from a Script-Controlled Stake Address

Important Technical Notes

Stake Address Lifecycle

  1. Registration: Script-controlled stake addresses must be registered before they can receive rewards

  2. Delegation: After registration, ADA must be delegated to a stake pool

  3. Rewards Accrual: Rewards begin accruing after 2-3 epochs (10-15 days)

  4. Withdrawal: Rewards can be withdrawn using the withdraw validator

Security Considerations

  • The redeemer is the only way to pass parameters to the validator

  • Include proper authorization checks in your validator logic

  • Consider time-locking or multi-signature requirements for high-value treasuries

Performance Optimization

  • Consider batching multiple reward withdrawals in a single transaction when possible

See Examples

Last updated

Was this helpful?