Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds zk cheatcode for retrieving bytecode hash #571

Closed

Conversation

dutterbutter
Copy link
Collaborator

Motivation

  • ZKsync makes uses of bytecodehash for deployments like create2, this cheatcode aims to provide foundry-zksync users an easier way to retrieve the bytecodehash.

Solution

  • Create getRawCodeHash cheatcode to retrieve bytecode hash

Usage example:

counter = new Counter();
(bool success, bytes memory returnData) = address(vm).call(
    abi.encodeWithSignature("getRawCodeHash(address)", address(counter))
);
require(success, "getRawCodeHash call failed");

// Decode the bytecode hash returned by the cheatcode
bytes32 rawCodeHash = abi.decode(returnData, (bytes32));

@Karrq
Copy link
Contributor

Karrq commented Oct 29, 2024

Hey @dutterbutter, is this still to be worked on? Considering our recent #604 we could move this implementation to be fully in solidity, for example as a set of methods in forge-zksync-std

@dutterbutter
Copy link
Collaborator Author

@Karrq yes it should be moved to std lib. Will close now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants