12

部署合约时遇到 invalid sender 错误时怎么办

 3 years ago
source link: https://learnblockchain.cn/article/2514
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

部署合约时遇到 invalid sender 错误时怎么办

HDWalletProvider 升级到 1.3.x 之后,只能对以太坊网络进行比较好的支持,并且需要显式指定 chainId。对于非以太坊网络比如当下比较热门的 heco/bsc,在官方解决到相应问题之前,还是保持在 1.2.x 版本比较好。

最近在使用 truffle 往 heco 上部署合约时,突然就碰到了一个之前没碰到过的错误:

image.png

多方查证,原来是最新版的 HDWalletProvider (版本 1.3.1) 需要指定 chainId

于是乎将将原来的写法:

provider: () => new HDWalletProvider(mnemonic, `wss://ws-testnet.hecochain.com`)

改为了下面这种形式:

provider: () => new HDWalletProvider({
        privateKeys: [mnemonic],
        providerOrUrl: `wss://ws-testnet.hecochain.com`,
        chainId: 256
      }),

但还是报错 "Error: Chain with ID 256 not supported", 原来这个版本只支持以太坊主网和测试网的 chainId,官方已经在这里记下了这个问题并在着手修复。

直接将HDWalletProvider版本调整到 1.2.6, 问题得以解决。

本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

  • 发表于 2021-05-13 04:51
  • 阅读 ( 142 )
  • 学分 ( 10 )
  • 分类:Solidity

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK