1

I am trying to compile this very simple smart contract but I am getting its bytecode = "0x":

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyERC20 is ERC20 {
    uint8 private _decimals;

    constructor(
        string memory name_,
        string memory symbol_,
        uint8 decimals_
    ) ERC20(name_, symbol_) {
        _decimals = decimals_;
    }

    function mint(address _to, uint256 _amount) public returns (bool) {
        _mint(_to, _amount);
        return true;
    }

    function decimals() public view override returns (uint8) {
        return _decimals;
    }
}

This is my hardhat.config.ts file:

import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
const { pk } = require('./.secrets.json');

module.exports = {
  zksolc: {
    version: "1.3.1",
    compilerSource: "binary",
    settings: {},
  },
  defaultNetwork: "zkSyncTestnet",
  networks: {
    zkSyncTestnet: {
      url: "https://zksync2-testnet.zksync.dev",
      ethNetwork: "goerli", // Can also be the RPC URL of the network (e.g. `https://goerli.infura.io/v3/<API_KEY>`)
      zksync: true,
      accounts: [pk]
    },
  },
  solidity: {
    version: "0.8.17",
  },
};

As you may see, I am using hardhat with @matterlabs/hardhat-zksync-solc.

1
  • As of today, zkSync devs are still looking into this issue... Mar 15, 2023 at 2:59

1 Answer 1

1

The latest is 1.3.8 and should solve the issues you are running into. Here is our changelog for how to update your project https://era.zksync.io/docs/dev/troubleshooting/changelog.html#compilers-and-plugins-apr-4th-2023

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.