> ## Documentation Index
> Fetch the complete documentation index at: https://cosmos-docs-sync-security-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Distribution

> Withdraw staking rewards and interact with the community pool

## Overview

The Distribution precompile provides access to the Cosmos SDK `x/distribution` module, enabling smart contracts to manage staking rewards, interact with the community pool, and handle validator commission operations.

**Precompile Address**: `0x0000000000000000000000000000000000000801`

**Related Module**: [x/distribution](/sdk/latest/modules/distribution/README)

## Gas Costs

<Info>
  Gas costs are approximated and may vary based on call complexity and chain settings.
</Info>

| Method           | Gas Cost                       |
| ---------------- | ------------------------------ |
| **Transactions** | `2000 + (30 × bytes of input)` |
| **Queries**      | `1000 + (3 × bytes of input)`  |

## Message Type Constants

The precompile defines the following constants for the various Cosmos SDK message types:

```solidity theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
// Transaction message type URLs
string constant MSG_SET_WITHDRAWER_ADDRESS = "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress";
string constant MSG_WITHDRAW_DELEGATOR_REWARD = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
string constant MSG_WITHDRAW_VALIDATOR_COMMISSION = "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission";
```

## Transaction Methods

### claimRewards

Claims staking rewards from multiple validators.

<Info>
  The `maxRetrieve` parameter limits the number of validators from which to claim rewards in a single transaction. This prevents excessive gas consumption when a delegator has rewards from many validators.
