2

I have already created a private blockchain in my system. Now can I create another private blockchain in the same system? I have tried to create one more by changing the chain id in genesis block and network id but still when I open the ethereum wallet I could see the contracts created by me in my first blockchain in black and white. Can anyone tell me why??

3 Answers 3

4

Yes, you can create multiple blockchains in same system. For that you need to change below configs in geth

  1. Port number: Default port is 30303. As far as I know you can't run two different eth clients for same ip and port number. Until if you install any VM's. So you can change port number using --port option . If you want to enable RPC then you need to use --rpc option for accessing current blockchain to web3js api's

  2. Data dir: default dir is ~/.ethereum, Please add your two different network dir's by specifying --datadir

  3. networkid: I'll suggest you to add two different unique network ids

So final command would be for block chain 1:

> geth --networkid 36562 --datadir ~/network1 --port 30304 

So final command for block chain 2:

> geth --networkid 36563 --datadir ~/network2 --port 30305 

for more details please refer below link

https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options

0

Change your private node directory path, for geth node, you can try with

 geth --datadir "/dirname" 

because you use same directory path(default directory) for both nodes that's why contracts created by first node show in the second node.

0

Running multiple chains on one PC is possible, and you've made a good start by creating a second genesis file with a different chain ID.

You now need to create a separate data directory for the second chain, then initialise geth with the second genesis file in that second data directory as follows:
geth --datadir '/path/to/your/second/datadir' init '/path/to/second/genesis/file'

then run geth with the chainID of the second chain within the second datadir, using a new port number to avoid clashing with the first instance (default is 30303):

geth --datadir '/path/to/second/datadir' --networkid <chain 2 id> --port 30304

once this is up and running you should have two separate chains and contracts/transactions from one won't be visible on the other. If you use mist you'll need to point it to the geth.ipc instance in each datadir respectively to have mist instances running on each chain simultaneously.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.