Skip to content

Latest commit

 

History

History
74 lines (49 loc) · 2.43 KB

lesson_3.md

File metadata and controls

74 lines (49 loc) · 2.43 KB

Goal:

  • Learners understand how to identify and configure node ports
  • Learners understand how key stored.

Lesson 3: Interacting chain with CLI and config port

Interacting chain with CLI

In previos lesson, we did make transaction successful with commandline. In this lesson, we're continue interact chain, that's include create key, give balance to new account, choose how to store key and make transaction with this account.

Read previos lesson for starting chain and make first transaction at: https://github.com/kaito2001/learn-cosmos-sdk-vbi/blob/main/docs/chapter_1/lesson_2.md

  1. Make new key
vbi-cosmos-basicd keys add <name> [flags]

Include:

  • name: name key
  • Here, we're attention for two flag. --home (default "$HOME/.name_chain", maybe custom this and store this key pair at new dir, example i wanna stored in dir .ABC, vbi-cosmos-basicd keys add --home '$HOME/.ABC'). --keyring-backend (suggest for use file option, should not use test)

result

  1. Give balance to key
vbi-cosmos-basicd add-genesis-account [address_or_key_name] [coin] [flags]
  • Here, an address is only active on the chain when it has a balance, [coin] - number balance + name token

  • Check balance account

vbi-cosmos-basicd q bank balances [address] [flag]

result

  • Account after add balances, in genesis file, it will be add:

result

  • Now, we create more account with 'test1' name and send balance from test to test1:

result

  • You should redo these steps with a store stored in the khsac directory.

Config Port

Now, we easy to see some port after we start run chain:

result

Config port's an essential thing in blockchain. For example, if the port you run coincides with other applications running in the background, it will surely report an error

A node has many ports to serve different purposes, but the three one worth focusing on are:

  1. RPC (Remote Procedure Call) listen port (default 26657)

  2. REST API listen port (default 1317)

  3. P2P listen port (default 26656)

  4. RPC

  • change rpc address in config.toml
  • vbi-cosmos-basicd start --rpc.laddr tcp://0.0.0.0:1800
  1. REST API:
  • enable REST API in app.toml
  • enable swagger in app.toml
  • change REST API in app.toml
  1. P2P:
  • change p2p address in config.toml
  • vbi-cosmos-basicd start --p2p.laddr tcp://0.0.0.0:1900

Help video: