简体   繁体   中英

Error when migrating contracts using truffle

When using traffle deploying contracts it gives these errors:

"Migrations" -- Unable to decode sender address from transaction: 
Incompatible EIP155-based V 38 and chain id 3. 
See the Common parameter of the Transaction constructor to set the chain id....

And my truffle-config.js like this:

 networks: {
development: {
  host: "127.0.0.1",     // Localhost (default: none)
  port: 9545,            // Standard Ethereum port (default: none)
  //gas: 8e6,
  //gasPrice: 20,
  network_id: "5777",       // Any network (default: none)
},

ropsten: {
  provider: () => new HDWalletProvider({
    privateKeys: [testnetPrivateKey],
    providerOrUrl: `https://eth-ropsten.alchemyapi.io/v2/${ropstenAlchemyApiKey}`
  }),
  network_id: 3,       // Ropsten's id
  networkCheckTimeout: 1000000000,
  gas: 4000000,
  confirmations: 1,    // # of confs to wait between deployments. (default: 0)
  timeoutBlocks: 50000,  // # of blocks before a deployment times out  (minimum/default: 50)
  skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
},

What does these errors mean and how should I configure to prevent that failure? Thanks!

When constructing HDWalletProvider pass chainId: 3 can solve the problem.

  ropsten: {
      provider: () => new HDWalletProvider({
      privateKeys: [testnetPrivateKey],
      providerOrUrl: `https://eth-ropsten.alchemyapi.io/v2/${ropstenAlchemyApiKey}`,
       ////////////////////////////
      chainId: 3 // add this

}),

Take a look here chainid-vs-networkid for more details about chaindId

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM