[Deployment] Proxy Deployment from a Factory making use of create2Account #639
-
EnvironmentTestnet zkSolc Versionlatest zksync-ethers Version^6.0.0 Hardhat.config.tsconst config: HardhatUserConfig = {
zksolc: {
version: 'latest',
settings: {
isSystem: true,
optimizer: {
fallbackToOptimizingForSize: false,
},
},
},
typechain: {
outDir: "typechain",
target: "ethers-v5",
},
defaultNetwork: 'zkSyncTestnet',
networks: {
hardhat: {
zksync: true,
},
zkSyncTestnet,
},
solidity: {
compilers: [{ version: '0.8.17' }]
} Deployment Script (WITHOUT PRIVATE KEY)const implementationArtifact = await deployer.loadArtifact("CharterWalletImplementation");
const implementation = await deployer.deploy(implementationArtifact, [], undefined, [])
const implementationaddr = await implementation.getAddress();
console.log(`DRIPImplementation: "${implementationaddr}",`);
//////////////////////////
// Deploy AccountFactory
const factoryArtifact = await deployer.loadArtifact("AccountFactory");
const proxyArtifact = await deployer.loadArtifact("CharterWalletImplementation");
*****************************************************
Why is it aritifact of CharterWallet Implementation and not the proxy artifact is because the implementation implements UUPSupgradble contract!
*****************************************************
const proxybytecodeHash = utils.hashBytecode(proxyArtifact.deployedBytecode);
const factory = await deployer.deploy(factoryArtifact, [implementationaddr, proxybytecodeHash, eoawallet.address], undefined, [
proxyArtifact.bytecode,
]);
const factoryaddr = await factory.getAddress();
console.log(`DRIPFactory: "${factoryaddr}",`); Package.json"zksync-ethers": "^6.0.0",
"@matterlabs/hardhat-zksync-upgradable": "^1.5.1",
"@matterlabs/hardhat-zksync-chai-matchers": "^1.3.0",
"@matterlabs/hardhat-zksync-deploy": "1.1.2",
"@matterlabs/hardhat-zksync-solc": "1.0.6",
"@matterlabs/hardhat-zksync-toolbox": "1.2.1",
"@matterlabs/hardhat-zksync-verify": "1.2.2",
"@matterlabs/zksync-contracts": "^0.6.1", Contract Codeimport {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {Initializable} from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
CharterWalletImplementation is UUPSUpgradeable,Initializable{} Does this work on other EVMs? (If yes, please list at least 1 of them)NA Description of What Your Contract Does
Repo Link (Optional)No response Additional DetailsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 27 replies
-
It seems like you are trying to deploy a proxy using a factory pattern on the ZKsync network, specifically using the
For more detailed guidance and examples, you might want to refer to the ZKsync documentation on deploying upgradable contracts and using factories. Here are some helpful links: These resources should provide you with the necessary code snippets and explanations to successfully deploy and manage your contracts on ZKsync. Your feedback helps us serve you better. If this fully addresses your question, please give it a thumbs up. If it doesn't, please give it a thumbs down. This will inform the community and team so we can improve our support. |
Beta Was this translation helpful? Give feedback.
Here is a repo with some examples. It contains multiple examples, from deploying an account manually, to deploying from a factory and lastly, deploying a proxy account from a factory.
the last scenario is the one you'll find useful in your case. To share some txs and contract addresses from my tests:
Find all the details and considerations in the repo readme file. We'll see how we can improve the docs for this particular case.