# Joining Network Using State Sync

The state sync feature allows a new peer to join the network by asking for a snapshot from existing peers. SEDA provides the following RPC nodes to support this feature. Use these addresses in Step 3:

<table><thead><tr><th width="100">Network</th><th width="181">RPC1</th><th width="181">RPC2</th></tr></thead><tbody><tr><td>seda-1 (mainnet)</td><td>13.40.140.211:26657</td><td>https://rpc.seda.xyz</td></tr><tr><td>seda-1-testnet (testnet)</td><td>18.171.235.206:26657</td><td>https://rpc.testnet.seda.xyz</td></tr></tbody></table>

Steps:

1. Check the [version history](broken://pages/bxtknGBwB2k8ogoOP0WD) and download the correct binary version from the SEDA Chain [repository](https://github.com/sedaprotocol/seda-chain).
2. Initialize your node for `mainnet` or `testnet`:

   ```
   sedad join <moniker> --network mainnet
   ```
3. Run the following commands to enable state sync and add trusted information to the configuration file `config.toml`.

   ```bash
   RPC="https://rpc.seda.xyz" # For testnet, use https://rpc.testnet.seda.xyz

   LATEST_HEIGHT=$(curl -s $RPC/block | jq -r .result.block.header.height); \
   BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)); \
   TRUST_HASH=$(curl -s "$RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash)

   sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
   s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$RPC,$RPC\"| ; \
   s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
   s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.sedad/config/config.toml
   ```

   1. To complete this step manually, fill out the following fields in `config.toml` with the information obtained from a trusted source. We recommend using the block height around 2,000 blocks before the latest block height.&#x20;

      ```
      [statesync]
      enable = true
      rpc_servers = "https://rpc.seda.xyz,13.40.140.211:26657"

      trust_height = 653231
      trust_hash = "B77528F6A290FCFBF25F730C6D490DE0DA7587EC6B2612AA2547773499CFB47E"
      trust_period = "168h0m0s"
      ```
4. (Optional) Sometimes a recent snapshot may not be available in the peer-to-peer network, making it difficult to verify its header. SEDA runs a node that broadcasts snapshots taken every 100 blocks to the network. To ensure that a request for snapshots is sent to this node, add the following address to the `persistent_peers` field in `config.toml`.\
   For mainnet:

   ```
   persistent_peers = "14b094f86c14e94e81dc097e123b8b41c72743a7@13.40.140.211:26656"
   ```

   For testnet:

   ```
   persistent_peers = "4e6e94cca6c2f520557ddb6574e90ffbc3b8e0bf@18.171.235.206:26656"
   ```
5. You may have to disable SEDA signer to start the node. If you are a validator, please read [SEDA Keys](/home/tech/for-chain-operators/seda-keys.md) to set up SEDA signer after you finish the current instructions.

   ```
   sedad config set app seda.enable-seda-signer false
   ```
6. Start the node.

   ```
   sedad start
   ```

{% hint style="warning" %}
State sync may be unreliable at times. If it fails, please retry the steps after a few hours or consider [Broken mention](broken://pages/fAq9kYgmoNOQ0rrELQPV).
{% endhint %}


---

# 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://docs.seda.xyz/home/tech/for-chain-operators/joining-network-using-state-sync.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.
