我正在尝试使用zkSync部署一个非常基本的智能契约。这是代码,从他们的文档:
部署,
import { Wallet, utils } from "zksync-web3";
import * as ethers from "ethers";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
import { mnemonic } from "../.secrets.json";
// 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("");
// 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]);
// OPTIONAL: Deposit funds to L2
// Comment this block if you already have funds on zkSync.
const depositHandle = await deployer.zkWallet.deposit({
to: deployer.zkWallet.address,
token: utils.ETH_ADDRESS,
amount: deploymentFee.mul(2),
});
// Wait until the deposit is processed on zkSync
await depositHandle.wait();
// 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}`);
}他们说用我想用来开发的钱包的私钥代替""。
对于那个PK,我应该使用什么格式?
如果使用mnemonic,就会得到以下错误:
Error: invalid hexlify value (argument="value", value="xyz", code=INVALID_ARGUMENT, version=bytes/5.7.0)如果我使用从metamask获得的私钥,则会得到以下错误:
Error: Bytecode length in 32-byte words must be odd这个PK的实际格式是什么?
https://ethereum.stackexchange.com/questions/144875
复制相似问题