How to verify smart contract on custom testnet via hardhat? (zkSync alpha testnet)

380 Views Asked by At

I know I can use the following to verify a smart contract via hardhat on a known network, but how about a custom network like zkSync alpha testnet?

npx hardhat verify "ADDRESS" --network "network name"

1

There are 1 best solutions below

0
Antonio U On

We've released a specific hardhat plugin to verify contracts on zkSync (@matterlabs/hardhat-zksync-verify). In summary, you'd need to add the following in the hardhat.config.ts file:

  zkTestnet: {
    url: "https://zksync2-testnet.zksync.dev", // URL of the zkSync network RPC
    ethNetwork: "goerli", // URL of the Ethereum Web3 RPC, or the identifier of the network (e.g. `mainnet` or `goerli`)
    zksync: true,
    verifyURL: 'https://zksync2-testnet-explorer.zksync.dev/contract_verification'
  }

And then you could run `yarn hardhat verify --network zkTestnet YOUR_CONTRACT_ADDRESS.

You can find all the details in this section of the docs: https://v2-docs.zksync.io/api/hardhat/plugins.html#hardhat-zksync-verify