Skip to main content
Watch the video walkthrough for this topic in the Video Tutorials section.
Address: 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:
Import both constants where you create the contract instance:

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.
Parameters:
  • delegator (indexed): The EVM address of the delegator who changes the setting
  • withdrawAddr: The new address that receives the rewards
Example usage:

DelegationRewardsWithdrawn

Emitted when a delegator withdraws rewards from a single validator.
Parameters:
  • delegator (indexed): The EVM address of the delegator who withdraws the rewards
  • validator: The Sei validator address (for example, “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 who withdraws the rewards
  • validators: An array of Sei validator addresses
  • amounts: An array of reward amounts, one for 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). 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.
Parameters:
  • withdrawAddr: The EVM address that receives future rewards
Gas cost: ~30,000 gas Example:
Recipient validation: Before you set the withdrawal address, make sure that it is associated and allowed to receive funds. The withdrawal address must be able to receive external funds. The precompile rejects an unassociated EVM address with the error cannot use an unassociated address as withdraw address. Separately, the bank module returns ErrInvalidRecipient for an address that it blocks from receiving external funds. For example, it blocks the cast address of an EVM account that was later associated with a different Sei address.If a withdrawal address that was set earlier becomes invalid, reward withdrawals automatically fall back to the delegator’s own address. An address is invalid when it is blocked or can no longer receive external funds.

withdrawDelegationRewards

Withdraws accumulated rewards from a specific validator.
Parameters:
  • validator: The Sei validator address (for example, “seivaloper1…”)
Gas cost: ~50,000-80,000 gas (varies with the reward amount) Example:

withdrawMultipleDelegationRewards

Withdraws rewards from multiple validators in a single transaction.
Parameters:
  • validators: An array of Sei validator addresses
Gas cost: ~40,000 + (30,000 × number of validators) Example:
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.
Parameters: None. The precompile determines the validator automatically from the caller’s associated Sei address. Gas cost: ~60,000-90,000 gas Example:
Validator only: Call this method only from the validator’s operator address. The precompile identifies the validator automatically from the caller’s associated Sei address. If the caller is not a validator operator, the call fails.

Query methods

rewards

Returns the 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 the Cosmos SDK).In contrast, withdrawn reward amounts 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

Because of how the Cosmos SDK tracks rewards, the distribution precompile uses different decimal precision for queries and withdrawals:

Why different precisions?

  1. 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.
  2. 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

  1. To withdraw from multiple validators, use one withdrawMultipleDelegationRewards batch call.
  2. Query rewards before you withdraw, to avoid unnecessary transactions.
  3. Set the withdrawal address once. Avoid repeated setWithdrawAddress calls.
  4. 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.