If you are new to the blockchain technology, taking our Introduction to Blockchain Technology self-paced course is highly recommended. Also, for a comprehensive coverage of blockchain development in Ethereum or mastering Solidity programming, taking our below self paced courses is highly recommended:
In our previous article (How to Run Geth on a Local Private Ethereum Blockchain with Mining), we discussed how to run Geth on a local private Ethereum network that includes mining component.
In this article, we learn how to create an account on a local private Ethereum network.
To start mining, we will need to create an ether account on the private blockchain. Let's get started:
1. Let's start a new terminal session with an open and running network connection. The attach sub-command will start a JSRE REPL console for interactive use. The REPL console can also be started by a sub-command console. The difference between the two is that attach starts the console without starting the geth nodes:
modules: admin:1.0 debug:1.0 eth:1.0 ethash:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0
2. Now, let's get started and create our very first account in the interactive console. When you create a new account, geth asks for a passphrase:
Make sure you type in a very strong password, and write it down somewhere and keep a few copies. You know the drill. After repeating the passphrase, you will see your new account:
Repeat passphrase: "0xde2d56b4abc0bf860d25781ca4a87772dec8f8a8"
3. You can check your account now; it will include the one we just created, as follows:
4. Let's check the balance of our new account; a 0 balance is expected for now:
web3.fromWei(eth.getBalance(eth.accounts), "ether") 0
New accounts can also be created non-interactively without opening the geth console. The --password flag can be used in this case if you have created a password file in plaintext format, as follows:
$ geth account new
$ geth account new --password <password file>
We have provided two ways of creating a new account:
At this point, we have a new account handy. We are going to mine on our local private network in the next section.
Mining on the local private blockchain can be started with the following command; we will be using --etherbase to credit all rewards to the account we just created:
$ geth --datadir data --mine --miner.threads=1 --miner.etherbase
Once started, it will keep running and writing out the logs, as follows:
INFO Successfully sealed new block number=1520 sealhash=7c9374...e035e4 hash=25a8c4...d0ae06 elapsed=5.228s
INFO block reached canonical chain number=1513 hash=7ca5de...5cab58 INFO mined potential block number=1520 hash=25a8c4...d0ae06
INFO Commit new mining work number=1521 sealhash=8ce312...0bec54 uncles=0 txs=0 gas=0 fees=0 elapsed=173.13µs
It will earn you ethers when new blocks are added to the blockchain. It's very realistic to become a billionaire if you keep mining:
web3.fromWei(eth.getBalance(eth.accounts), "ether") 40 web3.fromWei(eth.getBalance(eth.accounts), "ether") 7175 web3.fromWei(eth.getBalance(eth.accounts), "ether") 8360 web3.fromWei(eth.getBalance(eth.accounts), "ether") 9010
It must feel good to see the number keep increasing. But to stop the miner, you can use the console miner.stop() command.
In our next article (How to Use Ethereum Optional Flags with New Chains), we discuss what Ethereum Optional Flags are and how to use them.
This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.
Here is the list of our free webinars that are highly recommended:
Here is the list of our 10 free self-paced courses that are highly recommended:
If you like to learn more about Hyperledger Fabric, Hyperledger Sawtooth, Ethereum or Corda, taking the following self-paced classes is highly recommended:
If you want to master Hyperledger Fabric, Ethereum or Corda, taking the following live classes is highly recommended:
If you like to learn more about blockchain technology and how it works, reading the following articles is highly recommended:
If you like to learn more about blockchain development in Ethereum with Solidity, reading the following articles and tutorials is highly recommended:
If you like to learn more about blockchain development with Hyperledger, reading the following articles and tutorials is highly recommended:
If you like to learn more about blockchain development on Corda , reading the following articles and tutorials is highly recommended:
If you like to learn more about blockchain development in other platforms, reading the following articles and tutorials is highly recommended:
We offer private custom tutoring classes both online and in DC, MD and VA for almost all of our courses or bootcamps. Give us a call or email us to discuss your needs.
$50 Limited OfferREGISTER NOW