Skip to content

Commit

Permalink
Merge pull request #10 from matter-labs/fix/DEVRL-35
Browse files Browse the repository at this point in the history
update deps, adds minor improvements
  • Loading branch information
uF4No authored Apr 27, 2023
2 parents 2cbbf4b + 87cb0a0 commit a567128
Show file tree
Hide file tree
Showing 5 changed files with 419 additions and 367 deletions.
1 change: 1 addition & 0 deletions deploy/deploy-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";

export default async function (hre: HardhatRuntimeEnvironment) {
// Private key of the account used to deploy
const wallet = new Wallet("<WALLET_PRIVATE_KEY>");
const deployer = new Deployer(hre, wallet);
const factoryArtifact = await deployer.loadArtifact("AAFactory");
Expand Down
25 changes: 20 additions & 5 deletions deploy/deploy-multisig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
const AA_FACTORY_ADDRESS = "<FACTORY-ADDRESS>";

export default async function (hre: HardhatRuntimeEnvironment) {
const provider = new Provider("https://zksync2-testnet.zksync.dev");
const wallet = new Wallet("<WALLET_PRIVATE_KEY>").connect(provider);
const provider = new Provider("https://testnet.era.zksync.dev");
// Private key of the account used to deploy
const wallet = new Wallet("<WALLET-PRIVATE-KEY>").connect(provider);
const factoryArtifact = await hre.artifacts.readArtifact("AAFactory");

const aaFactory = new ethers.Contract(
Expand All @@ -23,33 +24,42 @@ export default async function (hre: HardhatRuntimeEnvironment) {
// For the simplicity of the tutorial, we will use zero hash as salt
const salt = ethers.constants.HashZero;

// deploy account owned by owner1 & owner2
const tx = await aaFactory.deployAccount(
salt,
owner1.address,
owner2.address
);
await tx.wait();

// Getting the address of the deployed contract
// Getting the address of the deployed contract account
const abiCoder = new ethers.utils.AbiCoder();
const multisigAddress = utils.create2Address(
AA_FACTORY_ADDRESS,
await aaFactory.aaBytecodeHash(),
salt,
abiCoder.encode(["address", "address"], [owner1.address, owner2.address])
);
console.log(`Multisig deployed on address ${multisigAddress}`);
console.log(`Multisig account deployed on address ${multisigAddress}`);

console.log("Sending funds to multisig account");
// Send funds to the multisig account we just deployed
await (
await wallet.sendTransaction({
to: multisigAddress,
// You can increase the amount of ETH sent to the multisig
value: ethers.utils.parseEther("0.006"),
value: ethers.utils.parseEther("0.008"),
})
).wait();

let multisigBalance = await provider.getBalance(multisigAddress);

console.log(`Multisig account balance is ${multisigBalance.toString()}`);

// Transaction to deploy a new account using the multisig we just deployed
let aaTx = await aaFactory.populateTransaction.deployAccount(
salt,
// These are accounts that will own the newly deployed account
Wallet.createRandom().address,
Wallet.createRandom().address
);
Expand All @@ -59,6 +69,7 @@ export default async function (hre: HardhatRuntimeEnvironment) {

aaTx = {
...aaTx,
// deploy a new account using the multisig
from: multisigAddress,
gasLimit: gasLimit,
gasPrice: gasPrice,
Expand Down Expand Up @@ -98,4 +109,8 @@ export default async function (hre: HardhatRuntimeEnvironment) {
multisigAddress
)}`
);

multisigBalance = await provider.getBalance(multisigAddress);

console.log(`Multisig account balance is now ${multisigBalance.toString()}`);
}
12 changes: 8 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
require("@matterlabs/hardhat-zksync-deploy");
require("@matterlabs/hardhat-zksync-solc");
import { HardhatUserConfig } from "hardhat/config";

module.exports = {
import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";

const config: HardhatUserConfig = {
zksolc: {
version: "1.3.5",
version: "1.3.10", // Use latest available in https://github.com/matter-labs/zksolc-bin/
compilerSource: "binary",
settings: {
isSystem: true,
Expand All @@ -24,3 +26,5 @@ module.exports = {
version: "0.8.16",
},
};

export default config;
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
},
"dependencies": {
"@matterlabs/hardhat-zksync-deploy": "^0.6.1",
"@matterlabs/hardhat-zksync-solc": "^0.3.14",
"@matterlabs/zksync-contracts": "^0.6.0",
"@matterlabs/hardhat-zksync-solc": "^0.3.16",
"@matterlabs/zksync-contracts": "^0.6.1",
"@openzeppelin/contracts": "^4.7.3",
"@openzeppelin/contracts-upgradeable": "^4.7.3",
"hardhat": "^2.12.0",
"zksync-web3": "^0.14.3"
}
Expand Down
Loading

0 comments on commit a567128

Please sign in to comment.