Truffle

松露遷移–network kovan問題

  • February 6, 2022

當我truffle migrate --network kovan在終端中執行時,契約部署不會執行。只是:

Compiling your contracts...==================== >Eveything is up to date, there is nothing to compile

這是我的 truffle-config.js 程式碼:

require('babel-polyfill');
require('dotenv').config();
const HDWalletProvider = require('truffle-hdwallet-provider-privkey');
const privateKeys = process.env.PRIVATE_KEYS || ""

module.exports = {
 networks: {
   development: {
     host: "127.0.0.1",
     port: 7545,
     network_id: "*" // Match any network id
   },
   kovan: {
     provider: function(){
       return new HDWalletProvider(
         privateKeys.split(','),
         'https://kovan.infura.io/v3/${process.env.INFURA_API_KEY}'
       )
     },
     gas: 5000000,
     gasPrice: 25000000000,
     network_id: 42
   }
 },
 contracts_directory: './src/contracts/',
 contracts_build_directory: './src/abis/',
 compilers: {
   solc: {
     optimizer: {
       enabled: true,
       runs: 200
     }
   }
 }
}

刪除建構目錄為我做了。之後,它正確地重新部署了我的契約。

您已經編譯並部署了您的智能合約。Eveything is up to date, there is nothing to compile當您嘗試部署同一合約兩次時,在遷移期間會出現該消息。

如果你想將你的合約重新部署到一個新地址,你可以使用以下--reset標誌:

truffle migrate --network kovan --reset

引用自:https://ethereum.stackexchange.com/questions/72825