I want to Create a Simple Counter Increment/decrement Smart Contract. Just to understand how we can implement UUPS in any project.
Counter.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
abstract contract Counter is UUPSUpgradeable{
uint public counter;
address public implmentation;
address public owner;
function initialize(uint intialValue) public {
counter = intialValue;
owner = msg.sender;
}
function incrementByOne() public {
counter++;
}
function upgradeTo(address newImplementation) external virtual override {
_upgradeTo(newImplementation);
}
function _authorizeUpgrade(address newImplementation) internal virtual override{
require(msg.sender==owner,"Unauthorised Upgrade");
_upgradeTo(newImplementation);
}
}
I have tried already to resolve errors but yet not find a proper doc/instructions to follow.
Error: *** Deployment Failed ***
"Counter" is an abstract contract or an interface and cannot be deployed.
* Import abstractions into the '.sol' file that uses them instead of deploying them separately.
* Contracts that inherit an abstraction must implement all its method signatures exactly.
* A contract that only implements part of an inherited abstraction is also considered abstract.
at Deployer._preFlightCheck (/home/rishabh/.nvm/versions/node/v14.0.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:179:1)
If anyone has implemented this UUPS proxy pattern, Please share the code or help me anyway possible. Thanks in advance.