Last active
May 15, 2024 07:19
-
-
Save pcaversaccio/0843d1afcdaea956e2cbed971de48124 to your computer and use it in GitHub Desktop.
Calculate the `CREATE2` address on zkSync using Vyper.
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
# @version ^0.3.10 | |
_CREATE2_PREFIX: constant(bytes32) = 0x2020dba91b30cc0006188af794c2fb30dd8520db7e2c088b7fc7c103c00ca494 | |
@external | |
@pure | |
def compute_create2_address_zksync(salt: bytes32, bytecode_hash: bytes32, deployer: address, input: Bytes[4_096]=b"") -> address: | |
constructor_input_hash: bytes32 = keccak256(input) | |
data: bytes32 = keccak256(concat(_CREATE2_PREFIX, empty(bytes12),\ | |
convert(deployer, bytes20), salt, bytecode_hash, constructor_input_hash)) | |
return convert(convert(data, uint256) & convert(max_value(uint160), uint256), address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment