错误场景 1
Error: Transaction reverted: trying to deploy a contract whose code is too large
解决办法: hardhat.config.js
内增加 settings 进行优化。
solidity: {
version: '0.8.19',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
更多信息: https://github.com/NomicFoundation/hardhat/issues/1430
错误场景 2
合约部署错误
ProviderError: too many arguments, want at most 1
解决办法:部署的时候,手动指定 gasLimit
const XXX = await ethers.deployContract('XXX', { gasLimit: '0x1000000' })
更多信息: https://github.com/NomicFoundation/hardhat/issues/4010