Deployer
Title: CREATE3-based deployer with admin control
Author: Malda Protocol
Minimal helper to precompute and deploy contracts via CREATE3 with two-step admin handover.
State Variables
admin
Current admin authorized to deploy and manage ownership
address public admin
pendingAdmin
Pending admin address that can accept control
address public pendingAdmin
Functions
onlyAdmin
Modifier to check if the caller is the admin
modifier onlyAdmin() ;
constructor
Initializes the deployer
constructor(address _admin) ;
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | Address that will control deployments |
receive
Accepts plain ETH transfers
receive() external payable;
setPendingAdmin
Propose a new admin that must later accept
function setPendingAdmin(address newAdmin) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
newAdmin | address | Address proposed as the next admin |
saveEth
Withdraws all ETH to the admin
function saveEth() external onlyAdmin;
setNewAdmin
Directly sets a new admin (without pending/accept)
function setNewAdmin(address _addr) external onlyAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
_addr | address | New admin address |
create
Deploys a contract using CREATE3
function create(bytes32 salt, bytes calldata code) external payable onlyAdmin returns (address deployed);
Parameters
| Name | Type | Description |
|---|---|---|
salt | bytes32 | Deterministic salt used for CREATE3 |
code | bytes | Creation bytecode to deploy |
Returns
| Name | Type | Description |
|---|---|---|
deployed | address | The deployed contract address |
acceptAdmin
Allows the pending admin to accept control
function acceptAdmin() external;
precompute
Precomputes the deployment address for a given salt
function precompute(bytes32 salt) external view returns (address);
Parameters
| Name | Type | Description |
|---|---|---|
salt | bytes32 | Deterministic salt used for CREATE3 |
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The address that would be deployed |
Events
AdminSet
Emitted when admin is updated
event AdminSet(address indexed _admin);
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | New admin address |
PendingAdminSet
Emitted when pending admin is set
event PendingAdminSet(address indexed _admin);
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | Pending admin address |
AdminAccepted
Emitted when pending admin accepts control
event AdminAccepted(address indexed _admin);
Parameters
| Name | Type | Description |
|---|---|---|
_admin | address | The admin address that just accepted |
Errors
NotAuthorized
Error thrown when the caller is not the admin
error NotAuthorized(address admin, address sender);