首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用deploy部署所需的私钥格式是什么?

使用deploy部署所需的私钥格式是什么?
EN

Ethereum用户
提问于 2023-02-14 05:05:29
回答 1查看 116关注 0票数 0

我正在尝试使用zkSync部署一个非常基本的智能契约。这是代码,从他们的文档:

部署,

代码语言:javascript
复制
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,就会得到以下错误:

代码语言:javascript
复制
Error: invalid hexlify value (argument="value", value="xyz", code=INVALID_ARGUMENT, version=bytes/5.7.0)

如果我使用从metamask获得的私钥,则会得到以下错误:

代码语言:javascript
复制
Error: Bytecode length in 32-byte words must be odd

这个PK的实际格式是什么?

EN

回答 1

Ethereum用户

回答已采纳

发布于 2023-02-14 11:54:43

您可以传递私钥、助记符短语等。zksync-web3也支持以太支持的所有方法。以下是以太文献中的更多信息。

如果您有元问询帐户,则可以使用按照本指南导出私钥

只需确保您只在开发中使用不同的帐户,并且不要将您的私钥推送到任何存储库。

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/144875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档