RPC for Soroban mainnet
Tags: stellar, soroban
Published: 2024-02-22 12:01:52

It's here! Soroban smart contracts have launched on Stellar mainnet on [20 Feb 2024 at 17:00 UTC](https://stellar.org/blog/developers/protocol-20-and-smart-contracts-are-live-on-mainnet).

The validators cast their votes at 17:00 UTC, and the first ledger after that ([50457424](https://stellar.expert/explorer/public/ledger/50457424)) was running on protocol 20.
And within seconds, the first smart contract was deployed:  [CDGFGODCSQQQFFBUEJGS7NIDUA5OQKBRFQ57IOKZAZIEJDNQNHS3RV5O](https://stellar.expert/explorer/public/contract/CDGFGODCSQQQFFBUEJGS7NIDUA5OQKBRFQ57IOKZAZIEJDNQNHS3RV5O) 

But then.. quiet!? No other contract calls. Why is that?
First of all, Soroban is in phase 0 for the first week, with very low limits on resources contracts can use.
But another thing that perhaps caught devs by surprise was the lack of RPC servers.
See, you need an RPC server to interact with Soroban. And for testnet and futurenet, the SDF has made their RPC server publicly availabe. Not so on mainnet though.

**So what's a dev to do?**
The docs have a [list of public RPC providers](https://soroban.stellar.org/docs/reference/rpc-list) you can have a look at. 
There are paid and free plans, and even no-signup options.
But you can also run one yourself. It's not very hard, I managed to do it.
There is a page in the [Soroban docs](https://soroban.stellar.org/docs/reference/rpc#docker-image), but I found myself needing more info.
And I've compiled that info and steps into a bite-size guide here!

You will need:
- ~ 80GB of disk space
- ~ 1 hour for initial sync
- ~ 1o minutes for re-sync when you re-start it
- An internet connection
- At least some CPU and RAM, I run it comfortably on my laptop with ([i5 12450h](https://www.intel.com/content/www/us/en/products/sku/132222/intel-core-i512450h-processor-12m-cache-up-to-4-40-ghz/specifications.html) CPU and 16 GB RAM.

The below is for Linux, see my [other post](https://dev.to/row-bear/soroban-rpc-on-windows-47kd) for Windows.

I give you my

## 10 easy steps to run Soroban-RPC

**1) Docker**
First, you'll need to install docker on your PC.
I followed [this guide](https://www.linuxtechi.com/how-to-install-docker-on-linux-mint/)

**2) Set up a folder**
Create a folder in your home/user dir, called soroban-rpc
For me, that is at /home/row-bear/soroban-rpc
(Or whatever you like, just remember the name)

**3) Get the Docker image**
In a new terminal window: `docker pull stellar/soroban-rpc image`

**4) Configure**
The RPC image will need a stellar-core.toml file.
The best practice is to craft one yourself, so you can evaluate which validators you want to include or exclude in your trust set.
I use [this one](https://gist.github.com/Row-Bear/952266e78ab8a5c623786fa4fa5feba2).
Place that file in the folder you made in step 2.
For me, it's at /home/row-bear/soroban-rpc/stellar-core.toml

**5) Start it up!**
Replace 'row-bear' in the below command with your username (or the whole path with whichever directory you made) and in a new terminal window, run:

```
docker run -p 8001:8001 -p 8000:8000 \
-v /home/row-bear/soroban-rpc:/config stellar/soroban-rpc \
--captive-core-config-path="/config/stellar-core.toml" \
--captive-core-storage-path="/var/lib/stellar/captive-core" \
--stellar-core-binary-path="/usr/bin/stellar-core" \
--db-path="/var/lib/stellar/soroban-rpc-db.sqlite" \
--stellar-captive-core-http-port=11626 \
--network-passphrase="Public Global Stellar Network ; September 2015" \
--history-archive-urls="https://history.stellar.org/prd/core-live/core_live_001" \
--admin-endpoint="0.0.0.0:8001" \
--endpoint="0.0.0.0:8000"
```
You may need to use `sudo`, depending on your system config.
If you want it to run on testnet or futurenet, adjust the passphrase in the command (and modify your stellar-core.toml !).

It will start and start to sync. This can take up to an hour, for the first time.

**6) Find the container ID**
To make sure you can stop and restart the image without doing the full sync again (and eating your disk space in the process!) we'll need to find the container id.
In a new terminal, run `docker container ls -a`
Remember the -a flag. Else, it will only show running containers. One might assume the container is gone, and keep creating new ones.. 1/10 do not recommend.

![Docker lists it's containers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/in9ewlt71kcemyjiun8m.png)


Note down the ID of the container that is running. For me, it's 929de777dddc

**7) Stopping and starting it**
In a terminal window, run 
`sudo docker stop <id>` and then
`sudo docker start <id>`
So, for me: `sudo docker stop 929de777dddc`

**8) Monitor the logs**
After restarting, you won't see the log output in your terminal window. If you want that, run:
`sudo docker logs -f <id>`

**9) Check the status**
Again in a terminal, you can run:

```
curl --location 'http://localhost:8000' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"id":2,
"method":"getHealth"
}'
```
If it's synced, you'll get: 
![Soroban-RPC reports 'Healthy' status](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4mc56bhf2fzjo1scj0s.png)


**10) Now let's use it!**
It's up and running, and hopefully synced.
If you use soroban-cli, you can now add a network to use your RPC: `soroban network add local_rpc --rpc-url http://localhost:8000 --network-passphrase "Public Global Stellar Network ; September 2015"'
Then, in your next `soroban contract invoke`, you can use your very own RPC with `--network local_rpc`

If you have any practical tips for others, please share them in the comments :-)

As always, join the [Stellar Dev](https://discord.gg/stellardev) discord to discuss the technical stuff, and the [Stellar Global](https://discord.gg/stellar-global-761985725453303838) discord for everything Stellar.

Happy coding!