Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 885
scranley Avatar asked Jan 25 '23 06:01

scranley


2 Answers

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

like image 192
scranley Avatar answered Apr 08 '23 23:04

scranley


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}`]
  }
like image 30
h.mavrodiev Avatar answered Apr 08 '23 23:04

h.mavrodiev