Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deployment] Proxy Deployment from a Factory making use of create2Account #665

Open
bxpana opened this issue Aug 20, 2024 Discussed in #639 · 0 comments
Open

[Deployment] Proxy Deployment from a Factory making use of create2Account #665

bxpana opened this issue Aug 20, 2024 Discussed in #639 · 0 comments
Labels
aa Question related to Account Abstraction deployment Questions for deployment docs Items needed to be added or updated in the documentation

Comments

@bxpana
Copy link
Contributor

bxpana commented Aug 20, 2024

Add to Community Code and update docs about using create2Account with proxies

Discussed in #639

Originally posted by 4NNNN July 28, 2024

Environment

Testnet

zkSolc Version

latest

zksync-ethers Version

^6.0.0

Hardhat.config.ts

const 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 Code

import {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

  1. I tried deploying a proxy to the wallet implemenation by not implementing a proxy import.

  2. So it was just a normal wallet contract but the proxy gets deployed by using hre.zkUpgrades.deployProxy.

  3. But while trying to populate a transaction and test it out for token transfers, errored up saying Sender is not an account.

  4. Which means you're calling a contract which was not deployed using create2Account or createAccount, so in this case I might have to deploy the proxy for the implementation using a proxy factory.

  5. I need reference on how to deploy a proxybytecodehash from the factory with the implementation address as a constructor parameter!

Repo Link (Optional)

No response

Additional Details

No response

@bxpana bxpana added deployment Questions for deployment aa Question related to Account Abstraction docs Items needed to be added or updated in the documentation labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aa Question related to Account Abstraction deployment Questions for deployment docs Items needed to be added or updated in the documentation
Projects
None yet
Development

No branches or pull requests

1 participant