truffle verify Failed to connect to Etherscan API at url https://api-rinkeby.etherscan.io/api

When using the truffle-plugin-verify plugin for code verification, an error is reported:

~> truffle run verify BTCContract --network rinkeby 
Verifying BTCContract
Failed to connect to Etherscan API at url https://api-rinkeby.etherscan.io/api
Failed to verify 1 contract(s): BTCContract

According to the prompt: the address https://api-rinkeby.etherscan.io/api cannot be connected .
So first ping this domain name,

~> ping api-rinkeby.etherscan.io
PING api-rinkeby.etherscan.io (128.121.146.101): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

Sure enough, the domain name could not be resolved.

Then it’s easy to handle, isn’t it enough to find the corresponding address under this domain name?
Go to this website https://url5.co/?t=1636355893
to find out the IP corresponding to the domain name api-rinkeby.etherscan.io
insert image description here
Try the first A ping IP (104.22.14.57), whether it can be pinged, try it and it can be pinged.
Then you only need to add a line of mapping to the local hosts file. I use MacOS, just edit /private/etc/hosts. Windows can find the corresponding hosts file and modify it.

104.22.14.57  api-rinkeby.etherscan.io  

insert image description here

Perform verification again after modification, and the verification is successful.

~> truffle run verify BTCContract --network rinkeby         
Verifying BTCContract
Contract source code already verified: https://rinkeby.etherscan.io/address/0xb3d0d1aAB33ccF565A6FD0D9543FBcE49bD952c9#code
Successfully verified 1 contract(s).

In addition, it can also be a version problem of node, truffle and verfify plugins.
I am using here

Truffle v5.4.6 (core: 5.4.6)
Solidity - 0.6.10 (solc-js)
Node v12.22.1
Web3.js v1.5.1
"truffle-plugin-verify": "0.5.16"

I hope the above content will help those who are encountering problems.

In addition: If the following situation occurs, it may be a service problem, and you will be fine after a while

Request failed with status code 403
Failed to connect to Etherscan API at url https://api-rinkeby.etherscan.io/api
Failed to verify 1 contract(s): BulldogTestyClub

Guess you like

Origin blog.csdn.net/qq_36838406/article/details/121208890