Distribution
Solidity Interface & ABI
Distribution.sol is an interface through which Solidity contracts can interact with Cosmos SDK distribution. This is convenient for developers as they don’t need to know the implementation details behind the x/distribution module in the Cosmos SDK. Instead, they can interact with distribution functions using the Ethereum interface they are familiar with.
Interface Distribution.sol
Distribution.solFind the Solidity interface in the evmos/extensions repo.
ABI
Find the ABI in the evmos/extensions repo.
Transactions
setWithdrawAddress/// @dev Change the address, that can withdraw the rewards of a delegator. /// Note that this address cannot be a module account. /// @param delegatorAddress The address of the delegator /// @param withdrawerAddress The address that will be capable of withdrawing rewards for /// the given delegator address function setWithdrawAddress( address delegatorAddress, string memory withdrawerAddress ) external returns (bool success);withdrawDelegatorRewards/// @dev Withdraw the rewards of a delegator from a validator /// @param delegatorAddress The address of the delegator /// @param validatorAddress The address of the validator /// @return amount The amount of Coin withdrawn function withdrawDelegatorRewards( address delegatorAddress, string memory validatorAddress ) external returns ( Coin[] calldata amount );withdrawValidatorCommission/// @dev Withdraws the rewards commission of a validator. /// @param validatorAddress The address of the validator /// @return amount The amount of Coin withdrawn function withdrawValidatorCommission( string memory validatorAddress ) external returns ( Coin[] calldata amount );
Queries
validatorDistributionvalidatorOutstandingRewardsvalidatorCommissionvalidatorSlashesdelegationRewardsdelegationTotalRewardsdelegatorValidatorsdelegatorWithdrawAddressdelegatorWithdrawAddressqueries withdraw address of a delegator
Events
Each of the transactions emits its corresponding event. These are:
SetWithdrawerAddressWithdrawDelegatorRewardsWithdrawValidatorCommission
Interact with the Solidity Interface
Below are some examples of how to interact with this Solidity interface from your smart contracts.
Make sure to import the precompiled interface, e.g.:
Grant approval for the desired messages
See below a function that grants approval to the smart contract to send all x/distribution module messages on behalf of the sender account. You can tweak this function to approve only the desired messages.
Set withdraw address
The changeWithdrawAddress function allows a user to set a new withdraw address in the Cosmos x/distribution module. For this transaction to be successful, make sure the user had already approved the MSG_SET_WITHDRAWER_ADDRESS message.
Withdraw staking rewards
The withdrawStakingRewards function allows a user to withdraw his/her rewards corresponding to a specified validator. For this transaction to be successful, make sure the user had already approved the MSG_WITHDRAW_DELEGATOR_REWARD message.
Withdraw validator commission
If the user is running a validator, he/she could withdraw the corresponding commission using a smart contract. The user could use a function similar to withdrawCommission. For this transaction to be successful, make sure the user had already approved the MSG_WITHDRAW_VALIDATOR_COMMISSION message.
Queries
Similarly to transactions, smart contracts can use query methods. To use these methods, there is no need for authorization, as these are read-only methods. Examples of this are the getDelegationRewards and getValidatorCommision functions that return the information for the specified validator address.
Last updated

