ZKSyncEra 合约编译及部署

安装环境 

  1. 下载代码编译环境 官方帮助文档 hardhat-zksync-solc | Welcome to our Docs | zkSync Era
https://github.com/matter-labs/hardhat-zksync

VCode 软件打开要目录

yarn install

合约代码复制到目录

找到文件修改网络文件 examples\basic-example\hardhat.config.ts

networks: {
        hardhat: {
            zksync: true,
        },
        // goerli: {
        //     url: "https://goerli.infura.io/v3/<API Key>" // The Ethereum Web3 RPC URL (optional).
        // },
        zkTestnet: {
            url: "https://testnet.era.zksync.dev", // The testnet RPC URL of zkSync Era network.
            ethNetwork: "goerli", // The Ethereum Web3 RPC URL, or the identifier of the network (e.g. `mainnet` or `goerli`)
            zksync: true
        }
    },

 进入目录编译

cd examples
cd basic-example
yarn hardhat compile
yarn build

 找到编译后的文件位置

 找到 bytecode

找到ABI JSON

 到些已经完成bytecode和ABI

合约验证官方文档 hardhat-zksync-verify | Welcome to our Docs | zkSync Era

添加依赖 

yarn add -D @matterlabs/hardhat-zksync-verify @nomiclabs/hardhat-etherscan

Configuration
Import the plugin in the hardhat.config.ts file

import "@matterlabs/hardhat-zksync-verify";

添加网络验证URL

networks: {
    goerli: {
      url: "https://goerli.infura.io/v3/<API_KEY>" // The Ethereum Web3 RPC URL (optional).
    },
    zkTestnet: {
      url: "https://testnet.era.zksync.dev", // The testnet RPC URL of zkSync Era network.
      ethNetwork: "goerli", // The Ethereum Web3 RPC URL, or the identifier of the network (e.g. `mainnet` or `goerli`)
      zksync: true,
      // Verification endpoint for Goerli
      verifyURL: 'https://zksync2-testnet-explorer.zksync.dev/contract_verification'
    }
},
// defaultNetwork: "zkTestnet", // optional (if not set, use '--network zkTestnet')

执行 

yarn hardhat verify --network <网络> <合约地址>
yarn hardhat verify --network zkTestnet 0xe922B1760474727305B44A73f3bA62c669Fec672

成功

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值