# RSK

RSK is configured by default to accept only localhost / 127.0.0.1 as the hostname

So when StackOS provides a custom hostname, or you configure your own DNS, RSK will refuse to serve any jsonrpc responses

### Solution

* Build the basic RSK mainnet image on your local machine

  * <https://developers.rsk.co/rsk/node/install/docker/>

  * ```
    docker build -t mainnet -f Dockerfile.MainNet .
    ```

  * You will end up with a mainnet image

### Prepare node.conf

Take the default node.conf and change the hosts the image will recognize

```
    web: {
        cors: "*",
        http: {
            enabled: true,
            bind_address = "0.0.0.0",
            hosts = ["tagethost.example.com"]
            port: 4444,
            }
        ws: {
            enabled: false,
            bind_address: "0.0.0.0",
            port: 4445,
            }
        }
    }

```

### Make a Dockerfile

```
FROM mainnet:latest
COPY node.conf /etc/rsk/node.conf
```

### Build & push your image

```
docker build -t dockerhubuser/myrsk:v123
docker push dockerhubuser/myrsk:v123
```

### Configure your pod

Download your own image that you just uploaded

![](/files/kChJUp9HXYOi0Hk1KRF3)

If you want to use custom DNS, set that up ahead of time

{% content-ref url="/pages/AxsBhGv6h4Tv3sIuF4Fh" %}
[Custom DNS](/stackos-docs/operations/custom-dns.md)
{% endcontent-ref %}

### Test your connection

Run curl against your host

```
curl https://rsk.mydomain.com/mainnet --header 'Content-Type: application/json'  -XPOST -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
```

Expect a response like<br>

```
{"jsonrpc":"2.0","id":1,"result":"0x0"}
```

### Debug your pod

Edit /etc/rsk/logback.xml and increase verbosity for jsonrpc

Wait 1 hour for rsk to read your new log config (or rebuild your docker image and force the change)

Watch for error messages

```
tail -f  /var/log/rsk/rsk.log | grep rpc
```

### Persistent Storage

If you wish to use persistent storage with rsk, be aware you must update the permissions of the storage directory

Here is an example configuraton

![](/files/1QePggBJwQLgL33dYZ3S)

After your pod boots, locate your pod name and shell into your pod:

{% content-ref url="/pages/f8p2oiwMIiPY9bDaaDIJ" %}
[WebTTY, Logs, Shell Access](/stackos-docs/operations/webtty-logs-shell-access.md)
{% endcontent-ref %}

**Then run the following command**

```
chown -R rsk:rsk /var/lib/rsk
```

Then your process will run normally.


---

# 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.stackos.io/stackos-docs/other-applications/rsk.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.
