# Unable to verify a contract on hardhat

**URL:** <https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759>\
**Category:** Support\
**Created:** [April 4, 2021, 2:41pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759 "2021-04-04T14:41:34Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Altaergo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/altaergo/32/3853_2.png) [@Altaergo](https://forum.openzeppelin.com/u/Altaergo)\
**Post date:** [April 4, 2021, 2:41pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/1 "2021-04-04T14:41:34Z")

</div>

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](https://forum.openzeppelin.com/t/verify-smart-contract-inheriting-from-openzeppelin-contracts/4119) correctly. Maybe a syntax problem due to multiple arguments in the constructor?

**💻 Environment**  
“hardhat”: “^2.0.2”  
solidity: ^0.6.6;

**📝Details**

**🔢 Code to reproduce**  
Here is the code I run in the terminal `npx hardhat verify --network rinkeby 0xA4630A1f2DaC2474d7397E7e8F3A41Bd574C1f9d 0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B 0x01BE23585060835E02B77ef475b0Cc51aA1e0709 0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311`  
for the constructor

```auto
constructor(
      address _vrfCoordinator,
      address _linkToken,
      bytes32 _keyHash)
      public
      VRFConsumerBase(_vrfCoordinator, _linkToken)
      ERC721("DungeonsAndDragonsCharacter", "D&D")
  { vrfCoordinator = _vrfCoordinator;
           keyHash = _keyHash;
           fee = 0.1 * 10**18; //0.1 LINK
  }

```

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [April 4, 2021, 2:53pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/2 "2021-04-04T14:53:38Z")

</div>

I am not sure, maybe you should use " to declare the constructor parameters, eg:

```auto
npx hardhat verify --network rinkeby DEPLOYED_CONTRACT_ADDRESS "Constructor argument 1"

```

but it may not work, so I recommend you try to use a `arguments.js` file like this:

```auto
module.exports = [
  Constructor argument 1,
  Constructor argument 2,
  Constructor argument 3,
];

```

For more details, you can find at here: [hardhat-etherscan](https://hardhat.org/plugins/nomiclabs-hardhat-etherscan.html#complex-arguments)

---

<div class="post-metadata">

**Author:** ![Altaergo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/altaergo/32/3853_2.png) [@Altaergo](https://forum.openzeppelin.com/u/Altaergo)\
**Post date:** [April 4, 2021, 8:17pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/3 "2021-04-04T20:17:21Z")

</div>

I’ve tried it. Does not seem to work. I dropped the question at the Hardhat discord. Not sure if they will respond. They never do lol.

---

<div class="post-metadata">

**Author:** ![Altaergo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/altaergo/32/3853_2.png) [@Altaergo](https://forum.openzeppelin.com/u/Altaergo)\
**Post date:** [April 4, 2021, 8:19pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/4 "2021-04-04T20:19:26Z")

</div>

FYI, Running into this when I try to verify using arguments.js

````auto
$ 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
````

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [April 5, 2021, 12:05am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/5 "2021-04-05T00:05:10Z")

</div>

How about like this:

```auto
module.exports = [    
    "0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B",
    "0x01BE23585060835E02B77ef475b0Cc51aA1e0709",
    "0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311"
  ];

```

---

<div class="post-metadata">

**Author:** ![Altaergo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/altaergo/32/3853_2.png) [@Altaergo](https://forum.openzeppelin.com/u/Altaergo)\
**Post date:** [April 5, 2021, 7:54am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/6 "2021-04-05T07:54:44Z")

</div>

I get this error when I use the quotes

````auto

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)```
````

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [April 6, 2021, 1:03am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/7 "2021-04-06T01:03:59Z")

</div>

A little weird, I will have a try later.

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [April 6, 2021, 9:49am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/8 "2021-04-06T09:49:35Z")

</div>

Hi @Altaergo,

Are you specifying a network?

---

<div class="post-metadata">

**Author:** ![Altaergo](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/altaergo/32/3853_2.png) [@Altaergo](https://forum.openzeppelin.com/u/Altaergo)\
**Post date:** [April 6, 2021, 4:19pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/9 "2021-04-06T16:19:16Z")

</div>

with this syntax for specifying the network, am still not getting anything

````auto
Nothing to compile
Compiling 1 file with 0.6.6
An unexpected error occurred:

TypeError: Cannot read property 'contracts' of undefined```
````

---

<div class="post-metadata">

**Author:** ![Yoshiko](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/yoshiko/32/6858_2.png) [@Yoshiko](https://forum.openzeppelin.com/u/Yoshiko)\
**Post date:** [April 7, 2021, 7:41am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/10 "2021-04-07T07:41:23Z")

</div>

I worked through Altaergo’s problem on discord.

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.

---

<div class="post-metadata">

**Author:** ![emergent1](https://avatars.discourse-cdn.com/v4/letter/e/a8b319/32.png) [@emergent1](https://forum.openzeppelin.com/u/emergent1)\
**Post date:** [October 28, 2021, 11:34am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/11 "2021-10-28T11:34:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Alexander\_Telegin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/alexander_telegin/32/14377_2.png) [@Alexander\_Telegin](https://forum.openzeppelin.com/u/Alexander_Telegin)\
**Post date:** [April 12, 2022, 6:00pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/12 "2022-04-12T18:00:44Z")

</div>

Funny thing - my issue was that Mac's Notes app replaces commas: " for ” (hope you can see the difference), after replacement - all works well

---

<div class="post-metadata">

**Author:** ![donodon](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/donodon/32/10622_2.png) [@donodon](https://forum.openzeppelin.com/u/donodon)\
**Post date:** [October 20, 2022, 9:25am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/13 "2022-10-20T09:25:32Z")

</div>

That was it! Thanks mate! Silly mistake...

---

<div class="post-metadata">

**Author:** ![Tom\_Lee](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/tom_lee/32/21939_2.png) [@Tom\_Lee](https://forum.openzeppelin.com/u/Tom_Lee)\
**Post date:** [December 8, 2024, 12:41pm UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/14 "2024-12-08T12:41:14Z")

</div>

hi sir I need your help

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [December 9, 2024, 12:40am UTC](https://forum.openzeppelin.com/t/unable-to-verify-a-contract-on-hardhat/6759/15 "2024-12-09T00:40:22Z")

</div>

Hi, welcome to the community! 👋

Try to use tool to verify contracts, such as Hardhat, Foundry and so on, there are some tutorials about this at the forum, try to search for these tutorials.
