# Bank

WARNING

Paloma's bank module inherits from the Cosmos SDK's [`bank`(opens new window)](https://docs.cosmos.network/master/modules/bank/) module. This document is a stub and covers mainly important Paloma-specific notes about how it is used.

The bank module is the base transactional layer of the Paloma blockchain. This module allows assets to be sent from one `Account` to another. The bank module defines the following types of send transactions: `MsgSend` and `MsgMultiSend`.

## Message types

### MsgSend

`MsgSend` transfers funds from a source account to a destination account.

```go
// MsgSend - high level transaction of the coin module
type MsgSend struct {
    FromAddress sdk.AccAddress `json:"from_address"`
    ToAddress   sdk.AccAddress `json:"to_address"`
    Amount      sdk.Coins      `json:"amount"`
}
```

The Bank module is used to send coins from one Paloma account to another. `MsgSend` is constructed to facilitate the transfer. If the balance of coins in the sender `Account` is insufficient or the recipient `Account` is unable to receive the funds via the bank module, the transaction fails. Fees already paid through failed transactions are not refunded.

### MsgMultiSend

```go
// MsgMultiSend - high level transaction of the coin module
type Input struct {
  Address sdk.AccAddress `json:"address" yaml:"address"`
  Coins   sdk.Coins      `json:"coins" yaml:"coins"`
}

type Output struct {
  Address sdk.AccAddress `json:"address" yaml:"address"`
  Coins   sdk.Coins      `json:"coins" yaml:"coins"`
}

type MsgMultiSend struct {
  Inputs  []Input  `json:"inputs" yaml:"inputs"`
  Outputs []Output `json:"outputs" yaml:"outputs"`
}
```

To send multiple transactions at once, use `MsgMultiSend`. For each transaction, `Inputs` contains the incoming transactions, and `Outputs` contains the outgoing transactions. The `Inputs` coin balance must exactly match the `Outputs` coin balance. Batching transactions via `MsgMultiSend` conserves gas fees and network bandwidth. Fees already paid through failed transactions are not refunded.

## Parameters

The genesis parameters outlined in the [Genesis Builder Script(opens new window)](https://github.com/paloma/genesis-tools/blob/main/src/genesis_builder.py#L92) are as follows:

````py
# Bank: setup supply
genesis['app_state']['bank']['supply'] = [{\
    'denom': DENOM_GRAIN,\
    'amount': str(TOTAL_ALLOCATION),\
}]

# Bank: set denom meta
genesis['app_state']['bank']['denom_metadata'] = [{\
    'description': 'The native staking token of Paloma 2.0',\
    'denom_units': [\
        {'denom': 'ugrain', 'exponent': 0, 'aliases': ['micrograin']},\
        {'denom': 'mgrain', 'exponent': 3, 'aliases': ['milligrain']},\
        {'denom': 'grain', 'exponent': 6, 'aliases': []},\
    ],\
    'base':    'ugrain',\
    'display': 'grain',\
    'name':    'GRAIN',\
    'symbol':  'GRAIN',\
}]
````
