Introduction
This guide provides a comprehensive walkthrough for setting up an Ethereum private chain using Geth on Windows 10, connecting to MetaMask as a visual wallet, and initiating mining operations.
1. Installing the Geth Client
Download and Installation Steps
Download Geth:
- Visit the official Geth downloads page.
- Select the Stable releases (Windows 10) version.
Installation:
- Run the installer and choose a preferred directory.
- Note: Disable proxy/VPN if downloads fail.
Verification:
Open Command Prompt (
cmd) and execute:geth -help- Successful installation displays a help menu.
2. Configuring the Genesis Block
Create genesis.json File
- Save the following JSON in your Geth directory (adjust parameters as needed):
{
"config": {
"chainId": 8434,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"alien": {
"period": 2,
"epoch": 300,
"maxSignersCount": 5,
"minVoterBalance": 100000000000000000000,
"genesisTimestamp": 1536136198,
"signers": [
"0x393faea80893ba357db03c03ee73ad3e31257469",
"0x30d342865deef24ac6b3ec2f3f8dba5109351571",
"0xd410f95ede1d2da66b1870ac671cc18b66a97778"
]
}
},
"nonce": "0x0",
"timestamp": "0x5b8f92c2",
"extraData": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x47b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"cbfc29c31a31c869f9eb59a084d9019965978a7e": {
"balance": "0x31d450f18af132720000000"
},
"393faea80893ba357db03c03ee73ad3e31257469": {
"balance": "0xd3c21bcecceda1000000"
},
"30d342865deef24ac6b3ec2f3f8dba5109351571": {
"balance": "0xd3c21bcecceda1000000"
},
"d410f95ede1d2da66b1870ac671cc18b66a97778": {
"balance": "0xd3c21bcecceda1000000"
},
"a25dc63609ea7ea999033e062f2ace42231c0b69": {
"balance": "0xd3c21bcecceda1000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}Key Parameters Explained
| Parameter | Purpose |
|---|---|
chainId | Unique network ID (avoid conflicts with public chains). |
difficulty | Sets mining difficulty (lower values ease CPU mining). |
alloc | Pre-funds accounts with Ether (in wei). |
gasLimit | Maximum gas per block (set high for private chains). |
3. Initializing the Private Chain
Run in Command Prompt:
geth --datadir .\db init genesis.json- Creates a
dbfolder withchaindata(blocks) andkeystore(accounts).
4. Starting the Node
Execute:
geth --http --http.api db,eth,net,web3,personal --datadir .\db --networkid 1997 console 2>> log2020526.logFlags:
--http: Enables HTTP-RPC for contract deployment.--networkid: MatcheschainIdfromgenesis.json.
Verify node status with:
admin.nodeInfo5. Creating Accounts
Steps:
Check existing accounts:
eth.accountsCreate a new account:
personal.newAccount()- Set a secure password.
Check balance:
eth.getBalance(eth.accounts[0])
6. Connecting MetaMask
- Install MetaMask (Chrome extension).
Configure Network:
- Select Localhost 8545 in MetaMask.
Import Account:
- Export private key from MetaMask (
Settings > Export Private Key). Import into Geth:
geth account import /path/to/private_key.txt- Move the generated file to
keystore.
- Export private key from MetaMask (
7. Mining Ether
Commands:
Set coinbase (mining reward address):
miner.setEtherbase(eth.accounts[0])Start mining (1 thread):
miner.start(1)Monitor balance:
eth.getBalance(eth.accounts[0])Stop mining:
miner.stop()
FAQs
Q1: Why is my Geth installation failing?
A: Ensure proxies/VPNs are disabled during download.
Q2: How do I reset my private chain?
A: Delete the db folder and reinitialize genesis.json.
Q3: Can I change the mining difficulty later?
A: Yes, modify difficulty in genesis.json and reinitialize.
Conclusion
This guide covers private chain setup, wallet integration, and mining. For advanced configurations, explore Geth documentation.