Below is a snippet of code I am using to compute the hashed bytecode of a contract, however this doesn't seem to work. This hash is passed to the create
function of the zkSync Era ContractDeployer.sol system contract?
const contractDeployerAddress = "0x0000000000000000000000000000000000008006"
const contractDeployer = new ethers.Contract(contractDeployerAddress, abi.abi, signer);
const salt = ethers.constants.HashZero;
const bytecodeUint8Array = utils.hashBytecode(guardianStorageArtifact.deployedBytecode)
console.log(bytecodeUint8Array)
const bytecodeHash = ethers.utils.keccak256(bytecodeUint8Array)
console.log(bytecodeHash)
const createCall = await contractDeployer.create(salt, bytecodeHash, "0x", {
gasLimit: 200000
});
const receipt = await createCall.wait();
console.log('Transaction confirmed in block:', receipt.blockNumber);
deployedBytecode
on the artifact have you tried using thebytecode
field instead i.e.guardianStorageArtifact.bytecode
? Also have you tried using the hardhat-zksync-deploy plugin which provides a simple interface for deploying contracts?