I am trying to deploy an ERC1967 contract using a deployer rather than a plugin ( since eventually, I need to deploy it using solidity contracts ). But contract is not getting created in my test suite.
Code to reproduce
pragma solidity ^0.8.2;
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
contract UnERC20Proxy is ERC1967Proxy {
constructor(address _logic, bytes memory _data)
ERC1967Proxy(_logic, _data)
{}
function getImplementation() public view returns (address) {
return _implementation();
}
function upgradeTo(address newImplementation) external {
_upgradeTo(newImplementation);
}
}
The problem is that web3.utils.asciiToHex("") is giving you 0x00, and you should be sending in an empty byte array. 0x00 is an array of 1 byte, and the proxy is using it to execute it as if it was an initialization function call.
I already tried that.
The above approach gives the following: Error: invalid arrayify value (argument="value", value="", code=INVALID_ARGUMENT, version=bytes/5.0.5)
await deployer.deploy(upgradeableProxy, logicContractAddr, adminAddr, "0x");
Fantastic! Thank you @frangio But could explain why and what does it mean?
Byte arrays are represented as hex strings. Hex strings are normally prefixed by 0x such as 0xab12, where ab12 are the hexadecimal bytes. The prefix on its own 0x is representing an empty byte array.