Guides
Delegations#
API Overview#
Delegations in Cardano enable users to participate in the network without running infrastructure themselves. Stake pool delegations allow users to earn rewards by supporting the network's security, while DRep delegations empower users to participate in governance decisions. The Anvil API simplifies implementing both delegation types through a unified interface, letting applications offer these essential features without complex blockchain interactions.
| Type | Purpose | Certificate Created |
|---|---|---|
pool |
Delegate to stake pool for rewards | StakeDelegation |
drep |
Delegate to DRep for governance | VoteDelegation |
API Endpoint#
URL: https://preprod.api.ada-anvil.app/v2/services/transactions/build
Method: POST
Headers: Content-Type: application/json, x-api-key: YOUR_API_KEY
Request Format#
{
"changeAddress": "addr_test1...",
"delegations": [
{
"type": "pool" | "drep",
"address": "addr_test1...",
"keyHash": "pool_id_or_drep_id"
}
]
}Parameters#
| Parameter | Description | Required |
|---|---|---|
type |
Either "pool" or "drep" |
Yes |
address |
User's full address | Yes |
keyHash |
Pool ID or DRep ID | Yes |
changeAddress |
Address for change | Yes |
utxos |
Array of UTXOs in CBOR hex format | Yes (in production) |
Implementation Guides#
Delegate to a DRepDRep delegation with Anvil API
Delegate to a Stake PoolStake pool delegation with Anvil API
Transaction Workflow#
- Prepare: Include delegation certificates in transaction
- Build & Sign: Process transaction with proper certificates and signatures
- Submit: Send to network (changes effective after current epoch)
Best Practices#
- Verification: Confirm pool/DRep IDs before delegation
- Testing: Use testnet before mainnet operations
- Error Handling: Implement robust handling for:
- Invalid address formats
- Unknown pool/DRep IDs
- Insufficient funds
- Missing signers