Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add bank readme #1091

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions bank/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Bank Module

## Table of Contents

* [Overview](#overview)
* [How does it work](#how-does-it-work)
* [How to send coins](#how-to-send-coins)
* [Query commands](#query-commands)

## Overview

The bank module is responsible for handling multi-asset coin transfers between accounts. It exposes several interfaces with varying capabilities for secure interaction with other modules which must alter user balances.

## How does it work

```
type MsgSend struct {
FromAddress types.HeimdallAddress `json:"from_address"`
ToAddress types.HeimdallAddress `json:"to_address"`
Amount sdk.Coins `json:"amount"`
}
```

[Handler](handler.go) for this transaction validates whether send is enabled or not

Once the event is validated by the Handler, it will send a particular amount of coins to the sender

## How to send coins

One can run the following transactions commands from the bank module :

* `send` - Send coin to an address.

### CLI commands
temaniarpit27 marked this conversation as resolved.
Show resolved Hide resolved

```
heimdallcli tx bank send [TO_ADDRESS] [AMOUNT] --chain-id <CHAIN_ID>
```

### REST endpoints

Rest endpoint creates a message which needs to be written to a file. Then the sender needs to sign and broadcast a transaction

```
curl -X POST http://localhost:1317/bank/accounts/<TO_ADDRESS>/transfers \
-H 'Content-Type: application/json' \
-d '{
"base_req": {
"chain_id": <CHAIN_ID>,
"from": <FROM_ADDRESS>
},
"amount": [
{
"denom": "matic",
"amount": <AMOUNT>
}
]
}' > <FILE>.json

heimdallcli tx sign <FILE>.json --chain-id <CHAIN_ID> > <FILE2>.json

heimdallcli tx broadcast <FILE2>.json
```

## Query commands

One can run the following query commands from the bank module :

* `balance` - Query for bank balance of an address.

### CLI commands

```
heimdallcli query bank balance [ADDRESS]
```

### REST endpoints

```
curl -X GET "localhost:1317/bank/balances/{ADDRESS}"
```