Build a real Ethereum-based PoW blockchain using the puppeth
tool bundled with geth
, the official Ethereum node software.
What does the "chain" in blockchain refer to?
Answer The chain of hashes that link each block to the previous.
What is a digital signature?
Answer A message that you can validate the integrity and authenticity of cryptographically.
What is a node?
Answer A node is a participant in the network that maintains a full copy of the blockchain.
Open a terminal window (GitBash in Windows) navigate to Ethereum tools folder to program the chain.
Generation of a genesis block using the puppeth
tool bundled with the Go Ethereum (geth
) tool.
geth
command-line tool.geth
is the official Ethereum node software used to initialize, run and manage Ethereum nodes.geth
will create a standard Ethereum node that will sync to the main network.geth
comes with a handy tool called puppeth
, we will create the networks!The Genesis block is the very first block in the chain. It contains the initial rules for the network, like the consensus algorithm and pre-funded accounts.
The consensus algorithm used is Proof of Work.
Pre-fund accounts by pasting an address from any Ethereum wallet that you control, without the 0x
prefix.
Continue with the default option for the prompt that asks, Should the precompile-addresses (0x1 .. 0xff) be pre-funded with 1 wei?
by hitting enter again until you reach the Chain ID
prompt
Once you enter the chain ID, hit enter, and you should show a success message and redirect to the original prompt.
The first step is to export our genesis configuration into a json
file.
Now, create at least two nodes to build the chain from the genesis block onward.
Be sure you are under your Ethereum tools directory and run the following command from the terminal window:
./geth account new --datadir node1
Next, create another account using a different datadir
by running the following command in the terminal window:
./geth account new --datadir node2
Your directory structure should look something like this:
The chain is ready to be started. Now it's time to initialize the nodes.
Open the terminal window (Git Bash in Windows), navigate to your Ethereum tools folder and launch the first node into mining mode with the following command:
./geth --datadir node1 --mine --miner.threads 1
--mine
flag tells the node to mine new blocks.--minerthreads
flag tells geth
how many CPU threads, or "workers" to use during mining.Launch the second node and configure it to talk to the chain!
Scroll up in the terminal window and copy the entire enode://
address (including the last @address:port
segment) of the first node located in the Started P2P Networking
line.
Launch the second node, enabling RPC, changing the default port, and passing the enodeid
of the first node you copied in quotes, the command will vary from OS X to Windows.
The output of the second node should show information about Importing block segments
and synchronization.
Connect a wallet (MyCrypto, MetaMask, etc.) with the blockchain you created.
node1
is mining.node2
is RPC enabled.Send a transaction on the chain. You should see the transaction go from Pending
to Successful
Congrats!
Twitter thread summary of this post: