Run Sonic API Node

Last updated 31 May 2024

Types of API nodes available

Before you start your Sonic API node, you need to decide which type you want to deploy based on your use case. There are two possible modes of operation:

  • Pruned API Node has a smaller database footprint utilising around 700 GB of storage initially. It can respond to state related RPC/Socket requests, allows you to interact with the network state, trace smart contract execution, and submit signed transaction to the network. The state history is limited to the block from which the state DB is created, usually using a validator type genesis file. If you try to query an older state, an error will be given.

  • Archive API Node has a larger database size using proximatelly 5.5 TB of storage initially. It can respond to all state related RPC/Socket requests for the whole blockchain history, allows you to interract with the network state at any block, trace smart contract execution, and submit signed transactions to the network. It's usually created from an archive genesis file.

What you need to do?

  1. Setup an appropriate server instance

  2. Install required development tools

  3. Build the Sonic node software

  4. Prime the Sonic database

  5. Synchronise with the network

Setup an appropriate server instance

A dedicated hardware (also called bare metal) will provide the best possible performance and speed. If you want to integrate your node into a broader infrastructure of your project, you may want to consider a cloud service provider, too. We recommend choosing one of the big cloud providers, e.g. Google GCP, or Amazon AWS.

Node hardware specification

A minimal configuration for the Sonic API node is a computation node with at least 4 vCPU and 32 GB of RAM. You will also need either at least 1.2TB, or 7TB of a local NVMe storage space for the Sonic database. The proper size depends on your selected APi node type. Remotely connected storage systems, e.g. Amazon EBS, usually don't provide required latency and random access performance required to run an API node.

The Google GCP N2D instances with local SSD drives, or Amazon AWS i3en.xlarge with the instance storage match the minimal requirements.

The number of vCPU and RAM available to the Sonic node dictates the final performance and responsiveness of the API interface. Please scale the size of your server specification for the expected amount of RPC requests. We recommend instances with 8 vCPU and 64 GB of RAM for smaller projects with less traffic, or 16 vCPU and 128 GB of RAM for public API endpoints. Another option is to deploy several smaller nodes and load balance the incoming traffic between them. The deployment setup details suitable for your specific case may vary.

We recommend using Ubuntu LTS Server (64-bit) or a similar linux distribution.

Required storage capacity

  • 1.2TB of local NVMe/SSD storage is sufficient to start a pruned API node using a validator genesis file.

  • 7TB of local NVMe/SSD storage is needed to provision a full archive API node.

Here you can obtain the latest genesis file:

Network settings

The Sonic node requires both TCP and UDP network traffic to be allowed on port 5050 by default. A custom port can be used with --port <port> flag when run your node.

The RPC/Socket interface of the node can be opened for incoming HTTP traffic on port 80, but the Sonic does not support SSL/TLS encryption. You will need to add a proxy server between the public HTTP interface and the Sonic node to be able to secure your connections with an SSL/TLS certificate.

Your cloud provider may offer a load balanced application proxy solution, which includes a certificate management. If you want to deploy such infrastructure yourself, you may want to check for example HAProxy, or Nginx community projects.

Install required development tools

You need the esential building tools and Go compiler version 1.21 or newer to build the Sonic client and bundled tools.

First, install the required build tools:

sudo apt-get install -y build-essential git

Install latest Go compiler from binary distribution:

sudo rm -rf /usr/local/go
sudo tar -xzf go1.22.4.linux-amd64.tar.gz -C /usr/local/
rm -f go1.22.4.linux-amd64.tar.gz

Setup Go language export paths:

sudo tee /etc/profile.d/ > /dev/null <<EOT
export GOROOT=/usr/local/go
export GOPATH=\$HOME/go
export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin


source /etc/profile.d/

Build the Sonic node software

Building the Sonic binary requires the essential software development tools and the Go language version 1.21 or newer to be available. Previous section contains basic steps to deploy the required applications on the recommended linux distribution. Please refer to your operating system manuals to install the development tools needed for this step.

Please check the latest release of the Sonic node and adjust your commands accordingly.

git clone
cd Sonic
git fetch --tags && git checkout -b v1.2.1-c tags/v1.2.1-c
make all

You can confirm the Sonic release by executing the version subcommand on the created binary.

build/sonicd version

Optionaly, you may want to copy the Sonic node app and the tooling into the system wide bin folder to make it available without explicitely specifying the binary path.

sudo mv build/sonic* /usr/local/bin/

Prime the Sonic database

You need a valid state database to be able to participate in the network. The fastest ands easiest way is to use a genesis file. Please check the official repository, where new signed genesis files are published, and pick the latest one suitable for your selected node type. You will need aproximately 50GB of storage for a pruned genesis file and 350GB of storage space for the full archive genesis download.

Obtain the latest genesis file and the corresponding checksum:


Check your download using the MD5 checksum file:

$ md5sum --check mainnet-285300-archive.g.md5
mainnet-285300-archive.g: OK

Use the Sonic tooling to prime state database using the downloaded genesis file. Refer to these steps to determine the amount of cache and memory consumption soft limit for your node. The --datadir flag should point to your local NVMe storage mount path.

GOMEMLIMIT=58GiB sonictool \
    --datadir ~/.sonic \
    --cache 25600 \
    genesis mainnet-285300-archive.g

The Sonic tool creates a primed state database from the genesis file. The last step is a validation procedure. It confirms that the expected state was built successfully reaching the expected root hash. You can refer to the official repository to verify that the state hash is indeed correct.

StateDB imported successfully, stateRoot matches module=gossip-store
  index=81990246 root="f60cd4…38652f"

How to calculate cache size and memory consumption soft limit values?

The Sonic node utilises large amount of RAM to achieve great speed and responsivness. It should be the only user space application consuming your system resources.

$ grep MemTotal /proc/meminfo
MemTotal:       65641928 kB
  • Approximately 40% of the available RAM should be used as the --cache for both the sonictool and sonicd applications. The final value denominated in MiB. For example: 64000 MiB RAM * 40% = 25600 MiB

  • Approximately 90% of the available RAM should be used as the application memory consumption limit. This limit is controled by GOMEMLIMIT environment variable. The final value includes an abbreviated units. We recommend using GiB for simplicity. For example: 64 GiB RAM * 90% ≈ 58 GiB

Synchronise with the network

Your node database has been primed to a certain epoch in the past using a genesis file and the Sonic tool. Now you need to get the node up to the current state. To do it, your node needs to be started in the read-only mode and establish a connection with the network. Please make sure your firewall is configured correctly to allow such communication. The mount of memory dedicated to node cache and the memory consumption limit is discussed above.

The RPC and/or Socket interfaces are turnned off by default. You need to specify which one you want to start and what range of services you want it to offer. You can find the default configuration in an example below. Please adjust the port, namespace, and domain related options based on your specific needs.

The HTTP API offers the Web3 interface for request-response type of interaction with the Fantom network. The WS API supports a sustained network connection with the ability to subscribe to certain network events, for example newblocks being created, or contracts being interacted with.

GOMEMLIMIT=58GiB sonicd \
    --datadir ~/.sonic \
    --cache 25600 \
    --http \
    --http.addr= \
    --http.port=8080 \
    --http.corsdomain="*" \
    --http.vhosts="*" \
    --http.api=eth,web3,net,ftm,txpool,abft,dag \
    --ws \
    --ws.addr= \
    --ws.port=8081 \"*" \

The Sonic node should start and connect with the network advancing the state by creating and processing new blocks. Please notice the age part of the log message, which tells you how far in the past these block are. The age should not exceed a couple of seconds once the node is fully synchronised.

Last updated

© 2024 Fantom Foundation