2

Lets say there are 2 organizations and each have their own private block chains in a different geographical region.

Now they need to have a collaboration and share some part of the data between them.

Is it possible to connect these 2 private block chain and have controlled access to each other?

1

Well yes that is possible, you can also connect 2 of them parallel based on your RAM, but you'll most probably get an out of memory error if you could try to connect 3 or more in parallel. But I don't think it is possible to share blockchains, its data between each other,

How can I create connected multiple blockchains?:

With Ethereum alone it's not possible (yet), unless you implement a custom solution.

But when you run multiple geth process for each private blockchain on the background, by using nodejs you could have connection to each different blockchains and their contracts, and they can send information between each other.

I would suggest to connect each private blockchain individually each will have its own folder to store its blockchain.

First on your node you have to create your private ethereum network on 2 different named folders (for example: --"datadir="/home/MyEthereumEbloc_1" and --datadir="/home/MyEthereumEbloc_2"), this will also create different geth.ipc for each. ipc:/home/MyEthereumEbloc_1/geth.ipc and ipc:/home/MyEthereumEbloc_2/geth.ipc.

Later on you should run 2 different geth process with different --port number, --identity, --networkid that you want to connect, --rpcport empty port that you could use and --bootnode that you would like to connect. Since 2 organization has their own private blockchain, their ip and port number will be unique for each.

For example: You could also run following commands in between nohup & which will run geth on the background.

geth --port 3000 --networkid 12345 --identity node1 --nodiscover \
        --nat none --datadir="/home/MyEthereumEbloc_1" --rpc --rpcaddr="localhost"\
        --rpcport 8545 --rpccorsdomain="*"--ipcapi "admin,eth,net,web3,debug"\ 
        --bootnodes enode://$id@<ip_1>:<port_1>

-

 geth --port 3001 --networkid 54321 --identity node2 --nodiscover \
        --nat none --datadir="/home/MyEthereumEbloc_2" --rpc --rpcaddr="localhost"\
        --rpcport 8546 --rpccorsdomain="*" --ipcapi "admin,eth,net,web3,debug" \
        --bootnodes enode://$id@<ip_2>:<port_2>

inside nodejs: since --rpcport 8545 is linked to --bootnodes enode://$id@<ip_1>:<port_1> and since --rpcport 8546 is linked to --bootnodes enode://$id@<ip_2>:<port_2> you can access the blockchain that is in your organisation by creating different web3 variables (web3_1, web3_2) inside nodejs.

var web3_1 = new Web3();
web3_1.setProvider(new web3_1.providers.HttpProvider('http://localhost:8545'));

var web3_2 = new Web3();
web3_2.setProvider(new web3_2.providers.HttpProvider('http://localhost:8546'));

if(!web3_1.isConnected()) console.log("not connected");
else                    console.log("connected");

if(!web3_2.isConnected()) console.log("not connected");
else                    console.log("connected");

Please note that if you run 2 geth process in one machine, it has been recommended that minimum 8GB RAM required, 4GB RAM for each. https://ethereum.stackexchange.com/a/9906/4575

| improve this answer | |
  • my question is not about running 2 nodes in a machine. it is about two private block chains distributed geographically communicating and sharing data – mahesh gupta Dec 27 '16 at 12:12
  • 1
    I did some addition, thats all I know. But still you have to run different geth processes on background to have access to the different blockchains, than they can share some data through contract on the same node. – alper Dec 27 '16 at 12:14

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