How to Deploy a Node on Injective Blockchain

How to Deploy a Node on Injective Blockchain

Running a node is the best way to join the Injective blockchain. Our step-by-step guide will show you how to deploy a node on the Injective network and the specific requirements you need to prepare before getting started.

What is an Injective Node?

An Injective node is a device (usually a computer) that provides a variety of services within the Injective network. Those include validating transactions, storing blockchain data, and enabling clients to interact with the blockchain.

The two key types of nodes on the Injective network are the full node and the validator node. To get more information on the Injective network and the current nodes, check out Injective Docs.

  • Full nodes: The most important node of the Injective network. These nodes participate in validating transactions and keep the entire blockchain's data.
  • Validator nodes: A special type of full node. These nodes are tasked with similar responsibilities; however, they can join the consensus and earn rewards in exchange for their services.
Run a Node on Injective Blockchain
Run a Node on Injective Blockchain

Injective Node Requirements

Node operators aiming to run an Injective node need to provision robust data center locations with redundant infrastructure components such as power, networking, firewalls, Hardware Security Modules (HSMs), and servers to ensure high availability and reliability.

The minimum hardware specifications for running an Injective node are as follows:

  • CPU: 8+ vCPU x64
  • RAM: 64+ GB RAM
  • Storage: 1+ TB SSD storage
  • Network Bandwidth: 1+ Gbps

However, as the network usage increases, it is recommended to consider higher hardware specifications for a more performant node:

  • CPU: 16+ vCPU
  • RAM: 128+ GB RAM
  • Storage: 2+ TB SSD storage
  • Network Bandwidth: 5+ Gbps

Opting for a higher storage capacity allows for less frequent data pruning from the node while ensuring more historical data can be retained.

How to Deploy a Node on Injective Blockchain

Step 1: Install Injectived

To start setting up an Injective node, you first need to install Injectived. This is the software that allows you to connect to the Injective blockchain and participate in the network.

Here are the steps to install Injective from binary (you can also choose to install from source, check the Injective Docs for this option):

  • Check out and download the latest version of Injective Chain binaries on the project's GitHub.
  • Unzip the file and add injectived, injective-exchange and peggo to your /usr/bin; then add libwasmvm.x86_64.so to the user library path /usr/lib.
  • Run the commands to check your binary version:
injectived version
peggo version
injective-exchange version

Confirm your version matches the output below

injectived version
Version dev (f32e524)
peggo version
Version dev (b5c188c)
injective-exchange version
Version dev (ca1da5e)

Step 2: Set up keyring

The keyring in the Injective network is a secure storage location for your private keys. It is used to store the cryptographic keys that allow you to interact with the Injective blockchain (running a validator node or sending/receiving tokens).

You can choose where you want to store your private keys. The available storage locations (backends) include:

  • The operating system (os backend).
  • The app's configuration directory (file backend).
  • The gpg encrypted files (pass backend).
  • KDE Wallet Manager (kwallet backend).
  • memory backend.
  • test backend.

To interact with the keyring and manage keys, you can use the injectived keys command. For auto-completion, run . <(injectived completion) at the start of a bash session.

To create a new key in the keyring, run the following commands:

injectived keys add my_validator --keyring-backend test

MY_VALIDATOR_ADDRESS=$(injectived keys show my_validator -a --keyring-backend test)

This command generates a new mnemonic phrase and stores it in the chosen backend. If this key will hold tokens of value, make sure to keep the mnemonic phrase securely.

The keyring supports eth_secp256k1 and ed25519 key types. You can create both types of keys within the keyring simultaneously.

Step 3: Set Up and Run a Local Node

Once you have added all the keys to the keyring, it is time to set up and run an Injective node on your local machine.

For a hassle-free establishment of a local node, proceed by downloading and executing the setup.sh script. This will effectively commence the initialization of your local Injective chain.

wget https://raw.githubusercontent.com/InjectiveLabs/injective-chain-releases/master/scripts/setup.shchmod +x ./setup.sh # Make the script executable./setup.sh

Start the node by running the following command:

injectived start # Blocks should start coming in after running this

Initialize the Chain

To prepare for running the Injective Chain node, it is necessary to first initialize both the chain and the node's genesis file.

# The <moniker> argument is the custom username of your node. It should be human-readable.injectived init <moniker> --chain-id=injective-1

To set up your node and define the initial state of the network, use the command provided above. This will generate all the necessary configuration files, including a default genesis file.

By default, these files are stored in the ~/.injectived. However, if you prefer a different location, you can specify it by using the --home flag. Keep in mind that if you choose to use a directory other than ~/.injectived, you must include the --home  flag every time you run an injectived command. If you already have a genesis file and wish to replace it, simply add the --overwrite or -o flag.

The ~/.injectived folder is structured as follows:

.                                   # ~/.injectived  |- data                           # Contains the databases used by the node.  |- config/      |- app.toml                   # Application-related configuration file.      |- config.toml                # Tendermint-related configuration file.      |- genesis.json               # The genesis file.      |- node_key.json              # Private key to use for node authentication in the p2p protocol.      |- priv_validator_key.json    # Private key to use as a validator in the consensus protocol.

Modify the genesis.json File

To ensure compatibility with the Injective Chain's native token inj, you need to make certain changes in the genesis.json file.

Specifically, update the staking bond_denom, crisis denom, gov denom, and mint denom values  accordingly. Executing the following commands will seamlessly accomplish this task:

cat $HOME/.injectived/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.jsoncat $HOME/.injectived/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.jsoncat $HOME/.injectived/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.jsoncat $HOME/.injectived/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="inj"' > $HOME/.injectived/config/tmp_genesis.json && mv $HOME/.injectived/config/tmp_genesis.json $HOME/.injectived/config/genesis.json

Note: Please ensure that you are using the default .injectived directory for the commands mentioned above. If you are using a different directory, you will need to make modifications to the commands or manually edit the genesis.json file to match your changes.

Create Keys for the Validator Account

Before proceeding further, make sure you've got at least one account in the state. To get started, simply whip up a fresh account in the keyring my_validator  using the test keyring backend (feel free to switch up names and backends if you fancy).

injectived keys add my_validator --keyring-backend=test# Put the generated address in a variable for later use.MY_VALIDATOR_ADDRESS=$(injectived keys show my_validator -a --keyring-backend=test)

After successfully creating a local account, proceed to add/allocate inj tokens to it in the genesis file of your chain. This step is crucial as it ensures that your chain acknowledges the presence of this account:

injectived add-genesis-account $MY_VALIDATOR_ADDRESS 100000000000000000000000000inj --chain-id=injective-1

$MY_VALIDATOR_ADDRESS stores the address of my_validator key in the keyring. In the Injective Chain, tokens are represented in the amount denom format. The amount is a decimal number with 18 digits of precision, while denom is the unique token identifier with its denomination key (e.g. inj). In this case, we are granting inj tokens, which is the token identifier used for staking in injectived.

Add the Validator to the Chain

The next step is to incorporate a validator into your chain. These validators serve as specialized full-nodes that actively participate in the consensus process with the objective of appending new blocks to the chain.

It is important to note that any account can declare its intention of becoming a validator operator; however, only those who possess sufficient delegation will be able to join the active set.

For this particular guide, you will be adding your local node (which was created using the init command mentioned previously) as a validator for your chain. It is worth mentioning that validators can be declared before initiating a chain by utilizing a distinctive transaction called gentx, which is included within the genesis file.

# Create a gentx.injectived gentx my_validator 1000000000000000000000inj --chain-id=injective-1 --keyring-backend=test# Add the gentx to the genesis file.injectived collect-gentxs

To get more information on gentx, run the following command:

injectived gentx --help

Configuring the Node Using app.toml and config.toml

In the ~/.injectived/config directory, you will find two automatically generated configuration files:

config.toml: serves as a configuration file for Tendermint and can be further explored in Tendermint's documentation.

On the other hand, app.tomlis specifically generated by the Cosmos SDK - the underlying framework of Injective Chain - and encompasses configurations related to state pruning strategies, telemetry settings, gRPC and REST server setups, state synchronization mechanisms, among others.

To modify the configuration, focus on the minimum-gas-prices field inside app.toml. This particular field determines the lowest gas prices that the validator node will consider acceptable for transaction processing. If it happens to be empty, ensure that you assign a value to it, such as 10inj, otherwise the node will cease functioning during startup.

In this guide, we will establish a minimum gas price of 0.

 # The minimum gas prices a validator is willing to accept for processing a # transaction. A transaction's fees must meet the minimum of any denomination # specified in this config (e.g. 0.25token1;0.0001token2). minimum-gas-prices = "0inj"

Run a Localnet

Now your node is up. Let's start running your node:

injectived start # Blocks should start coming in after running this

If you are interested in running a node on Mainnet or Testnet, please refer to the following guides:

And finally, make sure to regularly check out Injective Documentation for further updates.