2017-09-26 56 views
1

我已經正確安裝了geth,truffle和testrpc。現在我正在嘗試做一些以太坊合約教程。我初始化了項目truffle init,因此創建了具有默認合同的項目文件夾,然後我運行testrpc並通過鍵入truffle compile(構建目錄已成功創建)編譯合同。事情是,truffle test不工作,因爲如果沒有testrpc運行。我在Windows上使用Git Bash。可能是什麼問題? Screen無法連接到以太坊客戶端(testrpc)

回答

0

檢查了這一點

  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堅固版本。
相關問題