Address: 0x0000000000000000000000000000000000001007
The distribution precompile provides EVM access to Cosmos SDK’s distribution module. Smart contracts can manage staking rewards, validator commissions, and withdrawal addresses. This precompile is essential for DeFi applications that need to handle staking rewards programmatically.
Key Features
- Reward Management: Withdraw delegation rewards from validators
- Commission Handling: Validators can withdraw earned commissions
- Batch Operations: Withdraw from multiple validators efficiently
- Flexible Withdrawals: Set custom withdrawal addresses
- Comprehensive Queries: Access detailed reward information
Interface Overview
Events
The distribution precompile emits events for all state-changing operations, allowing off-chain services to track reward distributions and configuration changes.
WithdrawAddressSet
Emitted when a delegator changes their reward withdrawal address.
Parameters:
delegator (indexed): The EVM address of the delegator changing their settings
withdrawAddr: The new address where rewards will be sent
Example usage:
DelegationRewardsWithdrawn
Emitted when a delegator withdraws rewards from a single validator.
Parameters:
delegator (indexed): The EVM address of the delegator withdrawing rewards
validator: The Sei validator address (e.g., “seivaloper1…”)
amount: The amount of rewards withdrawn (in usei, 6 decimal precision)
Example usage:
MultipleDelegationRewardsWithdrawn
Emitted when a delegator withdraws rewards from multiple validators in a single transaction.
Parameters:
delegator (indexed): The EVM address of the delegator withdrawing rewards
validators: Array of Sei validator addresses
amounts: Array of reward amounts corresponding to each validator (in usei, 6 decimal precision)
Example usage:
ValidatorCommissionWithdrawn
Emitted when a validator operator withdraws their earned commission.
Parameters:
validator (indexed): The Sei validator address
amount: The commission amount withdrawn (in usei, 6 decimal precision)
Example usage:
Event Amounts: All event amounts use 6 decimal precision (usei), matching the actual withdrawn token amounts. This differs from the rewards() query which returns 18 decimal precision.
Transaction Methods
setWithdrawAddress
Sets the withdrawal address for staking rewards. By default, rewards are sent to the delegator’s address, but this can be customized.
Parameters:
withdrawAddr: EVM address where future rewards should be sent
Gas Cost: ~30,000 gas
Example:
withdrawDelegationRewards
Withdraws accumulated rewards from a specific validator.
Parameters:
validator: Sei validator address (e.g., “seivaloper1…”)
Gas Cost: ~50,000-80,000 gas (varies by reward amount)
Example:
withdrawMultipleDelegationRewards
Efficiently withdraws rewards from multiple validators in a single transaction.
Parameters:
validators: Array of Sei validator addresses
Gas Cost: ~40,000 + (30,000 × number of validators)
Example:
Batch Efficiency: Using withdrawMultipleDelegationRewards is significantly more gas-efficient than multiple individual calls, especially when withdrawing from 3+ validators.
withdrawValidatorCommission
Allows validators to withdraw their earned commission. Only callable by the validator operator address.
Parameters: None - the validator is automatically determined from the caller’s associated Sei address.
Gas Cost: ~60,000-90,000 gas
Example:
Validator Only: This method can only be called by the validator’s operator address. The precompile automatically identifies the validator based on the caller’s associated Sei address. If the caller is not a validator operator, the call will fail.
Query Methods
rewards
Retrieves comprehensive reward information for a delegator across all validators.
Data Structures:
Critical: Decimal Precision for RewardsThe rewards() query returns amounts with 18 decimal precision (DecCoins from Cosmos SDK).This is different from the actual withdrawn reward amounts, which use 6 decimal precision (sdk.Coins).To convert pending rewards to SEI for display:Withdrawn rewards are in usei (6 decimals):
Example:
Understanding Decimal Precision
The distribution precompile has different decimal precision for queries vs actual withdrawals due to how rewards are tracked in the Cosmos SDK:
Why Different Precisions?
-
Pending Rewards (18 decimals): The Cosmos SDK tracks pending rewards using
DecCoins (decimal coins) with 18 decimal precision for higher accuracy during reward accumulation.
-
Withdrawn Rewards (6 decimals): When rewards are actually withdrawn, they are converted to
sdk.Coins (usei) with 6 decimal precision to match Sei’s native token units.
Conversion Helper Functions
Note: When reconciling pending rewards with actual withdrawals, be aware of the 12-decimal difference (10^12 factor) between query results and withdrawal amounts.
Practical Examples
DeFi Yield Aggregator
Validator Commission Manager
Error Handling
Common error scenarios and how to handle them:
Gas Optimization Tips
- Batch Operations: Use
withdrawMultipleDelegationRewards for multiple validators
- Check Before Withdraw: Query rewards first to avoid unnecessary transactions
- Set Withdraw Address Once: Avoid repeated
setWithdrawAddress calls
- Commission Timing: Withdraw validator commission when amounts are substantial
Integration Patterns
Auto-Compounding Strategy
Treasury Management
View the complete distribution precompile source code and ABI
here.