Run a Local RPC Node

Run a full instance of the blockchain on your machine

You have the option of running a full node of the Energy Web Chain main network or Volta test network locally. Running a local node does requires a degree of technical capability. It helps to understand the benefits of doing so, and the alternatives to running a full local node.

There are a number of benefits to running your own node, which are described below.

What does it mean to run a node?

A 'client' is software that implements a blockchain's protocols and allows you to connect directly with the blockchain - that is to read data from the blockchain or initiate transactions on the blockchain, such as transferring tokens. Anyone can create client software, as long as it implements that blockchain's official protocols. Ethereum's protocols are specified in their yellow paper, and there are a number of Ethereum clients to choose from.

A node is any machine that is actively running client software and is connected to the blockchain. Blockchain is often called a “peer-to-peer” network, because its network is made up of many peers running nodes simultaneously that are connected to each other.

Depending on if you are running a full node, a light node, or an archive node (see the differences between these nodes here), your client will sync with the current state of blockchain and then continue to execute every transaction that is added to the blockchain. Essentially it is having a live copy or version of the blockchain running locally on your machine.

Depending on the blockchain you are you connecting to, this can take up large amounts of space and take a long time to retrieve and sync the history of the chain on your machine. For example, synching with the Energy Web chain will require much less resources than syncing with the Ethereum mainnet, as it is a much larger and longer-running blockchain.

What do I need to run a node?

To run a node, you need to install the client software. The Energy Web mainnet and Volta testnet both use the OpenEthereum client (formally known as Parity), because it supports the Authority Roundtable (AuRa), which is a consensus algorithm specifically for Proof-of-Authority (PoA) blockchains. You can read more about the PoA consensus algorithm and why we implemented it for the Energy Web Chain here.

Only approved validators can create or 'seal' new blocks on the Energy Web Chain. If you run a full local node, you will be able to validate transactions, but not create new blocks.

Benefits to Running a Local Node

  1. The more nodes there are, the more secure the system is as a whole. Blockchains are decentralized technology, so by design the system performs better if there are multiple instances of it rather than just one. The more nodes there are, the less points of failure or opportunities for malicious action.

  2. Your transactions are more direct and more secure. Software that provides intermediary connections to the blockchain like Infura or MetaMask are, like any other web-based software, susceptible to downtime or error. By connecting to the blockchain yourself, you are removing your dependency on external providers for secure and direct connection. You also do not expose your public keys to the browser.

  3. You can self-verify transactions. You have part or all of the blockchain running on your node, so you can query the chain for transactions directly (and as often as you want) rather than relying on a user interface like a block explorer. Your queries can be more specific and efficient, giving you only the information that you need, for example, ‘how many transactions did addresses X, Y and Z send during this time period on each day for the last 30 days?’

  4. You are not subject to rate limits. Infura (and therefore MetaMask, as it implements Infura to connect to the blockchain) does have rate limits for JSON RPC requests. If your development requires a lot of requests to the blockchain, running a local node may be more efficient.

Alternatives to Running a Local Node

Running a local node is not necessary to use applications that run on the blockchain or transfer tokens.

To use applications deployed on the Energy Web Chain, or to transfer tokens, you can connect to the blockchain through MetaMask using a remote RPC. You can see guidance for doing that on the Volta Test Network and the Energy Web Main Network here.

Run a local node using the command line

Hardware Requirements

  • Multi-core CPU

  • 4GB RAM

  • SSD drive and free space

    • EWC RPC node - 150 GB

    • Volta RPC node - 200 GB

  • A decent DSL connection is required

Download Chainspec file

Download and save the chain config to your local machine.

Note that there are different chainspec files for the Volta Testnet and the Energy Web production chain:

  • The chainspec file for Volta Test Network is here.

  • The chainspec file for Energy Web Main Network is here.

Volta Testnet chainspec:

curl -L https://raw.githubusercontent.com/energywebfoundation/ewf-chainspec/master/Volta.json -o chainspec-volta.json

Energy Web Chain (production) chainspec:

curl -L https://raw.githubusercontent.com/energywebfoundation/ewf-chainspec/master/EnergyWebChain.json -o chainspec-ewc.json

Using OpenEthereum Client

  1. Run the following command in your terminal. Provide the path to the chain config that you want to use. The following command references the Volta chain config.

chmod +x openethereum
./openethereum --chain /path/to/chainconfig/Volta.json

Your local node should start:

