编写一个测试用的实现合约
使用@openzeppelin/contracts-upgradeable
编写一个实现合约(注意,不需要自己实现代理合约,openzeppelin 已经实现好了)
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
contract Counter is Initializable, UUPSUpgradeable, OwnableUpgradeable {
uint256 public count;
// initialize: required
function initialize() public initializer {
__Ownable_init();
__UUPSUpgradeable_init();
}
// _authorizeUpgrade: required
function _authorizeUpgrade(address) internal override onlyOwner {}
function store(uint256 _count) external {
count = _count;
}
}
只是为了测试 uups 代理的编写、部署和验证,因此,这个合约特别简单,