Skip to content

Commit

Permalink
Fix command and improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrigada committed Oct 31, 2024
1 parent f1ba8a4 commit 663edac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/zksync-specifics/cheatcodes/zk-use-factory-dep.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ function zkUseFactoryDep(string calldata name) external pure;

### Description

Enables marking a bytecode as a factory dependency for the next CREATE or CALL and cleared after.
Marks a given contract as a factory dependency only for the next CREATE or CALL, unmarking it afterwards, similar to [`prank`](../../cheatcodes/prank.md).

This cheatcode is useful when deploying contracts through factories, as it allows marking bytecode as a factory dependency and deploying contracts by passing their bytecode hash to the factory.
This cheatcode is useful when deploying contracts through factories that do not directly depend on a given contract, as it allows explicitly marking this type of contract as a factory dependency, enabling the factory to deploy the contract.
More information on factory dependencies can be found in the [official ZKsync docs](https://docs.zksync.io/build/developer-reference/ethereum-differences/contract-deployment#note-on-factory_deps).

### Examples

```solidity
contract Deployer {
// Factory does not directly depend on TwoUserMultisig, so we need to mark it explicitly
// as a factory dependency to allow deployment through the factory
// Deploy the factory
Factory factory = new Factory(multisigBytecodeHash);
Expand Down
17 changes: 1 addition & 16 deletions src/zksync-specifics/examples/smart-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,21 +379,6 @@ contract DeployMultisig is Script {
vmExt.zkUseFactoryDep("TwoUserMultisig");
factory.deployAccount(salt, owner1, owner2);
string memory factoryArtifact = vm.readFile(
"zkout/AAFactory.sol/AAFactory.json"
);
bytes32 factoryBytecodeHash = vm.parseJsonBytes32(
factoryArtifact,
".hash"
);
Create2Factory create2Factory = new Create2Factory();
address multisigAddress = create2Factory.create2(
salt,
factoryBytecodeHash,
abi.encode(owner1, owner2)
);
console.log("Multisig deployed at: ", multisigAddress);
vm.stopBroadcast();
}
}
Expand All @@ -402,7 +387,7 @@ contract DeployMultisig is Script {
### Running the script

```sh
zkforge script ./script/DeployMultisig.s.sol:DeployMultisig --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast --via-ir --system-mode true --zksync
forge script ./script/DeployMultisig.s.sol:DeployMultisig --rpc-url <RPC_URL> --private-key <PRIVATE_KEY> --broadcast --via-ir --zk-enable-eravm-extensions --zksync
```

For the complete source code, visit the [minimal account abstraction multisig repository](https://github.com/dutterbutter/min-aa-multisig-foundry).

0 comments on commit 663edac

Please sign in to comment.