Intro To Ethereum Mining: Mine Ether On Your Private Ethereum Blockchain in 8 mins

Welcome to the second video in Ethereum Fundamentals. Today’s topic is: Introduction To Mining Ether. Let’s recap what we learned in the previous
video. We looked at Geth, the command line interface
for Ethereum. We learned how to install the latest version
of Geth for Windows. In the lab session, we saw how to set up Geth,
and create a private blockchain. Lastly, we created our first Ethereum account. So let’s look at our goals for today. We will start with an overview of ether. Next, we will learn about mining ether, which
is one of the most crucial concepts in blockchain technology and crypto currencies. Finally, we will continue our lab, where we
will learn how to create ether. Ok, let’s dive into today’s topic. What is ether, what is mining, and how are
the two related? What is ether? Simply put, ether is the “Fuel for operating
Ethereum”. As we saw in the previous video, computers
that run Ethereum are called nodes. These nodes need a way to be paid for “renting
out” their resources, namely, computational power, storage and networking, in order to
keep Ethereum up and running. But this needs to happen without the exchange
of traditional currency, given that Ethereum does not rely on a third party, like a state-backed
central bank. To solve this problem, ether is used to compensate
these nodes. Think of it as a token of value that is accepted
by all nodes on the Ethereum network. Now, assuming that you have some ether, what
can you do with it? If you are a developer, who is creating applications
on Ethereum, you need “space” on the Ethereum blockchain to store and run your applications. This means, you need a way to “rent space”
on the blockchain. Ether is used to compensate nodes, to provide
space in the blockchain for you. We will explore this mechanism, also known
as “Gas”, in detail later. Lastly, Ethereum can be traded for other currencies,
including crypto currencies such as Bitcoin, or traditional currencies such as the US Dollar. Several exchanges are available online, that
let you do so. So, how is new ether created? Ethereum relies on the growth of its blockchain. Unless new blocks containing transactions
are added to the blockchain, Ethereum becomes useless. How are these blocks created? These blocks are not created by a single node. They are created using a competition. Ethereum nodes compete with each other to
create the next block that will be added to the blockchain. They perform complex calculations, known as
hashing algorithms, that require a large amount of time and effort to generate the “right
answer”. The winning node, the one who comes up with
the “right answer”, is rewarded with new ether, that is credited to their account. Therefore, this process that results in the
“Creation of Ether” is called “Mining”. Ok, so far, we learned about ether, and the
process that creates it, mining. Now, let’s create some ether in our private
blockchain! Ensure that you have watched our previous
video, so that you can follow along. Please note: The concepts that you learn here,
can easily be used to create real ether. However, creating or mining real ether will
not be covered here. Let’s use geth to mine some ether, on a
private Ethereum blockchain. Let’s head into the nugget1 directory, and
list its contents. First, we need to have a coinbase, which refers
to the primary Ethereum account, that you will use to mine ether. Check if you have a “data” folder. If you don’t have it , pause the video now,
and follow the instructions in our previous video, to create an Ethereum account. Once you have a coinbase, run the “accounts”
helper script. This will generate a file called “output.txt”. Use notepad to open this file. We will see that this file contains a long
hex string, which represents the coinbase, or account, address. Note that your hex string will be different
that what you see here. Select this string with your cursor, and copy it using control C. Close notepad after copying this string. Next, we need to regenerate the genesis block, with your coinbase. Use notepad to open the “g2.json” file. Paste the coinbase, using control V, into
the spot that says, add your coinbase here. Save this file, and quit notepad. Run the command, “init g2.json”, to regenerate
the genesis block, with your coinbase. Ignore any error messages that may show up. Now, let’s check the balance of ether in
our coinbase. Use the “console” helper script to open
a geth console. Type “load script gethload.js” to load
our helper functions, into geth. Now, type “check all balances” to see
your coinbase balance. You will see, that you have a zero ether balance. Ok, so now, we are ready to start mining some ether! Exit the console, by typing “exit”. Now, use the “mine” helper script, to start
mining. We will let the script run for about 10 minutes, and see how its doing. After about 10 minutes of letting the miner run, let’s stop it. Use control C, followed by the exit command in geth, to exit the miner. From your Windows command line, start the geth console using the “console” helper script. Load the javascript helper functions using
“load script geth load dot js”. Type “check all balances”. You will see that your account contains some
ether deposited in it. Congrats! You have just earned some ether on your private blockchain. Hope you enjoyed this video. Stay tuned for the next one. Thank you!

7 thoughts on “Intro To Ethereum Mining: Mine Ether On Your Private Ethereum Blockchain in 8 mins”

  1. In this private network, there is only one account (one node?), then, what are the nodes that are mining ether and which blocks are they trying to add to the blockchain to do so?

  2. on the loadscript part i get loadscript not defined.
    running windows 10,have tried geth 1.5.5 and 1.5.6
    please advise thankyou

  3. sory error code:
    geth –datadir data –networkid 123 –nodiscover –maxpeers 0 init g1.json
    Fatal: invalid genesis file: json: cannot unmarshal hex string without 0x prefix into Go struct field Genesis.extraData of type hexutil.Bytes

    need your help thanks

Leave a Reply

Your email address will not be published. Required fields are marked *