> ## Documentation Index
> Fetch the complete documentation index at: https://docs-hosting.axiomesh.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Node

> Learn how to run an `AxiomLedger` node.

The steps to run an `AxiomLedger` node include:

1. Prepare the required environment
2. Obtain the node binary
3. Deploy and start the node
4. Connect to mainnet/testnet

## Environment Requirements

`AxiomLedger` supports the following operating systems:

* Linux:
  * Ubuntu 20.04
  * Centos 8
* MacOS: Ventura

## Obtain Node Binary

Note that the `AxiomLedger` binary contains a hidden `secret` to ensure that only nodes with the same `secret` can
connect to each other. The `secret` is injected into the binary during compilation. To connect to mainnet/testnet
you need to download the official binary released on GitHub.

### Download from GitHub

Go to the [Releases page](https://github.com/axiomesh/axiom-ledger/releases) of the `AxiomLedger` code repository, download the latest version binary zip file
for your operating system and CPU architecture, and unzip it in the deployment environment to get the AxiomLedger binary.

### Compile from Source

#### Prepare Compilation Environment

* Install Git.
* Compiling from source requires Golang environment above version `1.20`, see [Golang Installation Docs](https://go.dev/doc/install) for details.

#### Get AxiomLedger Code

1. Use the following commands to download the [repository code](https://github.com/axiomesh/axiom-ledger) and switch to the latest stable version tag.

   ```shell theme={null}
   git clone https://github.com/axiomesh/axiom-ledger.git
   cd axiom-ledger
   git checkout ${latest_tag}
   ```

2. Download dependencies.

   Use the following command to download dependency libraries.

   ```shell theme={null}
   go mod download
   ```

3. Compile the binary.

   Use the following command to compile the binary. Note that `secret` can be left unspecified. And `net` can be used to specify the configuration for
   mainnet or testnet. If not specified, it will default to the local 4-node configuration.

   ```shell theme={null}
   make build secret=${secret} net=${net_name}
   ```

   The compiled binary is at `./bin/axiom-ledger`.

## Deploy and Start Node

1. Generate related config files to specified directory.

   ```shell theme={null}
   axiom-ledger --repo=$WORKSPACE config generate
   ```

2. Modify config file.

   Config files are at `$WORKSPACE/config.toml`. You mainly need to modify ports and genesis validator configs.
   Nodes connect each other via P2P DHT network, so you only need to configure the P2P addresses of the genesis seed node.

   If you need to start quickly, you can configure it for solo node mode.

3. Start node.

   ```shell theme={null}
   axiom-ledger --repo=$WORKSPACE start
   ```

   To easily manage nodes, you can register `AxiomLedger` as a `systemctl` service:

   ```shell theme={null}
   [Unit]
   Description=AxiomLedger Node Service

   [Service]
   User=nodeuser
   Group=nodeuser

   LimitNOFILE=500000

   WorkingDirectory=$WORKSPACE
   ExecStart=/usr/local/bin/axiom-ledger --repo=$WORKSPACE start

   Restart=on-failure
   RestartSec=3s

   StandardOutput=journal
   StandardError=journal
   SyslogIdentifier=AxiomLedger

   [Install]
   WantedBy=multi-user.target
   ```

## Connect to Mainnet/Testnet

The default config generated from the official binary downloaded from GitHub already contains mainnet/testnet P2P seed node information. So after startup it will automatically connect to mainnet/testnet. However, before the governance proposal to add the node is approved, other nodes will reject this node's connection requests. The node can only join the network after the governance proposal is approved.
