Getting this error when trying to verify on Hardhat TypeError: Cannot read property 'contracts' of undefined. Seems like I followed this tutorial Verify smart contract inheriting from OpenZeppelin Contracts correctly. Maybe a syntax problem due to multiple arguments in the constructor?
Code to reproduce
Here is the code I run in the terminal npx hardhat verify --network rinkeby 0xA4630A1f2DaC2474d7397E7e8F3A41Bd574C1f9d 0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B 0x01BE23585060835E02B77ef475b0Cc51aA1e0709 0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311
for the constructor
FYI, Running into this when I try to verify using arguments.js
$ npx hardhat verify --constructor-args arguments.js 0xA4630A1f2DaC2474d7397E7e8F3A41Bd574C1f9d
Nothing to compile
Error in plugin @nomiclabs/hardhat-etherscan: Value 1.0268332219058108e+48 cannot be encoded for the parameter _vrfCoordinator.
Encoder error reason: invalid address (argument="address", value=1.0268332219058108e+48, code=INVALID_ARGUMENT, version=address/5.0.5)```
module.exports = [
0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B,
0x01BE23585060835E02B77ef475b0Cc51aA1e0709,
0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311
];```
The arguments.js file is in the root of the project
TypeError: Cannot read property 'contracts' of undefined
at SimpleTaskDefinition.action (D:\ETH\chainlink-nft-hardhat\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:711:29)
at Environment._runTaskDefinition (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:217:35)
at Environment.run (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:130:25)
at SimpleTaskDefinition.verifySubtask [as action] (D:\ETH\chainlink-nft-hardhat\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:265:34)
at Environment._runTaskDefinition (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:217:14)
at Environment.run (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:130:14)
at Environment._runTaskDefinition (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:217:14)
at Environment.run (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\core\runtime-environment.ts:130:14)
at main (D:\ETH\chainlink-nft-hardhat\node_modules\hardhat\src\internal\cli\cli.ts:188:5)```
It turns out it wasn’t anything code related, but it was something in npm and the packages he had installed.
I loaded his code into a new environment and was able to get it to verify.
Then he did the same thing and his code was able to verify.
So in summary, if something isn’t working, but should, you might want to start a fresh project and remove package dependencies you no longer rely on.
I also had to run npx hardhat clean
before running npx hardhat verify --network TESTrinkeby 0x474407a7d6aE50e86A3C0055338A5D5188Fea032 "0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B" "0x01BE23585060835E02B77ef475b0Cc51aA1e0709" "0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311"
in order to get it to verify.
I will say...I was stuck for a longggg time because I put commas between my constructor arguments (which I wouldn't have expected to be an invalid format). @Yoshiko's example is correct.