Setting up an Eth 2.0 Staking Validator with Teku
A quick guide to setting up your Eth2 node or validator on Teku with Alchemy as your web3 provider.
This guide assumes you have already generated your validator keys and have submitted your initial 32 Eth to the beacon chain. If you have not done so, please follow this guide.
To learn more about Teku, check out their Eth2 Documentation.
Note: The instructions below were adopted from the Teku Getting Started Guide.

Running an Eth 2.0 validator

1. Install Teku

You can find the full installation guide for Teku on the Teku how-to page.
1
brew tap ConsenSys/teku
2
brew install teku
Copied!

2. Run the beacon chain client

You can run just the beacon chain and point your eth1 endpoint to the alchemy url for your app. Make sure your network matches the network that you are trying to connect to:
  • Prymont -> eth-goerli
  • Mainnet -> eth-mainnet
1
teku --network=pyrmont --eth1-endpoints=<ALCHEMY API ENDPOINT HERE> \
2
--metrics-enabled --rest-api-enabled
Copied!
For example:
Mainnet
Testnet
1
teku --network=mainnet --eth1-endpoints=https://eth-mainnet.alchemyapi.io/v2/<ALCHEMY API KEY> \
2
--metrics-enabled --rest-api-enabled
Copied!
1
teku --network=pyrmont --eth1-endpoints=https://eth-goerli.alchemyapi.io/v2/<ALCHEMY API KEY> \
2
--metrics-enabled --rest-api-enabled
Copied!

3. Run your validator

In a separate terminal window (from your beacon node), start running the validator using the command below:
Copy the full path of your keys from when you set up your initial deposit. In the previous guide, the path for the keys were saved in
/Users/dubash/Downloads/eth2deposit-cli-256ea21-darwin-amd64/validator_keys/
Mainnet
Testnet
1
teku validator-client --network=mainnet --beacon-node-api-endpoint=http://192.10.10.101:5051 \
2
--validator-keys=eth2deposit:validator/passwords
Copied!
1
teku validator-client --network=pyrmont --beacon-node-api-endpoint=http://192.10.10.101:5051 \
2
--validator-keys=validator/keys:validator/passwords
Copied!
At this point you are up and running and ready for validator assignment!

Running beacon chain and validator using Docker

You can run both the beacon chain and validator using docker and docker compose. Full instructions can be found here. This will require you to have Docker Compose.

1. Creating your docker-compose file

Create a docker compose file in the location you want to run your validator:
1
touch docker-compose.yml
Copied!

2. Copy your key

Copy the full path of your keys from when you set up your initial deposit. In the previous guide, the example path for the keys were saved in:
~/Downloads/eth2deposit-cli-256ea21-darwin-amd64/validator_keys/as a file called keystore-m_12381_3600_0_0_0-1629939192.json
In this folder, you will find your keys in a json format. Let's make a copy of this and rename it to a txt format
1
cp keystore-m_12381_3600_0_0_0-1629939192.json keystore-m_12381_3600_0_0_0-1629939192.txt
Copied!
Now we have two files in our folder, one with a json extension and one with a txt.
We'll then create a folder called teku in our validator_keys directory. In this teku folder, we'll create a subfolder called validator and then create two new folders underneath validator. One called keys and one called passwords. The .json keys file will go in the keys folder and the .txt file will go into the passwords folder like below:
Finally, we'll copy the **absolute path ** of our teku folder by running:
1
gt; pwd
2
/Users/dubash/Downloads/eth2deposit-cli-256ea21-darwin-amd64/validator_keys/teku
Copied!
We'll use this path in our docker-compose in our volumes location on line 33. In addition, we'll use our Alchemy endpoint as our eth1 provider (line25).
Mainnet
Testnet
1
version: '3.4'
2
services:
3
besu_node:
4
image: hyperledger/besu:latest
5
command: ["--network=goerli",
6
"--data-path=/opt/besu/data/data",
7
"--host-allowlist=*",
8
"--sync-mode=FAST",
9
"--rpc-http-enabled",
10
"--rpc-http-cors-origins=*",
11
"--rpc-http-api=ETH,NET,CLIQUE,DEBUG,MINER,NET,PERM,ADMIN,EEA,TXPOOL,PRIV,WEB3"]
12
volumes:
13
- ./besu:/opt/besu/data
14
ports:
15
# Map the p2p port(30303) and RPC HTTP port(8545)
16
- "8545:8545"
17
- "30303:30303"
18
19
teku_node:
20
environment:
21
- "JAVA_OPTS=-Xmx4g"
22
image: consensys/teku:latest
23
command: ["--network=pyrmont",
24
"--data-base-path=/opt/teku/data",
25
"--eth1-endpoint=https://eth-mainnet.alchemyapi.io/v2/<YOUR ALCHEMY API KEY>",
26
"--validator-keys=/opt/teku/data/:/opt/teku/data/",
27
"--p2p-port=9000",
28
"--rest-api-enabled=true",
29
"--rest-api-docs-enabled=true"]
30
depends_on:
31
- besu_node
32
volumes:
33
- /Users/dubash/Downloads/eth2deposit-cli-256ea21-darwin-amd64/validator_keys/teku:/opt/teku/data
34
ports:
35
# Map the p2p port(9000) and REST API port(5051)
36
- "9000:9000"
37
- "5051:5051"
Copied!
1
version: '3.4'
2
services:
3
besu_node:
4
image: hyperledger/besu:latest
5
command: ["--network=goerli",
6
"--data-path=/opt/besu/data/data",
7
"--host-allowlist=*",
8
"--sync-mode=FAST",
9
"--rpc-http-enabled",
10
"--rpc-http-cors-origins=*",
11
"--rpc-http-api=ETH,NET,CLIQUE,DEBUG,MINER,NET,PERM,ADMIN,EEA,TXPOOL,PRIV,WEB3"]
12
volumes:
13
- ./besu:/opt/besu/data
14
ports:
15
# Map the p2p port(30303) and RPC HTTP port(8545)
16
- "8545:8545"
17
- "30303:30303"
18
19
teku_node:
20
environment:
21
- "JAVA_OPTS=-Xmx4g"
22
image: consensys/teku:latest
23
command: ["--network=pyrmont",
24
"--data-base-path=/opt/teku/data",
25
"--eth1-endpoint=https://eth-goerli.alchemyapi.io/v2/<YOUR ALCHEMY API KEY>",
26
"--validator-keys=/opt/teku/data/:/opt/teku/data/",
27
"--p2p-port=9000",
28
"--rest-api-enabled=true",
29
"--rest-api-docs-enabled=true"]
30
depends_on:
31
- besu_node
32
volumes:
33
- ~/Downloads/eth2deposit-cli-256ea21-darwin-amd64/validator_keys:/opt/teku/data
34
ports:
35
# Map the p2p port(9000) and REST API port(5051)
36
- "9000:9000"
37
- "5051:5051"
Copied!
Finally run docker compose up!

Running your validator assignment

Be ready for your validator assignment

Keep both terminal windows running so that your validator can receive tasks and execute validator responsibilities. You should already be aware of all the responsibilities and staking logistics for being a validator.
You can check the status of your validator using block explorers: beaconcha.in and beacon.etherscan.io.
You are now officially an Ethereum 2.0 validator, congrats! 🎉
Last modified 1mo ago