繁体   English   中英

使用 truffle 迁移合约时出错

[英]Error when migrating contracts using truffle

使用 traffle 部署合约时,会出现以下错误:

"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....

truffle-config.js是这样的:

 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 )
},

这些错误是什么意思,我应该如何配置以防止该故障? 谢谢!

构造 HDWalletProvider 时通过chainId: 3可以解决问题。

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

}),

看看这里chainid-vs-networkid了解更多关于chaindId的细节

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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