2024-03-05 10:49:35 UTC Starting OpenEthereum/v3.3.5-stable-6c2d392d8-20220405/x86_64-linux-gnu/rustc1.58.1
2024-03-05 10:49:35 UTC Keys path /home/ubuntu/.local/share/openethereum/keys/Volta
2024-03-05 10:49:35 UTC DB path /home/ubuntu/.local/share/openethereum/chains/Volta/db/d94a0a739a3e416a
2024-03-05 10:49:35 UTC State DB configuration: fast
2024-03-05 10:49:35 UTC Operating mode: active
2024-03-05 10:49:35 UTC Not preparing block; cannot sign.
2024-03-05 10:49:36 UTC Configured for Volta using AuthorityRound engine
2024-03-05 10:49:36 UTC Signal for switch to contract-based validator set.
2024-03-05 10:49:36 UTC Initial contract validators: [0x36f67dd84e7327c10c7ead6c429a47189798fbdc, 0x20df7a4e8408add37c6a5c4afc1b1509924619fe, 0x77901f14183b1669c80e8c6137ff6721c9a26b25]
2024-03-05 10:49:36 UTC Listening for new connections on 127.0.0.1:8546.
2024-03-05 10:49:40 UTC Not preparing block; cannot sign.
2024-03-05 10:49:41 UTC Public node URL: enode://bb4962584a90ebcb373f5dd22cbe005ddd1300e7889c124ba33bfb0c327799948d8248054b7b6301f3bee46844c16cdaaffd390472198ddfb96798c8d03868b7@172.31.16.183:30303
2024-03-05 10:49:46 UTC Syncing    #1143 0xa666…220c   114.43 blk/s    0.0 tx/s    0.0 Mgas/s      0+    0 Qed LI:#1143    2/25 peers   405 KiB chain 0 bytes queue  RPC:  0 conn,    0 req/s,    0 µs
2024-03-05 10:49:51 UTC Syncing    #3559 0xe8e6…6a6c   483.00 blk/s    0.0 tx/s    0.0 Mgas/s      0+  124 Qed LI:#3683    2/25 peers   978 KiB chain 187 KiB queue  RPC:  0 conn,    0 req/s,    0 µs
2024-03-05 10:49:56 UTC Syncing    #5930 0xc530…ce9d   474.11 blk/s    0.2 tx/s    0.0 Mgas/s      0+ 1182 Qed LI:#7112    3/25 peers   2 MiB chain 2 MiB queue  RPC:  0 conn,    0 req/s,    0 µs
2024-03-05 10:50:01 UTC Syncing    #8458 0x63ee…be65   505.40 blk/s    0.0 tx/s    0.0 Mgas/s      0+ 3226 Qed LI:#11684    3/25 peers   3 MiB chain 5 MiB queue  RPC:  0 conn,    0 req/s,    0 µs
2024-03-05 10:50:06 UTC Syncing   #10352 0xf609…52e3   379.12 blk/s    0.0 tx/s    0.0 Mgas/s      0+ 5142 Qed LI:#15494    3/25 peers   3 MiB chain 8 MiB queue  RPC:  0 conn,    0 req/s,    0 µs

Connect your local node to MetaMask

Connect your MetaMask to the Volta Test Network or Energy Web Chain via remote RPC. You can read how to do this here.

Get the URL of your MetaMask account. You can do this by clicking the settings dropdown and selecting "Expand View."

When the view is expanded, copy the URL in the browser

Run the following command in your terminal

openethereum --chain path/to/chainconfig/Volta.json --jsonrpc-cors METAMASK URL  

Run a local node using Docker with OpenEthereum client

This section describes minimal setup to run an RPC node locally or on the server using Docker container run with docker-compose. This is solely for development purposes, it's not a production grade recommendation.

Prerequisites

Set up

  1. Verify that prerequisites are installed:

docker --version 
docker-compose --version 
curl --version

2. Create working directory

mkdir openethereum 
cd openethereum 
mkdir -p chain-data/chains

3. Create docker-compose.yaml file

cat > docker-compose.yaml << 'EOF'
version: '3.8'
services:
  openethereum:
    image: openethereum/openethereum:v3.3.5
    restart: always
    ports:
      - 8545:8545
      - 8546:8546
      - 30303:30303
      - 30303:30303/udp
    command:
      --jsonrpc-interface all --chain /config/chainspec.json
      # Uncomment this if connecting local node to MetaMask
      # --jsonrpc-cors chrome-extension://URL-OF-METAMASK
    volumes:
      - ./chain-data:/home/openethereum/.local/share/io.parity.ethereum/
      - ./chainspec-volta.json:/config/chainspec.json:ro
      # chainspec file should be changed if using EWC
      # - ./chainspec-ewc.json:/config/chainspec.json:ro
