# 0G DA Node

## Resources

| Website | <https://0g.ai/>                                      |
| ------- | ----------------------------------------------------- |
| Github  | <https://github.com/0glabs>                           |
| x.com   | [https://x.com/0G\_labs](https://twitter.com/0G_labs) |
| Discord | <https://discord.com/invite/0glabs>                   |
| Docs    | <https://docs.0g.ai/0g-doc>                           |

## Prerequisite

To operate effectively, your DA signer needs to run a DA node to verify encoded blob data, sign it, and store it for future farming and rewards. Currently, to run a DA Node on Testnet, users must stake 10 OG tokens. These can be obtained through our [faucet](https://faucet.0g.ai/) or via rewards from running Storage Nodes or Validator Nodes. For official deployed contract addresses, visit [this page](https://docs.0g.ai/0g-doc/docs/contract-addresses).

## Hardware requirements

<table data-view="cards"><thead><tr><th>CPU</th><th>RAM</th><th>Storage</th><th>Network</th><th>OS</th></tr></thead><tbody><tr><td>8 cores</td><td>16 GB</td><td>1 TB NVME</td><td>100 MBps</td><td>Linux (Ubuntu 22.04 x64)</td></tr></tbody></table>

## Installation 💾

Install dependencies

```bash
sudo apt-get update && sudo apt-get install clang cmake build-essential pkg-config libssl-dev protobuf-compiler llvm llvm-dev
```

Install GO

```bash
cd $HOME && \
ver="1.23.3" && \
wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \
sudo rm -rf /usr/local/go && \
sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \
rm "go$ver.linux-amd64.tar.gz" && \
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile && \
source ~/.bash_profile && \
go version
```

Install Rust

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source $HOME/.cargo/env
rustc --version
```

Build binary from source

```bash
git clone -b v1.1.3 https://github.com/0glabs/0g-da-node.git

cd $HOME/0g-da-node
git stash
git fetch --all --tags
git checkout 9845b8b
git submodule update --init
cargo build --release

./dev_support/download_params.sh
```

Generate BLS private key, if you don't have one. It will register the signer information in DA contract when you first run DA node

{% hint style="info" %}
You must back up your BLS key.
{% endhint %}

```bash
cargo run --bin key-gen
```

Edit the configuration file (replace your \<public\_ip/dns>, signer\_bls\_private\_key, signer\_eth\_private\_key, miner\_eth\_private\_key)

```bash
nano $HOME/0g-da-node/config.toml
```

```bash
log_level = "info"

data_path = "./db/"

# path to downloaded params folder
encoder_params_dir = "params/" 

# grpc server listen address
grpc_listen_address = "0.0.0.0:34000"
# chain eth rpc endpoint
eth_rpc_endpoint = "https://evmrpc-testnet.0g.ai"
# public grpc service socket address to register in DA contract
# ip:34000 (keep same port as the grpc listen address)
# or if you have dns, fill your dns
socket_address = "<public_ip/dns>:34000"

# data availability contract to interact with
da_entrance_address = "0xE75A073dA5bb7b0eC622170Fd268f35E675a957B"
# deployed block number of da entrance contract
start_block_number = 326165

# signer BLS private key
signer_bls_private_key = ""
# signer eth account private key
signer_eth_private_key = ""
# miner eth account private key, (could be the same as 'signer_eth_private_key', but not recommended)
miner_eth_private_key = ""

# whether to enable data availability sampling
enable_das = "true"
```

Create a service file

```bash
sudo tee /etc/systemd/system/0gda.service > /dev/null <<EOF
[Unit]
Description=0G-DA Node
After=network.target

[Service]
User=$USER
WorkingDirectory=$HOME/0g-da-node
ExecStart=$HOME/0g-da-node/target/release/server --config $HOME/0g-da-node/config.toml
Restart=always
RestartSec=10
LimitNOFILE=65535

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

Start the node

```bash
sudo systemctl daemon-reload
sudo systemctl enable 0gda
sudo systemctl start 0gda
```

## Useful commands ⚙️

Stop the node

```bash
sudo systemctl stop zgs
```

Check logs

```bash
sudo journalctl -u 0gda -f -o cat
```

## Delete node 🗑️

```bash
sudo systemctl stop 0gda
sudo systemctl disable 0gda
sudo rm /etc/systemd/system/0gda.service
rm -rf $HOME/0g-da-node
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cryptomolot.gitbook.io/cryptomolot-docs/testnets/0g-zero-gravity/0g-da-node.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
