Skip to content

Distribution Polaris ​

Git Source

The Cosmos SDK distribution module is responsible for tracking and distributing rewards to validators and delegators in a blockchain network. The module passively distributes collected fees and other rewards to validators and delegators based on their participation in the network.Β It also defines the community pool, which is a pool of funds under the control of on-chain governance.

The interface includes functions to set and get the withdrawal address for delegation rewards, check if withdrawing rewards is enabled, withdraw delegator rewards, and retrieve the total rewards accumulated by a delegator. Additionally, it defines events for withdrawing rewards and setting the withdrawal address, as well as a struct to represent a delegator's rewards for a particular validator.

Developers can use this module to manage the distribution of rewards in their custom application-specific blockchains built using the Cosmos SDK. Berachain ensures that validators and delegators are fairly rewarded for their contributions to the network via this module.

Note: Link to existing contract ABI's can be found on Github here.

Interface of the distribution module's precompiled contract

Functions ​

getWithdrawEnabled ​

Returns whether withdrawing delegation rewards is enabled.

solidity
function getWithdrawEnabled() external view returns (bool);
function getWithdrawEnabled() external view returns (bool);

getWithdrawAddress ​

Returns the address that will receive the delegation rewards.

solidity
function getWithdrawAddress(address delegator) external view returns (address);
function getWithdrawAddress(address delegator) external view returns (address);

Parameters

NameTypeDescription
delegatoraddressthe delegator for which the withdraw address is returned.

getDelegatorValidatorReward ​

Returns the rewards accumulated by the delegator for the validator.

solidity
function getDelegatorValidatorReward(address delegator, address validator)
    external
    view
    returns (Cosmos.Coin[] memory);
function getDelegatorValidatorReward(address delegator, address validator)
    external
    view
    returns (Cosmos.Coin[] memory);

Parameters

NameTypeDescription
delegatoraddressThe delegator to retrieve the rewards for.
validatoraddressThe validator (operator address) to retrieve the rewards for.

getAllDelegatorRewards ​

Returns the all rewards accumulated by the delegator.

solidity
function getAllDelegatorRewards(address delegator) external view returns (ValidatorReward[] memory);
function getAllDelegatorRewards(address delegator) external view returns (ValidatorReward[] memory);

Parameters

NameTypeDescription
delegatoraddressThe delegator to retrieve the totalRewards for.

getTotalDelegatorReward ​

Returns the total rewards accumulated by the delegator.

solidity
function getTotalDelegatorReward(address delegator) external view returns (Cosmos.Coin[] memory);
function getTotalDelegatorReward(address delegator) external view returns (Cosmos.Coin[] memory);

Parameters

NameTypeDescription
delegatoraddressThe delegator to retrieve the totalRewards for.

setWithdrawAddress ​

The caller (msg.sender) can set the address that will receive the delegation rewards.

solidity
function setWithdrawAddress(address withdrawAddress) external returns (bool);
function setWithdrawAddress(address withdrawAddress) external returns (bool);

Parameters

NameTypeDescription
withdrawAddressaddressThe address to set as the withdraw address.

withdrawDelegatorReward ​

Withdraw the rewrads accumulated by the caller(msg.sender). Returns the rewards claimed.

solidity
function withdrawDelegatorReward(address delegator, address validator) external returns (Cosmos.Coin[] memory);
function withdrawDelegatorReward(address delegator, address validator) external returns (Cosmos.Coin[] memory);

Parameters

NameTypeDescription
delegatoraddressThe delegator to withdraw the rewards from.
validatoraddressThe validator (operator address) to withdraw the rewards from.

Events ​

WithdrawRewards ​

Emitted by the distribution module when amount is withdrawn from a delegation with validator as rewards.

solidity
event WithdrawRewards(address indexed validator, Cosmos.Coin[] amount);
event WithdrawRewards(address indexed validator, Cosmos.Coin[] amount);

Parameters

NameTypeDescription
validatoraddressThe validator address to withdraw the rewards from.
amountCosmos.Coin[]The amount of rewards withdrawn.

SetWithdrawAddress ​

Emitted by the distribution module when withdrawAddress is set to receive rewards upon withdrawal.

solidity
event SetWithdrawAddress(address indexed withdrawAddress);
event SetWithdrawAddress(address indexed withdrawAddress);

Parameters

NameTypeDescription
withdrawAddressaddressThe address to set as the withdraw address.

Structs ​

ValidatorReward ​

Represents a delegator's rewards for one particular validator.

solidity
struct ValidatorReward {
    address validator;
    Cosmos.Coin[] rewards;
}
struct ValidatorReward {
    address validator;
    Cosmos.Coin[] rewards;
}