Skip to main content

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

Find the Solidity interface in the HyperPaxeer/extensions repo.

ABI

Find the ABI in the HyperPaxeer/extensions repo.

Transactions

  • setWithdrawAddress
  • withdrawDelegatorRewards
  • withdrawValidatorCommission

Queries

  • validatorDistribution
  • validatorOutstandingRewards
  • validatorCommission
  • validatorSlashes
  • delegationRewards
  • delegationTotalRewards
  • delegatorValidators
  • delegatorWithdrawAddress delegatorWithdrawAddress queries withdraw address of a delegator

Events

Each of the transactions emits its corresponding event. These are:
  • SetWithdrawerAddress
  • WithdrawDelegatorRewards
  • WithdrawValidatorCommission

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.:

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. These are read-only methods. Examples of this are the getDelegationRewards and getValidatorCommision functions that return the information for the specified validator address.