无法连接到以太坊客户端(testrpc)

问题描述:

我已经正确安装了geth,truffle和testrpc。现在我正在尝试做一些以太坊合约教程。我初始化了项目truffle init,因此创建了具有默认合同的项目文件夹,然后我运行testrpc并通过键入truffle compile(构建目录已成功创建)编译合同。事情是,truffle test不工作,因为如果没有testrpc运行。我在Windows上使用Git Bash。可能是什么问题? Screen无法连接到以太坊客户端(testrpc)

检查了这一点

  1. 你需要在你的目录中的测试文件,然后才能运行truffle test
  2. 需要两个CMD窗口,
    • 一个运行testrpc命令(不要终止),
    • 要编译的第二个窗口
      要进行编译,请运行命令b elow Web3 = require('web3') web3 = new Web3(new Web3.providers.HttpProvider(" http://localhost:8545 ") solc = require('solc') sourceCode = fs.readFileSync('ContractFile.sol').toString() compileCode = solc.compile(sourceCode) //Get the interface of contract contractABI = JSON.parse(compileCode.contracts[':ContractFile'].interface) //Get the bytecode of the contract bytecode = compiledCode.contracts[':ContractFile'].bytecode //Ready to deploy ContractFileContract = web3.eth.contract(contractABI) //use the object above to deploy the contract ContractDeployed = ContractFileContract.new({data: bytecode, from: web3.eth.account[0], gas: 4700000}) //Check your testrpc console.
  3. 不要忘记你的合同的顶部declear坚固版本。