XDC Private Testnet (Geth Fork)
Setting up a Private Test Network
Ethereum enables users to set up a private test network separate from the main Ethereum chain. The testnet helps test distributed apps built on Ethereum, without exposing them to the real Ethereum network. The following is a step-by-step walk-through on how to set up and run your Ethereum testnet using Geth and Homebrew.
Step-by-step Walk-through
Step 1: Install Geth and Homebrew.
Step 2: Create Genesis file.
Step 3: Start your node.
Step 4: Mine Ether.
Step 1: Install Geth and Homebrew
Open the terminal and install homebrew.
Install Geth.
Step 2: Create Genesis File
The Genesis block is the first block in the chain. The Genesis file is the JSON file that defines the characteristics of the initial block and thus the rest of the blockchain.
Create a directory to hold your network files.
Create your Genesis file.
Open your Genesis file and paste the following:
Configuration
chainId: A unique identifier of new private blockchain.
homesteadBlock: Homestead is the first production release of Ethereum. Given that developers are already using this version, the value of this parameter is set to zero.
eip155Block/eip158Block: Ethereum Improvement Proposals (EIP) were implemented to release Homestead. Given that hard forks are not required in private blockchain development, its value is set to zero.
Gas limit: The gas limit is the maximum amount of gas spent on a particular transaction. Consider setting a fairly high value on the gas to avoid hitting the limit and slowing down your network.
alloc: Allows allocation of Ether to a specific address.
Step 3: Start Your Node
Instantiate your data directory
Start your Ethereum peer node
The output will look like this:
Display your Ethereum logs
Open terminal window, cd to my-eth-chain
and typetail -f myEth.log
Create or import an account
In Geth Javascript console, create an account:
Set default account
Step 4: Mine Ether
Check your balance
Run the following to mine ether:
Look at your terminal window, some mining actions will be visible in the logs. To stop mining:
Optional: Add other peers
On your same machine instantiate a new datadir:
Launch the second peer on a different port:
Display your Ethereum logs
Open another terminal window
cd to my-eth-chain
Type tail -f myEth2.log
Join the first peer
In the geth JavaScript console of your 1st peer, type:
The output will look like this:
In the geth JavaScript console of your new second peer, type:
Helpful geth console commands
admin.nodeInfo.enode net.listening net.peerCount admin.peers eth.coinbase eth.getBalance(eth.coinbase) personal eth.accounts miner.setEtherbase(web3.eth.accounts[0]) miner.setEtherbase(“0xae13d41d66af28380c7af6d825ab557eb271ffff”) miner.start() miner.stop() miner.hashrate eth.getBlock(0) eth.getBlock(“latest”) eth.blockNumber web3.eth.getBlock(BLOCK_NUMBER).hash eth.syncing debug.verbosity(6) //highest logging level, 3 is default
Last updated