Skip to content

Commit

Permalink
Merge pull request #45 from matter-labs/feat-jrigada-smart-account-docs
Browse files Browse the repository at this point in the history
docs: ZkUseFactoryDep cheatcode documentation
  • Loading branch information
Jrigada authored Oct 31, 2024
2 parents f503563 + 663edac commit efe54da
Show file tree
Hide file tree
Showing 3 changed files with 426 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
- [zkVm](./zksync-specifics/cheatcodes/zk-vm.md)
- [zkVmSkip](./zksync-specifics/cheatcodes/zk-vm-skip.md)
- [zkUsePaymaster](./zksync-specifics/cheatcodes/zk-use-paymaster.md)
- [zkUseFactoryDep](./zksync-specifics/cheatcodes/zk-use-factory-dep.md)
- [Gas Overview](./zksync-specifics/gas.md)
- [Paymaster Overview](./zksync-specifics/paymaster-overview.md)
- [Examples](./zksync-specifics/examples/README.md)
- [Paymaster Approval Based](./zksync-specifics/examples/paymaster-approval-based.md)
- [Ledger](./zksync-specifics/examples/ledger.md)

- [Multisig Smart Account](./zksync-specifics/examples/smart-account.md)
# Supported Commands
- [Command List](./supported-commands/README.md)

Expand Down
31 changes: 31 additions & 0 deletions src/zksync-specifics/cheatcodes/zk-use-factory-dep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## `zkUseFactoryDep`

### Signature

```solidity
function zkUseFactoryDep(string calldata name) external pure;
```

### Description

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 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);
// Mark the bytecode as a factory dependency
vmExt.zkUseFactoryDep("TwoUserMultisig");
// Deploy the account using the factory
factory.deployAccount(multisigBytecodeHash);
}
```
Loading

0 comments on commit efe54da

Please sign in to comment.