The Bank precompile provides ERC20-style access to native Cosmos SDK tokens, enabling smart contracts to query balances and token supplies through standardized interfaces. It serves as a Solidity wrapper around the Cosmos SDK x/bank module.Address: 0x0000000000000000000000000000000000000804Related Module: x/bank
Signature: balances(address account) → Balance[] memoryDescription: Queries all native token balances for a specific account address and returns an array of Balance (ERC-20 contract address & amount) structures.
Signature: totalSupply() → Balance[] memoryDescription: Queries the total supply of all native tokens in the system. Returns comprehensive supply information for every token registered in the system.
Signature: supplyOf(address erc20Address) → uint256Description: Queries the total supply of a specific token by providing its ERC20 contract address. More efficient when you need supply information for a single token.
// SPDX-License-Identifier: LGPL-3.0-onlypragma solidity >=0.8.18;/// @dev The IBank contract's address.address constant IBANK_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000804;/// @dev The IBank contract's instance.IBank constant IBANK_CONTRACT = IBank(IBANK_PRECOMPILE_ADDRESS);/// @dev Balance specifies the ERC20 contract address and the amount of tokens.struct Balance { /// contractAddress defines the ERC20 contract address. address contractAddress; /// amount of tokens uint256 amount;}/** * @author Evmos Team * @title Bank Interface * @dev Interface for querying balances and supply from the Bank module. */interface IBank { /// @dev balances defines a method for retrieving all the native token balances /// for a given account. /// @param account the address of the account to query balances for. /// @return balances the array of native token balances. function balances( address account ) external view returns (Balance[] memory balances); /// @dev totalSupply defines a method for retrieving the total supply of all /// native tokens. /// @return totalSupply the supply as an array of native token balances function totalSupply() external view returns (Balance[] memory totalSupply); /// @dev supplyOf defines a method for retrieving the total supply of a particular native coin. /// @return totalSupply the supply as a uint256 function supplyOf( address erc20Address ) external view returns (uint256 totalSupply);}
The precompile resolves native Cosmos SDK denominations to their corresponding ERC-20 contract addresses through the x/erc20 module’s token pair registry. Only tokens with registered token pairs are returned in query results.