# Setting "owner" principal for more than one actor

**URL:** <https://forum.dfinity.org/t/setting-owner-principal-for-more-than-one-actor/22938>\
**Category:** Motoko\
**Created:** [September 11, 2023, 4:25am UTC](https://forum.dfinity.org/t/setting-owner-principal-for-more-than-one-actor/22938 "2023-09-11T04:25:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwertytrewq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/qwertytrewq/32/10423_2.png) [@qwertytrewq](https://forum.dfinity.org/u/qwertytrewq)\
**Post date:** [September 11, 2023, 4:25am UTC](https://forum.dfinity.org/t/setting-owner-principal-for-more-than-one-actor/22938/1 "2023-09-11T04:25:38Z")

</div>

I found myself, while splitting my too big codebase (WASM code became greater than allowed) into two separate actors, writing the following in both halves after the split.

```auto
  func onlyMainOwner(caller: Principal) {
    if (?caller != founder) {
      Debug.trap("not the main owner");
    }
  };

```

Now, the question is how to (re)implement

```auto
  public shared({caller}) func setMainOwner(_founder: Principal) {
    onlyMainOwner(caller);

    founder := ?_founder;
  };

```

for it to work for both actors?

Variants that come to my mind:

1. The “main” actor’s `setMainOwner` to call the another’s actor’s (`await setMainOwner`) (what to do if the `await` happens to produce an error, e.g. because of overloaded network?)
2. Implement `onlyMainOwner` for one of the two actors as calling another one? (Bad variant, at least, in terms of efficiency.)
3. Set owners for both actors separately. If an owner transfer ever happens, then it is not too much work to make two function calls instead of one.

“3” seems the best. How do you think?

---

<div class="post-metadata">

**Author:** ![claudio](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/claudio/32/322_2.png) [@claudio](https://forum.dfinity.org/u/claudio)\
**Post date:** [September 12, 2023, 8:34pm UTC](https://forum.dfinity.org/t/setting-owner-principal-for-more-than-one-actor/22938/2 "2023-09-12T20:34:09Z")

</div>

3 sounds good to me too, but none of these (apart from maybe 2) really solve the problem if you want the change to be transactional - i.e. either all owner changes succeed or none of them do. But maybe you don’t need that for your application?

---

<div class="post-metadata">

**Author:** ![qwertytrewq](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/qwertytrewq/32/10423_2.png) [@qwertytrewq](https://forum.dfinity.org/u/qwertytrewq)\
**Post date:** [September 12, 2023, 10:56pm UTC](https://forum.dfinity.org/t/setting-owner-principal-for-more-than-one-actor/22938/3 "2023-09-12T22:56:15Z")

</div>

Yes, I don’t really need changing owner to be transactional. So, I think, I should choose “3”.
