I'm using hardhat to deploy the contract, is this correct?
async function main() {
// We get the contract to deploy
const Greeter = await ethers.getContractFactory("CreateToken");
const greeter = await Greeter.deploy("Benjamin", "benj", 7, '0x16EDE61a09835D35e60D92AE0F11CF148cE262bF', 3000000000);
Successfully submitted source code for contract
contracts/CreateToken.sol:CreateToken at 0x32220EF666E1054250e4f52f692C34a998220D0e
for verification on Etherscan. Waiting for verification result...
We tried verifying your contract CreateToken without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on Etherscan...
Successfully submitted source code for contract
contracts/CreateToken.sol:CreateToken at 0x32220EF666E1054250e4f52f692C34a998220D0e
for verification on Etherscan. Waiting for verification result...
Error in plugin @nomiclabs/hardhat-etherscan: The contract verification failed.
Reason: Fail - Unable to verify
NomicLabsHardhatPluginError: The contract verification failed.
Reason: Fail - Unable to verify
What I noticed is that if I try Remix and verify it using Remix verification plugin, it gets verified successfully but if I use truffle, I just cant get it verified.
I am not aware of anything different from verifying a contract deployed using Remix/Hardhat/Truffle and the same contract deployed using a factory contract.
You can verify using Hardhat even for contracts deployed elsewhere.
I just deployed with Hardhat and then verified with Hardhat to check that everything was working.
I deployed using Hardhat with the following script:
// scripts/deploy.js
async function main() {
// We get the contract to deploy
const CreateToken = await ethers.getContractFactory("CreateToken");
console.log("Deploying Token...");
const token = await CreateToken.deploy("Benj", "BEN", "7", "0x16EDE61a09835D35e60D92AE0F11CF148cE262bF", "1000000000000");
await token.deployed();
console.log("CreateToken deployed to:", token.address);
}
main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});
If you can deploy with Remix and verify with Remix, then that is ok. The important thing is to have appropriate testing and auditing.
VerifyArguments info is as follows:
Contract Address: 0xE0037Cae26496D1939f0617c678f20589d148A9d
deployer is 0x0CA993Af349c845312934eEDb96dA8292901C85f
1. V1 Invite has deployed at: 0xE0037Cae26496D1939f0617c678f20589d148A9d
Nothing to compile
Compiling 1 file with 0.8.0
Successfully submitted source code for contract
contracts/Invite.sol:Invite at 0xE0037Cae26496D1939f0617c678f20589d148A9d
for verification on Etherscan. Waiting for verification result...
We tried verifying your contract Invite without including any unrelated one, but it failed.
Trying again with the full solc input used to compile and deploy it.
This means that unrelated contracts may be displayed on Etherscan...
Successfully submitted source code for contract
contracts/Invite.sol:Invite at 0xE0037Cae26496D1939f0617c678f20589d148A9d
for verification on Etherscan. Waiting for verification result...
NomicLabsHardhatPluginError: The contract verification failed.
Reason: Fail - Unable to verify
at SimpleTaskDefinition.verifySubtask [as action] (/Users/xxy/Project/dapp/coinDao/node_modules/@nomiclabs/hardhat-etherscan/src/index.ts:330:9)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Environment._runTaskDefinition (/Users/xxy/Project/dapp/coinDao/node_modules/hardhat/src/internal/core/runtime-environment.ts:217:14)
at Environment.run (/Users/xxy/Project/dapp/coinDao/node_modules/hardhat/src/internal/core/runtime-environment.ts:129:14)
at main (/Users/xxy/Project/dapp/coinDao/scripts/verify/01_verify_invite.js:48:5)