0

I want to use remix IDE and want to connect web3provider which needs to be connected to private blockchain running on VM locally. My system is running on Windows 10 and I am running the VM on my local using vagrant, the subsequent vagrant file is

Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  config.vm.provider "virtualbox" do |vb|
    vb.customize ["modifyvm", :id, "--memory", "3072", "--cpus", "2", "--natnet1", "10.252/16"]
  end


  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "ubuntu/xenial64"
  config.vm.box_version = "20190625.2.0"
  config.vm.network "forwarded_port", guest: 8000, host: 8080
  config.vm.network "forwarded_port", guest: 3503, host: 8073
  config.vm.network "forwarded_port", guest: 3505, host: 8075
  config.vm.network "forwarded_port", guest: 8090, host: 8070
end

`

I have created an account which is to be used as a miner and connected that using the command nohup geth --datadir node1/ --syncmode 'full' --allow-insecure-unlock --port "30303" --rpc --rpcaddr "127.0.0.1" --rpcport "3503" --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://6b9a53203cd41106bf21c8496a1ff7d1e41b7437b9b41dedd557d89be35fcc3b18562f8ce81287b4872ca0adfc27c7b5ea98b159698ca7ac833ae133b82b672d@127.0.0.1:30302' --networkid 1505 --gasprice '1' --unlock 0 --p assword node1/password.txt --mine > node1/01.log 2>&1 &

though the blockchain network is up and running but cannot be able to connect the remix IDE on my local browser to be connected to VM's blockchain. The http endpoint which I am using to connect to remix IDE is http://127.0.0.1:3503

I have tried changing the rpcaddr to "0.0.0.0" but of no use. Can you please help me to identify where I would have gone wrong I am new to this please help me with this.

3

Think of your VM like a completely different machine. It has another IP for example. 127.0.0.1 accesses localhost and therefore your host machine.

So how do you fix this?

You need to connect to your VM with the correct IP. Go into your VM and run the command ifconfig.

A lot of stuff gets returned. You will surely recognice the correct IP when you see it. For example 192.xxx.xxx.xxx (even the first numbers vary 192 or 172 or 10).

Then you can connect from your host system with this new IP.

e.g. http://192.168.21.145:3503

There is more stuff to consider

To allow external connections (host -> VM) you need to allow this IP.

The easy way to do this is with rpcaddr 0.0.0.0. But this is very insecure. Now everyone can access your node (if the server runs in the internet and not on a local VM). So you should specify which IP can access your node.

Either manually input your device IP which makes all the call or build an API around it which handles this stuff for you.

  • Thanks Niklas , for the elaborate explanation, using that I got the idea that to connect to remix one must have a Web3provider like metamask. Otherwise it cannot just directly be connected to private blockchain, so I have created a rest API to connect to my blockchain using localhost:8073 as my 3503 rpcport is connected to outer windows machine using 8073 post as shown above in vagrant file and I am now able to connect to my blockchain network and able to use solc to convert the smart contract into binary to be placed inside my java application. Remix needs some Web3Provider – Kshitij Rastogi Sep 18 at 6:39
  • moreover with the above info, need to open the forwarding post from host machine to guest, for more ref how to open it , you can find it here howtogeek.com/122641/… – Kshitij Rastogi Sep 18 at 8:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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