I have made these steps for people who are struggling connecting their Geth nodes to Beacon Proof of Stake chain Ethereum using Consensus Client. By following these steps you can able to have your personal blockchain node and you don't need any third party provider like Infura.
You can watch the entire tutorial on my youtube: https://www.youtube.com/watch?v=anyBoghKp3I
- Go to the url and download latest GETH client https://geth.ethereum.org/downloads
- Make sure you have 2TB space in your SSD or hardisk.
- Make sure you have 16GB RAM (this recommended but you can still use 8 GB )
- Install the Geth client make sure to select "Development Tools" option while installing Geth.
- Open CMD in windows and write
geth --version
Note:- make sure you see the latest version otherwise your installation is not working properly.
-
Account creation : This will create a new ethereum EOA account under a new directory dedicated for geth client in development node. A development node is an in memory node that is used for testing purpose only. Make sure to enter a new password for this client. You can do this process multiple times to create new accounts.
geth --datadir C:\mynewnode\dev --dev account new
-
Create Secret File: Create password secret file and put inside C:\mynewnode\dev\secret . Afteward open this file and enter the password of the account that you want to use as an owner of the geth client.
-
Run Geth Client: Run the geth client by specifying data directory and secret file representing first EOA account password
geth --datadir C:\mynewnode\dev --dev --password C:\mynewnode\dev\secret
-
Connect JS Console to Geth: While you will see logs on the console screen of the geth, you will find there is a file generated by geth with the name .ipc. This is an inter process communication file and it should be used with your java script console to interact with the geth. Open a new command line windows and write below command
geth attach \.\pipe\geth.ipc
-
Commands for JS Console: Write following commands
eth.syncing eth.blockNumber
-
List accounts : List account will display existing EOA accounts you have created or generated throught "account new" command. Every new user will be stored under a keystore directory created inside the \mynode\dev\keystore.
eth.accounts
-
Check Ether Balance: to how much ethers they have
eth.getBalance(eth.accounts[0])
-
Send transactions between coinbase and account
eth.sendTransaction({from: eth.accounts[0],to:'0xA8CF550eC622c16b08ae50880c01B466C7E31Bc5' ,value: web3.toWei(0.5,'ether')});
-
Check Clef Version: write following commands
clef --version
-
Create User : You can also create a user using CLEF which is an external tool to manage users. In future geth might not allow user creation through geth commands. In that case, admin needs to start using CLEF commandline tool.
clef newaccount --keystore "C:\mynewnode\dev\keystore"
-
Check on JS Console: Open the JS window which is attach to geth, and write again eth.accounts. You will see new accounts the same way.
-
List accounts: To see number of accounts you have using CLEF you can use following commands (if you dont give keystore directory then it will detect accounts from a default keystore directory in the APPdata\romaing\ethereum
clef list-wallets --keystore "C:\mynewnode\dev\keystore"
To use a live network it is better first try SEPOLIA network which is a proof of stake conesnsus Ethereum test network.
-
Create Sepolia Accounts:
geth --datadir C:\mynewnode\sepolia --sepolia account new
-
Connect Geth Sepolia Network with HTTP: Now we will run geth account with exposed api and endpoints in http for other clients
geth --datadir C:\mynewnode\sepolia --sepolia --http --http.api eth,net,engine,admin
Note:- if you want to use your own JWT security token for third party or external tools then you can provide its path like adding this as a parameter --authrpc.jwtsecret E:\mynewnode\myjwtsecret (optional)
-
Logs Troubleshooting:
to read log : https://geth.ethereum.org/docs/fundamentals/logs
-
Attach the console :
geth attach \.\pipe\geth.ipc
-
Sepolia Balance:
If you are using sepolia account which shows zero as a balance then rememmber your geth is not sync. In order to sync, you have to run Prysm Consensus Node.
-
Download Prysm using CURL: Assuming you are running a windows otherwise check official prysm link: https://docs.prylabs.network/docs/install/install-with-script make sure to create a prysm directory where you will download this. Below command will also add a registry key in the windows so you can have verbose loggings.
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.bat -o prysm.bat && reg add HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1
-
Download Genesis File: To run Consensus client you have to download the genesis block file from the link in the prysm directory.
https://github.com/eth-clients/merge-testnets/blob/main/sepolia/genesis.ssz
-
Run Consensus Node (prysm): To run this beacon chain node you must make sure to add the ethereum address suggested-fee-recepient from existing accounts you created or imported inside geth. Secondly you have to provide the JWT token for the communication which you can find inside your directory\geth\jwsecret . This token is an auto generated token by geth for any external communication. Additionally you have to provide the endpoint location with the port. The endpoint url which has auth false try to use that url.
prysm.bat beacon-chain --execution-endpoint=http://localhost:8551 --sepolia --suggested-fee-recipient=0x278e31b7c9214e1332c5f1d418693bf8af0bcd88 --jwt-secret=C:\mynewnode\sepolia\geth\jwtsecret --genesis-state=genesis.ssz
-
Syncrhonization process and trouble shooting : To become a full node you have to allow this process to be completed in few days without downloading entire blocks you will not find Sepolia new state. To test the synchronization status you can follow below commands
curl http://localhost:3500/eth/v1/node/syncing curl http://localhost:3500/eth/v1alpha1/node/eth1/connections
You will find alot of logs on the command line console you can translate those logs just to make sure your own the right direction.
https://docs.prylabs.network/docs/troubleshooting/issues-errors https://geth.ethereum.org/docs/fundamentals/logs
- Go in metamask settings
- Create network manually
- Add http://localhost:8545 which is called ENDPOINT (you can find this endpoint on the geth console screen) and give chainid sepolia 11155111 with symbol as ETH
- Add the network
- If it connects congrats
- Now you dont need any infura (but make sure you have downloaded proper blocks)
-
Create a truffle project
-
Add the below configuration inside truffle-config
gethsepolia: { host:"127.0.0.1", port:8545, network_id: '11155111' }
-
make sure your migration script from account represent the account you will use (to deploy your contract)
-
Test on the geth supported sepolia network
truffle test --network gethsepolia
-
Open development console
truffle console --network gethsepolia accounts migrate
Congratulations: Now you are a fully decentralized who doesnt need any third party to connect with the blockchain. But rememmber you will always need better security so make sure you always remain up to date with the following two main links.
https://docs.prylabs.network/docs/getting-started https://geth.ethereum.org/docs/getting-started