0

Here 2 contracts: contract A and contract B

If I (deployer/owner) transferred the ownership of contract A to contract B, is there any solutions that can transfer the ownership of contract A from contract B to others?

What I can come up with is I have to write some functions in contract B to transfer the ownership of contract A to others. Any other better ideas?

THank u very much!

0

Contracts don't have any concept of an "owner" by default. Contracts only have the functionality you write into them.

A quite common scenario is that functionality is added, which creates the concept of "owner" and assigns it to the contract deployer. This is for example what the OpenZeppelin Ownable contract is for: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol . It also has functionality to transfer ownership.

2
  • Yep. I exactly used the OpenZeppelin Ownable contract to do this. My question is after I transferred the ownership of contract A to contract B, how to transfer the ownership of contract A from contract B to others? Do I need write some function in contract B to implement this? – xxs Feb 24 at 4:54
  • The Ownable contract has functionality to transfer ownership onwards. So the current owner has to call this function: github.com/OpenZeppelin/openzeppelin-contracts/blob/master/… – Lauri Peltonen Feb 24 at 4:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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