Setup the ETH RPC Adaptor for the Script Testnet

This page provides the instructions to setup the ETH RPC Adaptor for the Script Testnet on a virtual machine. The adaptor is a middleware which translates the Script RPC interface to the Ethereum RPC interface. To enable the Script ETH RPC API service, you’d need to run

  1. the Script Node, and

  2. the Script/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

(I) Install and Launch the Script Testnet Node (https://whitepaper.script.tv/validators/validator-node-setup)

(II) Install and Launch the ETH RPC adaptor

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 Script blockchain repo and install Script following the steps below:

mkdir -p $GOPATH/src/github.com/scripttoken

cd $GOPATH/src/github.com/scripttoken

git clone https://github.com/scriptnetwork/Node-Network-guide.git $GOPATH/src/github.com/scripttoken/script

cd script

git checkout release

export GO111MODULE=on

make install

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

cd $GOPATH/src/github.com/scripttoken

git clone https://github.com/scriptnetwork/script-eth-rpc-adaptor.git

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

export SCRIPT_ETH_RPC_ADAPTOR_HOME=$GOPATH/src/github.com/scripttoken/script-eth-rpc-adaptor

cd $SCRIPT_ETH_RPC_ADAPTOR_HOME

export GO111MODULE=on

make install

Start the Adaptor

Now, create the config folder for the RPC adaptor

export SCRIPT_ETH_RPC_ADAPTOR_HOME=$GOPATH/src/github.com/scripttoken/script-eth-rpc-adaptor

cd $SCRIPT_ETH_RPC_ADAPTOR_HOME

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

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

script:

rpcEndpoint: "http://127.0.0.1:16888/rpc"

node:

skipInitializeTestWallets: true

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:

screen -S rpc_adaptor # if you run the node on a Linux server

cd $SCRIPT_ETH_RPC_ADAPTOR_HOME

script-eth-rpc-adaptor start --config=../scriptnet/eth-rpc-adaptor

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

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 "0.0.0.0", 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}' http://127.0.0.1:18888/rpc

Query synchronization status

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://127.0.0.1:18888/rpc

Query block number

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://127.0.0.1:18888/rpc

Query account SPAY balance (should return an integer which represents the current SPAY balance in wei)

curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc15149236229bd13f0aec783a9cc8e8059fb28da", "latest"],"id":1}' http://127.0.0.1:18888/rpc

Last updated