github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/docs/run-node/run-node.md (about)

     1  <!--
     2  order: 2
     3  -->
     4  
     5  # Running a Node
     6  
     7  Now that the application is ready and the keyring populated, it's time to see how to run the blockchain node. In this section, the application we are running is called `fbchaind`, and its corresponding CLI binary `fbchaind`. {synopsis}
     8  
     9  ## Pre-requisite Readings
    10  
    11  - [Anatomy of an SDK Application](../basics/app-anatomy.md) {prereq}
    12  - [Setting up the keyring](./keyring.md) {prereq}
    13  
    14  ## Initialize the Chain
    15  
    16  ::: warning
    17  Make sure you can build your own binary, and replace `fbchaind` with the name of your binary in the snippets.
    18  :::
    19  
    20  Before actually running the node, we need to initialize the chain, and most importantly its genesis file. This is done with the `init` subcommand:
    21  
    22  ```bash
    23  # The argument <moniker> is the custom username of your node, it should be human-readable.
    24  fbchaind init <moniker> --chain-id my-test-chain
    25  ```
    26  
    27  The command above creates all the configuration files needed for your node to run, as well as a default genesis file, which defines the initial state of the network. All these configuration files are in `~/.fbchaind` by default, but you can overwrite the location of this folder by passing the `--home` flag.
    28  
    29  The `~/.fbchaind` folder has the following structure:
    30  
    31  ```bash
    32  .                                   # ~/.fbchaind
    33    |- data                           # Contains the databases used by the node.
    34    |- config/
    35        |- app.toml                   # Application-related configuration file.
    36        |- config.toml                # Tendermint-related configuration file.
    37        |- genesis.json               # The genesis file.
    38        |- node_key.json              # Private key to use for node authentication in the p2p protocol.
    39        |- priv_validator_key.json    # Private key to use as a validator in the consensus protocol.
    40  ```
    41  
    42  Before starting the chain, you need to populate the state with at least one account. To do so, first [create a new account in the keyring](./keyring.md#adding-keys-to-the-keyring) named `my_validator` under the `test` keyring backend (feel free to choose another name and another backend).
    43  
    44  Now that you have created a local account, go ahead and grant it some `okt` tokens in your chain's genesis file. Doing so will also make sure your chain is aware of this account's existence:
    45  
    46  ```bash
    47  fbchaind add-genesis-account $MY_VALIDATOR_ADDRESS 100000000okt
    48  ```
    49  
    50  Recall that `$MY_VALIDATOR_ADDRESS` is a variable that holds the address of the `my_validator` key in the [keyring](./keyring.md#adding-keys-to-the-keyring). Also note that the tokens in the SDK have the `{amount}{denom}` format: `amount` is is a 18-digit-precision decimal number, and `denom` is the unique token identifier with its denomination key (e.g. `okt`). Here, we are granting `okt` tokens, as `okt` is the token identifier used for staking in [`fbchaind`](https://github.com/okex/fbc). For your own chain with its own staking denom, that token identifier should be used instead.
    51  
    52  Now that your account has some tokens, you need to add a validator to your chain. Validators are special full-nodes that participate in the consensus process (implemented in the [underlying consensus engine](../intro/sdk-app-architecture.md#tendermint)) in order to add new blocks to the chain. Any account can declare its intention to become a validator operator, but only those with sufficient delegation get to enter the active set (for example, only the top 125 validator candidates with the most delegation get to be validators in the Cosmos Hub). For this guide, you will add your local node (created via the `init` command above) as a validator of your chain. Validators can be declared before a chain is first started via a special transaction included in the genesis file called a `gentx`:
    53  
    54  ```bash
    55  # Create a gentx.
    56  fbchaind gentx my_validator 100000stake --chain-id my-test-chain --keyring-backend test
    57  
    58  # Add the gentx to the genesis file.
    59  fbchaind collect-gentxs
    60  ```
    61  
    62  A `gentx` does three things:
    63  
    64  1. Registers the `validator` account you created as a validator operator account (i.e. the account that controls the validator).
    65  2. Self-delegates the provided `amount` of staking tokens.
    66  3. Link the operator account with a Tendermint node pubkey that will be used for signing blocks. If no `--pubkey` flag is provided, it defaults to the local node pubkey created via the `fbchaind init` command above.
    67  
    68  For more information on `gentx`, use the following command:
    69  
    70  ```bash
    71  fbchaind gentx --help
    72  ```
    73  
    74  ## Run a Localnet
    75  
    76  Now that everything is set up, you can finally start your node:
    77  
    78  ```bash
    79  fbchaind start
    80  ```
    81  
    82  You should see blocks come in.
    83  
    84  The previous command allow you to run a single node. This is enough for the next section on interacting with this node, but you may wish to run multiple nodes at the same time, and see how consensus happens between them.
    85  
    86  
    87  ## Next {hide}
    88  
    89  Read about the [Interacting with your Node](./interact-node.md) {hide}