Compile the Ethereum RPC Adaptor from Source Code

1. Setup

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/github.com/thetatoken 
cd $GOPATH/src/github.com/thetatoken
git clone https://github.com/thetatoken/theta-protocol-ledger.git $GOPATH/src/github.com/thetatoken/theta
cd theta
git checkout privatenet
export GO111MODULE=on
make install

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

cd $GOPATH/src/github.com/thetatoken
git clone https://github.com/thetatoken/theta-eth-rpc-adaptor

2. Build and Install

Build the binary under macOS or Linux

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

export THETA_ETH_RPC_ADAPTOR_HOME=$GOPATH/src/github.com/thetatoken/theta-eth-rpc-adaptor
cd $THETA_ETH_RPC_ADAPTOR_HOME
export GO111MODULE=on
make install

Cross compilation for Windows

On a macOS machine, the following command should build the theta-eth-rpc-adaptor.exe binary under build/windows/

make windows

3. Run the Adaptor with a local Theta private testnet

3.1 Launch a Theta private testnet

First, run a private testnet Theta node with its RPC port opened at 16888:

cd $THETA_HOME
cp -r ./integration/privatenet ../privatenet
mkdir ~/.thetacli
cp -r ./integration/privatenet/thetacli/* ~/.thetacli/
chmod 700 ~/.thetacli/keys/encrypted

theta start --config=../privatenet/node_eth_rpc --password=qwertyuiop

3.2 Launch the RPC adaptor

Then, open another terminal, create the config folder for the RPC adaptor

export THETA_ETH_RPC_ADAPTOR_HOME=$GOPATH/src/github.com/thetatoken/theta-eth-rpc-adaptor
cd $THETA_ETH_RPC_ADAPTOR_HOME
mkdir -p ../privatenet/eth-rpc-adaptor

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

theta:
  rpcEndpoint: "http://127.0.0.1:16888/rpc"
rpc:
  enabled: true
  httpAddress: "127.0.0.1"
  httpPort: 18888
  wsAddress: "127.0.0.1"
  wsPort: 18889
  timeoutSecs: 600 
  maxConnections: 2048
log:
  levels: "*:info"

Then, launch the adaptor binary with the following command:

cd $THETA_ETH_RPC_ADAPTOR_HOME
theta-eth-rpc-adaptor start --config=../privatenet/eth-rpc-adaptor

4. Run the Adaptor for the Theta Mainnet

First, follow the steps here to launch a Theta Mainnet node. Note that you can skip Step "3. Stake to the guardian node" and "4. TFUEL earning" if you just want to run a full node without staking. The full node should then run the Theta RPC server at http://127.0.0.1:16888/rpc.

Next, open a new terminal, create the config folder for the RPC adaptor

export THETA_ETH_RPC_ADAPTOR_HOME=$GOPATH/src/github.com/thetatoken/theta-eth-rpc-adaptor
cd $THETA_ETH_RPC_ADAPTOR_HOME
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:

theta:
  rpcEndpoint: "http://127.0.0.1:16888/rpc"
rpc:
  enabled: true
  httpAddress: "0.0.0.0"
  httpPort: 18888
  wsAddress: "0.0.0.0"
  wsPort: 18889
  timeoutSecs: 600 
  maxConnections: 2048
log:
  levels: "*:info"

Then, launch the adaptor binary with the following command:

cd $THETA_ETH_RPC_ADAPTOR_HOME
theta-eth-rpc-adaptor start --config=../mainnet/eth-rpc-adaptor

The ETH RPC server should now be started at port 18888.


What’s Next
Did this page help you?