Replies: 1 comment
-
I've encountered the same problem. I believe that UUPS upgradable contracts are very important, so I've found that Ethers.js is irreplaceable when it comes to deploying contracts. Here is my solution: import { viem, ethers, upgrades } from 'hardhat'
import { getAddress } from 'viem'
import type { DeployProxyOptions } from '@openzeppelin/hardhat-upgrades/src/utils'
export async function deployProxy (contractName: string, args: unknown[], options: DeployProxyOptions) {
const contract = await upgrades.deployProxy(
await ethers.getContractFactory(contractName),
args,
options
)
return viem.getContractAt(
contractName,
getAddress(contract.target as string)
)
}
export async function upgradeProxy (contractAddress: string, newContractName: string) {
const patch = await ethers.getContractFactory(newContractName)
return upgrades.upgradeProxy(contractAddress, patch)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here's the implementation with
Hardhat
+Ethers
:Based on Implementation
@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol
It seems the core is the getContractFactory function from
Ethers
.Is there an alternative to
Viem
? I couldn't find it in the documentation.Beta Was this translation helpful? Give feedback.
All reactions