Ethereum Dev Chain - Private Chain


To develop and test an Ethereum smart contract we need a test network. The easiest way is go get spin off our own test chain with sufficient amount ethers. Below are the steps for spinning a development chain.

First download the latest Geth from the below URL



As I am using a windows machine, I downloaded the windows version. Install the Geth on your machine as per the installation guide.

Create a folder called DevChain where you can keep the chain data.

After that let’s create an account using command prompt. Specify the password when prompted.


Now create a genesis file to define the genesis block, which is the start of the block chain. Here is the genesis file (“genesis_dev.json”) I am using. Replace the account number with number you got in the previous step.

{
  "nonce": "0x0000000000000042",
  "difficulty": "0x200",
  "config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
  },
  "alloc": {
    "0x0bd615694d433424c292599f080bda45b0c257fc": {
      "balance": "100000000000000000000000"
    }
  },
  "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "coinbase": "0x0000000000000000000000000000000000000000",
  "timestamp": "0x00",
  "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "gasLimit": "0x8000000"
}

Now create a batch file (“startgeth.bat”) which will initialize the network every time you run.

RD /S /Q %~dp0\devChain\geth

geth.exe --datadir=devChain init genesis_dev.json
geth.exe --mine --networkid=12345 --cache=2048 --maxpeers=0 --datadir=devChain --rpc --rpccorsdomain "*" --rpcapi "eth,web3,personal,net,miner,admin,debug" console 

Now run the batch file to initialize and start the test network.


Now our development network is ready to start deploying and testing smart contracts.



10 comments:

  1. Hi,
    I have a problem when deploy smart contract. Because my account have 0 ETH with balance so I have error when deploy: gas price.
    I try to use rinkeby account and make it have 3ETH, but when I use function get my balance, it equal 0.
    Please help me !
    Thanks !

    ReplyDelete
    Replies
    1. You need to set the default account to be used for collecting gas price
      eth.defaultAccount = eth.coinbase;
      Alternatively you can pass in the account to be used while deploying the contract.

      Delete
  2. individuals from all kinds of different backgrounds are putting resources into computerized monetary standards. Ricona ICO

    ReplyDelete
  3. Once encoded, the exchange is changed over to something many refer to as a block, which is essentially the term utilized for a scrambled gathering of new exchanges.ıco

    ReplyDelete
  4. It is nothing unexpected that money related organizations are investigating the one of a kind abilities of blockchain. QProfit System

    ReplyDelete
  5. And afterward envision that these systems are intended to refresh this spreadsheet every now and then. This is precisely what blockchain is. Btc double

    ReplyDelete
  6. For best trading in crypto code that's very real trading system in all click reference

    ReplyDelete
  7. Icopulse One of the main cryptocurrency uses is payments, with https://icopulse.com/ico-list/category/banking we make it possible in an efficient and simple way. By donwloading our app you will be able to access your coins to make all sorts of instant transactions wherever you are and whenever you want

    ReplyDelete
  8. The most generally acknowledged currency is Bitcoin and in the event that you have it, you won't confront any issue of various currency acknowledgment.
    binance.con

    ReplyDelete
  9. Above all else, the cryptographic forms of money made it to the standard as of late, hence all the news with respect to them and bits of gossip are "hot".http://icowatchers.co

    ReplyDelete

Ethereum Solidity Compiler

Ethereum contracts are written in the high level language called Solidity and compiled into bytecode using the Solidity compiler. This ...