I have created a smart contract using a factory method pattern as follows:

contract MyContractFactory is Ownable {
    function create(...) onlyOwner public returns (MyContract) {
        return new MyContract(...);

However, I have realized that I haven't transfered the ownership of myContract back to the the owner of MyContractFactory. Hence, I currently have no way to call any onlyOwner methods in myContract, even though transitively I'm the owner of myContract. The correct version should have been:

contract MyContractFactory is Ownable {
    function create(...) onlyOwner public returns (MyContract) {
        MyContract myContract = new MyContract(...);
        return myContract;

My question: Is there a way how can I execute a method that is onlyOwner in an instance of MyContract if I'm the owner only of the MyContractFactory instance (which is the owner of this MyContract instance)? I.e. somehow forward the execution from one smart contract to another?

It probably isn't possibly directly in Solidty, but maybe there is a hope to do it somehow in assembly?

1 Answer 1


Sorry. If I understand your question correctly, you want the factory contract to forward an instruction, e.g. changeOwner(me) to another contract.

If the factory was designed to do that, then no problem. It should not be possible to trick a deployed contract into cooperating as you suggest.

As you have observed, you could modify the factory with this requirement in mind. Another approach would be to include a purpose-built function to transfer ownership away later. Something like:

function giveAwayChild(address child, address newOwner) public onlyOwner ...

A pass-through pattern can also be used to forward certain commands while retaining ownership.

It's vital to think about the sort of controls that might be needed ever in a production setting because they can't be (easily) added later. I say "easily" because it's possible to consider upgradable contract patterns at the cost of considerable increased complexity. Again, it has to be done at the outset because the code can't be amended later.

Hope it helps.

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.