NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Build and Transact on Private Ethereum Blockchain with Geth CLI


1. INSTALL GETH

Go to https://geth.ethereum.org/, download and follows installation instructions.

TIP #1: Make sure you select the corrected version and platform of Geth

TIP #2: On Windows, make sure the installation directory of Geth is included in PATH environment.

2. ASSIGNMENT GOALS

In this assignment, you need to:

- Create a private network with 02 nodes with:
o Custom network Id
o And custom genesis node
- Connect each other as peers.
- Creates 02 accounts in each node.
- Start mining in 1st node to increase balance.
- Create transactions to transfer some Ether from mining account to:
o Other account on the same node
o One of accounts on the other node
- Check the status of transactions and balances of all accounts
3. INITIALIZE A PRIVATE NETWORK
3.1. Choose a Network ID
- Choose your own Network ID
- Note down this Network ID for later use

Submission:

- Submit your Network ID
3.2. Create 2 Nodes
- Create 2 data directories for 2 nodes.
- Create genesis.json file:

{
"config": {
"chainId": 0,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}


- Create 2 nodes by geth init with --datadir parameter and genesis.json file:
o geth init --datadir <directory_of_node-1> <path_to_genesis.json>
o geth init --datadir <directory_of_node-2> <path_to_genesis.json>
- Start 2 geth instances for 2 nodes with 2 console windows/instances
o geth
--datadir <directory_of_node-1>
--maxpeers 95 --networkid 13
--rpc --rpccorsdomain "*"
--port 30301 --rpcport 8544
--rpcapi="txpool,db,eth,net,web3,personal,admin,miner"
--ipcpath node1.ipc
o geth
--datadir <directory_of_node-2>
--maxpeers 95
--networkid 13
--rpc --rpccorsdomain "*"
--port 30302 --rpcport 8545
--rpcapi="txpool,db,eth,net,web3,personal,admin,miner"
--ipcpath node2.ipc
- Start geth client connect to 2 previous geth instances with 2 console windows/instances
o geth attach --datadir <directory_of_node-1> http://localhost:8544
o geth attach --datadir <directory_of_node-2> http://localhost:8545
- On each client, use > admin.nodeInfo to check information of node.
- Note down eNode of each node for later use.

Submission:

- Submit nodeInfo of each node. Make sure they are valid JSONs.
3.3. Connect all nodes as peers
- On each client, use > admin.addPeer(<eNode of the other node>) to connect the other node as peer.
- Use > net.peerCount to check connection status of peers.

Submission:

- Submit the results of > admin.peers[0].enode on each node
4. CREATE ACCOUNTS AND START MINING
4.1. Create 02 accounts on each nodes
- On each client, use > personal.newAccount(<password>) 2 times to create 02 accounts
TIP: Make sure you remember passwords for later use.
TIP: Those passwords are used for testing, so you can choose a simple password.
- Use > eth.accounts to list accounts on nodes.
- Use > eth.getBalance(<account>) to check balance of account.

Submission:

- Submit the results of > eth.accounts on each node
4.2. Start mining
- On node-1, use > miner.start(<number_of_threads>) to start mining
- Keep mining at least 2 minutes.
- Use > miner.stop() to stop mining
- Use > eth.getBalance(<account>) to check balance of mining account.

Submission:

- Submit the results of > eth.getBalance(<account>)
- Submit the balance of mining account in Ether
5. EXTRA POINTS: CREATE TRANSACTION TO TRANSFER

Goal:

- Transfer 10 Ether from Mining account to 2nd account on the same node (node-1).
- Transfer 05 Ether from Mining account to 1st account on the other node (node-2).

Submission:

- When all transaction are completed, submit the results of > eth.getBalance of:
o mining account
o 2nd account on node-1
o 1st account on node-2

Tips:

- To create a send transaction, the Sender Account must be unlocked first.
- Use > personal.unlockAccount to unlock account.
- Use > eth.sendTransaction to create a send transaction.
- Use > txpool.status to check transaction status
6. MATERIALS
- Geth CLI Options: https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options
- Ethereum Private Network and Explanation of Genesis file: https://gist.github.com/0mkara/b953cc2585b18ee098cd
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.