Private-Blockchain
用於元幣松露盒範例的 Truffle Migrate 失敗
松露遷移
Compiling your contracts... =========================== > Compiling .\contracts\ConvertLib.sol > Artifacts written to C:\blockchain_projects\truffle_projects\metacoin\build\contracts > Compiled successfully using: - solc: 0.5.12+commit.7709ece9.Emscripten.clang > Something went wrong while attempting to connect to the network. Check your network configuration. Could not connect to your Ethereum client with the following parameters: - host > 127.0.0.1 - port > 7545 - network_id > * Please check that your Ethereum client: - is running - is accepting RPC connections (i.e., "--rpc" option is used in geth) - is accessible over the network - is properly configured in your Truffle configuration file (truffle-config.js) Truffle v5.1.0 (core: 5.1.0) Node v10.16.3
已經執行 ganache-cli
我使用的是 ganache-cli,它偵聽埠 8545,解決方案是相應地更新 truffle-config.js 文件:
module.exports = { // Uncommenting the defaults below // provides for an easier quick-start with Ganache. // You can also follow this format for other networks; // see <http://truffleframework.com/docs/advanced/configuration> // for more details on how to specify configuration options! // networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*" }, test: { host: "127.0.0.1", port: 7545, network_id: "*" } } };
然後使用 –network 標誌指定要使用的網路:
truffle migrate --network development
首先,您需要在終端中執行ganache-cli 。(如果您沒有 ganache CLI,則首先通過執行此命令npm install -g ganache-cli安裝它)在此命令之後,您將能夠執行truffle migrate。
這會奏效。