0

I'm trying to create a contract and give a certain address, that is not the owner, permission to transfer ownership, or to atleast have the transferOwnership function public but only be able to transfer the ownership to one certain address. I've tried the following code (0x96c17dc512A94e4c4A9d8A9D7D7596a8c14addBf is the address that I in this case want to have access):

function _transferOwnership(address newOwner) public virtual {
    require(newOwner != address(0x96c17dc512A94e4c4A9d8A9D7D7596a8c14addBf));
    emit OwnershipTransferred(_owner, newOwner);
    _owner = newOwner;
}

Even with the 'require' line anyone can still transfer the ownership to any address without it having to be the address that I put in above. Would be eternally greatful if anyone could help

1 Answer 1

0

You code requires the newOwner to not be 0x96c17dc512A94e4c4A9d8A9D7D7596a8c14addBf. It needs to be require(newOwner == address(0x96c17dc512A94e4c4A9d8A9D7D7596a8c14addBf)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.