zkSyncDeployNewPythImpl.ts 1.6 KB

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