Event OwnershipTransferred


Somebody make me a contract but he add this function with an address inside. What does mean? When i deploy the contract that address it will be the new owner?

:1234: Code to reproduce

abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
    constructor () {
        _owner = 0xEBD6ccB02E3FBFc3569BC9c1fF92c0c9A51e0aDe;
        emit OwnershipTransferred(address(0), _owner);

    function owner() public view virtual returns (address) {
        return _owner;

    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");

    function renounceOwnership() public virtual onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);

    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;

:computer: Environment


Just by looking at this code fragment, yes.. its likely going to use that address as the initial owner.

Im not familiar with what you are building and what that address represents, but MOST likely you don't want/need that address harcoded there. Even less in the abstract contract.

A common practice is to setup the owner at the time of deployment to the sender of the tx, and then transfer the ownership to an account you control. So you could assign it to _msgSender() in this constructor.

Note: This is an abstract contract, so probably there is another contract in the solution which inherits from this and may be overriding this logic. Check if any of the contracts you have something like 'contract X is Ownable { ... }`. Any case you will probably want to remove that address and use the sender.

I have a question about the transferOwnership function.

It may be a stupid one (Pardon me, if it is stupid).

This function makes another address as the owner of the contract. In the contracts, which uses this contract to inherit upon probably have a mapping variable called _allowances (may be with any other name) which maps from the owner of the contract to another address, stating that this much of token can be handled by that particular address. So what will happen, if the ownership is transferred and, that mapping data _allowances remains unchanged? Will it cause any kind of malfunction, or the event OwnershipTransferred will handle all of that problems?