我正在Vagrant框中运行ganache-cli,并尝试将Metamask(Google Chrome)连接到它。但是Metamask无法连接到它。如果ganache-cli在主机上运行,它将连接。这是我的流浪文件
流浪文件
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.hostname = 'ethereum'
config.vm.box = "ubuntu/bionic64"
config.vm.provision :shell, path: "setup_dev_env.sh"
config.vm.box_check_update = false
config.vm.network "forwarded_port", guest: 3000, host: 3000, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 8545, host: 8545, host_ip: "127.0.0.1"
config.vm.synced_folder "SOME_PATH", "/home/vagrant/code"
config.vm.provider "virtualbox" do |vb|
vb.gui = false
vb.memory = "4096"
end
end
setup_dev_env.sh的内容
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install -y --allow-unauthenticated python3-pip mypy build-essential ethereum npm
sudo npm install -g ganache-cli
sudo apt-get update
答案 0 :(得分:2)
从ganache-cli --host 0.0.0.0
开始ganache-cli,然后在Metamask中以Custom RPC
的形式在New RPC URL
中输入http://0.0.0.0:8545
的详细信息