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.
For example: I switched from mainnet to rpc-mumbai.maticvigil.com, then I get the error 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.
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:
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
}
Confirmed the solution of "The Vikk" is working. Added also the account details and 0x before the private key.
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.
From what I am now seeing however, the transaction still hangs without any errors and --verbose provides nothing useful. 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 object0x in front of the privateKeychainId:80001 to the hardhat.config.js networks.matic objectHardhat github made an update to 2.6.2, which also does not resolve the problem.