0

Truffle migrate Error: You must specify a network_id in your 'rinkeby' configuration in order to use this network. this is my truffle-config.js

const HDWalletProvider = require("@truffle/hdwallet-provider")
const config = {
  alchemy: "0dba898c85ca47c2ac23471de88b0aaa", 
  privateKey: 'e97b717ee45bcf2e35e4b281f42f947984b17abf0a5a7c7fa8c9950a36a0c33d'
}
module.exports = {

  contracts_build_directory: "./src/build",

  networks: {

    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    },


  },

  mocha: {
  },
  ropsten: {
    provider: () => new HDWalletProvider(
      ['0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'],
      `https://ropsten.infura.io/9fa16570ba4a46bca697d1e4140be14c`,// your infura API key
    ),
    network_id: "3",

  },
  rinkeby: {
    provider: () => new HDWalletProvider(
      config.privateKey,
      `https://rinkeby.infura.io/v3/${config.alchemy}`,// your infura API key
    ),
    network_id: '4',
  },
  // Configure your compilers
  compilers: {
    solc: {
      version: "0.8.17", // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {          // See the solidity docs for advice about optimization and evmVersion
        optimizer: {
          enabled: true,
          runs: 200
        },
        evmVersion: "byzantium"
      }
    }
  }

};

I clearly set network_id

When I test network deployment, it prompts this error, I don't know how to solve this problem

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
kkpzj
  • 1

1 Answers1

0

Maybe because "Rinkeby" and "Ropsten" are deprecated you cannot connect to that provider. Use Goerli

goerli: {
      networkCheckTimeout: 10000,
      provider: () => new HDWalletProvider(
          config.privateKey,
          // get goerli endpoint
          `https://goerli.infura.io/v3/${config.alchemy}`,// your infura API key
    ),
      network_id: 5,
      gas: 5500000,
      gasPrice: 20000000000,
      confirmations: 2,
      timeoutBlocks: 200,
    },
  },

get token from goerli-faucet

truffle migrate --reset
truffle migrate --network goerli
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
  • thanks ,but This is the same question.. You must specify a network_id in your 'goerli' configuration in order to use this network. – kkpzj Feb 25 '23 at 05:21
  • @kkpzj are you running the command from where `truffle.config.js` is? In other words if you run `ls` command do you see the `truffle.config.js` file logged on terminal – Yilmaz Feb 25 '23 at 05:23
  • I found the error,goerli is not write in networks, thank you very much , but i have a new error : *** Deployment Failed *** Transaction's maxFeePerGas (30000000000) is less than the block's baseFeePerGas (64481757739) – kkpzj Feb 25 '23 at 10:21
  • this is my new truffle-config.js networks: { development: { host: "127.0.0.1", port: 8545, network_id: "*", // Any network (default: none) }, goerli: { provider: () => new HDWalletProvider( config.privateKey, `https://goerli.infura.io/v3/${config.alchemy}`, ), network_id: 5, from: "0xE72BB307051ea7788033F82d45bF6747afd5d2A6", gas: 5500000, gasPrice: 20000000000, confirmations: 2, pollingInterval:30000, networkCheckTimeout: 10000000, timeoutBlocks: 10000,}, }, – kkpzj Feb 25 '23 at 10:27