Use hardhat to verify smart contracts (goeril testnet)

experience

I wrote a simple Erc721 contract using openzeppelin and successfully deployed it to the goerli test network, but it keeps reporting errors during verification:

Error in plugin @nomiclabs/hardhat-etherscan: Failed to send contract verification request.
Endpoint URL: https://api-goerli.etherscan.io/api
Reason: Connect Timeout Error

NomicLabsHardhatPluginError: Failed to send contract verification request.
Endpoint URL: https://api-goerli.etherscan.io/api
Reason: Connect Timeout Error
    at verifyContract (F:\w\hardhat\project2\node_modules\@nomiclabs\hardhat-etherscan\src\etherscan\EtherscanService.ts:35:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async attemptVerification (F:\w\hardhat\project2\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:461:20)
    at async SimpleTaskDefinition.action (F:\w\hardhat\project2\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:765:48)
    at async Environment._runTaskDefinition (F:\w\hardhat\project2\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
    at async Environment.run (F:\w\hardhat\project2\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)
    at async SimpleTaskDefinition.verifySubtask [as action] (F:\w\hardhat\project2\node_modules\@nomiclabs\hardhat-etherscan\src\index.ts:299:28)
    at async Environment._runTaskDefinition (F:\w\hardhat\project2\node_modules\hardhat\src\internal\core\runtime-environment.ts:219:14)
    at async Environment.run (F:\w\hardhat\project2\node_modules\hardhat\src\internal\core\runtime-environment.ts:131:14)

    Caused by: ConnectTimeoutError: Connect Timeout Error
        at Timeout.onConnectTimeout [as _onTimeout] (F:\w\hardhat\project2\node_modules\undici\lib\core\connect.js:108:24)
        at listOnTimeout (node:internal/timers:559:11)
        at processTimers (node:internal/timers:500:7)

At this time, try to solve the problem according to the method on https://github.com/NomicFoundation/hardhat/issues/2348. Connect Timeout ErrorIt is indeed gone, but the following error is reported:

Error in plugin @nomiclabs/hardhat-etherscan: Failed to send contract verification request.
Endpoint URL: https://api-goerli.etherscan.io/api
Reason: read ECONNRESET

I googled for a long time and found nothing, and finally saw this sentence on the issue above ,
insert image description here
so I clicked into the warehouse , followed the README to install the dependencies at first, and found that the installed dependencies were still the same, and then tried to install, @jobinleung/hardhat-etherscanprompting that the package could not be found.
Finally, I had an idea, downloaded the Release from the above warehouse, replaced the original ethscan package , and finally solved this problem. Successful screenshot:

This error is that polling failed to obtain the status, and then I went to ethscan to check the contract, and the verification was successful!
insert image description here

Use this as a record to prevent stepping on the pit again.

Guess you like

Origin blog.csdn.net/smartContractXH/article/details/126822056