Watch the video walkthrough for this topic in the Video Tutorials section.
0x0000000000000000000000000000000000001007
The distribution precompile gives EVM access to the Cosmos SDK distribution module. Smart contracts can use it to manage staking rewards, validator commissions, and withdrawal addresses. DeFi dApps that need to handle staking rewards programmatically depend on this precompile.
Key features
- Withdraw delegation rewards from validators.
- Withdraw earned commission (validators only).
- Withdraw rewards from multiple validators in one batch call.
- Set a custom withdrawal address.
- Query detailed reward information with
rewards(address).
Interface overview
Setup
Install ethers and the Sei EVM bindings, which include the precompile address and ABI:Events
The distribution precompile emits events for all state-changing operations. Off-chain services can use these events to track reward distributions and configuration changes.WithdrawAddressSet
Emitted when a delegator changes their reward withdrawal address.delegator(indexed): The EVM address of the delegator who changes the settingwithdrawAddr: The new address that receives the rewards
DelegationRewardsWithdrawn
Emitted when a delegator withdraws rewards from a single validator.delegator(indexed): The EVM address of the delegator who withdraws the rewardsvalidator: The Sei validator address (for example, “seivaloper1…”)amount: The amount of rewards withdrawn (in usei, 6-decimal precision)
MultipleDelegationRewardsWithdrawn
Emitted when a delegator withdraws rewards from multiple validators in a single transaction.delegator(indexed): The EVM address of the delegator who withdraws the rewardsvalidators: An array of Sei validator addressesamounts: An array of reward amounts, one for each validator (in usei, 6-decimal precision)
ValidatorCommissionWithdrawn
Emitted when a validator operator withdraws their earned commission.validator(indexed): The Sei validator addressamount: The commission amount withdrawn (in usei, 6-decimal precision)
Event amounts: All event amounts use 6-decimal precision (usei). This matches the withdrawn token amounts. In contrast, the
rewards() query returns 18-decimal precision.Transaction methods
setWithdrawAddress
Sets the withdrawal address for staking rewards. By default, rewards go to the delegator’s address, but you can change it.withdrawAddr: The EVM address that receives future rewards
withdrawDelegationRewards
Withdraws accumulated rewards from a specific validator.validator: The Sei validator address (for example, “seivaloper1…”)
withdrawMultipleDelegationRewards
Withdraws rewards from multiple validators in a single transaction.validators: An array of Sei validator addresses
Batch efficiency: One
withdrawMultipleDelegationRewards call is significantly more gas-efficient than multiple individual calls, especially when you withdraw from 3 or more validators.withdrawValidatorCommission
Lets a validator withdraw its earned commission. Only the validator operator address can call this method.Query methods
rewards
Returns the reward information for a delegator across all validators.Understanding decimal precision
Because of how the Cosmos SDK tracks rewards, the distribution precompile uses different decimal precision for queries and withdrawals:Why different precisions?
-
Pending rewards (18 decimals): The Cosmos SDK tracks pending rewards as
DecCoins(decimal coins) with 18-decimal precision. This gives higher accuracy while rewards accumulate. -
Withdrawn rewards (6 decimals): When rewards are withdrawn, they are converted to
sdk.Coins(usei) with 6-decimal precision. This matches Sei’s native token units.
Conversion helper functions
When you reconcile pending rewards with withdrawals, remember the 12-decimal difference (10^12 factor) between query results and withdrawal amounts.
Practical examples
DeFi yield aggregator
Validator commission manager
Error handling
This example shows common error scenarios and how to handle them:Gas optimization tips
- To withdraw from multiple validators, use one
withdrawMultipleDelegationRewardsbatch call. - Query rewards before you withdraw, to avoid unnecessary transactions.
- Set the withdrawal address once. Avoid repeated
setWithdrawAddresscalls. - Withdraw validator commission when the amounts are substantial.
Integration patterns
Auto-compounding strategy
Treasury management
View the complete distribution precompile ABI at the Sei Chain v6.6.1 snapshot.