This contract is responsible for deploying and initializing new contracts using
a deployment method, such as CREATE2
or CREATE3
.
function deploy(bytes bytecode, bytes32 salt) external payable returns (address deployedAddress_)
Deploys a contract using a deployment method defined by derived contracts.
_The address where the contract will be deployed can be known in advance via {deployedAddress}.
The bytecode for a contract can be obtained from Solidity with
type(contractName).creationCode
.
Requirements:
bytecode
must not be empty.salt
must have not been used for bytecode
already by the same msg.sender
._Name | Type | Description |
---|---|---|
bytecode | bytes | The bytecode of the contract to be deployed |
salt | bytes32 | A salt to influence the contract address |
Name | Type | Description |
---|---|---|
deployedAddress_ | address | The address of the deployed contract |
function deployAndInit(bytes bytecode, bytes32 salt, bytes init) external payable returns (address deployedAddress_)
Deploys a contract using a deployment method defined by derived contracts and initializes it.
_The address where the contract will be deployed can be known in advance via {deployedAddress}.
The bytecode for a contract can be obtained from Solidity with
type(contractName).creationCode
.
Requirements:
bytecode
must not be empty.salt
must have not been used for bytecode
already by the same msg.sender
.init
is used to initialize the deployed contract as an option to not have the
constructor args affect the address derived by CREATE2
._Name | Type | Description |
---|---|---|
bytecode | bytes | The bytecode of the contract to be deployed |
salt | bytes32 | A salt to influence the contract address |
init | bytes | Init data used to initialize the deployed contract |
Name | Type | Description |
---|---|---|
deployedAddress_ | address | The address of the deployed contract |
function deployedAddress(bytes bytecode, address sender, bytes32 salt) public view returns (address)
Returns the address where a contract will be stored if deployed via {deploy} or {deployAndInit} by sender
.
Any change in the bytecode
(except for CREATE3
), sender
, or salt
will result in a new deployed address.
Name | Type | Description |
---|---|---|
bytecode | bytes | The bytecode of the contract to be deployed |
sender | address | The address that will deploy the contract via the deployment method |
salt | bytes32 | The salt that will be used to influence the contract address |
Name | Type | Description |
---|---|---|
[0] | address | deployedAddress_ The address that the contract will be deployed to |
function _deploy(bytes bytecode, bytes32 deploySalt) internal virtual returns (address)
function _deployedAddress(bytes bytecode, bytes32 deploySalt) internal view virtual returns (address)