truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

在使用Truffle部署合约的时候,突然发生了这样一个错误:

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

其实原因很简单,就是你没有先打开你的以太坊客户端,我用的是ganache,但是我又发现,ganache打开之后,还是这样,这是为什么?

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

就是因为你的ganache监听的端口和你的truffle-config.js文件里的配置不一样,所以就会发生这样的问题,所以我们只需要将ganache的这个端口改一下: 

step1:点击右上角的设置按钮

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

step2:改正端口号并保存

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

step3: 修改成功(注意这时current block还是0)

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

step4:truffle migrate

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

???不对啊,不是这样的啊,说好的后面的那堆xxxxx呢?怎么一行就完事了?看来是之前已经成功部署过一遍了,所以再部署就emmmmm(废话,没成功过我也不会写这篇文章了!)

小场面,不慌。

把build文件夹删掉,重新truffle compile,然后再truffle migrate(然后耐心地把图截全...)

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters

step5:回到ganache 你会发现current block变成4了,下面有一个地址的余额少了一些,说明成功!美滋滋。

truffle部署智能合约报错:Could not connect to your Ethereum client with the following parameters