Now we are going to learn about how to setup local ethereum private net for development purpose and how to do mining and get some test ethers.
Requirements:
Operating System:Windows,Linux,MacOs
RAM:Minimum 4GB
Core:Minimum 1
Step 1:
What are the things to Download?
-Geth(Go Ethereum)
https://ethereum.github.io/go-ethereum/downloads/
Download and Install it
-Mist(Browser for Solidity)
https://github.com/ethereum/mist/releases
Download as .zip and no need to install.
Step 2:
1.Open command prompt and enter
geth version
If it returns details about Geth like version, network Id means geth was successfully installed.
Suppose if it not,
-Go to project folder of Geth "C:\Program Files\Geth"
-Press Shift+Right Click
-On context menu click "Open command window here"
-Enter Geth version and check it.
It's because of Path(Environment Path variables) is not set for Geth.You can able to set it manually. If it is not set you can able to access geth only from that folder.
Step 3:
1. Go to your project folder and create one folder “FirstContract” and move into that.
1. Create genesis.json file(copy below configs and save as genesis.json at “C:\BlockChain\FirstContract”)
{
"coinbase" : "0x0000000000000000000000000000000000000001",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
"alloc": {},
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
}
}
More info about genesis.json ->https://github.com/ethereum/go-ethereum/wiki/Private-network#creating-the-genesis-block
Step 4:
1. On the same folder, Create one directory and named as “chaindata” at “C:\BlockChain\FirstContract”
2. Open CLI, enter
Geth –datadir=./chaindata init genesis.json and it returns like an image shown below
3. Next thing also In CLI,enter
Geth –datadir=./chaindata
Step 5:
1.Extract the files from downloaded Mist.zip file.
3.while we open this,you will see one thing on right side upper corner called “Private-Net”.
It shows clearly that we are in private net.If we do not start Step 3 process, this mist browser will open on the main network and start downloading blocks. So check that private net is shown or not, or else close the mist browser.
4.Click LAUNCH APPLICATION .
Below this, we are going to do some things.Bear in mind, it's all for development purpose only, not like real life things.
1.Click Add account on the page https://wallet.ethereum.org/
2.Pop-up will open and click Create new account.
3.Password pop-up will open.Give your password and confirm that.
4.Now the main account has been created. On left side lower corner has one small red tag(Private).That clearly shows we are only in private development environment.
Step 7:
1.Open CLI , move into the project folder and enter
It is the command to open the geth console on a running geth instance.
2.Then enter
miner.start(1);
It’s the command to start mining.It holds the variables pass the number of cores. After a few minutes, you have some ethers added to your account.
After getting enough ether, stop the mining using this CLI command
Miner.stop();
It will return true, so mining has been stopped.
Now you get some ethers in your main account.This is not real ethers, it's purely for development purpose.
Comments
Post a Comment