-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
for verification on the block explorer. Waiting for verification result... #5858
Comments
Are you able to verify if you do so via the command line rather than the script? |
Thank you for your reply. When I deployed successfully through the script but the verification failed and kept waiting, I forced it to end and verified it through the command line, but it was still stuck in a long wait. |
So you see the long wait, whether it goes through the programmatic API or at the cli. Can I confirm:
@schaable where are the potential pauses in a verification with parameters? |
If I don't stop manually and wait for a long time, an error will occur. if (network.config.chainId === 100100100 && process.env.AMAZETEST_API_KEY) { // BaseRegistrarImplementation if (network.config.chainId === 100100100 && process.env.AMAZETEST_API_KEY) { |
The verification task polls for the verification status after sending the verification request to Etherscan. However, the error you're encountering seems to point to a network issue rather than a pause during verification. To validate this, I’ve created an example with two contracts. In this setup, one contract receives the address of the other as a constructor argument and initializes it. Then, I wrote a script to deploy and verify both contracts: // Storage.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
contract Storage {
uint256 private value;
function setValue(uint256 _value) external {
value = _value;
}
function getValue() external view returns (uint256) {
return value;
}
} // Manager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.27;
import "./Storage.sol";
contract Manager {
Storage private storageContract;
constructor(address _storageAddress) {
storageContract = Storage(_storageAddress);
}
function updateStorageValue(uint256 _value) external {
storageContract.setValue(_value);
}
function retrieveStorageValue() external view returns (uint256) {
return storageContract.getValue();
}
} // scripts/deploy.ts
import { ethers, run } from "hardhat";
async function main() {
// Deploy Storage contract
const Storage = await ethers.getContractFactory("Storage");
const storage = await Storage.deploy();
await storage.deploymentTransaction()?.wait(5);
const storageContractAddress = await storage.getAddress();
console.log("Storage deployed to:", storageContractAddress);
// Deploy Manager contract with Storage contract address
const Manager = await ethers.getContractFactory("Manager");
const manager = await Manager.deploy(storageContractAddress);
await manager.deploymentTransaction()?.wait(5);
const managerContractAddress = await manager.getAddress();
console.log("Manager deployed to:", managerContractAddress);
await verify(storageContractAddress, [], "contracts/Storage.sol:Storage");
await verify(
managerContractAddress,
[storageContractAddress],
"contracts/Manager.sol:Manager"
);
}
async function verify(
address: string,
constructorArguments: any[],
contract: string
) {
console.log("Verifying contract", contract, "at address", address);
try {
await run("verify:verify", {
address,
constructorArguments,
contract,
});
} catch (error) {
console.error(error);
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
}); The script works correctly when deploying to the Sepolia network: ➜ npx hardhat run scripts/deploy.ts --network sepolia
Storage deployed to: 0xcB4ad50602DC86d7BB14E4012148c70FB0aeBA14
Manager deployed to: 0x597029E29AAe7b042Da0D7690cea12eDd64F9CDc
Verifying contract contracts/Storage.sol:Storage at address 0xcB4ad50602DC86d7BB14E4012148c70FB0aeBA14
The contract 0xcB4ad50602DC86d7BB14E4012148c70FB0aeBA14 has already been verified on the block explorer. If you're trying to verify a partially verified contract, please use the --force flag.
https://sepolia.etherscan.io/address/0xcB4ad50602DC86d7BB14E4012148c70FB0aeBA14#code
Verifying contract contracts/Manager.sol:Manager at address 0x597029E29AAe7b042Da0D7690cea12eDd64F9CDc
The contract 0x597029E29AAe7b042Da0D7690cea12eDd64F9CDc has already been verified on the block explorer. If you're trying to verify a partially verified contract, please use the --force flag.
https://sepolia.etherscan.io/address/0x597029E29AAe7b042Da0D7690cea12eDd64F9CDc#code @wjh-x can you try deploying to Sepolia to check if you still encounter the same error? |
Hello everyone, I encountered a problem where the deployment contract verification failed.
For example, the second BaseRegistrarImplementation contract needs to use the address of the first ENSRegistry contract. The first contract can be verified normally on the browser, but the second contract is always waiting. Below is my project information. Please help me. Thank you.
package.json
{ "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.0", "@nomicfoundation/hardhat-ethers": "^3.0.8", "@nomicfoundation/hardhat-ignition": "^0.15.0", "@nomicfoundation/hardhat-ignition-ethers": "^0.15.0", "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox": "^5.0.0", "@nomicfoundation/hardhat-verify": "^2.0.11", "@typechain/ethers-v6": "^0.5.0", "@typechain/hardhat": "^9.0.0", "chai": "^4.2.0", "ethers": "^6.13.4", "hardhat": "^2.22.14", "hardhat-gas-reporter": "^1.0.8", "solidity-coverage": "^0.8.0", "typechain": "^8.3.0" }, "packageManager": "[email protected]+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610", "dependencies": { "@ensdomains/ens-contracts": "1.0.1", "dotenv": "^16.4.5", "hardhat-deploy": "^0.14.0", "undici": "^6.20.1", "viem": "^2.21.34" } }
hardhat.config.js
`require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ethers");
require("hardhat-deploy");
require("dotenv").config();
const { ProxyAgent, setGlobalDispatcher } = require("undici");
const proxyAgent = new ProxyAgent("http://127.0.0.1:7890");
setGlobalDispatcher(proxyAgent);
const RPC_URL = process.env.RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
const AMAZETEST_API_KEY = process.env.AMAZETEST_API_KEY;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY;
const SEPOLIA_RPC_URL = process.env.SEPOLIA_RPC_URL;
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
defaultNetwork: "hardhat",
networks: {
amazetest: {
url: RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 100100100,
},
amazemainnet: {
url: RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 94,
},
sepolia: {
url: SEPOLIA_RPC_URL,
accounts: [PRIVATE_KEY],
chainId: 11155111,
},
},
// etherscan: {
// apiKey: ETHERSCAN_API_KEY,
// },
etherscan: {
apiKey: {
amazetest: AMAZETEST_API_KEY,
},
customChains: [
{
network: "amazetest",
chainId: 100100100,
urls: {
apiURL: "https://testnet.amazechain.com/api",
browserURL: "https://testnet.amazechain.com/",
},
},
],
},
solidity: "0.8.27",
};
Below is my deploy.js code
const { ethers, run, network } = require("hardhat");const { namehash } = require("viem/ens");
async function main() {
// ENSRegistry
const eNSRegistryFactory = await ethers.getContractFactory(
"contracts/ens/ENSRegistry.sol:ENSRegistry"
);
console.log("deploy contract ENSRegistry...");
const eNSRegistry = await eNSRegistryFactory.deploy();
await eNSRegistry.waitForDeployment();
console.log(
deploy contract to: ${eNSRegistry.target}
);if (network.config.chainId === 100100100 && process.env.AMAZETEST_API_KEY) {
console.log("waitting for block taxes...");
await eNSRegistry.deploymentTransaction().wait(2);
await verify(
eNSRegistry.target,
[],
"contracts/ens/ENSRegistry.sol:ENSRegistry"
);
}
// BaseRegistrarImplementation
const baseNode = namehash("eth"); // 0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae
// console.log(baseNode);
const baseRegistrarImplementationFactory = await ethers.getContractFactory(
"contracts/ens/BaseRegistrarImplementation.sol:BaseRegistrarImplementation"
);
console.log("deploy contract BaseRegistrarImplementation...");
const baseRegistrarImplementation =
await baseRegistrarImplementationFactory.deploy(
eNSRegistry.target,
baseNode
);
await baseRegistrarImplementation.waitForDeployment();
console.log(
deploy contract to: ${baseRegistrarImplementation.target}
);if (network.config.chainId === 100100100 && process.env.AMAZETEST_API_KEY) {
console.log("waitting for block taxes...");
await baseRegistrarImplementation.deploymentTransaction().wait(2);
await verify(
baseRegistrarImplementation.target,
[eNSRegistry.target, baseNode],
"contracts/ens/BaseRegistrarImplementation.sol:BaseRegistrarImplementation"
);
}
}
// 验证合约
async function verify(contractAddress, args, contractPath) {
console.log("verifying contract...");
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
contract: contractPath,
});
} catch (e) {
if (e.message.toLowerCase().includes("alreay verified")) {
console.log("already verified");
} else {
console.log(e);
}
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
This is my run
yarn hardhat run scripts/deploy.js --network amazetestyarn run v1.22.22
warning package.json: No license field
$ /Users/macbook/Desktop/wjh/blockchain/ens/node_modules/.bin/hardhat run scripts/deploy.js --network amazetest
deploy contract ENSRegistry...
deploy contract to: 0xD15f731a40aE1FBc6da1855686E1A63cc10Ec479
waitting for block taxes...
verifying contract...
The contract 0xD15f731a40aE1FBc6da1855686E1A63cc10Ec479 has already been verified on the block explorer. If you're trying to verify a partially verified contract, please use the --force flag.
https://testnet.amazechain.com/address/0xD15f731a40aE1FBc6da1855686E1A63cc10Ec479#code
deploy contract BaseRegistrarImplementation...
deploy contract to: 0x111549c39480AcF2C0E94a2cef4Cc0E355d334d9
waitting for block taxes...
verifying contract...
Successfully submitted source code for contract
contracts/ens/BaseRegistrarImplementation.sol:BaseRegistrarImplementation at 0x111549c39480AcF2C0E94a2cef4Cc0E355d334d9
for verification on the block explorer. Waiting for verification result...`
The text was updated successfully, but these errors were encountered: