Account Abstraction multisig deployment estimategas error #630
-
EnvironmentTestnet zkSolc Versionlatest zksync-ethers Version6.10.0 Hardhat.config.tsrequire("@nomicfoundation/hardhat-toolbox");
require("@matterlabs/hardhat-zksync")
require("dotenv").config()
/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
zksolc: {
version: "latest",
settings: {
enableEraVMExtensions: true,
},
},
solidity: {
version: "0.8.20",
eraVersion: "1.0.0",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
}
},
deployerAccounts: {
'zkTestnet': 0,
dafault: 0,
},
defaultNetwork: "zkSyncTestnet",
networks: {
hardhat: {
zksync: true,
},
zkSyncTestnet: {
url: "http://localhost:8011",
ethNetwork: "localhost",
zksync: true,
chainId: 260
},
zkSyncSepoliaTestnet: {
url: "https://sepolia.era.zksync.dev",
ethNetwork: "sepolia",
zksync: true,
chainId: 300,
verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
},
dockerizedNode: {
url: "http://localhost:3050",
ethNetwork: "http://localhost:8545",
zksync: true,
chainId: 270
},
zkSyncMainnet: {
url: "https://mainnet.era.zksync.io",
ethNetwork: "mainnet",
zksync: true,
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
},
},
gasReporter: {
enabled: true,
currency: 'USD',
//outputFile: 'gas-reporter.txt',
coinmarketcap: process.env.COINMARKETCAP_API_KEY
},
}; Deployment Script (WITHOUT PRIVATE KEY)const {ethers, network, userConfig, artifacts} = require("hardhat")
const { Wallet, utils, Provider, types, EIP712Signer } = require("zksync-ethers")
const addresses = require("../address.json")
const AA_FACTORY_ADDRESS = addresses[network.config.chainId]
module.exports = async () => {
const provider = new Provider(userConfig.networks.zkSyncTestnet.url)
//const provider = new Provider(userConfig.networks.zkSyncSepoliaTestnet.url)
const wallet = new Wallet(process.env.RICH_ACCOUNTS_PRIVATE_KEY).connect(provider)
//const wallet = new Wallet(process.env.WALLET_PRIVATE_KEY).connect(provider)
const factoryArtifact = await artifacts.readArtifact("AAFactory")
const aaFactory = new ethers.Contract(
AA_FACTORY_ADDRESS,
factoryArtifact.abi,
wallet
)
const owner1 = Wallet.createRandom()
const owner2 = Wallet.createRandom()
const salt = ethers.ZeroHash;
const tx = await aaFactory.deployAccount(salt, owner1.address, owner2.address, {gasLimit: BigInt("30000000")})
await tx.wait()
const abiCoder = new ethers.AbiCoder()
const multisigAddress = utils.create2Address(
AA_FACTORY_ADDRESS,
await aaFactory.aaBytecodeHash(),
salt,
abiCoder.encode(['address', 'address'], [owner1.address, owner2.address])
)
console.log(`Multisig account deployed on address ${multisigAddress}`)
} Package.json{
"name": "zksyncaccountabstraction",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@matterlabs/hardhat-zksync": "^1.1.0",
"@matterlabs/hardhat-zksync-deploy": "^1.5.0",
"@matterlabs/hardhat-zksync-ethers": "^1.1.0",
"@matterlabs/hardhat-zksync-node": "^1.1.0",
"@matterlabs/hardhat-zksync-solc": "^1.2.1",
"@matterlabs/zksync-contracts": "^0.6.1",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@openzeppelin/contracts": "^4.6.0",
"dotenv": "^16.4.5",
"ethers": "^6.13.1",
"hardhat": "^2.22.6",
"zksync-ethers": "^6.10.0"
}
} Contract CodeAAFactory.sol-
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@matterlabs/zksync-contracts/l2/system-contracts/Constants.sol";
import "@matterlabs/zksync-contracts/l2/system-contracts/libraries/SystemContractsCaller.sol";
contract AAFactory {
error AAFactory__AccountDeployerFailed();
bytes32 public aaBytecodeHash;
constructor(bytes32 _aaBytecodeHash) {
aaBytecodeHash = _aaBytecodeHash;
}
function deployAccount(
bytes32 _salt,
address _owner1,
address _owner2
) external returns (address accountAddress) {
(bool success, bytes memory returnData) = SystemContractsCaller
.systemCallWithReturndata(
uint32(gasleft()),
address(DEPLOYER_SYSTEM_CONTRACT),
uint128(0),
abi.encodeCall(
DEPLOYER_SYSTEM_CONTRACT.create2Account,
(
_salt,
aaBytecodeHash,
abi.encode(_owner1, _owner2),
IContractDeployer.AccountAbstractionVersion.Version1
)
)
);
if (!success) {
revert AAFactory__AccountDeployerFailed();
}
(accountAddress) = abi.decode(returnData, (address));
}
}
I am using local zksync node for testing. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It appears that the issue you're encountering with the
If after trying these steps the issue persists, consider providing more detailed logs and error messages to the zkSync developer community or seeking direct support from zkSync's development team. 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.
-
It worked after I added
|
Beta Was this translation helpful? Give feedback.
It worked after I added
"create"
argument in the deploy function on my AAFactory deployment script-