I am getting the following error after running yarn hardhat deploy-zksync
:
Running deploy script for the Greeter contract
An unexpected error occurred:
Error: Bytecode length in 32-byte words must be odd
at hashBytecode (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/zksync-web3/build/src/utils.js:205:15)
at ContractFactory.getDeployTransaction (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/zksync-web3/build/src/contract.js:42:55)
at Deployer.estimateDeployGas (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/@matterlabs/hardhat-zksync-deploy/src/deployer.ts:157:34)
at async Deployer.estimateDeployFee (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/@matterlabs/hardhat-zksync-deploy/src/deployer.ts:139:21)
at async default_1 (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/deploy/deploy.ts:20:25)
at async runScript (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/@matterlabs/hardhat-zksync-deploy/src/plugin.ts:73:5)
at async callDeployScripts (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/@matterlabs/hardhat-zksync-deploy/src/plugin.ts:43:13)
at async SimpleTaskDefinition.zkSyncDeploy [as action] (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/@matterlabs/hardhat-zksync-deploy/src/task-actions.ts:5:5)
at async Environment._runTaskDefinition (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/hardhat/src/internal/core/runtime-environment.ts:311:14)
at async Environment.run (/Users/matifalcone/GMG/P2E/smart-contracts-sponsored-transactions/node_modules/hardhat/src/internal/core/runtime-environment.ts:159:14)
error Command failed with exit code 1.
The code for the deploy.ts
script is as follows:
import { Wallet, utils } from "zksync-web3";
import * as ethers from "ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
// An example of a deploy script that will deploy and call a simple contract.
export default async function (hre: HardhatRuntimeEnvironment) {
console.log(`Running deploy script for the Greeter contract`);
// Initialize the wallet.
const wallet = new Wallet("<WALLET-PRIVATE-KEY>");
// Create deployer object and load the artifact of the contract you want to deploy.
const deployer = new Deployer(hre, wallet);
const artifact = await deployer.loadArtifact("Greeter");
// Estimate contract deployment fee
const greeting = "Hi there!";
const deploymentFee = await deployer.estimateDeployFee(artifact, [greeting]);
// Deploy this contract. The returned object will be of a `Contract` type, similarly to ones in `ethers`.
// `greeting` is an argument for contract constructor.
const parsedFee = ethers.utils.formatEther(deploymentFee.toString());
console.log(`The deployment is estimated to cost ${parsedFee} ETH`);
const greeterContract = await deployer.deploy(artifact, [greeting]);
//obtain the Constructor Arguments
console.log("constructor args:" + greeterContract.interface.encodeDeploy([greeting]));
// Show the contract info.
const contractAddress = greeterContract.address;
console.log(`${artifact.contractName} was deployed to ${contractAddress}`);
}