From 93fcebcda5805b9395ecece1b9c066d27740e741 Mon Sep 17 00:00:00 2001 From: Phureewat A Date: Fri, 16 Feb 2024 10:46:29 +0700 Subject: [PATCH 1/2] feat: add zksync mainnet to hardhat config --- contracts/hardhat.config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index aff41ff..eee584b 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -33,6 +33,12 @@ const config: HardhatUserConfig = { verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification", }, + zkSyncMainnet: { + url: "https://mainnet.era.zksync.io", + ethNetwork: "mainnet", + zksync: true, + verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification", + }, }, solidity: { version: "0.8.17", From cef0359271bc3db3b48b28006f1920b140d92c41 Mon Sep 17 00:00:00 2001 From: Phureewat A Date: Fri, 16 Feb 2024 16:57:44 +0700 Subject: [PATCH 2/2] fix: fetch network provider from hre instead of hard coded to testnet --- contracts/deploy/allowListPaymaster.ts | 7 ++----- contracts/deploy/erc20fixedPaymaster.ts | 4 +--- contracts/deploy/erc721gatedPaymaster.ts | 4 +--- contracts/deploy/gaslessPaymaster.ts | 4 +--- contracts/deploy/timeBasedPaymaster.ts | 4 +--- contracts/deploy/use-greeter.ts | 6 +++--- 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/contracts/deploy/allowListPaymaster.ts b/contracts/deploy/allowListPaymaster.ts index 71df3a7..d55b523 100644 --- a/contracts/deploy/allowListPaymaster.ts +++ b/contracts/deploy/allowListPaymaster.ts @@ -1,8 +1,7 @@ import { Provider, Wallet } from "zksync-web3"; import * as ethers from "ethers"; -import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { HardhatRuntimeEnvironment, HttpNetworkUserConfig } from "hardhat/types"; import { Deployer } from "@matterlabs/hardhat-zksync-deploy"; -import { HttpNetworkUserConfig } from "hardhat/types"; // load env file import dotenv from "dotenv"; @@ -17,9 +16,7 @@ if (!PRIVATE_KEY) export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the AllowlistPaymaster contract...`); - // Currently targeting the Sepolia zkSync testnet - const network = hre.userConfig.networks?.zkSyncTestnet; - const provider = new Provider((network as HttpNetworkUserConfig).url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); // The wallet that will deploy the token and the paymaster // It is assumed that this wallet already has sufficient funds on zkSync diff --git a/contracts/deploy/erc20fixedPaymaster.ts b/contracts/deploy/erc20fixedPaymaster.ts index 3c7c808..836b72b 100644 --- a/contracts/deploy/erc20fixedPaymaster.ts +++ b/contracts/deploy/erc20fixedPaymaster.ts @@ -24,9 +24,7 @@ if (!TOKEN_ADDRESS) export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the ERC20fixedPaymaster contract...`); - // Currently targeting the Sepolia zkSync testnet - const network = hre.userConfig.networks?.zkSyncTestnet; - const provider = new Provider((network as HttpNetworkUserConfig).url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); // The wallet that will deploy the token and the paymaster // It is assumed that this wallet already has sufficient funds on zkSync const wallet = new Wallet(PRIVATE_KEY); diff --git a/contracts/deploy/erc721gatedPaymaster.ts b/contracts/deploy/erc721gatedPaymaster.ts index dc5c81e..3eedb36 100644 --- a/contracts/deploy/erc721gatedPaymaster.ts +++ b/contracts/deploy/erc721gatedPaymaster.ts @@ -23,9 +23,7 @@ if (!NFT_COLLECTION_ADDRESS) export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the ERC721gatedPaymaster contract...`); - // Currently targeting the Sepolia zkSync testnet - const network = hre.userConfig.networks?.zkSyncTestnet; - const provider = new Provider((network as HttpNetworkUserConfig).url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); // The wallet that will deploy the token and the paymaster // It is assumed that this wallet already has sufficient funds on zkSync diff --git a/contracts/deploy/gaslessPaymaster.ts b/contracts/deploy/gaslessPaymaster.ts index d715580..19c5675 100644 --- a/contracts/deploy/gaslessPaymaster.ts +++ b/contracts/deploy/gaslessPaymaster.ts @@ -18,9 +18,7 @@ if (!PRIVATE_KEY) export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the GaslessPaymaster contract...`); - // Currently targeting the Sepolia zkSync testnet - const network = hre.userConfig.networks?.zkSyncTestnet; - const provider = new Provider((network as HttpNetworkUserConfig).url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); // The wallet that will deploy the token and the paymaster // It is assumed that this wallet already has sufficient funds on zkSync const wallet = new Wallet(PRIVATE_KEY); diff --git a/contracts/deploy/timeBasedPaymaster.ts b/contracts/deploy/timeBasedPaymaster.ts index bfc4c4c..67f33bd 100644 --- a/contracts/deploy/timeBasedPaymaster.ts +++ b/contracts/deploy/timeBasedPaymaster.ts @@ -18,9 +18,7 @@ if (!PRIVATE_KEY) export default async function (hre: HardhatRuntimeEnvironment) { console.log(`Running deploy script for the TimeBasedPaymaster contract...`); - // Currently targeting the Sepolia zkSync testnet - const network = hre.userConfig.networks?.zkSyncTestnet; - const provider = new Provider((network as HttpNetworkUserConfig).url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); const wallet = new Wallet(PRIVATE_KEY); const deployer = new Deployer(hre, wallet); diff --git a/contracts/deploy/use-greeter.ts b/contracts/deploy/use-greeter.ts index e5b55a4..dd40652 100644 --- a/contracts/deploy/use-greeter.ts +++ b/contracts/deploy/use-greeter.ts @@ -1,6 +1,6 @@ import { Provider } from "zksync-web3"; import * as ethers from "ethers"; -import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { HardhatRuntimeEnvironment, HttpNetworkUserConfig } from "hardhat/types"; // load env file import dotenv from "dotenv"; @@ -14,7 +14,7 @@ const PRIVATE_KEY = process.env.WALLET_PRIVATE_KEY || ""; if (!PRIVATE_KEY) throw "⛔️ Private key not detected! Add it to the .env file!"; -// Address of the contract on zksync testnet +// Address of the greeter contract on zksync const CONTRACT_ADDRESS = ""; if (!CONTRACT_ADDRESS) throw "⛔️ Contract address not provided"; @@ -25,7 +25,7 @@ export default async function (hre: HardhatRuntimeEnvironment) { // Initialize the provider. // @ts-ignore - const provider = new Provider(hre.userConfig.networks?.zkSyncTestnet?.url); + const provider = new Provider((hre.network.config as HttpNetworkUserConfig).url); const signer = new ethers.Wallet(PRIVATE_KEY, provider); // Initialise contract instance