Closed xluckydegen closed 2 months ago
Hello @xluckydegen,
I've tried to compile this TestCoin contract and it failed. Do you have a way for me to download the whole TestCoin project, so I can reproduce the deployment issue?
Hello @ethanz0g ,
you can easily fix it by adding Ownable(address(this)) param. It seems there were some changes in openzepelling or compiler. it is working in my hardhat without that but it is required in remix now.
Feel free to use this code. Anyway, this was not the original issue. The issue is that as soon as you will add AccessControl your RPCs are failing.
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
contract TestCoin is ERC20,Ownable,AccessControl {
constructor(string memory name) ERC20(name, name) Ownable(address(this)) {
_mint(msg.sender, 1_000_000 * 10**18);
}
function mint(address acc, uint256 amount) public {
}
function addMinter(address minter) public onlyOwner {
}
}
PS:
Yes, I'm checking it now and version 4.9.0 was without constructor and now latest 5.0.0 requires constructor param
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
Hello @xluckydegen ,
Now the compilation and deployment both succeeded without any complaints. The contract is here:
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
contract TestCoin is ERC20,Ownable,AccessControl {
constructor(string memory name) ERC20(name, name) Ownable(address(this)) {
_mint(msg.sender, 1_000_000 * 10**18);
}
function mint(address acc, uint256 amount) public {
}
function addMinter(address minter) public onlyOwner {
}
}
The code is exactly yours except the first line, which is a comment needed in some environments. If you still encounter issues when deploying, you might want to share your deployment script here.
Just checked it and upgrading solidity compiler to 0.8.20 and openzepellin to 5.0.2 fixed it on my side too.
Hello, I'm playing with your chain and trying to deploy some of my contracts. but it seems there is some bug in the deployment process.
This is my minimal test case. As soon as TestCoin derive from AccessControl, the RPC is returning the errors:
This is the error message: