Running your own Ethereum Node
Parity Ethereum is an implementation of the software required to participate in the Ethereum network by running a node. It consists of a full node implementation, capable to synchronize to the Ethereum blockchain, validate and execute transactions, and even mine ether. In a recent article, we introduced the Parity Ethereum client and its features. In this current article, we take a practical approach and look at how to use the software to run a node and interact with the Ethereum network.
The installation of Parity Ethereum is fairly straightforward. As Parity is a command-line software, some knowledge on how to interact with the command-line is required, even on graphical systems, such as Windows. A number of pre-compiled executables can be downloaded on the latest release page. Releases are either labeled stable or beta. While beta versions of Parity Ethereum tend to be fairly reliable, stable versions should be chosen for production systems. The actual installation procedure consists of downloading a standalone binary and copying it into a suitable path, depending on the operating system. Once it is installed, this single binary is the only executable required.
Alternatively, installation can be performed via a package manager, such as Homebrew on macOS or by compiling the source code following the build instructions.
Running and Synchronizing a Node
Once Parity Ethereum has been installed running a node using the default configuration is as easy as launching the executable on the command line by typing:
This will start a node, download the latest network state and expose a JSON RPC API on port 8545 of the local machine. Synchronizing to the latest network state may take a long time (ranging from minutes to hours) and transactions can be executed only after the sync process has been completed.
Several sync modes exist, the default being the relatively fast warp mode. This mode omits the processing of older blocks, speeding up syncing significantly. Warp mode can be disabled by adding the following flag:
It is also possible to start Parity, in order to participate in other Ethereum networks, such as the public test networks.
For example, syncing to the Ropsten testnet can be achieved with:
parity –chain ropsten
Similarly, the Parity-run proof of authority testnet Kovan is accessible with:
parity –chain kovan
Interacting with a Running Instance
Once Parity Ethereum is running it is possible to interact with the node programmatically through the JSON RPC API. This can be done using a compatible programming language library, such as web3.js.
> Web3 = require(“web3”)
> web3 = new Web3(new Web3.providers.HttpProvider(“http://localhost:8545”));
Once connected to the node, the usual web3.js commands can be used to interact with the node.
A number of interactions are also possible directly from the command line. For instance, it is easy to create a new account:
parity account new
It is important to remember that accounts are locked by default, so in order to make use of a locally managed account, parity has to be started as follows:
parity –unlock <account no> –password <filename>
In this command, the password for the account to be unlocked is assumed to be stored in the file supplied to the password flag.
As we explained in our previous article, Parity Ethereum is extremely flexible and supports a large number of powerful configurations.
In order to conveniently launch a node with custom configurations, a config file, usually called config.toml can be used. Since the syntax for this file is quite complex, it is best to start with a template, which can be created using the Parity Config Generator.
The following is an example configuration for the Kovan test network:
# This config should be placed in following path:
# $HOME/Library/Application Support/io.parity.ethereum/config.toml
# Kovan Test Network
chain = “kovan”
# JSON-RPC over HTTP will be accessible on port 9545.
port = 9545
# You will be paid $0.0004 for a basic transaction – Minimum gas price will be set accordingly.
usd_per_tx = “0.0004”
# Prune old state data. Maintains journal overlay – fast but extra 50MB of memory used.
pruning = “fast”
# Enables Fat DB
fat_db = “on”
Further detail on all of Parity Ethereum’s command-line flags and configuration options can be found in the official documentation.