# 0g Node Installation

By [Line 510](https://paragraph.com/@line-510) · 2024-07-15

---

**Dependencies Installation**
-----------------------------

    # Install dependencies for building from source
    sudo apt update
    sudo apt install -y curl git jq lz4 build-essential
    
    # Install Go
    sudo rm -rf /usr/local/go
    curl -L https://go.dev/dl/go1.21.6.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
    echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> $HOME/.bash_profile
    source .bash_profile
    

**Node Installation**
---------------------

    # Clone project repository
    cd && rm -rf 0g-chain
    git clone https://github.com/0glabs/0g-chain
    cd 0g-chain
    git checkout v0.2.3
    
    # Build binary
    make install
    
    # Set node CLI configuration
    0gchaind config chain-id zgtendermint_16600-2
    0gchaind config keyring-backend test
    0gchaind config node tcp://localhost:26657
    
    # Initialize the node
    0gchaind init "line510" --chain-id zgtendermint_16600-2
    
    # Download genesis and addrbook files
    curl -L https://snapshots-testnet.line510.io/0g-testnet/genesis.json > $HOME/.0gchain/config/genesis.json
    curl -L https://snapshots-testnet.line510.io/0g-testnet/addrbook.json > $HOME/.0gchain/config/addrbook.json
    
    # Set seeds
    sed -i -e 's|^seeds *=.*|seeds = "81987895a11f6689ada254c6b57932ab7ed909b6@54.241.167.190:26656,010fb4de28667725a4fef26cdc7f9452cc34b16d@54.176.175.48:26656,e9b4bc203197b62cc7e6a80a64742e752f4210d5@54.193.250.204:26656,68b9145889e7576b652ca68d985826abd46ad660@18.166.164.232:26656"|' $HOME/.0gchain/config/config.toml
    
    # Set minimum gas price
    sed -i -e 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0.0025ua0gi"|' $HOME/.0gchain/config/app.toml
    
    # Set pruning
    sed -i \
      -e 's|^pruning *=.*|pruning = "custom"|' \
      -e 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|' \
      -e 's|^pruning-interval *=.*|pruning-interval = "17"|' \
      $HOME/.0gchain/config/app.toml
    
    # Download latest chain data snapshot
    curl "https://snapshots-testnet.line510.io/0g-testnet/0g-testnet_latest.tar.lz4" | lz4 -dc - | tar -xf - -C "$HOME/.0gchain"
    
    # Create a service
    sudo tee /etc/systemd/system/0gchaind.service > /dev/null << EOF
    [Unit]
    Description=0G node service
    After=network-online.target
    [Service]
    User=$USER
    ExecStart=$(which 0gchaind) start
    Restart=on-failure
    RestartSec=10
    LimitNOFILE=65535
    [Install]
    WantedBy=multi-user.target
    EOF
    sudo systemctl daemon-reload
    sudo systemctl enable 0gchaind.service
    
    # Start the service and check the logs
    sudo systemctl start 0gchaind.service
    sudo journalctl -u 0gchaind.service -f --no-hostname -o cat

---

*Originally published on [Line 510](https://paragraph.com/@line-510/0g-node-installation)*
