In this post, we are going to setup a testnet of ethereum using Geth. Testnet is use full in many cases like when we want to do some transactions on ethereum network without spending actual ethers. we will still need ethers to do transactions on testnet but generating ether on test is very easy and can be done on your laptop and may be within in 10 minutes we will have enough ethers to do some transactions. I am going to run this on ubuntu 10.06. you should have already geth installed on your system which i have covered in this post

You can start the testnode by simply passing parameter " --testnet" while starting geth.

./geth --testnet

I am going to run geth node as background process. I have a small start up script here which set all the required parameters while starting geth and redirect the output to a logfile.

vi testnet-start-geth.sh

#!/bin/bash
export GOPATH=/ethereum/go
export PATH=$PATH:/ethereum/go/bin
/ethereum/go-ethereum/build/bin/geth --testnet --rpc --rpccorsdomain "*" --datadir /ethereum/blocks-test 2>> /ethereum/logs/test-ethereum.log

--rpc use if you want to access geth over RPC

--rpccorsdomain you can restrict the access of RPC using this flag

--datadir use this to download blockchian block in the directory of choice

set execute permission on script and start it

daemon /home/ethereum/testnet-start-geth.sh

and you can watch the log to see the progress of startup...it will take sometime to synch the entire blockchain.

To start the geth in mining mode you will have to pass an additional parameter "--mine"

/ethereum/go-ethereum/build/bin/geth --testnet --mine --rpc --rpccorsdomain "*" --datadir /ethereum/blocks-test 2>> /ethereum/logs/test-ethereum.log

modify the startup script and start it with daemon

daemon /home/ethereum/testnet-start-geth.sh

you can not start actual mining until your node download all the blocks, This site site will give you the last block number mined on the testnet. you can watch the log to compare with the number given by above site to see your node if fully synced.

Or, you can attach to geth to use the interactive mode

/ethereum/go-ethereum/build/bin/geth attach ipc:/ethereum/blocks-test/testnet/geth.ipc

After the node is fully synced and you start mining , an account need to be created where you want to store the mined ether.


And now mining can be started...

After you issuie the mining command you will see "Generating DAG" in the log , actual mining will not start until generating DAG is 100% complete..

As soon as mining start , all the cpus utilizations will go to 100% and it will start hashing hard to win the ethers.

and here you go , we have already mined some ethers within 10 minutes..

geth #testnet #ethereum #blockchain