MiniDeployer ​
Inherits: Owned
A contract that allows deployers to deploy any contract by passing the contract data in bytes
The main objective of this contract is to avoid storing contract addresses in our protocols which requires 160 bits of storage Instead, we can just store the nonce & deployment of this address to calculate the address realtime using "AddressCalcs" library
Functions ​
constructor ​
Constructor to initialize the contract
solidity
constructor(address owner_) Owned(owner_);
Parameters
Name | Type | Description |
---|---|---|
owner_ | address | The address of the contract owner |
_deploy ​
Internal function to deploy a contract
Uses inline assembly for efficient deployment
solidity
function _deploy(bytes memory bytecode_) internal returns (address address_);
Parameters
Name | Type | Description |
---|---|---|
bytecode_ | bytes | The bytecode of the contract to deploy |
Returns
Name | Type | Description |
---|---|---|
address_ | address | The address of the deployed contract |
deployContract ​
Deploys a new contract
Decrements the deployer's allowed deployments count if not the owner
solidity
function deployContract(bytes calldata contractCode_) external onlyOwner returns (address contractAddress_);
Parameters
Name | Type | Description |
---|---|---|
contractCode_ | bytes | The bytecode of the contract to deploy |
Returns
Name | Type | Description |
---|---|---|
contractAddress_ | address | The address of the deployed contract |
Events ​
LogContractDeployed ​
Emitted when a new contract is deployed
solidity
event LogContractDeployed(address indexed contractAddress);
Errors ​
MiniDeployer__InvalidOperation ​
Thrown when an invalid operation is attempted
solidity
error MiniDeployer__InvalidOperation();