OpenZeppelin requiring solidity 0.8.20

Hey guys I'm working with Alchemy University and we are deploying ERC-20 tokens. When I try and deploy my contract to Goeril test network I am getting an error that says my open zepplin is only compatible with solidity pragma 8.20 but when I try and make this change myself I get a number of errors in my code that are telling me the version is not going to work. Here is my error below when I am using the 8.19 that has worked for me in all my projects up until now. npx hardhat run scripts/deploy.js --network goerli
Error HH606: The project cannot be compiled, see reasons below.

The Solidity version pragma statement in these files doesn't match any of the configured compilers in your config. Change the pragma or configure additional compiler versions in your hardhat config.

  • @openzeppelin/contracts/token/ERC20/ERC20.sol (^0.8.20)
  • @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol (^0.8.20)
  • @openzeppelin/contracts/token/ERC20/IERC20.sol (^0.8.20)
  • @openzeppelin/contracts/interfaces/draft-IERC6093.sol (^0.8.20)
  • @openzeppelin/contracts/utils/Context.sol (^0.8.20)

These files and its dependencies cannot be compiled with your config. This can happen because they have incompatible Solidity pragmas, or don't match any of your configured Solidity compilers.

  • contracts/Stan.sol
    Is there a way that I can install OpenZeppelin in a way that is compatable with solidity 8.19 or is there something obvious that I am missing in general?

Change the pragma in each one of your own solidity files to ^0.8.20, and change the compiler version in your hardhat configuration file to 0.8.20 or 0.8.21 or 0.8.22.

when I do that I am met with this error. Thankyou for the quick reply though!

No screenshots or images please.

There's one error-message at the top that screenshot, and a completely different error-message at the bottom of it.

Please post all the relevant information in plain text, which can be copy and pasted.

This includes relevant source code, error messages, project configuration, etc.

Sorry about that, my first time on this forum. When I change my solidity file and my config file to 8.20 within, the contract file will tell me the compiler wont work as well as one of the functions within my deploy scripts. In terms of the line within my deploy.js file that isn't working, its this right here. const weiAmount = (await deployer.getBalance()).toString(); does solidity 8.20 have a new way of calling deploy.getBalance because when I change the pragma to 8.20 its not working

Update on my issue, I went into my hardhat config file and made it to where it can accept both 8.19 and 8.20 and that seemed to fix at least the error for compiling. So now I am just left with my error of TypeError: deployer.getBalance is not a function. Any ideas would be greatly appreciated

Thanks @barakman!

I'm closing since the initial issue seems solved. Feel free to post any other question in a different thread but please review the following guidelines for clarity:

1 Like