This contract provides an interface for upgradable smart contracts and includes the functionality to perform upgrades.
bytes32 _IMPLEMENTATION_SLOT
constructor() internal
Constructor sets the implementation address to the address of the contract itself
This is used in the onlyProxy modifier to prevent certain functions from being called directly on the implementation contract itself. The owner is initially set as address(1) because the actual owner is set within the proxy. It is not set as the zero address because Ownable is designed to throw an error for ownership transfers to the zero address.
function implementation() public view returns (address implementation_)
Returns the address of the current implementation
Name | Type | Description |
---|---|---|
implementation_ | address | Address of the current implementation |
function upgrade(address newImplementation, bytes32 newImplementationCodeHash, bytes params) external
Upgrades the contract to a new implementation
This function is only callable by the owner.
Name | Type | Description |
---|---|---|
newImplementation | address | The address of the new implementation contract |
newImplementationCodeHash | bytes32 | The codehash of the new implementation contract |
params | bytes | Optional setup parameters for the new implementation contract |
function setup(bytes data) external
Sets up the contract with initial data
This function is only callable by the proxy contract.
Name | Type | Description |
---|---|---|
data | bytes | Initialization data for the contract |
function _setup(bytes data) internal virtual
Internal function to set up the contract with initial data
This function should be implemented in derived contracts.
Name | Type | Description |
---|---|---|
data | bytes | Initialization data for the contract |