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.
type MsgSend struct {
FromAddress types.HeimdallAddress `json:"from_address"`
ToAddress types.HeimdallAddress `json:"to_address"`
Amount sdk.Coins `json:"amount"`
}
Handler 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
One can run the following transactions commands from the bank module :
send
- Send coin to an address.
heimdallcli tx bank send [TO_ADDRESS] [AMOUNT] --chain-id <CHAIN_ID>
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
One can run the following query commands from the bank module :
balance
- Query for bank balance of an address.
heimdallcli query bank balance [ADDRESS]
curl -X GET "localhost:1317/bank/balances/{ADDRESS}"