On hardhat when deploying a contract or minting an NFT getting error: ProviderError: invalid sender
Asked Answered
A

3

5

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?

Ahmad answered 26/8, 2021 at 7:17 Comment(0)
A
9

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
    }

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

Ahmad answered 26/8, 2021 at 7:17 Comment(2)
I too am experiencing this problem when publishing to the testnet. Unfortunately your solution doesn't resolve the issue for me. Do you have any further information or detail? Thanks.Guadalquivir
my transactions are stuck in the mempool even with this...Urquhart
G
1

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:

  1. Tried adding gasPrice and/or gas to the hardhat.config.js networks.matic object
  2. Tried to put 0x in front of the privateKey
  3. Tried adding chainId:80001 to the hardhat.config.js networks.matic object
  4. Tried increasing gasPrice to over 500 gwei
  5. Tried 3 different RPC endpoints including a private one requiring an API key

Hardhat github made an update to 2.6.2, which also does not resolve the problem.

Guadalquivir answered 28/8, 2021 at 9:39 Comment(0)
L
1

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}`]
  }
Lurleen answered 31/8, 2021 at 6:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.