Ownable2StepMsgSender API Reference
Ownable2StepMsgSender is a convenience wrapper around Ownable2Step that initializes ownership to msg.sender.
Use this contract when the deployer should be the initial owner, without explicitly specifying the owner address.
Usage Boundary
You use this contract when deploying contracts that should be owned by the deployer.
- Contracts inherit this implementation to initialize ownership automatically.
- Use this variant when deployment is performed directly by the intended owner.
- Use
Ownable2Stepinstead if ownership must be assigned to a different address at deployment. - You are responsible for ensuring the deployer address is the correct initial owner.
Contract
@chainlink/contracts/src/v0.8/shared/access/Ownable2StepMsgSender.sol
Import
import {Ownable2StepMsgSender} from "@chainlink/contracts/src/v0.8/shared/access/Ownable2StepMsgSender.sol";
If you have not installed the package:
npm install @chainlink/contracts@latest
Inheritance
contract Ownable2StepMsgSender is Ownable2Step
External API
constructor
constructor()
Ownable2Step(msg.sender, address(0))
{}
Initializes ownership with
msg.senderas the owner.
- Assumes the deployer is the intended owner.
- No pending owner is set at deployment.
All other functions are inherited from Ownable2Step.
Events
No new events declared.
For a cross-contract event index, see Events.
Errors
No new custom errors declared.
For a cross-contract error index, see Errors.
Security model
- Ownership is assigned to the deployer (
msg.sender) at deployment time. - If deployed through a factory or proxy, the factory or proxy may become the owner instead of the intended user.
- Ownership transfer follows the two-step acceptance process inherited from
Ownable2Step.
Notes
- This contract simplifies ownership initialization for common deployment patterns.
- This contract relies on
msg.senderat deployment time to determine the initial owner. - If deployed via a factory, the factory contract becomes the owner unless ownership is reassigned.
- When used behind a proxy, ownership may be assigned during proxy initialization rather than contract deployment.
- It should not be used when ownership needs to be assigned to a different address at deployment.
- Ensure deployment is executed from the correct address to avoid unintended ownership assignment.