zkSyncDeployNewPythImpl.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. require("dotenv").config({ path: ".env" });
  2. import { utils, Wallet } from "zksync-web3";
  3. import { HardhatRuntimeEnvironment } from "hardhat/types";
  4. import { Deployer } from "@matterlabs/hardhat-zksync-deploy";
  5. import { assert } from "chai";
  6. import { writeFileSync } from "fs";
  7. import { ethers } from "ethers";
  8. function envOrErr(name: string): string {
  9. const res = process.env[name];
  10. if (res === undefined) {
  11. throw new Error(`${name} environment variable is not set.`);
  12. }
  13. return res;
  14. }
  15. export default async function (hre: HardhatRuntimeEnvironment) {
  16. // Initialize the wallet.
  17. const wallet = Wallet.fromMnemonic(envOrErr("MNEMONIC"));
  18. // Create deployer object and load the artifact of the contract we want to deploy.
  19. const deployer = new Deployer(hre, wallet);
  20. // Deposit some funds to L2 in order to be able to perform L2 transactions. Uncomment
  21. // this if the deployment account is unfunded.
  22. //
  23. // const depositAmount = ethers.utils.parseEther("0.005");
  24. // const depositHandle = await deployer.zkWallet.deposit({
  25. // to: deployer.zkWallet.address,
  26. // token: utils.ETH_ADDRESS,
  27. // amount: depositAmount,
  28. // });
  29. // // Wait until the deposit is processed on zkSync
  30. // await depositHandle.wait();
  31. const pythImplArtifact = await deployer.loadArtifact("PythUpgradable");
  32. const pythImplContract = await deployer.deploy(pythImplArtifact);
  33. console.log(
  34. `Deployed Pyth implementation contract on ${pythImplContract.address}`
  35. );
  36. console.log(
  37. "Please use this address as the candidate new implementation in the deployment script."
  38. );
  39. }