EOF

4. Download database snapshot - this takes some time and requires resources due to the size of the .tar file, but it will speed up synchronization process.

*Note that this step is optional. If you do not download the database snapshot, move to Step 6.

Volta (depending on your internet connection ~1 hour download time for us):

curl -L -C - https://chain-download.energyweb.org/volta -o ./chain-data/chains/volta.tar

Energy Web Chain (production) (30 minutes download time for us):

curl -L -C - https://chain-download.energyweb.org/ewc -o ./chain-data/chains/energywebchain.tar

5. Unpack database snapshot. This snapshot only works with OpenEthereum client.

*Note that this step is optional. If you did not complete Step 5, skip this step and move to Step 6.

Volta:

sudo tar -xvf ./chain-data/chains/volta.tar -C ./chain-data/chains

Energy Web Chain (production):

curl -L -C - https://chain-download.energyweb.org/ewc -o ./chain-data/chains/energywebchain.tar

6. Set permissions:

sudo chmod -R 777 chain-data

8. Start container:

docker-compose up -d

9. Examine logs:

docker-compose logs --tail 20 openethereum

The log output should be similar to the following (sometimes the logging output does not appear immediately, wait some time):

openethereum_1  | 2024-03-05 10:54:30 UTC Starting OpenEthereum/v3.3.5-stable/x86_64-linux-musl/rustc1.59.0
openethereum_1  | 2024-03-05 10:54:30 UTC Keys path /home/openethereum/.local/share/io.parity.ethereum/keys/Volta
openethereum_1  | 2024-03-05 10:54:30 UTC DB path /home/openethereum/.local/share/io.parity.ethereum/chains/Volta/db/d94a0a739a3e416a
openethereum_1  | 2024-03-05 10:54:30 UTC State DB configuration: fast
openethereum_1  | 2024-03-05 10:54:30 UTC Operating mode: active
openethereum_1  | 2024-03-05 10:54:30 UTC Not preparing block; cannot sign.
openethereum_1  | 2024-03-05 10:54:30 UTC Configured for Volta using AuthorityRound engine
openethereum_1  | 2024-03-05 10:54:30 UTC Signal for switch to contract-based validator set.
openethereum_1  | 2024-03-05 10:54:30 UTC Initial contract validators: [0x36f67dd84e7327c10c7ead6c429a47189798fbdc, 0x20df7a4e8408add37c6a5c4afc1b1509924619fe, 0x77901f14183b1669c80e8c6137ff6721c9a26b25]
openethereum_1  | 2024-03-05 10:54:30 UTC Listening for new connections on 127.0.0.1:8546.
openethereum_1  | 2024-03-05 10:54:35 UTC Not preparing block; cannot sign.
openethereum_1  | 2024-03-05 10:54:35 UTC Public node URL: enode://b111a66d9d0cc942abe1c728d74e8109673a1dc80a2d50be8546993c51cecd6151f2c7e3322bb6a992adcd906af5f686b8d14d8c4373aafdd02c108aeb71ab07@172.28.0.2:30303
openethereum_1  | 2024-03-05 10:54:40 UTC Syncing    #1450 0x4a2f…7898   144.03 blk/s    0.0 tx/s    0.0 Mgas/s      0+   73 Qed LI:#1524    2/25 peers    434 KiB chain  105 KiB queue  RPC:  0 conn,    0 req/s,    0 µs
openethereum_1  | 2024-03-05 10:54:45 UTC Syncing    #2097 0xdef1…082f   129.40 blk/s    0.0 tx/s    0.0 Mgas/s      0+ 2601 Qed LI:#4699    2/25 peers    767 KiB chain    4 MiB queue  RPC:  0 conn,    0 req/s,    0 µs

10. After some, you will sync with the network. Until a full sync, you will see be in a "syncing" state:

12021-11-03 15:33:42 UTC Syncing #14332274 0x2b0d...23c2 0.00 blk/s 0.0 tx/s 0.0 Mgas/s 0+ 0 Qed LI:#14332276 1/25 peers 72 KiB chain 0 bytes queue RPC: 0 conn, 0 req/s, 87 µs

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

The output will show current synchronization status:

{"jsonrpc":"2.0","result":{"currentBlock":"0xdab79f","highestBlock":"0xdac9d2","startingBlock":"0xdab172","warpChunksAmount":null,"warpChunksProcessed":null},"id":1}

It will take some time to fully sync with the current state of the blockchain. When the synchronization is finished status will be:

{"jsonrpc":"2.0","result":false,"id":1}

Additional Resources

Last updated