2020-07-02 08:22:45 +00:00
<!--
2020-07-17 18:07:05 +00:00
order: 2
2020-07-02 08:22:45 +00:00
-->
# Run a Node
Run a local node and start the REST and JSON-RPC clients {synopsis}
2020-07-17 18:07:05 +00:00
## Pre-requisite Readings
2020-07-02 08:22:45 +00:00
2020-07-17 18:07:05 +00:00
- [Installation ](./installation.md ) {prereq}
2020-07-31 21:42:04 +00:00
## Automated deployment
2020-07-02 08:22:45 +00:00
2020-07-17 18:07:05 +00:00
Run the local node with faucet enabled:
2020-07-02 08:22:45 +00:00
::: warning
2020-07-17 18:07:05 +00:00
The script below will remove any pre-existing binaries installed. Use the manual deploy if you want
to keep your binaries and configuration files.
2020-07-02 08:22:45 +00:00
:::
```bash
./init.sh
```
In another terminal window or tab, run the Ethereum JSON-RPC server as well as the SDK REST server:
```bash
2020-08-05 15:17:50 +00:00
ethermintcli rest-server --laddr "tcp://localhost:8545" --unlock-key mykey --chain-id 8
2020-07-02 08:22:45 +00:00
```
2020-07-31 21:42:04 +00:00
## Manual deployment
2020-07-17 18:07:05 +00:00
2020-07-31 21:42:04 +00:00
The instructions for setting up a brand new full node from scratch are the the same as running a
[single node local testnet ](./testnet.md#single-node-local-manual-testnet ).
2020-07-17 18:07:05 +00:00
## Start node
To start your node, just type:
```bash
2020-08-05 15:17:50 +00:00
ethermintd start
2020-07-17 18:07:05 +00:00
```
2020-07-02 08:22:45 +00:00
## Key Management
2020-08-05 15:17:50 +00:00
To run a node with the same key every time: replace `ethermintcli keys add $KEY` in `./init.sh` with:
2020-07-02 08:22:45 +00:00
```bash
2020-08-25 09:06:47 +00:00
echo "your mnemonic here" | ethermintcli keys add $KEY --recover
2020-07-02 08:22:45 +00:00
```
2020-07-17 18:07:05 +00:00
::: tip Ethermint currently only supports 24 word mnemonics.
2020-07-02 08:22:45 +00:00
:::
2020-07-17 18:07:05 +00:00
You can generate a new key/mnemonic with:
2020-07-02 08:22:45 +00:00
```bash
2020-08-25 09:06:47 +00:00
ethermintcli keys add $KEY
2020-07-02 08:22:45 +00:00
```
To export your ethermint key as an ethereum private key (for use with Metamask for example):
```bash
2020-08-05 15:17:50 +00:00
ethermintcli keys unsafe-export-eth-key $KEY
2020-07-02 08:22:45 +00:00
```
2020-07-17 18:07:05 +00:00
For more about the available key commands, use the `--help` flag
2020-07-02 08:22:45 +00:00
```bash
2020-08-05 15:17:50 +00:00
ethermintcli keys -h
2020-07-17 18:07:05 +00:00
```
### Keyring backend options
2020-07-02 08:22:45 +00:00
2020-07-17 18:07:05 +00:00
The instructions above include commands to use `test` as the `keyring-backend` . This is an unsecured
keyring that doesn't require entering a password and should not be used in production. Otherwise,
Ethermint supports using a file or OS keyring backend for key storage. To create and use a file
stored key instead of defaulting to the OS keyring, add the flag `--keyring-backend file` to any
relevant command and the password prompt will occur through the command line. This can also be saved
as a CLI config option with:
2020-07-02 08:22:45 +00:00
2020-07-17 18:07:05 +00:00
```bash
2020-08-05 15:17:50 +00:00
ethermintcli config keyring-backend file
2020-07-02 08:22:45 +00:00
```
2020-07-17 18:07:05 +00:00
## Clearing data from chain
### Reset Data
Alternatively, you can **reset** the blockchain database, remove the node's address book files, and reset the `priv_validator.json` to the genesis state.
::: danger
2020-08-05 15:17:50 +00:00
If you are running a **validator node** , always be careful when doing `ethermintd unsafe-reset-all` . You should never use this command if you are not switching `chain-id` .
2020-07-17 18:07:05 +00:00
:::
::: danger
**IMPORTANT**: Make sure that every node has a unique `priv_validator.json` . **Do not** copy the `priv_validator.json` from an old node to multiple new nodes. Running two nodes with the same `priv_validator.json` will cause you to double sign!
:::
First, remove the outdated files and reset the data.
2020-07-02 08:22:45 +00:00
```bash
2020-08-05 15:17:50 +00:00
rm $HOME/.ethermintd/config/addrbook.json $HOME/.ethermintd/config/genesis.json
ethermintd unsafe-reset-all
2020-07-17 18:07:05 +00:00
```
2020-07-02 08:22:45 +00:00
2020-07-17 18:07:05 +00:00
Your node is now in a pristine state while keeping the original `priv_validator.json` and `config.toml` . If you had any sentry nodes or full nodes setup before, your node will still try to connect to them, but may fail if they haven't also been upgraded.
### Delete Data
2020-08-05 15:17:50 +00:00
Data for the Daemon and CLI binaries should be stored at `~/.ethermintd` and `~/.ethermintcli` , respectively by default. To **delete** the existing binaries and configuration, run:
2020-07-17 18:07:05 +00:00
```bash
rm -rf ~/.emint*
2020-07-02 08:22:45 +00:00
```
2020-07-17 18:07:05 +00:00
To clear all data except key storage (if keyring backend chosen) and then you can rerun the full node installation commands from above to start the node again.
2020-07-02 08:22:45 +00:00
## Next {hide}
2020-07-17 18:07:05 +00:00
Learn about running a Ethermint [testnet ](./testnet.md ) {hide}