Environment
"@openzeppelin/hardhat-upgrades": "1.21.0",
"hardhat": "^2.11.2"
Hello Everybody,
I'm trying to deploy my upgradeable contract using Hardhat/Ethers and Openzeppelin Upgrades and not able to deploy because it gives me this error:
Error: types/values length mismatch (count={"types":4,"values":0}, value={"types":[{"name":"maxBatchSize_","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"collectionSize_","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"amountForAuctionAndDev_","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true},{"name":"amountForDevs_","type":"uint256","indexed":null,"components":null,"arrayLength":null,"arrayChildren":null,"baseType":"uint256","_isParamType":true}],"values":[]}, code=INVALID_ARGUMENT, version=abi/5.7.0)
at Logger.makeError (C:\Users\ARIE\ERC721A\node_modules\@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Users\ARIE\ERC721A\node_modules\@ethersproject\logger\src.ts\index.ts:281:20)
at AbiCoder.encode (C:\Users\ARIE\ERC721A\node_modules\@ethersproject\abi\src.ts\abi-coder.ts:101:20)
at Interface._encodeParams (C:\Users\ARIE\ERC721A\node_modules\@ethersproject\abi\src.ts\interface.ts:323:31)
at Interface.encodeDeploy (C:\Users\ARIE\ERC721A\node_modules\@ethersproject\abi\src.ts\interface.ts:327:21)
at getDeployData (C:\Users\ARIE\ERC721A\node_modules\@openzeppelin\hardhat-upgrades\src\utils\deploy-impl.ts:49:45)
at deployProxyImpl (C:\Users\ARIE\ERC721A\node_modules\@openzeppelin\hardhat-upgrades\src\utils\deploy-impl.ts:72:22)
at Proxy.deployProxy (C:\Users\ARIE\ERC721A\node_modules\@openzeppelin\hardhat-upgrades\src\deploy-proxy.ts:35:28)
at main (C:\Users\ARIE\ERC721A\scripts\deploy.js:14:19) {
reason: 'types/values length mismatch',
code: 'INVALID_ARGUMENT',
count: { types: 4, values: 0 },
value: {
types: [ [ParamType], [ParamType], [ParamType], [ParamType] ],
values: []
}
}
HardHat configuration:
require("@nomiclabs/hardhat-waffle");
require("@openzeppelin/hardhat-upgrades");
require("@nomiclabs/hardhat-ethers");
module.exports = {
solidity: "0.8.11",
settings: {
optimizer: {
enabled: true,
runs: 500,
}
}
};
Deploy script:
const { ethers, upgrades } = require('hardhat');
const fs = require('fs');
async function main() {
const NFTCollectible = await ethers.getContractFactory("NFTCollectible");
console.log('Deploying contract...');
const nftcollectible = await upgrades.deployProxy(
NFTCollectible,
[],
{ initializer: 'initialize' }
);
await nftcollectible.deployed();
const addresses = {
proxy: nftcollectible.address,
admin: await upgrades.erc1967.getAdminAddress(nftcollectible.address),
implementation: await upgrades.erc1967.getImplementationAddress(nftcollectible.address)
};
console.log('Contract deployed to address:', addresses);
try {
await run('verify', { address: addresses.implementation });
} catch (e) {}
fs.writeFileSync('deployment-addresses.json', JSON.stringify(addresses));
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
Command :
npx hardhat run scripts/deploy.js --network localhost
Contract script: NFTCollectible.sol
Â
Thanks.