Setup the ETH RPC Adaptor for the Theta Mainnet

This page provides the instructions to setup the ETH RPC Adaptor for the Theta Mainnet on a virtual machine. The adaptor is a middleware which translates the Theta RPC interface to the Ethereum RPC interface. To enable the Theta ETH RPC API service, you’d need to run 1) the Theta Node, and 2) the Theta/ETH RPC adaptor on the same VM. Below is the recommended VM spec:

OS: Ubuntu (18.04.4 LTS or higher version)
CPU: 4 cores or more
Memory: 32 GB or more
Hardrive: 1 TB+ SSD drive

1. Install and Launch the Theta Mainnet Node

1.1. Installation

Please follow the instructions below to download the latest precompiled Linux binary and the necessary data. If you prefer to compile from the source code, please follow the steps here. If you are running the node on a Linux server, you'd need to run the node in a screen or tmux session or as a background process, so that after you've logged off, the Theta node can continue to run.

screen -S theta_mainnet # if you run the node on a Linux server
mkdir ~/theta_mainnet
cd ~/theta_mainnet
mkdir bin
mkdir -p guardian_mainnet/node
curl -k --output bin/theta `curl -k ''`
curl -k --output bin/thetacli `curl -k ''`
wget -O guardian_mainnet/node/snapshot `curl -k`
curl -k --output guardian_mainnet/node/config.yaml `curl -k ''`
chmod +x bin/theta
chmod +x bin/thetacli
cd bin/

1.2. Launch the Theta Node

Now launch Theta with the following commands.

./theta start --config=../guardian_mainnet/node --password=<YOUR_PASSWORD>

NOTE: When the Theta node launches for the first time, you need to choose a password to encrypt the signing key of the guardian node. Please choose a secure password and keep it in a safe place. The next time when you restart the node, you will need the password to unlock it.

It might take some time for the node to sync up with the network (typically should be less than 1 hour). To check if the node is already in-sync with the network, you can execute the following command in another console:

./thetacli query status

The syncing field in the return indicates whether the node is still in the synchronization mode. If it is false, it means the node is already synced to the lastest block.

2. Install and Launch the ETH RPC adaptor

2.1 Install the adaptor

You'd need to compile the adaptor from the source code. First, install Go 1.14.2 and set environment variables GOPATH , GOBIN, and PATH. Next, clone the Theta blockchain repo and install Theta following the steps below:

mkdir -p $GOPATH/src/ 
cd $GOPATH/src/
git clone $GOPATH/src/
cd theta
git checkout release
export GO111MODULE=on
make install

Next, clone the theta-eth-rpc-adaptor repo:

cd $GOPATH/src/
git clone

Following the steps below to build the theta-eth-rpc-adaptor binary and copy it into your $GOPATH/bin.

export GO111MODULE=on
make install

2.2. Start the Adaptor

Now, create the config folder for the RPC adaptor

mkdir -p ../mainnet/eth-rpc-adaptor

Use your favorite editor to open file ../mainnet/eth-rpc-adaptor/config.yaml, paste in the follow content, save and close the file:

  rpcEndpoint: ""
  skipInitializeTestWallets: true
  enabled: true
  httpAddress: ""
  httpPort: 18888
  wsAddress: ""
  wsPort: 18889
  timeoutSecs: 600 
  maxConnections: 2048
  levels: "*:info"

Then, launch the adaptor binary with the following command:

screen -S rpc_adaptor # if you run the node on a Linux server
theta-eth-rpc-adaptor start --config=../mainnet/eth-rpc-adaptor

The ETH RPC server should now be started at port 18888. Please checkout this link for the ETH RPC APIs that are currently supported.

2.3 Sanity checks

After the adaptor is started, you can issue the following curl commands to make sure the ETH RPC APIs service is up and running. Note that in the config.yaml file, rpc.httpAddress is set to "", which enables the RPC APIs to be accessible from a remote machine. Of course, you'd also need to setup proper firewall rules to allow remote access.

# Query Chain ID
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}'

# Query synchronization status
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}'

# Query block number
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}'

# Query account TFuel balance (should return an integer which represents the current TFuel balance in wei)
curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc15149236229bd13f0aec783a9cc8e8059fb28da", "latest"],"id":1}'