Hi, I was trying out the UUPS contract here by the OpenZeppelin team (UUPS Proxies: Tutorial (Solidity + JavaScript))
I didn't change anything from the tutorial:
// contracts/MyTokenV1.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
contract MyTokenV1 is Initializable, ERC20Upgradeable {
function initialize() initializer public {
__ERC20_init("MyToken", "MTK");
_mint(msg.sender, 1000 * 10 ** decimals());
}
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
}
Subsequently, I deployed the code:
const { ethers, upgrades } = require("hardhat");
import verify from "../verify-contract";
async function deployTokenContract() {
const TokenContract = await ethers.getContractFactory("MyTokenV1");
// Deploy using upgradeable proxy pattern
const token = await upgrades.deployProxy(TokenContract, [], {
initializer: "initialize",
});
console.log(`Token contract deployed to ${token.target}`);
// Verify the deployed contract
await verify(token.target, []);
}
deployTokenContract()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Verification Code:
import { run } from "hardhat";
const { ethers } = require("hardhat");
const network: Record<number, string> = {
5611: "op_bnb_testnet",
204: "op_bnb_mainnet",
80002: "polygonAmoy",
};
const verify = async (
contractAddress: string,
args: any[],
contract?: string
) => {
console.log("Wait 5 blocks...");
let currentBlock = await ethers.provider.getBlockNumber();
while (currentBlock + 5 > (await ethers.provider.getBlockNumber())) {}
console.log("Verifying contract...");
const { chainId } = await ethers.provider.getNetwork();
if (!chainId || !network[chainId]) {
console.log("Invalid ChainId");
return;
}
try {
await run("verify:verify", {
address: contractAddress,
constructorArguments: args,
network: network[chainId],
contract,
});
} catch (e) {
console.log(e);
}
};
export default verify;
I was able to verify the implementation contract: https://testnet.opbnbscan.com/address/0xDD335111e92cdb8782Cf1cA4F426CA92CB1872A7?tab=Contract&p=1&view=contract_code
However, when it comes to the proxy contract (0x4427F9cbb1BBaAdf9B6df16B600C590195fBb297),
I get the error:
Could not find an event with any of the following topics in the logs for address 0x4427F9cbb1BBaAdf9B6df16B600C590195fBb297: OwnershipTransferred(address,address)
I have tried to check through other support articles (How to verify UUPS proxy on Etherscan), but it does not seem to help.
Will deeply appreciate any advice. Thanks in advance!