我试图编译这个非常简单的智能契约,但我得到了它的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;
}
}这是我的hardhat.config.ts文件:
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",
},
};如您所见,我将hardhat与@matterlabs/hardhat-zksync-solc结合使用。
发布于 2023-04-06 10:59:26
最新的版本是1.3.8,应该可以解决您遇到的问题。下面是我们关于如何更新项目https://era.zksync.io/docs/dev/troubleshooting/changelog.html#compilers-and-plugins-apr-4th-2023的更改
https://ethereum.stackexchange.com/questions/144948
复制相似问题