Step 1 : Create few sample accounts to use on the network
$ geth --datadir "nodedata" account new
Step 2 : Use puppeth
to initialize network
$ puppeth
Geth 1.6 ships a new tool called puppeth, which aims to solve this particular pain point. Puppeth is a CLI wizard that aids in creating a new Ethereum network down to the genesis, bootnodes, signers, ethstats, faucet, dashboard and more, without the hassle that it would normally take to configure all these services one by one. Puppeth uses ssh to dial into remote servers, and builds its network components out of docker containers using docker-compose. The user is guided through the process via a command line wizard that does the heavy lifting and topology configuration automatically behind the scenes.
Follow the wizard steps
... and continue few more steps
Ctrl + D
[to exit puppets prompt]
Step 3 : Initiate blockchain with genesis block
$ geth --datadir ./nodedata/ init ajit.json
Step 4 : Run Node
$ geth --identity "AJIT" --networkid "5777" --datadir "nodedata" --http --http.port "8545" --unlock "0" --http.corsdomain "*" --http.api "miner,eth,net,web3,personal" --allow-insecure-unlock --nodiscover --miner.etherbase "0x3f6006424f39039C7ab161A8b442be4DAd7f503c"
At this point the ethereum node is ready. The account 0x3f6006424f39039C7ab161A8b442be4DAd7f503c is the one which we created in first step. This account will be used as "etherbase", which means "mining" rewards will be transferred to this account.
Next step we need to attach this node using IPC. You can locate IPC path in Step 4 output
Open new terminal and run following command
$ geth attach ipc:/{working directory path}/nodedata/geth.ipc
This command will connect Geth JavaScript console to the ethernet node created in earlier step
- Note that AJIT is the instance of the node in this example.
- Coinbase (etherbase) account is 0x3f6006424f39039C7ab161A8b442be4DAd7f503c which we configured.
- Node data (blocks) will be stored at directory "nodedata"
- We have enabled accounts "admin", "debug", "eth", "ethash", "miner", "net", "personal", "rpc", "txpool" and "web3" while running the note in Step 4
Now to start auto-mining on this node run following command in Geth JavaScript console
$ miner.start()
Go to the terminal instance in which we have started the node, you will observe polling status to mine the block. If try to do any "transfer" at this point, it will be auto mined.
Step 4 : Transfer Ether
We have only one account active in our node and that is the "coinbase" account. Let's create two more account so that we can trasnfer ether between accounts. Follow Step 1 to create two mode accounts
Following two accounts are now ready to use 0xE481bc9a0bD07D9aDD366277D4f0181464a6f341 and 0xbE2186604DFaB58FeA8b675268db31D2e0678f58 Use eth.accounts and eth.getBalance commands to list the accounts and check balance
Newly created accout has zero balance. First account has some balance since we have mentioned to fund it while creating genesis block. We can also pre-create accounts and then mention opening balance of the account in genesis config file, in our case we could mention in ajit.congig file Use following command to transfer some Wei (Geth JavaScript console).
$ eth.sendTransaction({from: '0x3f6006424f39039C7ab161A8b442be4DAd7f503c', to: '0xe481bc9a0bd07d9add366277d4f0181464a6f341', value: 100})
0xf1b5e15e371a7a0edac4edc9661cccaa1b338c472c754f2d8efabb17c947454b is the transaction hash Also observe mining log in "node termin console"
Run following command in Geth console to view details of the transaction
$ eth.getTransaction('0xf1b5e15e371a7a0edac4edc9661cccaa1b338c472c754f2d8efabb17c947454b')
Check balance again. 0xe481bc9a0bd07d9add366277d4f0181464a6f341 account has 100 Wei now.
Lastly to stop the node we have to close stop mining with following command and then press Ctrl + C on node termininal to stop the node.
You can clean the working folder if you don't need it any longer. Next time when you want to start the node
- Gitter
- Stack Exchange
- KBA Official Telegram Channel
- KBA Facebook
- KBA Official LinkedIn Group
- Go Ethereum Discord Channel
- Blockchain Education Network
- Ethereum Community List
- Capture the Ether
- ETH.Build
- Gitcoin
- Scaffold-ETH
- Damn Vulnerable Defi
- Ethereum Mainnet Statistics
- [Cryptozombies.io][(https://cryptozombies.io/)
- Solidity by example
- Hardhat