简体   繁体   English

在安全帽上部署合同或创建 NFT 时出现错误:ProviderError: invalid sender

[英]On hardhat when deploying a contract or minting an NFT getting error: ProviderError: invalid sender

I am using HardHat to deploy contracts on Polygon (Matic), it works most of the time when deploying or minting.. but then it usually breaks when I switch from testnet to mainnet.我正在使用 HardHat 在 Polygon (Matic) 上部署合约,它在部署或铸造时大部分时间都可以工作......但是当我从测试网切换到主网时它通常会中断。

For example: I switched from mainnet to rpc-mumbai.maticvigil.com, then I get the error ProviderError: invalid sender.例如:我从主网切换到 rpc-mumbai.maticvigil.com,然后我收到错误 ProviderError: invalid sender。

Then I updated my hardhat.config.js to point to matic-mumbai.chainstacklabs.com and I am able to mint and deploy contracts with no errors.然后我更新了我的 hardhat.config.js 以指向 matic-mumbai.chainstacklabs.com,我能够创建和部署合约而没有错误。

I am reaching out to see if this is a known issue occurring with polygon and or hardhat?我正在联系,看看这是否是多边形和/或安全帽发生的已知问题?

Add this to your hardhat.config.js, after accounts:将此添加到您的 hardhat.config.js,在帐户之后:

 gasPrice: 8000000000, // default is 'auto' which breaks chains without the london hardfork

Full entry:完整条目:

  matic: {
      url: "https://matic-mumbai.chainstacklabs.com",
      accounts: [PRIVATE_KEY],
      gasPrice: 8000000000, // default is 'auto' which breaks chains without the london hardfork
    }

Ref: https://github.com/nomiclabs/hardhat/issues/1828参考: https : //github.com/nomiclabs/hardhat/issues/1828

Confirmed the solution of "The Vikk" is working.确认“The Vikk”的解决方案有效。 Added also the account details and 0x before the private key.在私钥之前还添加了帐户详细信息和 0x。

 mumbai: {
  url: "https://polygon-mumbai.g.alchemy.com/v2/<API_KEY>",
  accounts: [`0x${PRIVATE_KEY}`]
  }

I discovered the issue with "Invalid sender".我发现了“无效发件人”的问题。 This for me was that the wallet address had not sent any transactions and only had deposits from the testnet faucet.这对我来说是钱包地址没有发送任何交易,只有来自测试网水龙头的存款。 For whatever reason it made that error disappear when I sent a transaction manually through Metamask then sent it back then tried to issue the hardhat run command again.无论出于何种原因,当我通过 Metamask 手动发送交易然后将其发送回来然后尝试再次发出安全帽运行命令时,它使该错误消失。

From what I am now seeing however, the transaction still hangs without any errors and --verbose provides nothing useful.然而,从我现在看到的情况来看,事务仍然没有任何错误地挂起,并且 --verbose 没有提供任何有用的信息。 This appears to be some kind of conflict pertaining to the London Hardfork.这似乎是与伦敦硬分叉有关的某种冲突。 I have not resolved the issue.我还没有解决这个问题。 Will report back later with more information if I have it.如果我有更多信息,稍后将向您报告。

What I have done so far:到目前为止我做了什么:

  1. Tried adding gasPrice and/or gas to the hardhat.config.js networks.matic object尝试将gasPrice和/或gas添加到 hardhat.config.jsnetworks.matic 对象
  2. Tried to put 0x in front of the privateKey试图将0x放在 privateKey 前面
  3. Tried adding chainId:80001 to the hardhat.config.js networks.matic object尝试将chainId:80001添加到 hardhat.config.jsnetworks.matic 对象
  4. Tried increasing gasPrice to over 500 gwei尝试将 gasPrice 提高到 500 gwei 以上
  5. Tried 3 different RPC endpoints including a private one requiring an API key尝试了 3 个不同的 RPC 端点,包括一个需要 API 密钥的私有端点

Hardhat github made an update to 2.6.2, which also does not resolve the problem. Hardhat github 更新到2.6.2,也没有解决问题。

Same issue here.同样的问题在这里。 I've tried a private key generated from Vanity ETH as well as a private key from my MetaMask wallet.我尝试了从 Vanity ETH 生成的私钥以及来自我的 MetaMask 钱包的私钥。 Also tried adding 0x prefix and with / without gasPrice but getting the same error.还尝试添加0x前缀和带 / 不带 gasPrice 但得到相同的错误。

Here's my config:这是我的配置:

module.exports = {
  solidity: "0.8.2",
  networks: {
    mumbai: {
      url: "https://rpc-mumbai.maticvigil.com/",
      account: [process.env.PRIVATE_KEY],
      gasPrice: 8000000000,
    }
  }
};

Anyone have any luck figuring this out?任何人都有运气解决这个问题?

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

相关问题 通过 Hardhat 将智能合约部署到孟买 tes.net 时出错 - Error while deploying a smart contract to Mumbai testnet through Hardhat 部署智能合约时获取“未定义”的参数数量无效 - Getting Invalid number of parameters for “undefined” when deploying smart contract 使用 Node.js 编译和部署以太坊智能合约时出错 - Getting error when compiling and deploying ethereum smart contract with Node.js 如何仅使用 dApp 限制 NFT 铸造 - How to restrict NFT minting using the dApp only 在以太坊中部署智能合约时如何解决错误? - How to solve the error when deploying a smart contract in Ethereum? 尝试通过 hardhat 功能编译我的合约时出错 - Error in trying to compile my contract through the hardhat feature sendSignedTransaction:Quorum 上的发件人无效错误 - sendSignedTransaction: Invalid sender error on Quorum 安装 hardhat 时出现此错误 -> 找不到模块 '@nomicfoundation/hardhat-toolbox - I'm getting this error while installing hardhat -> Cannot find module '@nomicfoundation/hardhat-toolbox 尝试使用安全帽编译合约但出现错误:- 错误:找不到指定的模块 - Tried to compile contract using hardhat but got error:- Error: The specified module could not be found 在 Firebase 中部署函数时出错 - Getting error when deploying functions in Firebase
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM