skill·2026-03-09·6 min read

Aleo Staking & Delegation

Aleo Staking & Delegation

1. Overview

All staking, delegation, and credit transfer operations on Aleo are handled by the credits.aleo system program. This skill covers the complete function reference, staking mechanics, and operational workflows.

Version & Canonical Syntax

  • Target: Leo compiler >= 3.5.0 and current credits.aleo interface on active Aleo networks
  • Canonical syntax: CLI examples assume leo execute credits.aleo <function> ... --broadcast command forms
  • Amount formatting: Credit amounts are expressed in microcredits as u64 literals
  • When docs conflict: Prefer current network docs and leo execute credits.aleo --help output

2. Key Concepts & Glossary

  • Validator: A node that participates in consensus. Must self-bond a minimum of 100 credits and attract 10,000,000 total delegated credits to join the committee.
  • Delegator/Staker: A user who bonds credits to a validator. Minimum 10,000 credits per delegation.
  • Committee: The set of validators actively participating in consensus.
  • Commission: A percentage of rewards taken by the validator. Set once when first bonding and immutable thereafter.
  • Withdrawal Address: The address authorized to unbond/withdraw credits. Can be different from the staking address.
  • Unbonding Period: 360 blocks (~1 hour) between requesting unbond and claiming credits.
  • credits.aleo: The system program that manages all credit operations.

3. Staking Parameters

ParameterValue
Minimum validator self-bond100 credits
Minimum total delegation to join committee10,000,000 credits
Minimum delegation per delegator10,000 credits
Maximum delegators per validator100,000
Unbonding period360 blocks (~1 hour)
Commission rateSet once, immutable

4. credits.aleo Function Reference

Credit Transfer Functions

FunctionDescriptionExample CLI
transfer_publicTransfer public credits between addressesleo execute credits.aleo transfer_public "aleo1receiver..." "1000000u64"
transfer_privateTransfer private credits (record-to-record)leo execute credits.aleo transfer_private <record> "aleo1receiver..." "1000000u64"
transfer_public_to_privateConvert public to private credits (shielding)leo execute credits.aleo transfer_public_to_private "aleo1receiver..." "1000000u64"
transfer_private_to_publicConvert private to public credits (unshielding)leo execute credits.aleo transfer_private_to_public <record> "aleo1receiver..." "1000000u64"
joinCombine two credit records into oneleo execute credits.aleo join <record1> <record2>
splitSplit one credit record into twoleo execute credits.aleo split <record> "500000u64"

Fee Functions

FunctionDescription
fee_publicPay transaction fee from public balance
fee_privatePay transaction fee from a private credit record

Staking Functions

FunctionDescription
bond_validatorValidator self-bond (min 100 credits)
bond_publicDelegate credits to a validator (min 10,000 credits)
unbond_publicRequest unbonding (starts 360-block timer)
claim_unbond_publicClaim credits after unbonding period
set_validator_stateToggle validator open/closed to delegators

5. Delegation Workflow

Step 1: Bond (Delegate) Credits

bash
# Delegate 10,000 credits to a validator
leo execute credits.aleo bond_public \
    "aleo1validator_address..." \
    "aleo1your_withdrawal_address..." \
    "10000000000u64" \
    --broadcast
# Note: amount is in microcredits (10,000 credits = 10,000,000,000 microcredits)

Step 2: Check Delegation Status

bash
# Query the bonded mapping
leo query program credits.aleo --mapping-value bonded "aleo1your_address..."

Step 3: Unbond Credits

bash
# Request unbonding (starts 360-block timer)
leo execute credits.aleo unbond_public "10000000000u64" --broadcast

Step 4: Wait for Unbonding Period

bash
# Check unbonding status
leo query program credits.aleo --mapping-value unbonding "aleo1your_address..."

# Check current block height
leo query block --latest

Step 5: Claim After Unbonding

bash
# Claim unbonded credits (only after 360 blocks have passed)
leo execute credits.aleo claim_unbond_public --broadcast

6. Validator Setup Workflow

bash
# 1. Self-bond as a validator (minimum 100 credits)
leo execute credits.aleo bond_validator \
    "aleo1your_withdrawal_address..." \
    "100000000u64" \
    10u8 \
    --broadcast
# 10u8 = 10% commission rate (immutable after this call!)

# 2. Open for delegations
leo execute credits.aleo set_validator_state true --broadcast

# 3. Check committee membership
leo query program credits.aleo --mapping-value committee "aleo1your_address..."

7. On-Chain Mappings for Monitoring

MappingKeyValueDescription
committeevalidator addresscommittee infoActive validators
delegatedvalidator addresstotal delegatedTotal credits delegated to validator
bondedstaker addressbond infoIndividual bond amounts
unbondingstaker addressunbond infoPending unbond requests
withdrawstaker addresswithdrawal addressWithdrawal address mapping
metadatavalidator addressmetadataValidator metadata

Query example:

bash
leo query program credits.aleo --mapping-value committee "aleo1validator..."
leo query program credits.aleo --mapping-value bonded "aleo1staker..."
leo query program credits.aleo --mapping-value unbonding "aleo1staker..."

8. Common Errors and Fixes

ErrorCauseFix
Bonding less than 10,000 creditsTransaction rejectedBond at least 10,000 credits (10,000,000,000 microcredits)
Using credits instead of microcreditsWrong amount (1Mx too small)1 credit = 1,000,000 microcredits
Claiming before 360 blocksTransaction rejectedWait for unbonding period to complete
Wrong withdrawal addressCannot unbondEnsure withdrawal address matches when bonding
Changing commission rateImpossibleCommission is immutable after bond_validator
Delegating to closed validatorTransaction rejectedCheck set_validator_state first

9. Security Notes

  • Staking is public — all delegation amounts and validators are visible on-chain
  • Withdrawal address controls unbonding — protect this key carefully
  • Commission rate is permanent — choose carefully on first bond_validator
  • Monitor validator uptime — poor performance may affect rewards
  • Never share private keys used for staking

10. Performance Notes

  • Batch status checks using scheduled polling intervals instead of per-block manual queries
  • Cache validator metadata and only refresh committee/delegated mappings when new blocks arrive
  • Keep delegation workflows idempotent in automation so retries do not emit duplicate transactions
  • Prefer explicit unbond tracking keyed by height to avoid unnecessary failed claim_unbond_public calls
  • Credit transfers and fees: see aleo_smart_contracts for credits.aleo internals
  • Backend SDK for staking: see aleo_backend
  • Deploy staking dashboards: see aleo_frontend
  • Complete recipes: see aleo_cookbook

12. Agent SOP: Staking Workflow

  1. Normalize units first: convert user-facing credits into u64 microcredits before building any command
  2. Validate prerequisites: ensure validator state and withdrawal address assumptions are correct
  3. Execute one staking action at a time and record transaction IDs for auditability
  4. Query on-chain mappings after each step to confirm state transitions
  5. Enforce unbond timing by checking block height before any claim attempt
  6. On failure: map to the error matrix above and retry only after the underlying cause is resolved

Sources