Operator Factory
The factory design pattern is a well know programming pattern: Rather than compiling and creating instances of a contract yourself, the factory does it for you.
As explained in the operator guide, the OperatorFactory
contract comes with these benefits:
- Node operators do not need to manually compile and deploy operator or/and forwarder contracts. They can deploy them directly from the factory. See thedeploynewoperator, deploynewforwarder, and deploynewoperatorandforwarder functions.
- Clients can verify if the factory deployed a given contract. See the created function.
Api Reference
Methods
typeAndVersion
function typeAndVersion() external pure virtual returns (string)
The type and version of this contract.
Return Values
Name | Type | Description |
---|---|---|
string | Type and version string |
deployNewOperator
function deployNewOperator() external returns (address)
Creates a new operator contract with the msg.sender as owner. Emits OperatorCreated
event.
deployNewOperatorAndForwarder
function deployNewOperatorAndForwarder() external returns (address, address)
Creates a new operator contract with the msg.sender as the owner and a new forwarder with the operator as the owner. Emits:
- OperatorCreated event.
- AuthorizedForwarderCreated event.
deployNewForwarder
function deployNewForwarder() external returns (address)
Creates a new forwarder contract with the msg.sender as owner. Emits AuthorizedForwarderCreated event.
deployNewForwarderAndTransferOwnership
function deployNewForwarderAndTransferOwnership(address to, bytes message) external returns (address)
Creates a new forwarder contract with the msg.sender as owner. Emits AuthorizedForwarderCreated event.
created
function created(address query) external view returns (bool)
Indicates whether this factory deployed an address.
Events
OperatorCreated
event OperatorCreated(address operator, address owner, address sender)
AuthorizedForwarderCreated
event AuthorizedForwarderCreated(address forwarder, address owner, address sender)