forked from foundry-rs/book
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from matter-labs/feat-jrigada-smart-account-docs
docs: ZkUseFactoryDep cheatcode documentation
- Loading branch information
Showing
3 changed files
with
426 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
``` |
Oops, something went wrong.