Hi everyone.
I wrote a task responsible for deploying a uups contract. And I have accomplished to verify the implementation contract programmatically. After deployment - verification process, I need to go through "More Options" > "Is this a proxy?" > "Verify" > "Save" to see "Read as Proxy" and "Writeas Proxy".
Is it possible to do this programmatically as well? You can find my task example below.
const { task } = require("hardhat/config");
task("myTask", "It's doing something")
.addParam(`firstparam`, "My first param.")
.addParam(`secondparam`, "My second param.")
.setAction(async (taskArgs) => {
const myContractFactory = await ethers.getContractFactory('MyContract')
let creationParams = class {
constructor(first, second) {
this.first = first;
this.second= second;
}
};
const myContract = await upgrades.deployProxy(
myContractFactory,
[
new creationParams(
taskArgs.firstparam,
taskArgs.secondparam
),
],
{ initializer: 'initializeAssetPool' }
)
await myContract.deployed()
console.log(`Proxy Contract address : ${myContract.address}`)
const implementationAddress = await upgrades.erc1967.getImplementationAddress(myContract.address);
console.log(`Implementation Contract address : ${implementationAddress}`)
console.log("Verifying the Implementation Contract...")
await myContract.deployTransaction.wait(6)
await verifyImplementation(implementationAddress, [])
console.log("Verifying process finished.")
})
async function verifyImplementation(implementationAddress, args) {
try {
await hre.run("verify:verify", {
address: implementationAddress,
constructorArguments: args,
})
} catch (error) {
if (error.message.toLowerCase().includes("already verified")) {
console.log("This contract already verified!!!")
} else {
console.log(error)
}
}
}
Thank you for now.