[英]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:到目前为止我做了什么:
gasPrice
and/or gas
to the hardhat.config.js networks.matic objectgasPrice
和/或gas
添加到 hardhat.config.jsnetworks.matic 对象0x
in front of the privateKey0x
放在 privateKey 前面chainId:80001
to the hardhat.config.js networks.matic objectchainId:80001
添加到 hardhat.config.jsnetworks.matic 对象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.