Hey OZ community,
Context
I am using the "@openzeppelin/contracts/utils/Create2.sol";
library, with the following deploy
function.
function deploy(
uint256 amount,
bytes32 salt,
bytes memory bytecode
) internal returns (address) {
address addr;
require(address(this).balance >= amount, "Create2: insufficient balance");
require(bytecode.length != 0, "Create2: bytecode length is zero");
assembly {
addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
}
require(addr != address(0), "Create2: Failed on deploy");
return addr;
}
We've been using the Create2
library in production for a while (here), and only recently noticed a Create2: Failed on deploy
error faced by one of our users.
Question
In what cases is the value of addr
in addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
the zero address?