# Bank

# Summary

This module is mainly used to transfer coins between accounts, query account balances, and provide common offline transaction signing and broadcasting methods. In addition, the available units of tokens in the Plug Chain Hub system are defined using coin-type.

# Usage Scenario

  1. Query the balances of an account

    Query the total balance of an account or of a specific denomination.

    plugchaind query bank balances [address] --denom=[denom]
    
  2. Transfer between accounts

    For example, transfer 10uplugcn from account A to account B:

    plugchaind tx bank send [A] [B] [10plug] --fees=20uplugcn --chain-id=plugchain_520-1
    

    Plug Chain Hub supports multiple tokens in circulation, and in the future Plug Chain Hub will be able to include multiple tokens in one transaction.

  3. Sign transactions generated offline

    To improve account security, Plug Chain Hub supports offline signing of transactions to protect the account's private key. In any transaction, you can build an unsigned transaction using the flag --generate-only. Take transfer transaction as an example:

    plugchaind tx bank send [from_key_or_address] [to_address] [amount]  --fees=20uplugcn --generate-only
    

    Return the built transaction with empty signatures:

    {
        "type": "auth/StdTx",
        "value": {
            "msg": [ "txMsg" ],
            "fee": "fee",
            "signatures": null,
            "memo": ""
        }
    }
    

    Save the result to a file.

    Sign the transaction:

    plugchaind tx sign <file> --chain-id=plugchain_520-1 --from=<key-name>
    

    Return signed transactions:

    {
        "type": "auth/StdTx",
        "value": {
            "msg": [ "txMsg" ],
            "fee": "fee",
            "signatures": [
            {
                "pub_key": {
                "type": "tendermint/PubKeySecp256k1",
                "value": "A+qXW5isQDb7blT/KwEgQHepji8RfpzIstkHpKoZq0kr"
                },
                "signature": "5hxk/R81SWmKAGi4kTW2OapezQZpp6zEnaJbVcyDiWRfgBm4Uejq8+CDk6uzk0aFSgAZzz06E014UkgGpelU7w==",
                "account_number": "0",
                "sequence": "11"
            }
            ],
            "memo": ""
        }
    }
    

    Save the result to a file.

  4. Broadcast transactions

    plugchaind tx broadcast <file>
    

    The transaction will be broadcast and executed in Plug Chain Hub.