National Institute of Applied Science and
Technology
Blockchain Practical Work
Ethereum Private Blockchain Setup
Student :
Ali Doggaz, Salma Borchani, Achref Level :
Saidi, Salem Hamdani, Mahdi 5éme Génie Logicielle
Ghorbel
TABLE DES MATIÈRES Table des matières
Table des matières
1 Introduction 2
2 Environment Setup 2
2.1 Installing Ethereum Client (Geth) . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Creating Directories for Miners . . . . . . . . . . . . . . . . . . . . . . . . 4
3 Genesis Block Configuration 4
3.1 Creating the Genesis File . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
4 Blockchain Initialization 5
4.1 Initializing Miner Nodes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5 Creating Accounts 6
5.1 Account Creation for Miner #1 . . . . . . . . . . . . . . . . . . . . . . . . 6
6 Mining Process Setup 8
6.1 Preparing and Running Miner . . . . . . . . . . . . . . . . . . . . . . . . . 8
7 Account Management and Transactions 10
7.1 Viewing Account Balances . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7.2 Sending Transactions within Miner #1 . . . . . . . . . . . . . . . . . . . . 11
8 Inter-Miner Transactions 11
8.1 Sending Ethers between Miner Nodes . . . . . . . . . . . . . . . . . . . . . 11
9 Conclusion 13
A Appendix : Script Files 13
A.1 startminer1.sh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
A.2 startminer2.sh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Rapport - Ethereum Private Blockchain Setup 1
2 Environment Setup
1 Introduction
In this report, we document the setup process for creating a private Ethereum blo-
ckchain, including installing dependencies, configuring nodes, and testing transactions.
Screenshots of key steps are provided.
2 Environment Setup
2.1 Installing Ethereum Client (Geth)
To install the Ethereum client Geth, we used Homebrew (Mac).
Figure 1 – Installing Geth
Note : After noticing that the latest version isn’t working properly, we had to change
the version on geth. As I am using MAC OS, I had to install the tar package manually of
the correct stable version on Mac.
Rapport - Ethereum Private Blockchain Setup 2
2.1 Installing Ethereum Client (Geth) 2 Environment Setup
Figure 2 – Geth version
Rapport - Ethereum Private Blockchain Setup 3
2.2 Creating Directories for Miners 3 Genesis Block Configuration
2.2 Creating Directories for Miners
Here is the content of the genesis file, with the 3 appropriate EIPs :
Figure 3 – Genesis.json
Separate directories are created for each miner to store blockchain data :
Figure 4 – Directory Structure
3 Genesis Block Configuration
3.1 Creating the Genesis File
A genesis file is created to initialize the blockchain with specific parameters.
Rapport - Ethereum Private Blockchain Setup 4
4 Blockchain Initialization
Figure 5 – creation of genesis.json
4 Blockchain Initialization
4.1 Initializing Miner Nodes
Each miner node is initialized with the genesis block :
cd ~/ C h a i n S k i l l s
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner1 i n i t g e n e s i s . j s o n
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner2 i n i t g e n e s i s . j s o n
Rapport - Ethereum Private Blockchain Setup 5
5 Creating Accounts
Figure 6 – Miner 1 Init
Figure 7 – Miner 2 Init
5 Creating Accounts
5.1 Account Creation for Miner #1
The default account for Miner #1 is created using :
Rapport - Ethereum Private Blockchain Setup 6
5.1 Account Creation for Miner #1 5 Creating Accounts
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner1 account new
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner1 account new
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner2 account new
g e t h −−d a t a d i r ~/ C h a i n S k i l l s / miner2 account new
Figure 8
Rapport - Ethereum Private Blockchain Setup 7
6 Mining Process Setup
6 Mining Process Setup
6.1 Preparing and Running Miner
A password file is created for Each Miner’s default account :
echo " t e s t 1 2 3 " > ~/ C h a i n S k i l l s / miner1 / password . s e c
Miner #1 is then started using our bash script :
Figure 9 – Startminer script
Rapport - Ethereum Private Blockchain Setup 8
6.1 Preparing and Running Miner 6 Mining Process Setup
Figure 10 – Miner Running
Rapport - Ethereum Private Blockchain Setup 9
7 Account Management and Transactions
Figure 11 – JS console
7 Account Management and Transactions
7.1 Viewing Account Balances
Using the Geth console, the balances of each account can be viewed :
e t h . g e t B a l a n c e ( et h . c o i n b a s e )
Figure 12 – Display Balance of miner 1 and 2
Rapport - Ethereum Private Blockchain Setup 10
7.2 Sending Transactions within Miner #1 8 Inter-Miner Transactions
7.2 Sending Transactions within Miner #1
A test transaction is sent from account #0 to account #1 :
e t h . s e n d T r a n s a c t i o n ( { from : et h . a c c o u n t s [ 0 ] , t o : et h . a c c o u n t s [ 1 ] , v a l u e : web
8 Inter-Miner Transactions
8.1 Sending Ethers between Miner Nodes
To verify communication between the nodes, 5 ethers are sent from Miner #1 to Miner
#2’s account :
e t h . s e n d T r a n s a c t i o n ( { from : et h . c o i n b a s e , t o : ’ [REPLACE␣WITH␣ADDRESS␣OF␣ACCO
Rapport - Ethereum Private Blockchain Setup 11
8.1 Sending Ethers between Miner Nodes 8 Inter-Miner Transactions
Figure 13 – Sending Transaction
Figure 14 – New Balances
Rapport - Ethereum Private Blockchain Setup 12
A Appendix : Script Files
9 Conclusion
The private Ethereum blockchain was successfully set up with two miner nodes ca-
pable of managing accounts, conducting transactions, and mining ethers in a controlled
environment. This setup demonstrates the fundamental process of blockchain creation
and management on a local network.
A Appendix : Script Files
A.1 startminer1.sh
#! / b i n / b ash
g e t h −−i d e n t i t y miner1 −−n e t w o r k i d 42 −−d a t a d i r / U s e r s / a l i d o g g a z /TP1_BlockC
−−n o d i s c o v e r −−mine −−r pc −−r p c p o r t 8042 −−p o r t 30303 −−u n l o c k 0 −−pas
−−i p c p a t h / U s e r s / a l i d o g g a z /TP1_BlockChain/ C h a i n S k i l l s / miner1 / g eth . i p c
−−a l l o w −i n s e c u r e −u n l o c k "
A.2 startminer2.sh
#! / b i n / b ash
g e t h −−i d e n t i t y miner2 −−n e t w o r k i d 42 −−d a t a d i r / U s e r s / a l i d o g g a z /TP1_BlockC
−−n o d i s c o v e r −−mine −−r pc −−r p c p o r t 8043 −−p o r t 30304 −−u n l o c k 0 −−pas
−−i p c p a t h / U s e r s / a l i d o g g a z /TP1_BlockChain/ C h a i n S k i l l s / miner2 / g eth . i p c
−−a l l o w −i n s e c u r e −u n l o c k "
Rapport - Ethereum Private Blockchain Setup 13