Links

Run an API node

API node parameters

The hardware requirements for the API node depend on the traffic pointed to the individual node. It has to be able to stay synchronized and serve the requests at the same time. Therefore, you should scale it according to your expected load.
Minimum requirements for API node with all history (Q4 2022):
  • Cloud: AWS EC2 m5.xlarge with 4 vCPUs (3.1 GHz), 16 GB of memory and at least 7 TB of Amazon EBS General Purpose SSD (gp2) storage (or equivalent or better).
  • You will need at least 7TB of SSD storage for the full archive node.
  • We recommend at least 1 Gbps network bandwidth for a public API node.
  • Ubuntu Server 20.04 LTS (64-bit) or similar Linux/Unix based system.

What are we going to do?

Setting up the node

Network Settings

Open up port 22 for SSH, as well as port 5050 for both TCP and UDP traffic for node P2P network. Also if you plan to expose the API, then select a port which will serve the RPC API request. A custom port can be used with --port <port> flag for P2P and --http.port <port> flag for API when you run your node, more on that later in this article. Keep all other ports closed as the node doesn't need any other.

Set up Non-Root User

If there is already a non-root user with sudo rights available, you can skip this step.
# SSH into your machine
(local)$ ssh [email protected]{IP_ADDRESS}
# Update the system
$ sudo apt-get update && sudo apt-get upgrade -y
# Create a non-root user
$ USER={USERNAME}
$ sudo mkdir -p /home/$USER/.ssh
$ sudo touch /home/$USER/.ssh/authorized_keys
$ sudo useradd -d /home/$USER $USER
$ sudo usermod -aG sudo $USER
$ sudo chown -R $USER:$USER /home/$USER/
$ sudo chmod 700 /home/$USER/.ssh
$ sudo chmod 644 /home/$USER/.ssh/authorized_keys
Make sure to paste your public SSH key into the authorized_keys file of the newly created user in order to be able to log in via SSH.
# Enable sudo without password for the user
$ sudo vi /etc/sudoers
Add the following line to the end of the file:
{USERNAME} ALL=NOPASSWD: ALL
Now close the root SSH connection to the machine and log in as your newly created user:
# Close the root SSH connection
$ exit
# Log in as new user
(local)$ ssh {USERNAME}@{IP_ADDRESS}

Install Required Tools

You are still logged in as the new user via SSH. Now we are going to install Go and Opera.
First, install the required build tools:
# Install build-essential
$ sudo apt-get install -y build-essential

Install Go

# Install latest Go compiler
$ wget https://go.dev/dl/go1.19.1.linux-amd64.tar.gz
$ sudo tar -xvf go1.19.1.linux-amd64.tar.gz
$ sudo mv go /usr/local
Export the required Go paths
# Export go paths
$ vi ~/.bash_aliases
# Append the following lines
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Validate your Go installation
# $ go version

Build and run your API node

For building go-opera from the source, please always checkout the latest supported version. The list of actual releases and release candidates can be found here in description.
# Install Opera
$ git clone https://github.com/Fantom-foundation/go-opera.git
$ cd go-opera/
$ git checkout release/1.1.1-rc.2
$ make
Validate your Opera installation:
$./build/opera version
Version: 1.1.1-rc.2
For running an API node, you need to download a genesis file and synchronize from this genesis state to present. On this page, you can download it according to your needs. For providing just latest informations with your API node, you can select the pruned ones, without a history data. In case that you want to provide all historical data, then you have to select genesis file with "Starting EVM history" filled with Full in the table.
The other option is to use a snapshot. More information about snapshots you can find here.
For the first run with a genesis file, you have to provide a path to this file with the --genesis parameter. It is not needed once the genesis is processed and also it is not needed when running with the snapshot. With the parameter --datadir, you specify where your blockchain data will be stored. In case of using snapshot, you need to point a datadir to the snapshot location.
# Start opera node
$ nohup ./build/opera \
--genesis=mainnet-109331-full-mpt.g \
--datadir={DATA LOCATION} \
--http.port=8080 \
--http.api=eth,web3,net,txpool,ftm &
You can check other parameters with opera help command. Note that https and ws must not be enabled on a server that stores wallet account.

Run transaction tracing API node

Running a transaction tracing node is very similar as a standard API node. It uses a different version of github repository for building from the source code. The other thing is that the transaction traces are created when blocks are processed during blockchain synchronization, so it is a good practise to start a node from scratch and let it synchronize with --tracenode parameter.
You have to run your transaction tracing node using tx-tracing go-opera 1.1.1-rc.2 (full sync mode). This version is used in Q3 of 2022. For newer versions please check the actual txtracing branch in the Fantom foundation github repository. Note that --http and --ws must not be enabled on a server that stores wallet account.
# Install Opera
$ git clone https://github.com/Fantom-foundation/go-opera.git
$ cd go-opera/
$ git checkout release/txtracing/1.1.1-rc.2
$ make
Validate your Opera installation:
$./build/opera version
Version: 1.1.1-txtracing-rc.2
Download a genesis file from this list of genesis files with full history (Starting EVM history column with Full).
# Start opera node
$ nohup ./opera \
--tracenode \
--genesis=mainnet-109331-full-mpt.g \
--datadir={DATA LOCATION} \
--http.port=8080 \
--http.api=eth,web3,net,txpool,ftm,trace,debug &
The most important parameter for the transaction tracing node is the --tracenode. It enables the tracing capabilities. The trace parameter of the --http.api exposes the trace API on the http interface.
You can check other parameters with opera help command. The default synchronization mode is full. You shouldn't use any other mode as tracing needs all the data generated during the regular syncing procedure.