Bank Module (x/bank)
Overview
Thex/bank module is responsible for handling multi-asset coin transfers between accounts and tracking the total supply of all assets in the application. It provides secure interfaces for other modules to interact with user balances.
Purpose: Enable token transfers, track total supply, and manage denomination metadata for all assets in the blockchain.
Key Features
- Multi-Asset Support: Handle multiple token denominations
- Supply Tracking: Passive tracking of total supply for all coins
- Module Accounts: Special accounts for modules to hold and manage tokens
- Send Restrictions: Flexible restrictions on token transfers
- Denomination Metadata: Store descriptive information about tokens
State
The bank module maintains the following state:Storage Indexes
Account Balances
Balances are stored per address and denomination, allowing efficient O(1) lookups.Total Supply
The total supply is updated every time coins are minted or burned:- Minting: During inflation or module-specific operations
- Burning: Due to slashing, vetoed proposals, or module operations
Module Accounts
Module accounts are special accounts used by modules to hold tokens:Permissions
- Minter: Allows minting specific amounts of coins
- Burner: Allows burning specific amounts of coins
- Staking: Allows delegating and undelegating coins
Keepers
BaseKeeper
Provides full-permission access to modify any account’s balance:SendKeeper
Provides access to transfer coins between accounts (without minting/burning):ViewKeeper
Provides read-only access to account balances:Messages
MsgSend
Send coins from one address to another:- Coins must have sending enabled
- Recipient address cannot be restricted
- Sender must have sufficient balance
MsgMultiSend
Send coins from one sender to multiple recipients:Parameters
| Parameter | Type | Description |
|---|---|---|
| DefaultSendEnabled | bool | Default value for whether transfers are enabled |
| SendEnabled (deprecated) | []SendEnabled | List of specific denoms with custom send settings |
Events
MsgSend Events
| Type | Attribute Key | Attribute Value |
|---|---|---|
| transfer | recipient | |
| transfer | amount | |
| message | module | bank |
| message | action | send |
| message | sender |
Keeper Events
MintCoins
BurnCoins
Queries
Balance Query
Total Supply
Denomination Metadata
Send Enabled
Transactions
Send Tokens
gRPC Endpoints
Balance
AllBalances
TotalSupply
Code Examples
Send Coins
Mint Coins to Module
Transfer from Module to Account
Query Balance
Check Spendable Balance
Send Restrictions
Custom send restrictions can be added to control token transfers:CLI Commands Reference
| Command | Description |
|---|---|
simd query bank balances [address] | Query account balances |
simd query bank total | Query total supply |
simd query bank denom-metadata | Query denomination metadata |
simd query bank send-enabled | Query send enabled settings |
simd tx bank send [from] [to] [amount] | Send tokens |