</Info>

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionClaimRewards {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      event RewardsClaimed(address indexed delegator, uint256 maxRetrieve, bool success);
      
      function claimRewards(uint32 maxRetrieve) external returns (bool success) {
          (bool callSuccess, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature("claimRewards(address,uint32)", msg.sender, maxRetrieve)
          );
          
          require(callSuccess, "Claim rewards call failed");
          success = abi.decode(result, (bool));
          
          emit RewardsClaimed(msg.sender, maxRetrieve, success);
          return success;
      }
      
      function claimAllRewards() external returns (bool success) {
          // Use a high maxRetrieve value to claim from all validators
          return claimRewards(100);
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Claiming rewards requires a signed transaction"
  ```
</CodeGroup>

### withdrawDelegatorRewards

Withdraws staking rewards from a single, specific validator.

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionExample {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      struct Coin {
          string denom;
          uint256 amount;
      }
      
      event RewardsWithdrawn(address indexed delegator, string indexed validator, uint256 amount);
      
      function withdrawRewards(string calldata validatorAddress) external returns (Coin[] memory amount) {
          (bool success, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature("withdrawDelegatorRewards(address,string)", msg.sender, validatorAddress)
          );
          
          require(success, "Withdraw rewards failed");
          amount = abi.decode(result, (Coin[]));
          
          uint256 totalAmount = 0;
          for (uint i = 0; i < amount.length; i++) {
              totalAmount += amount[i].amount;
          }
          emit RewardsWithdrawn(msg.sender, validatorAddress, totalAmount);
          
          return amount;
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Reward withdrawal requires a signed transaction"
  ```
</CodeGroup>

### setWithdrawAddress

Sets or changes the withdrawal address for receiving staking rewards.

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionSetWithdrawAddress {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      event WithdrawAddressSet(address indexed delegator, string withdrawerAddress, bool success);
      
      function setWithdrawAddress(string calldata withdrawerAddress) external returns (bool success) {
          (bool callSuccess, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature("setWithdrawAddress(address,string)", msg.sender, withdrawerAddress)
          );
          
          require(callSuccess, "Set withdraw address call failed");
          success = abi.decode(result, (bool));
          
          emit WithdrawAddressSet(msg.sender, withdrawerAddress, success);
          return success;
      }
      
      function resetWithdrawAddress() external returns (bool success) {
          // Reset to delegator's own address by converting msg.sender to bech32
          // Note: In practice, you'd need to convert the EVM address to bech32 format
          string memory selfAddress = "art1..."; // This would be the bech32 equivalent
          return setWithdrawAddress(selfAddress);
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Setting withdraw address requires a signed transaction"
  ```
</CodeGroup>

### withdrawValidatorCommission

Withdraws a validator's accumulated commission rewards.

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionWithdrawCommission {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      struct Coin {
          string denom;
          uint256 amount;
      }
      
      event ValidatorCommissionWithdrawn(string indexed validatorAddress, uint256 totalAmount);
      
      function withdrawValidatorCommission(string calldata validatorAddress) external returns (Coin[] memory amount) {
          (bool success, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature("withdrawValidatorCommission(string)", validatorAddress)
          );
          
          require(success, "Withdraw validator commission failed");
          amount = abi.decode(result, (Coin[]));
          
          uint256 totalAmount = 0;
          for (uint i = 0; i < amount.length; i++) {
              totalAmount += amount[i].amount;
          }
          emit ValidatorCommissionWithdrawn(validatorAddress, totalAmount);
          
          return amount;
      }
      
      // Helper function for validator operators to withdraw their own commission
      function withdrawMyCommission(string calldata myValidatorAddress) external returns (Coin[] memory) {
          return withdrawValidatorCommission(myValidatorAddress);
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Withdrawing validator commission requires a signed transaction"
  ```
</CodeGroup>

### fundCommunityPool

Sends tokens directly to the community pool.

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionFundCommunityPool {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      struct Coin {
          string denom;
          uint256 amount;
      }
      
      event CommunityPoolFunded(address indexed depositor, string denom, uint256 amount, bool success);
      
      function fundCommunityPool(Coin[] calldata amount) external returns (bool success) {
          (bool callSuccess, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature("fundCommunityPool(address,(string,uint256)[])", msg.sender, amount)
          );
          
          require(callSuccess, "Fund community pool call failed");
          success = abi.decode(result, (bool));
          
          // Emit events for each coin funded
          for (uint i = 0; i < amount.length; i++) {
              emit CommunityPoolFunded(msg.sender, amount[i].denom, amount[i].amount, success);
          }
          
          return success;
      }
      
      function fundCommunityPoolSingleCoin(string calldata denom, uint256 amount) external returns (bool success) {
          Coin[] memory coins = new Coin[](1);
          coins[0] = Coin(denom, amount);
          return fundCommunityPool(coins);
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Funding community pool requires a signed transaction"
  ```
</CodeGroup>

### depositValidatorRewardsPool

Deposits tokens into a specific validator's rewards pool.

<CodeGroup>
  ```solidity Solidity expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  // SPDX-License-Identifier: MIT
  pragma solidity ^0.8.0;

  contract DistributionDepositValidatorRewards {
      address constant DISTRIBUTION_PRECOMPILE = 0x0000000000000000000000000000000000000801;
      
      struct Coin {
          string denom;
          uint256 amount;
      }
      
      event ValidatorRewardsPoolDeposited(
          address indexed depositor, 
          string indexed validatorAddress, 
          string denom, 
          uint256 amount, 
          bool success
      );
      
      function depositValidatorRewardsPool(
          string calldata validatorAddress,
          Coin[] calldata amount
      ) external returns (bool success) {
          (bool callSuccess, bytes memory result) = DISTRIBUTION_PRECOMPILE.call(
              abi.encodeWithSignature(
                  "depositValidatorRewardsPool(address,string,(string,uint256)[])", 
                  msg.sender, 
                  validatorAddress, 
                  amount
              )
          );
          
          require(callSuccess, "Deposit validator rewards pool call failed");
          success = abi.decode(result, (bool));
          
          // Emit events for each coin deposited
          for (uint i = 0; i < amount.length; i++) {
              emit ValidatorRewardsPoolDeposited(
                  msg.sender, 
                  validatorAddress, 
                  amount[i].denom, 
                  amount[i].amount, 
                  success
              );
          }
          
          return success;
      }
      
      function depositSingleCoinToValidator(
          string calldata validatorAddress,
          string calldata denom, 
          uint256 amount
      ) external returns (bool success) {
          Coin[] memory coins = new Coin[](1);
          coins[0] = Coin(denom, amount);
          return depositValidatorRewardsPool(validatorAddress, coins);
      }
  }
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Transaction methods require signatures - use ethers.js or other Web3 library
  echo "Depositing to validator rewards pool requires a signed transaction"
  ```
</CodeGroup>

## Query Methods

### delegationTotalRewards

Retrieves comprehensive reward information for all of a delegator's positions.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the relevant parts of the precompile
  const precompileAbi = [
    "function delegationTotalRewards(address delegatorAddress) view returns (tuple(string validatorAddress, tuple(string denom, uint256 amount, uint8 precision)[] reward)[] rewards, tuple(string denom, uint256 amount, uint8 precision)[] total)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input: The address of the delegator to query
  const delegatorAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // Placeholder

  async function getTotalRewards() {
    try {
      const result = await contract.delegationTotalRewards(delegatorAddress);
      console.log("Total Rewards:", JSON.stringify({
        rewards: result.rewards,
        total: result.total
      }, null, 2));
    } catch (error) {
      console.error("Error fetching total rewards:", error);
    }
  }

  getTotalRewards();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + padded delegator address
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x54be1a28000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### delegationRewards

Queries pending rewards for a specific delegation.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function delegationRewards(address delegatorAddress, string memory validatorAddress) view returns (tuple(string denom, uint256 amount, uint8 precision)[] rewards)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Inputs
  const delegatorAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // Placeholder
  const validatorAddress = "artvaloper1..."; // Placeholder

  async function getDelegationRewards() {
    try {
      const rewards = await contract.delegationRewards(delegatorAddress, validatorAddress);
      console.log("Delegation Rewards:", JSON.stringify(rewards, null, 2));
    } catch (error) {
      console.error("Error fetching delegation rewards:", error);
    }
  }

  getDelegationRewards();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder addresses with your actual data.
  # Data is ABI-encoded: function selector + padded delegator address + encoded validator address string.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x9ad563b4000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002b61727476616c6f70657231713233347273673574367568766a6b6c376c38396d6e30707172737475760000000000000000000000000000000000000000000000"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### delegatorValidators

Retrieves a list of all validators from which a delegator has rewards.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function delegatorValidators(address delegatorAddress) view returns (string[] validators)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input
  const delegatorAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // Placeholder

  async function getDelegatorValidators() {
    try {
      const validators = await contract.delegatorValidators(delegatorAddress);
      console.log("Validators:", validators);
    } catch (error) {
      console.error("Error fetching delegator validators:", error);
    }
  }

  getDelegatorValidators();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + padded delegator address.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0xa66cb605000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### delegatorWithdrawAddress

Queries the address that can withdraw rewards for a given delegator.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function delegatorWithdrawAddress(address delegatorAddress) view returns (string withdrawAddress)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input
  const delegatorAddress = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"; // Placeholder

  async function getWithdrawAddress() {
    try {
      const withdrawAddress = await contract.delegatorWithdrawAddress(delegatorAddress);
      console.log("Withdraw Address:", withdrawAddress);
    } catch (error) {
      console.error("Error fetching withdraw address:", error);
    }
  }

  getWithdrawAddress();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + padded delegator address.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x5431f450000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### communityPool

Queries the current balance of the community pool.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function communityPool() view returns (tuple(string denom, uint256 amount, uint8 precision)[] coins)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  async function getCommunityPoolBalance() {
    try {
      const balance = await contract.communityPool();
      console.log("Community Pool Balance:", JSON.stringify(balance, null, 2));
    } catch (error) {
      console.error("Error fetching community pool balance:", error);
    }
  }

  getCommunityPoolBalance();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> with your actual RPC endpoint.
  # Data is ABI-encoded: just the function selector.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x14d140b0"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### validatorCommission

Queries the accumulated commission for a specific validator.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function validatorCommission(string memory validatorAddress) view returns (tuple(string denom, uint256 amount, uint8 precision)[] commission)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input
  const validatorAddress = "artvaloper1..."; // Placeholder

  async function getValidatorCommission() {
    try {
      const commission = await contract.validatorCommission(validatorAddress);
      console.log("Validator Commission:", JSON.stringify(commission, null, 2));
    } catch (error) {
      console.error("Error fetching validator commission:", error);
    }
  }

  getValidatorCommission();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + encoded validator address string.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x3dd40f780000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002b61727476616c6f70657231713233347273673574367568766a6b6c376c38396d6e30707172737475760000000000000000000000000000000000000000000000"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### validatorDistributionInfo

Queries a validator's commission and self-delegation rewards.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function validatorDistributionInfo(string memory validatorAddress) view returns (tuple(string operatorAddress, tuple(string denom, uint256 amount, uint8 precision)[] selfBondRewards, tuple(string denom, uint256 amount, uint8 precision)[] commission) distributionInfo)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input
  const validatorAddress = "artvaloper1..."; // Placeholder

  async function getValidatorDistInfo() {
    try {
      const info = await contract.validatorDistributionInfo(validatorAddress);
      console.log("Validator Distribution Info:", JSON.stringify(info, null, 2));
    } catch (error) {
      console.error("Error fetching validator distribution info:", error);
    }
  }

  getValidatorDistInfo();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + encoded validator address string.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x54212a890000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002b61727476616c6f70657231713233347273673574367568766a6b6c376c38396d6e30707172737475760000000000000000000000000000000000000000000000"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### validatorOutstandingRewards

Queries the outstanding rewards of a validator.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function validatorOutstandingRewards(string memory validatorAddress) view returns (tuple(string denom, uint256 amount, uint8 precision)[] rewards)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Input
  const validatorAddress = "artvaloper1..."; // Placeholder

  async function getOutstandingRewards() {
    try {
      const rewards = await contract.validatorOutstandingRewards(validatorAddress);
      console.log("Validator Outstanding Rewards:", JSON.stringify(rewards, null, 2));
    } catch (error) {
      console.error("Error fetching outstanding rewards:", error);
    }
  }

  getOutstandingRewards();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and the placeholder address with your actual data.
  # Data is ABI-encoded: function selector + encoded validator address string.
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x85b2d2da0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002b61727476616c6f70657231713233347273673574367568766a6b6c376c38396d6e30707172737475760000000000000000000000000000000000000000000000"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

### validatorSlashes

Queries slashing events for a validator within a specific height range.

<CodeGroup>
  ```javascript Ethers.js expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  import { ethers } from "ethers";

  // ABI definition for the function
  const precompileAbi = [
    "function validatorSlashes(string validatorAddress, uint64 startingHeight, uint64 endingHeight, tuple(bytes key, uint64 offset, uint64 limit, bool countTotal, bool reverse) pageRequest) view returns (tuple(uint64 validatorPeriod, tuple(uint256 value, uint8 precision) fraction, int64 height)[] slashes, tuple(bytes nextKey, uint64 total) pageResponse)"
  ];

  // Provider and contract setup
  const provider = new ethers.JsonRpcProvider("<RPC_URL>");
  const precompileAddress = "0x0000000000000000000000000000000000000801";
  const contract = new ethers.Contract(precompileAddress, precompileAbi, provider);

  // Inputs
  const validatorAddress = "artvaloper1..."; // Placeholder
  const startingHeight = 1000; // Starting block height
  const endingHeight = 2000; // Ending block height
  const pageRequest = {
    key: "0x",
    offset: 0,
    limit: 10,
    countTotal: true,
    reverse: false
  };

  async function getValidatorSlashes() {
    try {
      const [slashes, pageResponse] = await contract.validatorSlashes(
        validatorAddress,
        startingHeight,
        endingHeight,
        pageRequest
      );
      console.log("Validator Slashes:", JSON.stringify(slashes, null, 2));
      console.log("Page Response:", JSON.stringify(pageResponse, null, 2));
    } catch (error) {
      console.error("Error fetching validator slashes:", error);
    }
  }

  getValidatorSlashes();
  ```

  ```bash cURL expandable lines theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
  # Note: Replace <RPC_URL> and parameters with your actual data.
  # Data is ABI-encoded: function selector + encoded validator address + heights + page request
  curl -X POST --data '{
      "jsonrpc": "2.0",
      "method": "eth_call",
      "params": [
          {
              "to": "0x0000000000000000000000000000000000000801",
              "data": "0x8f2473ce0000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000003e800000000000000000000000000000000000000000000000000000000000007d000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002b61727476616c6f70657231713233347273673574367568766a6b6c376c38396d6e3070717273747576000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
          },
          "latest"
      ],
      "id": 1
  }' -H "Content-Type: application/json" <RPC_URL>
  ```
</CodeGroup>

## Full Solidity Interface & ABI

```solidity title="Distribution Solidity Interface" lines expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.17;

import "../common/Types.sol";

/// @dev The DistributionI contract's address.
address constant DISTRIBUTION_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000801;

/// @dev The DistributionI contract's instance.
DistributionI constant DISTRIBUTION_CONTRACT = DistributionI(
    DISTRIBUTION_PRECOMPILE_ADDRESS
);

struct ValidatorSlashEvent {
    uint64 validatorPeriod;
    Dec fraction;
}

struct ValidatorDistributionInfo {
    string operatorAddress;
    DecCoin[] selfBondRewards;
    DecCoin[] commission;
}

struct DelegationDelegatorReward {
    string validatorAddress;
    DecCoin[] reward;
}

/// @author Evmos Team
/// @title Distribution Precompile Contract
/// @dev The interface through which solidity contracts will interact with Distribution
/// @custom:address 0x0000000000000000000000000000000000000801
interface DistributionI {
    event ClaimRewards(address indexed delegatorAddress, uint256 amount);
    event SetWithdrawerAddress(address indexed caller, string withdrawerAddress);
    event WithdrawDelegatorReward(address indexed delegatorAddress, address indexed validatorAddress, uint256 amount);
    event WithdrawValidatorCommission(string indexed validatorAddress, uint256 commission);
    event FundCommunityPool(address indexed depositor, string denom, uint256 amount);
    event DepositValidatorRewardsPool(address indexed depositor, address indexed validatorAddress, string denom, uint256 amount);

    function claimRewards(address delegatorAddress, uint32 maxRetrieve) external returns (bool success);
    function setWithdrawAddress(address delegatorAddress, string memory withdrawerAddress) external returns (bool success);
    function withdrawDelegatorRewards(address delegatorAddress, string memory validatorAddress) external returns (Coin[] calldata amount);
    function withdrawValidatorCommission(string memory validatorAddress) external returns (Coin[] calldata amount);
    function fundCommunityPool(address depositor, Coin[] memory amount) external returns (bool success);
    function depositValidatorRewardsPool(address depositor, string memory validatorAddress, Coin[] memory amount) external returns (bool success);

    function validatorDistributionInfo(string memory validatorAddress) external view returns (ValidatorDistributionInfo calldata distributionInfo);
    function validatorOutstandingRewards(string memory validatorAddress) external view returns (DecCoin[] calldata rewards);
    function validatorCommission(string memory validatorAddress) external view returns (DecCoin[] calldata commission);
    function validatorSlashes(string memory validatorAddress, uint64 startingHeight, uint64 endingHeight, PageRequest calldata pageRequest) external view returns (ValidatorSlashEvent[] calldata slashes, PageResponse calldata pageResponse);
    function delegationRewards(address delegatorAddress, string memory validatorAddress) external view returns (DecCoin[] calldata rewards);
    function delegationTotalRewards(address delegatorAddress) external view returns (DelegationDelegatorReward[] calldata rewards, DecCoin[] calldata total);
    function delegatorValidators(address delegatorAddress) external view returns (string[] calldata validators);
    function delegatorWithdrawAddress(address delegatorAddress) external view returns (string memory withdrawAddress);
    function communityPool() external view returns (DecCoin[] calldata coins);
}
```

```json title="Distribution ABI" lines expandable theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "_format": "hh-sol-artifact-1",
  "contractName": "DistributionI",
  "sourceName": "solidity/precompiles/distribution/DistributionI.sol",
  "abi": [
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "ClaimRewards",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "depositor",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "validatorAddress",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "string",
          "name": "denom",
          "type": "string"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "DepositValidatorRewardsPool",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "depositor",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "string",
          "name": "denom",
          "type": "string"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "FundCommunityPool",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "caller",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "string",
          "name": "withdrawerAddress",
          "type": "string"
        }
      ],
      "name": "SetWithdrawerAddress",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "indexed": true,
          "internalType": "address",
          "name": "validatorAddress",
          "type": "address"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "amount",
          "type": "uint256"
        }
      ],
      "name": "WithdrawDelegatorReward",
      "type": "event"
    },
    {
      "anonymous": false,
      "inputs": [
        {
          "indexed": true,
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        },
        {
          "indexed": false,
          "internalType": "uint256",
          "name": "commission",
          "type": "uint256"
        }
      ],
      "name": "WithdrawValidatorCommission",
      "type": "event"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "internalType": "uint32",
          "name": "maxRetrieve",
          "type": "uint32"
        }
      ],
      "name": "claimRewards",
      "outputs": [
        {
          "internalType": "bool",
          "name": "success",
          "type": "bool"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [],
      "name": "communityPool",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            },
            {
              "internalType": "uint8",
              "name": "precision",
              "type": "uint8"
            }
          ],
          "internalType": "struct DecCoin[]",
          "name": "coins",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "delegationRewards",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            },
            {
              "internalType": "uint8",
              "name": "precision",
              "type": "uint8"
            }
          ],
          "internalType": "struct DecCoin[]",
          "name": "rewards",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        }
      ],
      "name": "delegationTotalRewards",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "validatorAddress",
              "type": "string"
            },
            {
              "components": [
                {
                  "internalType": "string",
                  "name": "denom",
                  "type": "string"
                },
                {
                  "internalType": "uint256",
                  "name": "amount",
                  "type": "uint256"
                },
                {
                  "internalType": "uint8",
                  "name": "precision",
                  "type": "uint8"
                }
              ],
              "internalType": "struct DecCoin[]",
              "name": "reward",
              "type": "tuple[]"
            }
          ],
          "internalType": "struct DelegationDelegatorReward[]",
          "name": "rewards",
          "type": "tuple[]"
        },
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            },
            {
              "internalType": "uint8",
              "name": "precision",
              "type": "uint8"
            }
          ],
          "internalType": "struct DecCoin[]",
          "name": "total",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        }
      ],
      "name": "delegatorValidators",
      "outputs": [
        {
          "internalType": "string[]",
          "name": "validators",
          "type": "string[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        }
      ],
      "name": "delegatorWithdrawAddress",
      "outputs": [
        {
          "internalType": "string",
          "name": "withdrawAddress",
          "type": "string"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "depositor",
          "type": "address"
        },
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        },
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            }
          ],
          "internalType": "struct Coin[]",
          "name": "amount",
          "type": "tuple[]"
        }
      ],
      "name": "depositValidatorRewardsPool",
      "outputs": [
        {
          "internalType": "bool",
          "name": "success",
          "type": "bool"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "depositor",
          "type": "address"
        },
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            }
          ],
          "internalType": "struct Coin[]",
          "name": "amount",
          "type": "tuple[]"
        }
      ],
      "name": "fundCommunityPool",
      "outputs": [
        {
          "internalType": "bool",
          "name": "success",
          "type": "bool"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "internalType": "string",
          "name": "withdrawerAddress",
          "type": "string"
        }
      ],
      "name": "setWithdrawAddress",
      "outputs": [
        {
          "internalType": "bool",
          "name": "success",
          "type": "bool"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "validatorCommission",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            },
            {
              "internalType": "uint8",
              "name": "precision",
              "type": "uint8"
            }
          ],
          "internalType": "struct DecCoin[]",
          "name": "commission",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "validatorDistributionInfo",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "operatorAddress",
              "type": "string"
            },
            {
              "components": [
                {
                  "internalType": "string",
                  "name": "denom",
                  "type": "string"
                },
                {
                  "internalType": "uint256",
                  "name": "amount",
                  "type": "uint256"
                },
                {
                  "internalType": "uint8",
                  "name": "precision",
                  "type": "uint8"
                }
              ],
              "internalType": "struct DecCoin[]",
              "name": "selfBondRewards",
              "type": "tuple[]"
            },
            {
              "components": [
                {
                  "internalType": "string",
                  "name": "denom",
                  "type": "string"
                },
                {
                  "internalType": "uint256",
                  "name": "amount",
                  "type": "uint256"
                },
                {
                  "internalType": "uint8",
                  "name": "precision",
                  "type": "uint8"
                }
              ],
              "internalType": "struct DecCoin[]",
              "name": "commission",
              "type": "tuple[]"
            }
          ],
          "internalType": "struct ValidatorDistributionInfo",
          "name": "distributionInfo",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "validatorOutstandingRewards",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            },
            {
              "internalType": "uint8",
              "name": "precision",
              "type": "uint8"
            }
          ],
          "internalType": "struct DecCoin[]",
          "name": "rewards",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        },
        {
          "internalType": "uint64",
          "name": "startingHeight",
          "type": "uint64"
        },
        {
          "internalType": "uint64",
          "name": "endingHeight",
          "type": "uint64"
        },
        {
          "components": [
            {
              "internalType": "bytes",
              "name": "key",
              "type": "bytes"
            },
            {
              "internalType": "uint64",
              "name": "offset",
              "type": "uint64"
            },
            {
              "internalType": "uint64",
              "name": "limit",
              "type": "uint64"
            },
            {
              "internalType": "bool",
              "name": "countTotal",
              "type": "bool"
            },
            {
              "internalType": "bool",
              "name": "reverse",
              "type": "bool"
            }
          ],
          "internalType": "struct PageRequest",
          "name": "pageRequest",
          "type": "tuple"
        }
      ],
      "name": "validatorSlashes",
      "outputs": [
        {
          "components": [
            {
              "internalType": "uint64",
              "name": "validatorPeriod",
              "type": "uint64"
            },
            {
              "components": [
                {
                  "internalType": "uint256",
                  "name": "value",
                  "type": "uint256"
                },
                {
                  "internalType": "uint8",
                  "name": "precision",
                  "type": "uint8"
                }
              ],
              "internalType": "struct Dec",
              "name": "fraction",
              "type": "tuple"
            }
          ],
          "internalType": "struct ValidatorSlashEvent[]",
          "name": "slashes",
          "type": "tuple[]"
        },
        {
          "components": [
            {
              "internalType": "bytes",
              "name": "nextKey",
              "type": "bytes"
            },
            {
              "internalType": "uint64",
              "name": "total",
              "type": "uint64"
            }
          ],
          "internalType": "struct PageResponse",
          "name": "pageResponse",
          "type": "tuple"
        }
      ],
      "stateMutability": "view",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "address",
          "name": "delegatorAddress",
          "type": "address"
        },
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "withdrawDelegatorRewards",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            }
          ],
          "internalType": "struct Coin[]",
          "name": "amount",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "validatorAddress",
          "type": "string"
        }
      ],
      "name": "withdrawValidatorCommission",
      "outputs": [
        {
          "components": [
            {
              "internalType": "string",
              "name": "denom",
              "type": "string"
            },
            {
              "internalType": "uint256",
              "name": "amount",
              "type": "uint256"
            }
          ],
          "internalType": "struct Coin[]",
          "name": "amount",
          "type": "tuple[]"
        }
      ],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ],
  "bytecode": "0x",
  "deployedBytecode": "0x",
  "linkReferences": {},
  "deployedLinkReferences": {}
}
```
