zkSyncDeployNewPythImpl.ts 1.6 KB

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