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

# Cosmos Precompiles

> How EVM communicates with Cosmos SDK modules through precompiles

## How EVM Communicates with Cosmos

The EVM communicates with the Cosmos part of the chain through **precompiles** - Go code that directly interacts with other module states (e.g., Bank module).

Precompiles are special contract addresses that execute native Go code instead of EVM bytecode, enabling seamless integration between EVM and Cosmos SDK modules.

## Cosmos SDK Precompiles

There are **5 Cosmos SDK precompiles** exposed inside the EVM:

### 1. Staking Precompile

Interact with the staking module directly from EVM contracts:

* **Delegate tokens**: Delegate native tokens to validators
* **Undelegate tokens**: Undelegate from validators
* **Redelegate tokens**: Move delegation between validators
* **Query delegation information**: Get delegation details

**Use Cases:**

* Automated staking strategies
* Liquid staking protocols
* Validator selection algorithms

### 2. Distribution Precompile

Manage staking rewards from EVM contracts:

* **Claim rewards**: Claim staking rewards
* **Withdraw rewards**: Withdraw accumulated rewards
* **Query reward information**: Get reward details

**Use Cases:**

* Automated reward claiming
* Reward distribution protocols
* Staking aggregators

### 3. Slashing Precompile

Handle slashing operations and re-staking:

* **Re-staking operations**: Manage validator re-staking
* **Reward management**: Handle slashing-related rewards
* **Validator penalties**: Query and handle penalties

**Use Cases:**

* Slashing protection protocols
* Validator health monitoring
* Risk management systems

### 4. Governance Precompile

Participate in on-chain governance from EVM contracts:

* **Vote on proposals**: Cast votes on governance proposals
* **Create proposals**: Submit new governance proposals
* **Query proposal information**: Get proposal details and status

**Use Cases:**

* Automated governance participation
* Governance aggregators
* Proposal creation tools

### 5. Bank Precompile

Transfer native Cosmos tokens from EVM contracts:

* **Transfer tokens**: Send native tokens
* **Query balances**: Get token balances
* **Multi-send operations**: Batch token transfers

**Use Cases:**

* Token bridges
* Payment protocols
* Multi-sig wallets

## ERC20 Precompiles

Each **TokenFactory token** has its own ERC20 precompile address, allowing:

* **Control token balance**: Manage token balances from EVM
* **Transfer tokens**: Transfer TokenFactory tokens
* **Use tokens in EVM contracts**: Seamless integration

This enables TokenFactory tokens (created via Cosmos SDK) to be used directly in EVM contracts without wrapping.

## Using Precompiles

Precompiles are called like regular contract calls in Solidity:

```solidity theme={null}
// Example: Calling a precompile
// (Addresses and interfaces are examples - actual addresses will be documented)

interface IStakingPrecompile {
    function delegate(address validator, uint256 amount) external;
}

contract MyContract {
    address constant STAKING_PRECOMPILE = 0x0000000000000000000000000000000000000800;
    
    function stake(address validator, uint256 amount) external {
        IStakingPrecompile(STAKING_PRECOMPILE).delegate(validator, amount);
    }
}
```

## Precompile Addresses

Precompile addresses are fixed and documented. See [Using Precompiles](https://mantrachain.mintlify.site/developers/evm/using-precompiles.md) for detailed addresses and interfaces.

## Benefits of Precompiles

1. **Direct Cosmos Integration**: Access Cosmos SDK features from EVM
2. **No Wrapping Required**: Use native Cosmos tokens directly
3. **Atomic Operations**: Precompile calls are part of the transaction
4. **Gas Efficient**: Native Go code execution is more efficient than contract calls

## Next Steps

* Learn how to [use precompiles in your contracts](https://mantrachain.mintlify.site/developers/evm/using-precompiles.md)
* Understand [transaction sequencing](https://mantrachain.mintlify.site/developers/architecture/transaction-sequencing.md)
* Explore [ERC-20 token creation](https://mantrachain.mintlify.site/developers/architecture/erc20-tokens.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.